| 05-16-2008, 09:04 AM | #1 | |
i have 4 jass trigger for just 1 spell, i used global variables for them, and i dont have an idea on combining them thats why i need some help on combining these 4 jass triggers and change the global variables to structs or private globals Ill post the description of the spell Quote:
Triggers: This trigger creates the illusion JASS:function Trig_MODStart_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A033' endfunction function Trig_MODStart_Actions takes nothing returns nothing set udg_MODunit = GetTriggerUnit() set udg_MODloc = GetSpellTargetLoc() call CasterCastAbility(GetOwningPlayer(GetTriggerUnit()), 'A034', "852274", GetTriggerUnit(), false) endfunction //=========================================================================== function InitTrig_MODStart takes nothing returns nothing set gg_trg_MODStart = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_MODStart, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_MODStart, Condition( function Trig_MODStart_Conditions ) ) call TriggerAddAction( gg_trg_MODStart, function Trig_MODStart_Actions ) endfunction This trigger moves the illusion to the target area note that i used the orc campaign hero Rokhan with the unit id 'Orkn' JASS:function Trig_MODMove_Conditions takes nothing returns boolean return GetUnitTypeId(GetSummonedUnit()) == 'Orkn' and IsUnitIllusion(GetSummonedUnit()) endfunction function Trig_MODMove_Actions takes nothing returns nothing set udg_MODfake = GetSummonedUnit() call CS_MoveUnitLoc(udg_MODfake, udg_MODloc) endfunction //=========================================================================== function InitTrig_MODMove takes nothing returns nothing set gg_trg_MODMove = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_MODMove, EVENT_PLAYER_UNIT_SUMMON ) call TriggerAddCondition( gg_trg_MODMove, Condition( function Trig_MODMove_Conditions ) ) call TriggerAddAction( gg_trg_MODMove, function Trig_MODMove_Actions ) endfunction This trigger moves the caster and removes the illusion, IF it finishes channeling the ability JASS:function Trig_MODRemove_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A033' endfunction function Trig_MODRemove_Actions takes nothing returns nothing call CS_MoveUnit(udg_MODunit, GetUnitX(udg_MODfake), GetUnitY(udg_MODfake)) call RemoveUnit(udg_MODfake) call RemoveLocation(udg_MODloc) endfunction //=========================================================================== function InitTrig_MODRemove takes nothing returns nothing set gg_trg_MODRemove = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_MODRemove, EVENT_PLAYER_UNIT_SPELL_FINISH ) call TriggerAddCondition( gg_trg_MODRemove, Condition( function Trig_MODRemove_Conditions ) ) call TriggerAddAction( gg_trg_MODRemove, function Trig_MODRemove_Actions ) endfunction This trigger removes the illusion IF the caster stops channeling the spell JASS:function Trig_MODEnd_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A033' endfunction function Trig_MODEnd_Actions takes nothing returns nothing call RemoveUnit(udg_MODfake) endfunction //=========================================================================== function InitTrig_MODEnd takes nothing returns nothing set gg_trg_MODEnd = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_MODEnd, EVENT_PLAYER_UNIT_SPELL_ENDCAST ) call TriggerAddCondition( gg_trg_MODEnd, Condition( function Trig_MODEnd_Conditions ) ) call TriggerAddAction( gg_trg_MODEnd, function Trig_MODEnd_Actions ) endfunction ========================================================== heres another spell trigger problem, the spell is based on invisibility, and can be targeted to allied unit or self, then the trigger runs a timer that checks if the targeted unit is still near a tree for 150 range, if not, then the trigger removes the invisibility buff, and stops the timer but the problem is, it wont work, please help me with this heres the trigger i used ABC for attaching structs JASS:scope DarkStrike globals private integer count = 0 endglobals struct DarkStriker unit target endstruct private function CheckTrees takes nothing returns nothing set count = count + 1 endfunction private function HideStart takes nothing returns nothing local timer t = GetExpiredTimer() local DarkStriker d = GetTimerStructA(t) local location loc = GetUnitLoc(d.target) call EnumDestructablesInCircleBJ(150, loc, function CheckTrees) if count == 0 then call UnitRemoveAbility(d.target, 'B016') call d.destroy() call ReleaseTimer(t) call RemoveLocation(loc) endif set loc = null set t = null endfunction private function EternalForest takes nothing returns nothing local DarkStriker d = DarkStriker.create() local timer t = NewTimer() set d.target = GetSpellTargetUnit() call TimerStart(t, 1, true, function HideStart) call SetTimerStructA(t, d) endfunction public function InitTrig takes nothing returns nothing // a special event made by vex, actually this works just like // unit starts the effect of an ability event combined with a spell id condition // this event has no errors call OnAbilityEffect('A032', SCOPE_PRIVATE + "EternalForest") endfunction endscope +rep for helpers and credits to them for my map RotG Reborn |
| 05-16-2008, 07:51 PM | #2 |
Well, let's do some debugging then: The first thing you need to know is if all triggers run. Add: JASS:call BJDebugMsg("Trigger [name of trigger] ran") etc. to the beginning of all your triggers. Also check if illusions are returned by SummonedUnit(): JASS:function Trig_MODMove_Actions takes nothing returns nothing set udg_MODfake = GetSummonedUnit() call BJDebugMsg("Name of illusion: "+GetUnitName(udg_MODfake)) call CS_MoveUnitLoc(udg_MODfake, udg_MODloc) endfunction |
| 05-16-2008, 09:28 PM | #3 |
Yep, it's all about the scientific method, my friend. Try to avoid changing more than one thing inbetween tests, if you can. |
| 05-16-2008, 09:33 PM | #4 |
k ill try it, thanks |
