- Joined
- Mar 7, 2012
- Messages
- 30
Hello. I'm kinda new to mapmaking & triggering (about 1 month now ) and I'm trying to make a trigger. I need to make spells which will "change" the user into an animal and then when the animal uses the ability it will come back to its original form. So this is I got it work so far: First I store the transforming abilities in an array and the form of each ability in another array (I have just put one for now). I also store a Rect which for some reason it won't work.
The second part: When the Shape_Form unit casts the ability "Shift Back" the original unit will come back to the Shape_Form's place with the normal owner and vulnerable. The Shape_Form unit will be removed. So this is the JASS part (I will put a comment on each line I have a problem)
I have used locals because if I use globals it won't work if multiple players shapeshift. Thanks in advance for any help given
-
Shape Forms
-
Events
- Map initialization
- Conditions
-
Actions
- Set Shape_Rect = (Rect(9.00, 225.00, 13.00, 230.00)) //area,will eplain later
- Set Shape_Count = 1 //how many spells there are
- Set Shape_Abil[1] = Shapeshift (Wolf) //the spell
- Set Shape_Form[1] = Dire Wolf // the form of each spell
-
Events
The second part: When the Shape_Form unit casts the ability "Shift Back" the original unit will come back to the Shape_Form's place with the normal owner and vulnerable. The Shape_Form unit will be removed. So this is the JASS part (I will put a comment on each line I have a problem)
JASS:
function Trig_Shapeshift_Copy_Actions takes nothing returns nothing
local integer abil_number //this is the number of the ability found in array
local unit shape_unit //this is the original unit
local unit shape_unit2 //this is the unit that will be spawned
local player shape_player //this is the owner of the original unit
set abil_number = 0
set shape_unit = GetTriggerUnit()
set shape_player = GetOwningPlayer(GetTriggerUnit())
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = udg_Shape_Count
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( GetSpellAbilityId() == udg_Shape_Abil[GetForLoopIndexA()] ) then
set abil_number = GetForLoopIndexA()
else
call DoNothing( )
endif
exitwhen abil_number > 0
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
if abil_number > 0 then
call CreateNUnitsAtLocFacingLocBJ( 1, udg_Shape_Form[abil_number], GetOwningPlayer(shape_unit), GetUnitLoc(shape_unit), GetRandomLocInRect(GetPlayableMapRect()) )
set shape_unit2 = GetLastCreatedUnit()
call SetUnitInvulnerable( shape_unit, true )
call SetUnitPositionLoc( shape_unit, GetRandomLocInRect(udg_Shape_Rect) )
call SetUnitOwner( shape_unit, Player(PLAYER_NEUTRAL_PASSIVE), true )
loop
//this is the part I don't know what to add to check for ability until it
//gets the ability "Shift Back" (abilcode) casted by the shape_unit2
endloop //the part below hasn't been tested since I cant make the
//condition
call SetUnitPositionLoc(shape_unit, GetUnitLoc(shape_unit2) )
call RemoveUnit( shape_unit2 )
call SetUnitInvulnerable( shape_unit, false )
call SetUnitOwner( shape_unit, shape_player, true )
else
call DoNothing( )
endif
endfunction
//===========================================================================
function InitTrig_Shapeshift_Copy takes nothing returns nothing
set gg_trg_Shapeshift_Copy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Shapeshift_Copy, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddAction( gg_trg_Shapeshift_Copy, function Trig_Shapeshift_Copy_Actions )
endfunction
I have used locals because if I use globals it won't work if multiple players shapeshift. Thanks in advance for any help given
Last edited: