GUI Spell problem

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2008
Messages
253
Hello everybody, I'm having some problems with my spell. For now it's just firing a rocket and that's it, but the problem is that it won't stop.

Trigger 1:

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Aimed Shot
  • Actions
    • -------- 0 = Distance --------
    • -------- 1 = Angle --------
    • -------- 2 = Damage --------
    • -------- 3 = Projectile --------
    • -------- 4 = End Location --------
    • -------- ---------------------- --------
    • Set Unit = (Casting unit)
    • -------- ---------------------- --------
    • Set Integer[1] = (Level of Disengage for Unit)
    • -------- ---------------------- --------
    • Set Location[1] = (Position of Unit)
    • -------- ---------------------- --------
    • Set Location[2] = (Target point of ability being cast)
    • -------- ---------------------- --------
    • Set AimedShotAngle = (Angle from Location[1] to Location[2])
    • -------- ---------------------- --------
    • Set AimedShotDamage = ((Real(Integer[1])) x 40.00)
    • -------- ---------------------- --------
    • Set AimedShotDistance = (1250.00 x 0.03)
    • -------- ---------------------- --------
    • Set AimedShotEnd = (Location[1] offset by 1250.00 towards AimedShotAngle degrees)
    • -------- ---------------------- --------
    • -------- Store the values --------
    • Unit - Create 1 Aimed Shot Dummy for (Owner of Unit) at Location[1] facing AimedShotAngle degrees
    • Set AimedShotDummy = (Last created unit)
    • Hashtable - Save AimedShotDistance as 0 of (Key (Last created unit)) in AimedShotTable
    • Hashtable - Save AimedShotAngle as 1 of (Key (Last created unit)) in AimedShotTable
    • Hashtable - Save AimedShotDamage as 2 of (Key (Last created unit)) in AimedShotTable
    • Hashtable - Save Handle OfAimedShotDummy as 3 of (Key (Last created unit)) in AimedShotTable
    • Hashtable - Save Handle OfAimedShotEnd as 4 of (Key (Last created unit)) in AimedShotTable
    • -------- ---------------------- --------
    • Unit Group - Add AimedShotDummy to AimedShotUnits
    • -------- ---------------------- --------
    • Custom script: call RemoveLocation(udg_Location[1])
    • Custom script: call RemoveLocation(udg_Location[2])
    • Custom script: call RemoveLocation(udg_AimedShotEnd)
Trigger 2:

  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
    • -------- 0 = Distance --------
    • -------- 1 = Angle --------
    • -------- 2 = Damage --------
    • -------- 3 = Projectile --------
    • -------- 4 = End Location --------
    • -------- ---------------------- --------
    • Unit Group - Pick every unit in AimedShotUnits and do (Actions)
      • Loop - Actions
        • Set AimedShotDistance = (Load 0 of (Key (Picked unit)) from AimedShotTable)
        • Set AimedShotAngle = (Load 1 of (Key (Picked unit)) from AimedShotTable)
        • Set AimedShotDamage = (Load 2 of (Key (Picked unit)) from AimedShotTable)
        • Set AimedShotDummy = (Load 3 of (Key (Picked unit)) in AimedShotTable)
        • Set AimedShotEnd = (Load 4 of (Key (Picked unit)) in AimedShotTable)
        • Set Location[1] = (Position of AimedShotDummy)
        • Set Location[2] = AimedShotEnd
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Distance between Location[1] and Location[2]) Less than 38.00
          • Then - Actions
            • Set Location[4] = (Position of AimedShotDummy)
            • Special Effect - Create a special effect at Location[4] using Abilities\Weapons\Mortar\MortarMissile.mdl
            • Special Effect - Destroy (Last created special effect)
            • Unit Group - Remove (Picked unit) from AimedShotUnits
            • Unit - Remove AimedShotDummy from the game
            • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in DisengageTable
            • Custom script: call RemoveLocation( udg_Location[4] )
          • Else - Actions
            • Set Location[3] = (Location[1] offset by 38.00 towards AimedShotAngle degrees)
            • Unit - Move AimedShotDummy instantly to Location[3]
            • Custom script: call RemoveLocation( udg_Location[3] )
        • Custom script: call RemoveLocation( udg_Location[1] )
        • Custom script: call RemoveLocation( udg_Location[2] )
(Some variables will be used later, because it's not finished yet)

Help would be appreciated, thanks in advance, Quetzalcotl
 
Level 8
Joined
Apr 30, 2009
Messages
338
To trigger 2 you need to add an If/Then/Else action over the entire current trigger:

If: Number of units in unit group AimedShotUnits is equal to 0

Then: Turn off this Trigger

Else: everything you have right now


Then for trigger one you must do this at the very end:

If: Trigger 2 is on equal to False

Then: Turn on trigger 2

Else:


And you don't need to save reals or integers to variables, you can just take them right from the hash tables.
 
What I would suggest:
1) Add an expiration timer to the dummy unit upon creation. Set the time to the time it'll last (so that it travels your desired distance)
2) After that, add a If/Then/Else to check if the dummy is dead. If it is, remove it from the Group and Flush its Hashtable data.
3) When it hits, kill it instead of removing it. You can move the Remove Unit action to within the If/Then/Else that I suggested above.

Hope this helps! Please contact me if you need more help! My spellpack has a somewhat similar spell (crap implementation instructions though) so you can check it out if you want :D
 
Status
Not open for further replies.
Top