• 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.

Channel System Error

Status
Not open for further replies.
Level 15
Joined
Oct 16, 2010
Messages
942
I'm trying to make a channel system for an ORPG i'm developing but its not working quite right.

Basically, a unit casts a spell and saves the casting time of the ability and the trigger that is to be run when the channel is finished to the casting unit. I then run through a periodic to check if the channel is interrupted for some reason (if the unit moves or is stunned). Once the casting time is reached, the channel is stopped and the saved trigger is run.

I made a test ability that should have a 2.5 second casting time. My problem is for some reason the channel is almost instantanious instead of taking 2.5 seconds.

Here are the triggers, any help would be appreciated!


Channel System

  • Channel Hashtable
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set HASHTABLE_channel = (Last created hashtable)
      • Trigger - Turn on Channel Periodic <gen>
  • Channel Periodic
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CHANNEL_unitgroup and do (Actions)
        • Loop - Actions
          • -------- ---------------------------------------------------------------- --------
          • -------- Checks to see if the unit has moved from the last periodic proc --------
          • -------- ---------------------------------------------------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load (Integer(casting count)) of (Custom value of (Picked unit)) from HASHTABLE_channel) Greater than 0.00
            • Then - Actions
              • Hashtable - Save (X of (Position of (Picked unit))) as (Integer(pos1x)) of (Custom value of (Picked unit)) in HASHTABLE_channel
              • Hashtable - Save (Y of (Position of (Picked unit))) as (Integer(pos1y)) of (Custom value of (Picked unit)) in HASHTABLE_channel
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Load (Integer(pos1x)) of (Custom value of (Picked unit)) from HASHTABLE_channel) Not equal to (Load (Integer(pos2x)) of (Custom value of (Picked unit)) from HASHTABLE_channel)
                      • (Load (Integer(pos1y)) of (Custom value of (Picked unit)) from HASHTABLE_channel) Not equal to (Load (Integer(pos2y)) of (Custom value of (Picked unit)) from HASHTABLE_channel)
                • Then - Actions
                  • Set BOOLEAN_temp = True
                • Else - Actions
              • Hashtable - Save (X of (Position of (Picked unit))) as (Integer(pos2x)) of (Custom value of (Picked unit)) in HASHTABLE_channel
              • Hashtable - Save (Y of (Position of (Picked unit))) as (Integer(pos2y)) of (Custom value of (Picked unit)) in HASHTABLE_channel
            • Else - Actions
              • Hashtable - Save (X of (Position of (Picked unit))) as (Integer(pos2x)) of (Custom value of (Picked unit)) in HASHTABLE_channel
              • Hashtable - Save (Y of (Position of (Picked unit))) as (Integer(pos2y)) of (Custom value of (Picked unit)) in HASHTABLE_channel
          • -------- ------------------------------------------------------------------------------------------------ --------
          • -------- If the unit has moved, or if it has been stunned, then the channel is exited --------
          • -------- ------------------------------------------------------------------------------------------------ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Picked unit) has buff Stunned (Pause)) Equal to True
                  • BOOLEAN_temp Equal to True
            • Then - Actions
              • Set BOOLEAN_temp = False
              • Hashtable - Save 0.00 as (Integer(casting time)) of (Custom value of (Picked unit)) in HASHTABLE_channel
              • Unit Group - Remove (Picked unit) from CHANNEL_unitgroup
            • Else - Actions
              • -------- ---------------------------------------------------------------- --------
              • -------- Adds the .05 seconds that have passed since the last periodic proc to the casting count --------
              • -------- ---------------------------------------------------------------- --------
              • Hashtable - Save ((Load (Integer(casting count)) of (Custom value of (Picked unit)) from HASHTABLE_channel) + 0.05) as (Integer(casting count)) of (Custom value of (Picked unit)) in HASHTABLE_channel
              • -------- ---------------------------------------------------------------- --------
              • -------- If the casting count is equal to the casting time then the channel is exited and the saved trigger is run --------
              • -------- ---------------------------------------------------------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Integer(casting count)) of (Custom value of (Picked unit)) from HASHTABLE_channel) Greater than or equal to (Load (Integer(casting time)) of (Custom value of (Picked unit)) from HASHTABLE_channel)
                • Then - Actions
                  • Hashtable - Save 0.00 as (Integer(casting count)) of (Custom value of (Picked unit)) in HASHTABLE_channel
                  • Unit Group - Remove (Picked unit) from CHANNEL_unitgroup
                  • Trigger - Run (Load (Integer(trigger)) of (Custom value of (Picked unit)) in HASHTABLE_channel) (ignoring conditions)
                • Else - Actions

