Spell Problems

Gwafu

Active Member
Reaction score
12
Confuse
When the effect runs out, the confused/target unit still attacks his last attacked unit.

Trigger:
  • Confusion 1
    • Events
    • Conditions
      • ((Damage source) is in Confusion_UG) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Key target) is stored as a Handle of (Key (Damage source)) in Confusion_Hash) Equal to False
        • Then - Actions
          • Hashtable - Save Handle Of(Triggering unit) as (Key target) of (Key (Damage source)) in Confusion_Hash
        • Else - Actions



Trigger:
  • Confusion 2
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Confusion 1 <gen> the event (Unit - (Triggering unit) Takes damage)


Trigger:
  • Confusion 3
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Confusion_UG is empty) Equal to False
        • Then - Actions
          • Unit Group - Pick every unit in Confusion_UG and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Key target) is stored as a Handle of (Key (Picked unit)) in Confusion_Hash) Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) has buff Confusion ) Equal to True
                    • Then - Actions
                      • Set Confusion_Point = (Position of (Picked unit))
                      • Set Confusion_TempGroup = (Units within (Current acquisition range of (Picked unit)) of Confusion_Point matching ((Life of (Matching unit)) Greater than (0.41 - 0.05)))
                      • Unit - Order (Picked unit) to Attack (Random unit from Confusion_TempGroup)
                      • Custom script: call DestroyGroup (udg_Confusion_TempGroup)
                      • Custom script: call RemoveLocation (udg_Confusion_Point)
                    • Else - Actions
                      • Hashtable - Save Handle OfNo unit as (Key target) of (Key (Picked unit)) in Confusion_Hash
                      • Unit - Order (Picked unit) to Stop
                      • Unit Group - Remove (Picked unit) from Confusion_UG
                      • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Confusion_Hash
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Life of (Load (Key target) of (Key (Picked unit)) in Confusion_Hash)) Less than (0.41 - 0.05)
                    • Then - Actions
                      • Hashtable - Save Handle OfNo unit as (Key target) of (Key (Picked unit)) in Confusion_Hash
                      • Unit - Order (Picked unit) to Stop
                      • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Confusion_Hash
                    • Else - Actions
        • Else - Actions
          • Trigger - Turn off (This trigger)


Trigger:
  • Confusion 4
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • ((Triggering unit) is in Confusion_UG) Equal to True
    • Actions
      • Set Confusion_MainUnit = (Load (Key target) of (Key (Triggering unit)) in Confusion_Hash)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of Confusion_MainUnit) Greater than (0.41 - 0.05)
        • Then - Actions
          • Wait 0.00 seconds
          • Unit - Order (Triggering unit) to Attack Confusion_MainUnit
        • Else - Actions


Trigger:
  • Confusion 5
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Confusion
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is in Confusion_UG) Equal to False
        • Then - Actions
          • Unit Group - Add (Target unit of ability being cast) to Confusion_UG
          • Trigger - Turn on Confusion 3 <gen>
        • Else - Actions


Trigger:
  • Confusion 6
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in Confusion_UG) Equal to True
    • Actions
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in Confusion_Hash
      • Unit Group - Remove (Triggering unit) from Confusion_UG


Here's what it does:

~The target unit will randomly attack anything and it's uncontrollable, but after the effect runs out, it should stop attacking (if the target is a friend) or continue attacking (if it is an enemy).

~Gwafu
 

Moridin

Snow Leopard
Reaction score
144
I'm not exactly sure how the boolean hashtable conditions work, but an efficient way to find out why it isn't stopping is to use

Game - Display text to all players

..command.

Also, because you know that the problem is where the unit doesn't stop, you can narrow the possiblities to:
1) The conditions never not get satisfied, meaning the code never gets to the blocks where it orders the stop.
2) It gets to the block but the stop order doesn't work (highly unlikely).

Just run through those conditions and ensure that they really will give false once the spell is over.
 

Gwafu

Active Member
Reaction score
12
Hmm, I think the periodic is the problem.
I set it to 0.50, it still don't stop.
I set it to 0.25, still don't
Set it to 0.15, and it goes crazy. Like it can't attack now, it's like the target is dancing and won't attack.
 

farold

New Member
Reaction score
3
Trigger:
  • Actions
    • Unit - Pause (Triggering unit)
    • Unit - Unpause (Triggering unit)

Try this :thup:
 

hgkjfhfdsj

Active Member
Reaction score
55
- disable/enable trigger in confusion 4 before ordering triggering unit to attack CofusionMainUnit (infinite loop)
- remove unit from group before ordering to stop (so it doesnt fire the order event(
 

Gwafu

Active Member
Reaction score
12
What do you mean by disable? Where should I enable it and disable it?
 

hgkjfhfdsj

Active Member
Reaction score
55
freehand:
Trigger:
  • Confusion 4
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • ((Triggering unit) is in Confusion_UG) Equal to True
    • Actions
      • Set Confusion_MainUnit = (Load (Key target) of (Key (Triggering unit)) in Confusion_Hash)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of Confusion_MainUnit) Greater than (0.41 - 0.05)
        • Then - Actions
          • Wait 0.00 seconds
          • Disable (This Trigger)
          • Unit - Order (Triggering unit) to Attack Confusion_MainUnit
          • Enable (This Trigger)
        • Else - Actions


you probably wont need the wait in this case

Trigger:
  • Else - Actions
    • Hashtable - Save Handle OfNo unit as (Key target) of (Key (Picked unit)) in Confusion_Hash
    • Unit Group - Remove (Picked unit) from Confusion_UG //switch these 2
    • Unit - Order (Picked unit) to Stop //switch these 2
    • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Confusion_Hash
 

hgkjfhfdsj

Active Member
Reaction score
55
so what was the problem again?
- purpose of damage event? i dont think a unit that is changing target every 1s will ever land a hit :p
- i suggest you set the target in Confusion 3 when 'key target is stored == false' rather than on damage
- switch turn on/off (off first then on)
- on buff removal, spell ends >> unit stops attacking
- Confusion_MainUnit in Confusion 4 will most likely be null
 

Gwafu

Active Member
Reaction score
12
i suggest you set the target in Confusion 3 when 'key target is stored == false' rather than on damage
Care to explain?

switch turn on/off (off first then on)
Oh lol.

on buff removal, spell ends >> unit stops attacking
Dude, wait, what?

Confusion_MainUnit in Confusion 4 will most likely be null
I'll run more tests.



EDIT: Nevermind ._., managed to make it work.
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top