• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Spell Problems

Status
Not open for further replies.
Level 13
Joined
Mar 29, 2012
Messages
542
hyy...guys....need help...!!?

If you want to help, i think you should read this

:ogre_icwydt: Ok... now... here is my spell trigger
[trigger=]Cluster Rockets
Events
Map initialization
Conditions
Actions
-------- CONFIGURABLE --------
Set CR_Ability = Cluster Rockets
Set CR_Interval = 0.03
-------- Unit is an ally --------
Set CR_Condition[1] = False
-------- Unit is a structure --------
Set CR_Condition[2] = True
-------- Unit is a ground unit --------
Set CR_Condition[3] = True
-------- Unit is a flying unit --------
Set CR_Condition[4] = False
-------- Unit is magic immune --------
Set CR_Condition[5] = False
-------- Rockets movement speed --------
Set CR_MoveSpeed[1] = 30.00
Set CR_MoveSpeed[2] = 30.00
Set CR_MoveSpeed[3] = 30.00
-------- Damage cause by a rocket --------
Set CR_Damage[1] = 40.00
Set CR_Damage[2] = 50.00
Set CR_Damage[3] = 60.00
-------- Damage range --------
Set CR_DamageRange[1] = 150.00
Set CR_DamageRange[2] = 150.00
Set CR_DamageRange[3] = 150.00
-------- Rocket collision size --------
Set CR_RocketCollision[1] = 75.00
Set CR_RocketCollision[2] = 75.00
Set CR_RocketCollision[3] = 75.00
-------- Number of rockets after splitted --------
Set CR_SplittedRockets[1] = 3
Set CR_SplittedRockets[2] = 4
Set CR_SplittedRockets[3] = 5
-------- Rocket distance to be splitted (between rocket position and targeted point) --------
Set CR_SplitDistance = 500.00
-------- Rockets model --------
Set CR_RocketModel = Abilities\Weapons\CannonTowerMissile\CannonTowerMissile.mdl
-------- Primary rocket explosion effect --------
Set CR_Effect[1] = Abilities\Weapons\SteamTank\SteamTankImpact.mdl
-------- Secondary rocket explosion effect --------
Set CR_Effect[2] = Abilities\Weapons\SteamTank\SteamTankImpact.mdl
-------- Primary rocket size (%) --------
Set CR_RocketSize = 150.00
-------- Secondary rockets size (%) --------
Set CR_RocketsSize = 100.00
-------- Rockets starting fly height --------
Set CR_RocketStartHeight = 50.00
-------- Damage attack-type --------
Set CR_AttackType = Siege
-------- Damage damage-type --------
Set CR_DamageType = Demolition
-------- Primary rocket dummy unit-type --------
Set CR_RocketType[1] = Dummy
-------- Secondary rocket dummy unit-type --------
Set CR_RocketType[2] = Dummy
-------- Initialize --------
Custom script: call ExecuteFunc("InitTrig_CR_Triggers")
Custom script: endfunction
-------- =========================================================================== --------
Custom script: function CR_Cast_Conditions takes nothing returns boolean
Custom script: if (GetSpellAbilityId() == udg_CR_Ability) then
Custom script: return true
Custom script: endif
Custom script: endfunction
Custom script: function CR_Cast_Actions takes nothing returns nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CR_IndexSize Equal to 0
Then - Actions
Trigger - Turn on CR_Loop
Else - Actions
Set CR_IndexSize = (CR_IndexSize + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CR_IndexSize Greater than CR_MaxIndex
Then - Actions
Set CR_Index[CR_IndexSize] = CR_IndexSize
Set CR_MaxIndex = CR_IndexSize
Else - Actions
Set CR_CurrentIndex = CR_Index[CR_IndexSize]
Set CR_Caster[CR_CurrentIndex] = (Triggering unit)
Set CR_Owner[CR_CurrentIndex] = (Triggering player)
Set TempLoc = (Position of CR_Caster[CR_CurrentIndex])
Set TempLoc2 = (Target point of ability being cast)
Set CR_TargetLoc[CR_CurrentIndex] = TempLoc2
Set CR_Distance[CR_CurrentIndex] = (Distance between TempLoc and TempLoc2)
Set CR_Angle[CR_CurrentIndex] = (Angle from TempLoc to TempLoc2)
Set CR_Level = (Level of (Ability being cast) for CR_Caster[CR_CurrentIndex])
Set CR_MoveSpeed[CR_CurrentIndex] = CR_MoveSpeed[CR_Level]
Set CR_Damage[CR_CurrentIndex] = CR_Damage[CR_Level]
Set CR_DamageRange[CR_CurrentIndex] = CR_DamageRange[CR_Level]
Set CR_RocketCollision[CR_CurrentIndex] = CR_RocketCollision[CR_Level]
Set CR_SplittedRockets[CR_CurrentIndex] = CR_SplittedRockets[CR_Level]
Set CR_Splitted[CR_CurrentIndex] = False
Custom script: set udg_CR_RocketsGroup[udg_CR_CurrentIndex] = CreateGroup()
Unit - Create 1 CR_RocketType[1] for CR_Owner[CR_CurrentIndex] at TempLoc facing CR_Angle[CR_CurrentIndex] degrees
Set CR_Rocket[CR_CurrentIndex] = (Last created unit)
Custom script: if UnitAddAbility(udg_CR_Rocket[udg_CR_CurrentIndex], 'Arav') and UnitRemoveAbility(udg_CR_Rocket[udg_CR_CurrentIndex], 'Arav') then
Custom script: endif
Animation - Change CR_Rocket[CR_CurrentIndex] flying height to CR_RocketStartHeight at 0.00
Special Effect - Create a special effect attached to the chest of CR_Rocket[CR_CurrentIndex] using CR_RocketModel
Animation - Change CR_Rocket[CR_CurrentIndex]'s size to (CR_RocketSize%, CR_RocketSize%, CR_RocketSize%) of its original size
Custom script: call RemoveLocation(udg_TempLoc)
Custom script: call RemoveLocation(udg_TempLoc2)
Custom script: endfunction
-------- =========================================================================== --------
Custom script: function CR_Loop_Actions takes nothing returns nothing
For each (Integer CR_LoopInt) from 1 to CR_IndexSize, do (Actions)
Loop - Actions
Set CR_CurrentIndex = CR_Index[CR_LoopInt]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CR_Splitted[CR_CurrentIndex] Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(CR_RocketsGroup[CR_CurrentIndex] is empty) Equal to True
Then - Actions
Custom script: call RemoveLocation(udg_CR_TargetLoc[udg_CR_CurrentIndex])
Custom script: call DestroyGroup(udg_CR_RocketsGroup[udg_CR_CurrentIndex])
Set CR_Index[CR_LoopInt] = CR_Index[CR_IndexSize]
Set CR_Index[CR_IndexSize] = CR_CurrentIndex
Set CR_IndexSize = (CR_IndexSize - 1)
Set CR_LoopInt = (CR_LoopInt - 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CR_IndexSize Equal to 0
Then - Actions
Trigger - Turn off (This trigger)
Skip remaining actions
Else - Actions
Else - Actions
Unit Group - Pick every unit in CR_RocketsGroup[CR_CurrentIndex] and do (Actions)
Loop - Actions
Set CR_Angle2 = (Facing of (Picked unit))
Set TempLoc = (Position of (Picked unit))
Set TempLoc2 = (TempLoc offset by CR_MoveSpeed[CR_CurrentIndex] towards CR_Angle2 degrees)
Custom script: call SetUnitX(GetEnumUnit(), GetLocationX(udg_TempLoc2))
Custom script: call SetUnitY(GetEnumUnit(), GetLocationY(udg_TempLoc2))
Unit - Make (Picked unit) face CR_TargetLoc[CR_CurrentIndex] over 0.00 seconds
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Random 1 units from (Units within CR_RocketCollision[CR_CurrentIndex] of TempLoc2 matching ((((Matching unit) belongs to an ally of CR_Owner[CR_CurrentIndex]) Equal to CR_Condition[1]) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) is and do (Actions)
Loop - Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units within CR_DamageRange[CR_CurrentIndex] of TempLoc2 matching ((((Matching unit) belongs to an ally of CR_Owner[CR_CurrentIndex]) Equal to CR_Condition[1]) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) is A structure) Equal to CR and do (Actions)
Loop - Actions
Unit - Cause CR_Caster[CR_CurrentIndex] to damage (Picked unit), dealing CR_Damage[CR_CurrentIndex] damage of attack type CR_AttackType and damage type CR_DamageType
Custom script: call DestroyEffect(AddSpecialEffectLoc(udg_CR_Effect[2], udg_TempLoc2))
Unit - Kill (Picked unit)
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units within 150.00 of CR_TargetLoc[CR_CurrentIndex] matching (((Matching unit) is in CR_RocketsGroup[CR_CurrentIndex]) Equal to True)) and do (Actions)
Loop - Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units within CR_DamageRange[CR_CurrentIndex] of TempLoc2 matching ((((Matching unit) belongs to an ally of CR_Owner[CR_CurrentIndex]) Equal to CR_Condition[1]) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) is A structure) Equal to CR and do (Actions)
Loop - Actions
Unit - Cause CR_Caster[CR_CurrentIndex] to damage (Picked unit), dealing CR_Damage[CR_CurrentIndex] damage of attack type CR_AttackType and damage type CR_DamageType
Custom script: call DestroyEffect(AddSpecialEffectLoc(udg_CR_Effect[2], udg_TempLoc2))
Unit - Kill (Picked unit)
Custom script: call RemoveLocation(udg_TempLoc)
Custom script: call RemoveLocation(udg_TempLoc2)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CR_Distance[CR_CurrentIndex] Greater than CR_SplitDistance
Then - Actions
Set TempLoc = (Position of CR_Rocket[CR_CurrentIndex])
Set TempLoc2 = (TempLoc offset by CR_MoveSpeed[CR_CurrentIndex] towards CR_Angle[CR_CurrentIndex] degrees)
Custom script: call SetUnitX(udg_CR_Rocket[udg_CR_CurrentIndex], GetLocationX(udg_TempLoc2))
Custom script: call SetUnitY(udg_CR_Rocket[udg_CR_CurrentIndex], GetLocationY(udg_TempLoc2))
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Random 1 units from (Units within CR_RocketCollision[CR_CurrentIndex] of TempLoc2 matching ((((Matching unit) belongs to an ally of CR_Owner[CR_CurrentIndex]) Equal to CR_Condition[1]) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) is and do (Actions)
Loop - Actions
Set CR_Splitted[CR_CurrentIndex] = True
Set CR_Distance[CR_CurrentIndex] = (CR_Distance[CR_CurrentIndex] - CR_MoveSpeed[CR_CurrentIndex])
Custom script: call RemoveLocation(udg_TempLoc)
Custom script: call RemoveLocation(udg_TempLoc2)
Else - Actions
Set TempLoc = (Position of CR_Rocket[CR_CurrentIndex])
For each (Integer CR_LoopInt2) from 1 to CR_SplittedRockets[CR_CurrentIndex], do (Actions)
Loop - Actions
Set CR_Angle[CR_CurrentIndex] = (CR_Angle[CR_CurrentIndex] + (360.00 / (Real(CR_SplittedRockets[CR_CurrentIndex]))))
Unit - Create 1 CR_RocketType[2] for CR_Owner[CR_CurrentIndex] at TempLoc facing CR_Angle[CR_CurrentIndex] degrees
Unit Group - Add (Last created unit) to CR_RocketsGroup[CR_CurrentIndex]
Custom script: if UnitAddAbility(GetLastCreatedUnit(), 'Arav') and UnitRemoveAbility(GetLastCreatedUnit(), 'Arav') then
Custom script: endif
Animation - Change (Last created unit) flying height to CR_RocketStartHeight at 0.00
Special Effect - Create a special effect attached to the chest of (Last created unit) using CR_RocketModel
Animation - Change (Last created unit)'s size to (CR_RocketsSize%, CR_RocketsSize%, CR_RocketsSize%) of its original size
Set CR_Splitted[CR_CurrentIndex] = True
Custom script: call DestroyEffect(AddSpecialEffectLoc(udg_CR_Effect[1], udg_TempLoc))
Unit - Kill CR_Rocket[CR_CurrentIndex]
Custom script: call RemoveLocation(udg_TempLoc)
Custom script: endfunction
-------- =========================================================================== --------
Custom script: function InitTrig_CR_Triggers takes nothing returns nothing
Custom script: call TriggerClearActions(GetTriggeringTrigger())
Custom script: set udg_CR_Cast = CreateTrigger()
Custom script: call TriggerRegisterAnyUnitEventBJ(udg_CR_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT)
Custom script: call TriggerAddCondition(udg_CR_Cast, Condition(function CR_Cast_Conditions))
Custom script: call TriggerAddAction(udg_CR_Cast, function CR_Cast_Actions)
Custom script: set udg_CR_Loop = CreateTrigger()
Custom script: call TriggerRegisterTimerEventPeriodic(udg_CR_Loop, udg_CR_Interval)
Custom script: call TriggerAddAction(udg_CR_Loop, function CR_Loop_Actions)
[/trigger]


And here is my problems ::ogre_datass::ogre_frown:
:fp: The missile don't move
:fp: I don't know more :ogre_frown:

Help me please...!!:ogre_rage::goblin_cry::vw_death:

+Rep !!
I promise !:grin::wink:
 
Is your missile a flying unit?
If that's the case,the unit wont be moved because you are using SetUnitX/Y

Also dont use Polar offset when using SetUnitX/Y,use this:
call SetUnitX(udg_yourunit,GetUnitX(udg_YourUnit) + speed * Cos(angle * bj_DEGTORAD))
call SetUnitY(udg_yourunit,GetUnitY(udg_YourUnit) + speed * Sin(angle * bj_DEGTORAD))

Also dont create a spell with just one trigger,write it in JASS instead.(because Mag will reject it if you did it)
Also put the temploc outside the Main If block,so you dont call so many function calls.

call TriggerAddCondition(udg_CR_Cast, Condition(function CR_Cast_Conditions))
Use Filter instead of Condition

Also if you want to add the Spell Effect,put the actions before you return the Condition of the spell.

Also,Assasin's Creed,the trigger CR_Loop is there.He is just creating the trigger just like JASS spells/.
 
Status
Not open for further replies.
Top