• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Spell] How do I do this?

Status
Not open for further replies.
Level 20
Joined
Apr 14, 2012
Messages
2,901
I am really sorry if the title is unhelpful with the problem at hand, as I can't put to words the situation.

Months ago when I was still free to experiment with the Trigger Editor I was making spells like mad. They weren't perfect, some had weird bugs, some weren't even MUI. But there was this one spell (Actually two, they were kind of a duo) I started, but never finished. The first one (let's call it the First) wasn't an Aura or a Target Unit, but kind-of a Target Point, and the second one was kind of the Switch (I'll explain later). The process goes like this:

-When the caster casts the First, you point the cursor to a point on the ground, then it will summon a stationary dummy unit with no timed life. Now the dummy unit doesn't do anything special, except detonate magnificently when the Switch is activated.

-The caster may keep on doing this until he reaches a limit, which varies by level. The limit keeps the caster from summoning too many dummies. Afterwards he may now cast the Switch, will basically tells all present dummy units to blow up. But the twist is, they don't blow up at the same time. They detonate t seconds from the last, each with varying effects.

That's how it goes. But here are the things I can't figure out:
1.) If multiple casters do this, how do I keep track of the dummy units? Also since the limit variable is configurable, it might be very hard to store the data in like, DummyUnit[arrayint].
2.)

  • Example Switch Trigger
  • Events
    • Unit - Unit casts an ability
  • Conditions
    • Ability being cast == Switch
  • Actions
    • For each tempint from 1 to int, do (Actions)
      • Loop - Actions
        • Set ExplosionCount = ExplosionCount + 1
        • if ExplosionCount == int, then do (then Actions) else do (else Actions)
          • Then - Actions
            • Unit - Kill DummyUnit[tempint]
            • /* I put final explosion effects here *\
          • Else - Actions
            • if ExplosionCount == 1 , then do (then Actions) else do (else Actions)
            • Unit - Kill DummyUnit[tempint]
        • //I put first explosion effects here
It's a rough sketch but what I'm trying to convey is that it takes an awful long branch of if-then-elses if I want to make different effects with t second intervals. Also, in relation with number one, how do I time the explosions with the deaths of the different dummy units with the different owners? Please help.

This spell has been bugging me for the past few days now, but I think it's time for me to ask for your help.

Thanks :))
 
a. Hero places dummy
b. add one instance (store Dummy[A], Hero[A], DelayTime[A]*, EffectType[A] = 1 initial, Countdown[A] = 0.00 initial) (currentIndex is A)


  • Set TempInt1 = 0
  • Set TempRecord = 0
  • Set TempEffectInt = 0
  • For each tempint from 1 to MaxIndex
    • If Hero[tempint] == Hero[A]
      • Then - Actions
        • If DelayTime[tempInt] > TempRecord
          • Then - Actions
            • Set TempRecord = DelayTime[tempInt]
            • Set TempEffectInt = EffectType[tempInt]
          • Else - Actions
        • Else - Actions
  • Set DelayTime[A] = TempRecord + 2
This determines the highest DelayTime[A] for the hero, and the delay time for the most recent cast (A). For different effects you say, add this:

  • If (TempEffectInt + 1) greater than <max # of effects>
    • Then - Actions
      • Set TempEffectInt = 1
      • Else - Actions
        • If TempEffectInt == 0
          • Then - Actions
            • Set EffectType[A] = TempEffectInt + 1
          • Else - Actions
Meanwhile this gives an integer per effect you want (1 to max). Though EffectType[A] is set to 1 upon instance creation, TempEffectInt changes EffectType[A] if it holds any value.


Upon Switch activation, only then do you turn on the loop trigger. First, loop through all indices then check if the Triggering Unit == Hero[A]. Just like normal dynamic indexing loops, go from 1 to MaxIndex and detonate the corresponding dummy for the instance once the Countdown[A] is greater than or equal to DelayTime[A]. (Of course you add to Countdown[A] every time the trigger runs)

Have multiple If/Then/Elses in the loop, checking the EffectType[A] and acting accordingly. Deindex upon detonation as usual.
====================

I hope I'm making sense, or I probably need sleep. :cry:
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
Wow I am having a hard time processing this. My triggering skills have dulled since I stopped practicing :(

But anyway, I'm just going to go through the first part first:

a. Hero places dummy
b. add one instance (store Dummy[A], Hero[A], DelayTime[A]*, EffectType[A] = 1 initial, Countdown[A] = 0.00 initial) (currentIndex is A)

So it goes like this (more or less) for when the Hero places the dummy: (?)
  • First Ability or Dummy Placement
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • Ability being cast == First
  • Actions
    • Set position = target point of ability being cast
    • Set maxindex = maxindex + 1
    • Unit - create 1 Dummy at position
    • Set Dummy[maxindex] = Last Created Unit
    • Set Hero[maxindex] = Triggering Unit
    • Set DelayTime[A] <--- I do not get this part, can you explain further part by part? :)
    • Set EffectType[maxindex] = 1
    • Set Countdown[maxindex] = 0.00
I also don't understand what EffectType[A] is... I mean, if it's an Effect why is it an integer?
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
So there'd be three triggers: the placement, the switch, the loop?

Also, can someone explain these: (sorry I am slow at the moment)
...First, loop through all indices then check if the Triggering Unit == Hero[A]. Just like normal dynamic indexing loops....
What is a normal dynamic indexing loop?

I now have the idea for the EffectType[currentindex] down.

EDIT: Is this spell possible with hashtables?
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
Hmm... so the Placement trigger would look like this, am I correct?

  • Placement
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to AbilPlace
    • Actions
      • Set maxnidex = (maxnidex + 1)
      • Set Hero[maxnidex] = (Triggering unit)
      • Set targetloc[maxnidex] = (Target point of ability being cast)
      • Unit - Create 1 Peasant for Player 1 (Red) at targetloc[maxnidex] facing Default building facing degrees
      • Set Dummy[maxnidex] = (Last created unit)
      • Set EffectType[maxnidex] = 1
      • Set Countdown[maxnidex] = 0.00
      • Set TempInt = 0
      • Set TempRecord = 0
      • Set TempEffectInt = 0
      • For each (Integer TempInt) from 1 to maxnidex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero[TempInt] Equal to Hero[currentindex]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer(DelayTime[TempInt])) Greater than TempRecord
                • Then - Actions
                  • Set TempRecord = (Integer(DelayTime[TempInt]))
                  • Set TempEffectInt = EffectType[TempInt]
                • Else - Actions
            • Else - Actions
      • Set DelayTime[currentindex] = ((Real(TempRecord)) + (Real(2)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TempEffectInt + 1) Greater than 5
        • Then - Actions
          • Set TempEffectInt = 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempEffectInt Equal to 0
            • Then - Actions
              • Set EffectType[currentindex] = (TempEffectInt + 1)
            • Else - Actions
But something doesn't make sense to me. How come some var have an array of currentindex (as currentindex is A), if currentindex doesn't get used until the loop trigger? Or is this code meant to work in combo with the Switch and loop trigs?
 
Status
Not open for further replies.
Top