Test Ability (2.5 sec. cast)

  • Judgement Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Judgement
    • Actions
      • -------- ---------------------------------------------------------------- --------
      • -------- TEST ABILITY - saves the casting time and the trigger to run when the channel is complete to the unit --------
      • -------- ---------------------------------------------------------------- --------
      • Hashtable - Save 2.50 as (Integer(casting time)) of (Custom value of (Triggering unit)) in HASHTABLE_channel
      • Hashtable - Save Handle OfJudgement Finish <gen> as (Integer(trigger)) of (Custom value of (Triggering unit)) in HASHTABLE_channel
      • Animation - Play (Triggering unit)'s spell channel animation
      • Unit Group - Add (Triggering unit) to CHANNEL_unitgroup
  • Judgement Finish
    • Events
    • Conditions
    • Actions
      • -------- ---------------------------------------------------------------- --------
      • -------- This trigger runs when the channel is complete --------
      • -------- ---------------------------------------------------------------- --------
      • Quest - Display to (All players) the Quest Update message: CASTING FINISHED!


EDIT - btw, I ran a test and when the channel finishes the casting count and casting time are both -1590.22 instead of 2.5 like they should be.
 
Level 15
Joined
Oct 16, 2010
Messages
942
EDIT - I found the problem. For some reason converting strings to integers and then using those as keys screwed it up. When I switched them to just straight integers it worked perfectly.

Two questions though if you happen to read this.

1. What exactly is leaking in the triggers? Is it the 'position of unit' function I use when trying to see if the caster is moving? I didn't think that would leak since i'm just applying it to a hashtable.
2. Will using the custom value of units cause glitches or is it just more efficient to use unit handles?
 
Last edited:
1)
The leaks are the following ones:
• Hashtable - Save (X of (Position of (Picked unit))) as (Integer(pos1x)) of (Custom value of (Picked unit)) in HASHTABLE_channel
Hashtable - Save (Y of (Position of (Picked unit))) as (Integer(pos1y)) of (Custom value of (Picked unit)) in HASHTABLE_channel

You save the X of a location; that location [(Position of (Picked unit))] leaks.
Set the variable first, e.g. Set Point1 = (Position of (Picked unit)) and then
Hashtable - Save (X of Point1) as...

• Hashtable - Save (X of (Position of (Picked unit))) as (Integer(pos2x)) of (Custom value of (Picked unit)) in HASHTABLE_channel
Hashtable - Save (Y of (Position of (Picked unit))) as (Integer(pos2y)) of (Custom value of (Picked unit)) in HASHTABLE_channel

Same as above.

• Hashtable - Save (X of (Position of (Picked unit))) as (Integer(pos2x)) of (Custom value of (Picked unit)) in HASHTABLE_channel
Hashtable - Save (Y of (Position of (Picked unit))) as (Integer(pos2y)) of (Custom value of (Picked unit)) in HASHTABLE_channel

Same as above.

2) I don't think that's 100% MUI. If two units of the group have the same custom value, their actions will collide. You had better save the values to the Picked unit itself, not its custom value, e.g.:
  • Hashtable - Save 2.50 as Key(castingtime) of (Key(Triggering unit)) in HASHTABLE_channel
Generally, don't involve Custom values, because, if there are other spells or systems that also use custom values, they will be increasing them and the system of yours will not function as intended.
 
Level 15
Joined
Oct 16, 2010
Messages
942
I didn't think it allocated memory for the points since I was just grabbing their x/y values - thanks for the info

I thought every unit had a different custom value? maybe I was wrong. I'll change it to unit handles anyway. The only reason I didn't use unit handles in the first place was b/c I couldn't find the commands for them in newgen.

TY
 
I didn't think it allocated memory for the points since I was just grabbing their x/y values - thanks for the info

I thought every unit had a different custom value? maybe I was wrong. I'll change it to unit handles anyway. The only reason I didn't use unit handles in the first place was b/c I couldn't find the commands for them in newgen.

TY

everything takes memory...

yeah they can have different custom values but they can be the same since you just set it... while UnitId is unique for every unit and you cannot modify it...

if using NewGen, you gotta use jass hashtables because the GUI one is screwed...
 
Status
Not open for further replies.
Top