| 08-18-2003, 09:55 PM | #121 |
I was the one who added the prime function (it was correct), but was changed to isPrime, and returned a boolean instead of an integer. :ggani: |
| 08-20-2003, 02:59 AM | #122 |
Hopefully you'll all be able to submit your functions soon =) Stoned gave me phpmyadmin access and an ftp account just for the library, so I'm gonna start coding now ;) |
| 08-20-2003, 07:14 PM | #123 |
I have created a new function, but I have problems with it. This function makes a unit give an item to another unit and will take care of the distance, where you can give items to other units (it's in Gamplay Constants). Code:
//**************************************************************************************************************
//*
//* New globals: bj_UnitGiveItemToUnit_whichUnit, bj_UnitGiveItemToUnit_toUnit, bj_UnitGiveItemToUnit_whichItem
//* Associated functions: UnitGiveItemToUnit_Child_Condition, UnitGiveItemToUnit_Child_Action
//*
//**************************************************************************************************************
function UnitGiveItemToUnit_Child_Condition takes nothing returns boolean
// if (GetFilterUnit() == bj_UnitGiveItemToUnit_whichUnit) then
if (DistanceBetweenUnits(bj_UnitGiveItemToUnit_whichUnit,bj_UnitGiveItemToUnit_toUnit) <= 150) then
return true
endif
return false
endfunction
function UnitGiveItemToUnit_Child_Action takes nothing returns nothing
local integer itemSlot = 0
if (GetTriggerUnit() != bj_UnitGiveItemToUnit_whichUnit) then
call BJDebugMsg(GetUnitName(GetTriggerUnit()))
return
endif
loop
exitwhen itemSlot > 6
if (UnitItemInSlot(bj_UnitGiveItemToUnit_whichUnit,itemSlot) == bj_UnitGiveItemToUnit_whichItem) then
call UnitRemoveItem(bj_UnitGiveItemToUnit_whichUnit, bj_UnitGiveItemToUnit_whichItem)
call UnitAddItem(bj_UnitGiveItemToUnit_toUnit, bj_UnitGiveItemToUnit_whichItem)
return
endif
endloop
// call DestroyTrigger(
endfunction
function UnitGiveItemToUnit takes unit whichUnit, unit toUnit, item whichItem returns nothing
local trigger dispatcher = CreateTrigger()
set bj_UnitGiveItemToUnit_whichUnit = whichUnit
set bj_UnitGiveItemToUnit_toUnit = toUnit
call IssuePointOrderById(whichUnit,851986,GetUnitX(toUnit),GetUnitY(toUnit))
call TriggerAddAction(dispatcher,function UnitGiveItemToUnit_Child_Action)
//call TriggerRegisterUnitInRange(dispatcher, toUnit, 150.00, Condition(function UnitGiveItemToUnit_Child_Condition))
call TriggerRegisterUnitInRange(dispatcher, toUnit, 150.00, null)
endfunction |
| 08-22-2003, 07:17 PM | #124 |
SCFreak: You should consider using the globals already built in. I'm trying to make sure the functions are as self contained as possible. Check out the way the timed special effects functions that Peppar posted work. |
| 08-22-2003, 10:19 PM | #125 |
That's not the problem. And I looked at his functions (thats how I got the idead to make that). Please give it a look. I tested a bit around and it doesn't work. I don't have the time right now to do intensive testing (I have to work on UMSWE 4). |
| 08-23-2003, 04:16 PM | #126 | |
Quote:
I was suggesting it for the sake of making the function easier for others to use, not for making it work ;) I'll take a closer look at it later. BTW, something else I found in common.j: Code:
//===================================================
// Unit Type Constants for use with IsUnitType()
//===================================================
constant unittype UNIT_TYPE_HERO = ConvertUnitType(0)
constant unittype UNIT_TYPE_DEAD = ConvertUnitType(1)
constant unittype UNIT_TYPE_STRUCTURE = ConvertUnitType(2)
constant unittype UNIT_TYPE_FLYING = ConvertUnitType(3)
constant unittype UNIT_TYPE_GROUND = ConvertUnitType(4)
constant unittype UNIT_TYPE_ATTACKS_FLYING = ConvertUnitType(5)
constant unittype UNIT_TYPE_ATTACKS_GROUND = ConvertUnitType(6)
constant unittype UNIT_TYPE_MELEE_ATTACKER = ConvertUnitType(7)
constant unittype UNIT_TYPE_RANGED_ATTACKER = ConvertUnitType(8)
constant unittype UNIT_TYPE_GIANT = ConvertUnitType(9)
constant unittype UNIT_TYPE_SUMMONED = ConvertUnitType(10)
constant unittype UNIT_TYPE_STUNNED = ConvertUnitType(11)
constant unittype UNIT_TYPE_PLAGUED = ConvertUnitType(12)
constant unittype UNIT_TYPE_SNARED = ConvertUnitType(13)
constant unittype UNIT_TYPE_UNDEAD = ConvertUnitType(14)
constant unittype UNIT_TYPE_MECHANICAL = ConvertUnitType(15)
constant unittype UNIT_TYPE_PEON = ConvertUnitType(16)
constant unittype UNIT_TYPE_SAPPER = ConvertUnitType(17)
constant unittype UNIT_TYPE_TOWNHALL = ConvertUnitType(18)
constant unittype UNIT_TYPE_ANCIENT = ConvertUnitType(19)The Stunned, Plagued, Snared, and Giant types don't show up in the GUI boolean comparison Unit - Unit Classification Check, but the others do. Should add it to UMSWE if you haven't already. I wonder if it would be possible to set the stun value to true for JASS spells and the like. EDIT: Argh, why are the forums so stupid as to look for smiley faces WITHIN CODE TAGS? Yeesh. |
| 08-23-2003, 07:33 PM | #127 |
I have already included them, but thanks for the effort. I looked a bit around and found out that there is no unit using the GIANT flg, although it is in the Object Editor. I added it, because maybe someone can make use of it. |
| 08-24-2003, 05:00 AM | #128 | |
Quote:
Actually, that could be EXTREMELY useful. You see, right now I assign all units that aren't really units (i.e. they're around for some technical reason, for example an invisible caster that casts two buffs on a unit to make it look like 1 super buff, or an invisible hero that wastes item charges to wittle them down to the right number) to be sappers. This way when all of my JASS spells pick targets, I can make add a test for sappers to make sure these units aren't killed. I can also use the ability editor to stop normal abilities from being able to attack suicidal units. There are some instances where you might need 2 types of special units like this. I know there was a time when I could've used it but I found a workaround (can't remember the exact circumstances). Unit-type modifications in general that have no real effect can be useful in this way =) Also -- reading some other forums threads I found out that the map author, map name, and description text fields for a map are all stored in the .wts file in the TRIGSTR_000 format, so it should be possible to make the following functions: -GetMapName() -GetMapDescription() -GetMapAuthor() For some reason these don't always appear in maps, but for the most part they should work.... |
| 08-24-2003, 10:30 PM | #129 |
This would be fine, but I think, we can go farther. I can figure a function, that can return any string stored in this file. I will do some testing and come back with (hopefully) results. |
| 08-25-2003, 06:14 AM | #130 |
NO - YOU CAN'T get the author name or map name from the wts file. I messed with this topic for some time trying to create a map protector that compares the author name and map name with the original ones - it doesn't work for the reasons below. Yes, you can get the string from the wts file using 'Conversion - Get Externalized String' which is StringIdentity("TRIGSTR_XXX") in JASS. But you cannot work with it. You can't use it to compare it with other strings nor can you use the string in other functions than in any of the display functions. the identity "TRIGSTR_XXX" will always stay "TRIGSTR_XXX" until it is used in one of the displaying functions and the game will only look up the wts file until you want to display it on screen (for example using DisplayTimedTextToPlayer) And it will only look up the wts file if you use the string in one of the few functions that support this (all these functions are displaying functions such as show text and transmissions) Another thing is that using the 'Externalized String' function you can't get an existing externalized string. You have to put in a new string which must be specially marked in the wts file or another file. Because if you convert it to custom text and put in another string identity (ig "TRIGSTR_001" instead of "TRIGSTR_010" it will not read it. Instead it will always return "TRIGSTR_001" even if you want to display it. That's about what I know, hope it helps you and saves you some work |
| 08-25-2003, 08:36 AM | #131 |
PitzerMike, you CAN get the author name from the wts file. Not only the display natives convert it. Instead SetPlayerName does too. And that one you can get back with GetPlayerName. Then you can do your comparison. And I had no problems reading existing strings in the wts file with that. |
| 08-25-2003, 09:50 AM | #132 |
I also tried that But GetPlayerName never read the player name from the wts file, it only read the Profile Name of the player (it will return WorldEdit for Player 1 for example when testing a map) Anyway I believe that there might be a way. If you could upload a working example I would be greatly obliged to test it |
| 08-25-2003, 09:55 AM | #133 |
What I mean is something like that: local string s call SetPlayerName(Player(11), "TRIGSTR_001") set s = GetPlayerName(Player(11)) if s == "Whatever is in the wts file at that position" then ... |
| 08-25-2003, 10:00 AM | #134 |
oh I see:ggani: this should work Didn't know you could use SetPlayerName in other functions than Config |
| 08-25-2003, 10:04 AM | #135 |
Yes, you can. I use it for example to set the names of the Computers to the profile names in AMAI. |
