• 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] Stupid Spell Question

Status
Not open for further replies.
Level 5
Joined
Jun 7, 2008
Messages
141
Hello Hive ^_^
I am trying to make a "Lightning Bolt" spell where when you cast this spell to a target unit, a lightning bolt will strike to that unit every .10 seconds. The number of bolts depends on what level the spell is. If the spell was level 1, then one bolt, then 2, 3 bolts, 3, 5 bolts, 4, 10 bolts.

Some info you might need:
1. The 4 spells are contained in a Spell Book.
2. The based "dummy" spell which is used by the caster is based on "Ensnare"
3. The "dummy" spell summons a dummy unit to cast a number of bolts of lightning to the target every .10 seconds.

To make things quick, Ill only show you my triggers for the levels 1 and 4 spells.
  • Lightning Bolt 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Lightning Bolt (Level 1)
    • Actions
      • Unit - Create 1 Dummy Lightning Bolt (Female) for Player 7 (Green) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
  • Lightning Bolt 4
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Lightning Bolt (Level 4)
    • Actions
      • Unit - Create 1 Dummy Lightning Bolt (Female) for Player 7 (Green) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
      • Wait 0.10 seconds
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
      • Wait 0.10 seconds
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
      • Wait 0.10 seconds
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
      • Wait 0.10 seconds
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
      • Wait 0.10 seconds
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
      • Wait 0.10 seconds
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
      • Wait 0.10 seconds
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
      • Wait 0.10 seconds
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
      • Wait 0.10 seconds
      • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
+REP to those who help. I know this is a frikkin simple spell I am making but I need this so much.
 
Level 14
Joined
Nov 4, 2006
Messages
1,241
and whats not working? i guess its either the (last created Unit) after the wait, which might cause problems, also making your spell not MUI, or maybe you should change (Targeted Unit) to (Target Unit of Ability being cast), as Targeted Unit refers to a different event
 
Level 5
Joined
Jun 7, 2008
Messages
141
and whats not working? i guess its either the (last created Unit) after the wait, which might cause problems, also making your spell not MUI, or maybe you should change (Targeted Unit) to (Target Unit of Ability being cast), as Targeted Unit refers to a different event

Hmmm. Yea. That fixed it. But now theres another problem.
Thanks so much. lol. Simple problem. +Rep.

Sometimes, the Lightning Bolt happens and sometimes it doesn't.

And I'm pretty sure that it has something to do with the Base Order Id Strings. I already changed the String Order for each level of the spell but when I cast for example level 1, It casts either 1, 2, 3, or 4, which causes problems.
 
Level 9
Joined
May 10, 2009
Messages
542
Hmm? Really, I would just make an invisible dummy following caster which has... oh no that won't work. Oooh you're using GUI too... Jass tutorials are lost on me.
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
  • Set temppoint = (Position of (Triggering Unit))
  • For each Integer A from 1 to X do:
    • Unit - Create 1 dummy at *location* for (Owner of (Triggering Unit)) facing default building degrees
    • Unit - Order (Last created unit) to Neutral - Firebolt (Target unit of ability being cast)
    • Unit - Add a 0.1 seocnds generic expiration timer to (last created unit)
    • Wait 0.1 seconds
  • Custom script: call RemoveLocation(udg_temppoint)
 
Level 5
Joined
Jun 7, 2008
Messages
141
  • Set temppoint = (Position of (Triggering Unit))
  • For each Integer A from 1 to X do:
    • Unit - Create 1 dummy at *location* for (Owner of (Triggering Unit)) facing default building degrees
    • Unit - Order (Last created unit) to Neutral - Firebolt (Target unit of ability being cast)
    • Unit - Add a 0.1 seocnds generic expiration timer to (last created unit)
    • Wait 0.1 seconds
  • Custom script: call RemoveLocation(udg_temppoint)

As much as I want to apply this, i think this uses variables... Which, I don't know how to use...
 
Level 9
Joined
May 10, 2009
Messages
542
Variable is your friend :D

And it's pretty easy to use:

Locations(position of some unit = point call RemoveLocation(udg_MyLocVar)
Integers (level of ability, number of units 1, 10, 1337) = integer
Reals (damage, heal, area of effect) 5.2, 90.00 = real
Unit Groups = Unit group call DestroyGroup(udg_MyGroupVar)

Just some basic variables ;D

I was talking to the thread starter - seriously, you can't get off the ground without variables! I hugely recommend that you learn variables.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I was talking to the thread starter
I think that was pretty obvious, -BerZeKeR- was probably talking to the thread starter.


Variables allow you to:

  • Reduce lag, prevent server splits and crashes (by removing memory leaks, which you also need to learn at all costs).
  • Transfer data from trigger to trigger
  • Create spells that are MPI/MUI (so the spells don't get messed up if multiple players/units cast them at the same time).
  • Create systems (from easy systems, like kill-counters to item-combining systems, every system needs variables).

Loops:


Loops can make your trigger a lot shorter, easier to read and easier to edit, for example:

You want a unit to cast firebolt 10 times, you have used 20 actions for that (!).
This is how it looks with a simple loop:
  • Actions
    • For each integer A from 1 to 10 do (Actions)
      • Loop - Actions
        • Unit - Order (Last created unit) to Neutral - Firebolt (Targeted unit)
        • Wait 0.10 seconds
Wow... that's it...
Those 20 actions have been combined into this little thing...
If you want to set the number of firebolts cast, you only need to change 1 little integer.

Now, isn't that easier? :D

What have we learned today?

  • You can't do anything without variables, theye are used in every scripting language, in every map (exceptions: melee-maps, epicwar-maps),
  • Loops are an easy way to combine huge triggers into a few actions, which is easier to read and edit.
 
Status
Not open for further replies.
Top