- Joined
- Sep 9, 2007
- Messages
- 6,759
Can someone please review this?
I created like 6 resources with this base.
I created like 6 resources with this base.
code
only an argument and you don't need to store it (which you couldn't, that's why it matters), it could be just fired using a static trigger, and "this" + "value" could be retrieved using static members/globals.What do you mean exactly? The name of the topic for the "Each Static Members" ?You may want to change the documentation to "code forEach"
Filter(function F1)
X times will not create X boolexpr but only one.Is anyone actually using this?
@Nes:
Well, it's a fully-featured list you can do nearly anything with
And that's the problem. We put even single globals into separate resources here, in the JASS section, y'know.
Also, the documentation doesn't meet the standards either, because it's actually informative.
But you shouldn't create resources because you can,
you should do it because you need them :/
Lol, you do realize that I am actually using those collections right? Trigger will be used in PriorityTrigger, which will be used for DDS. I released all of those in preparation for the DDS update ;o.
Uhm yeah, so you wanna tell me you need Trigger, BooleanExpression, Alloc Alternative, StaticQueueArray, StaticStackArray, List, Dummy, SharedUniqueNXQueue, UniqueNXQueue, NXQueue, SharedQueue, NXStack, UniqueNXStack, SharedUniqueNXStack, Stack, SharedStack, UniqueNXList, UniqueList, StaticQueue, etc. for it?Lol, you do realize that I am actually using those collections right? Trigger will be used in PriorityTrigger, which will be used for DDS. I released all of those in preparation for the DDS update ;o.
You can look into the future! :OI told you Anachron.
Uhm yeah, so you wanna tell me you need Trigger, BooleanExpression, Alloc Alternative, StaticQueueArray, StaticStackArray, List, Dummy, SharedUniqueNXQueue, UniqueNXQueue, NXQueue, SharedQueue, NXStack, UniqueNXStack, SharedUniqueNXStack, Stack, SharedStack, UniqueNXList, UniqueList, StaticQueue, etc. for it?
You can look into the future! :O
globals
Stack array unitsInStash
endglobals
//Updating the stash part
if (unitsInStash[playerIndex] == null) then
set unitsInStash[playerIndex] = Stack.create()
endif
call unitsInStash[playerIndex].add(GetUnitUserData(boughtUnit))
//Check if the new unit has 3 occurences of the same unit-type in the stack
call AutoUpgradeUnit(boughtUnit, playerIndex)
function AutoUpgradeUnit takes unit target, integer playerIndex returns nothing
local integer unitStashOccurences
local location unitLocation = GetUnitLoc(target)
local integer targetUnitType = GetUnitTypeId(target)
local integer raceId
local unit currentUnit
local integer currentUnitId
local integer unitUpgrade
//local boolean found = false
set unitStashOccurences = GetUnitOccurencesInStash(target, playerIndex)
//call unitsInStash[playerIndex].reset()
if unitStashOccurences == 3 then
call DisplayTextToForce( GetPlayersAll(), "ACTUAL STASH SIZE : " + I2S(unitsInStash[playerIndex].count) )
loop
exitwhen not unitsInStash[playerIndex].hasNext()
set currentUnitId = unitsInStash[playerIndex].getNext()
call DisplayTextToForce( GetPlayersAll(), "CURRENT LOOP UNIT ID : " + I2S(currentUnitId) )
if ( currentUnitId == targetUnitType ) then
//Clean handlers and removing necessary units to combine
set currentUnit = GetUnitFromAliveUnits(playerIndex, currentUnitId)
call unitsInStash[playerIndex].delete(currentUnitId)
call RemoveUnit(currentUnit)
endif
//Replace the unit by his next tier
if ( currentUnit == target ) then
set raceId = GetRaceId(target)
//Load (tier_level) of (unit_type) in (unit_race_upgrades)
set unitUpgrade = String2UnitIdBJ( LoadStringBJ( ( GetUnitPointValue(target) + 1 ), udg_UnitTypesInRaces[GetUnitUserData(target)], udg_UNIT_UPGRADES[raceId] ) )
call DisplayTextToForce( GetPlayersAll(), LoadStringBJ( ( GetUnitPointValue(target) + 1 ), udg_UnitTypesInRaces[GetUnitUserData(target)], udg_UNIT_UPGRADES[raceId] ) )
call CreateNUnitsAtLoc( 1, unitUpgrade, ConvertedPlayer(playerIndex), unitLocation, 270.00 )
call AddSpecialEffectLocBJ( unitLocation, "Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call unitsInStash[playerIndex].add( GetUnitUserData(GetLastCreatedUnit()) )
//set found = true
endif
endloop
call unitsInStash[playerIndex].reset()
endif
call RemoveLocation(unitLocation)
endfunction
function GetUnitOccurencesInStash takes unit target, integer playerIndex returns integer
local integer targetUnitType = GetUnitTypeId(target)
local integer currentUnitId
local integer occurencesCount = 0
local unit currentUnit
//call DisplayTextToForce( GetPlayersAll(), "OccurenceFunction - targetUnitType : " + I2S(targetUnitType) + " / stashCount : " + I2S(currentStack.count) )
loop
exitwhen not unitsInStash[playerIndex].hasNext()
set currentUnitId = unitsInStash[playerIndex].getNext()
set currentUnit = GetUnitFromAliveUnits(playerIndex, currentUnitId)
if ( GetUnitTypeId(currentUnit) == targetUnitType ) then
set occurencesCount = occurencesCount + 1
set udg_CurrentUnitLocation[currentUnitId] = GetUnitLoc(currentUnit)
endif
endloop
call unitsInStash[playerIndex].reset()
return occurencesCount
endfunction
[B]call[/B] [COLOR=#dd4444]CreateNUnitsAtLoc[/COLOR][COLOR=sienna]([/COLOR] [COLOR=#3333FF]1[/COLOR][COLOR=sienna],[/COLOR] unitUpgrade[COLOR=sienna],[/COLOR] [COLOR=#dd4444]ConvertedPlayer[/COLOR][COLOR=sienna]([/COLOR]playerIndex[COLOR=sienna]),[/COLOR] unitLocation[COLOR=sienna],[/COLOR] [COLOR=#3333FF]270.00[/COLOR] [COLOR=sienna])[/COLOR]
[B]call[/B] [COLOR=#dd4444]AddSpecialEffectLocBJ[/COLOR][COLOR=sienna]([/COLOR] unitLocation[COLOR=sienna],[/COLOR] [COLOR=blue]"Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl"[/COLOR] [COLOR=sienna])[/COLOR]
[B]call[/B] [COLOR=#dd4444]DestroyEffectBJ[/COLOR][COLOR=sienna]([/COLOR] [COLOR=#dd4444]GetLastCreatedEffectBJ[/COLOR][COLOR=sienna]()[/COLOR] [COLOR=sienna])[/COLOR]
[B]call[/B] unitsInStash[COLOR=sienna][[/COLOR]playerIndex[COLOR=sienna]][/COLOR].[COLOR=color: #666666]add[/COLOR][COLOR=sienna]([/COLOR] [COLOR=purple]GetUnitUserData[/COLOR][COLOR=sienna]([/COLOR][COLOR=#dd4444]GetLastCreatedUnit[/COLOR][COLOR=sienna]())[/COLOR] [COLOR=sienna])[/COLOR]
The same behaviour is working in GUI but I could not test it here because this part of code will never be reached cause of the iterator problem...First, I am not sure you can use GetLastCreatedUnit() with CreateNUnitsAtLoc.
Their UserData is initialized with an Unit Indexer event, I've checked everything until I've came across this bug. I'll guess I'll stick with hastables for the moment, your library itself is cool though.Second: Where does GetLastCreatedUnit get it's UserData from when its just created? Aren't you just adding zero values to the stack?