I'm trying to create a spring that will launch a specific unit type up in the air once it gets close (provided that certain conditions are met). Once the spring has activated it will be disabled for a few seconds. I've already created a system that handles the movement for the launch.
I'll try to explain what I've attempted to do below:
Once the specific unit type gets close to a spring the trigger calls GroupEnumUnitsInRange to find a nearby spring. This was supposed to be done by filtering all the units of a specific type (the spring) and only units that have 100 mana (I intended to use mana as a method of deciding whether or not the spring would be ready to launch the unit).
If the picked unit is a spring and it currently has 100 mana this should run:
Now the problem is that I don't much about Unit Groups in JASS (or JASS in general, I suppose). Currently the filter only checks for the spring's rawcode - how would I get it to for check mana aswell? Can a single filter function return multiple booleans? Also, how would I go about incorporating the actions? And last, would there be a better/easier way of doing this?
I'll try to explain what I've attempted to do below:
Once the specific unit type gets close to a spring the trigger calls GroupEnumUnitsInRange to find a nearby spring. This was supposed to be done by filtering all the units of a specific type (the spring) and only units that have 100 mana (I intended to use mana as a method of deciding whether or not the spring would be ready to launch the unit).
JASS:
function GroupFilter takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 'n002'
endfunction
function Trig_Collision_Spring_Actions takes nothing returns nothing
local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())
local integer i = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
local group g = CreateGroup()
if (GetUnitTypeId(GetTriggerUnit()) == 'e000' and udg_BOOLEAN_PlayerStatus[i] == false) then
call GroupEnumUnitsInRange(g, 125, x, y, Filter(function GroupFilter))
call DestroyGroup(g)
set g = null
endif
endfunction
If the picked unit is a spring and it currently has 100 mana this should run:
JASS:
if (udg_REAL_Gravity[i] == 0.50) then
set udg_REAL_VerticalSpeed[i] = 15.00
else
set udg_REAL_VerticalSpeed[i] = -15.00
endif
Now the problem is that I don't much about Unit Groups in JASS (or JASS in general, I suppose). Currently the filter only checks for the spring's rawcode - how would I get it to for check mana aswell? Can a single filter function return multiple booleans? Also, how would I go about incorporating the actions? And last, would there be a better/easier way of doing this?