Knockback system trouble

Curo

Why am I still playing this game...?
Reaction score
109
Been a while since I've asked for help here. Basically, I have a periodic forced movement/knockback system that utilizes hashtables to track individual units. Pretty simple, but I made it from scratch (almost), so it doesn't work.

I'd also appreciate any tips at making it more efficient.

I've added in debug display text lines to find when it stops working. It stops at the following line in the second trigger:
Trigger:
  • Set TempRl[1] = (0.04 x ((Load (Key distance) of (Key (Picked unit)) from movement_table) / (Load (Key speed) of (Key (Picked unit)) from movement_table)))


None of the actions afterward are performed. TempRl is a real variable array (size 10). Here are both relevant triggers. The first one works fine. The second one stops 4 action lines in, as noted above:

Trigger:
  • Knockback Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Knockback
    • Actions
      • Set TempPoint[1] = (Position of (Triggering unit))
      • Set TempPoint[2] = (Position of (Target unit of ability being cast))
      • Hashtable - Save (Angle from TempPoint[1] to TempPoint[2]) as (Key angle) of (Key (Target unit of ability being cast)) in movement_table
      • Custom script: call RemoveLocation (udg_TempPoint[1])
      • Custom script: call RemoveLocation (udg_TempPoint[2])
      • Hashtable - Save 400.00 as (Key distance) of (Key (Target unit of ability being cast)) in movement_table
      • Hashtable - Save 400.00 as (Key distance remaining) of (Key (Target unit of ability being cast)) in movement_table
      • Hashtable - Save 1.00 as (Key speed) of (Key (Target unit of ability being cast)) in movement_table
      • Hashtable - Save True as (Key destroys trees) of (Key (Target unit of ability being cast)) in movement_table
      • Hashtable - Save Abilities\Spells\Human\FlakCannons\FlakTarget.mdl as (Key effect) of (Key (Target unit of ability being cast)) in movement_table
      • Unit Group - Add (Target unit of ability being cast) to knockback_group


Trigger:
  • Movement
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in knockback_group and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • Set TempRl[1] = (0.04 x ((Load (Key distance) of (Key (Picked unit)) from movement_table) / (Load (Key speed) of (Key (Picked unit)) from movement_table)))
          • Set TempPoint[1] = (Position of TempUnit)
          • Set TempPoint[2] = (TempPoint[1] offset by TempRl[1] towards (Load (Key angle) of (Key (Picked unit)) from movement_table) degrees)
          • Custom script: call RemoveLocation (udg_TempPoint[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempUnit is Snared) Equal to False
              • TempUnit Not equal to boss[11]
              • TempUnit Not equal to boss[13]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Key destroys trees) of (Key (Picked unit)) from movement_table) Equal to True
                • Then - Actions
                  • Destructible - Pick every destructible within 100.00 of TempPoint[2] and do (If ((((Destructible-type of (Picked destructible)) Equal to Winter Tree Wall) or ((Destructible-type of (Picked destructible)) Equal to Ashenvale Tree Wall)) or ((Destructible-type of (Picked destructible)) Equal to Ashenvale Canopy Tree)) then do (Destructi
                • Else - Actions
              • Unit - Move TempUnit instantly to TempPoint[2]
            • Else - Actions
          • Set TempRl[2] = ((Load (Key distance remaining) of (Key (Picked unit)) from movement_table) - TempRl[1])
          • Set TempString = (Load (Key effect) of (Key (Picked unit)) from movement_table)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempString Not equal to <Empty String>
            • Then - Actions
              • Special Effect - Create a special effect at TempPoint[2] using TempString
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
          • Custom script: call RemoveLocation (udg_TempPoint[2])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempRl[2] Greater than 0.00
            • Then - Actions
              • Hashtable - Save TempRl[2] as (Key distance remaining) of (Key (Picked unit)) in movement_table
            • Else - Actions
              • Unit Group - Remove TempUnit from knockback_group
 
I've made a unit moving system(beta version) that supports knockback. Tell me everything about it, and I post you map with the knockback you want
 
I've made a unit moving system(beta version) that supports knockback. Tell me everything about it, and I post you map with the knockback you want

Thanks for the offer. I may consider it if I can't debug my coding. No jass though please, as it takes me forever to read through it.

I'm also trying to incorporate this as a universal movement system. There are other parts that use "set X/Y" movement, but the knockback part is what I'm dealing with at the moment. I hope to eventually use it for dummy projectiles and other forced movement, rotation, charging/dashing, etc.

I've seen other systems, and aside from the fact that most are jass and too complicated for me to decipher, I prefer to do my own coding.

But as far as the code I've presented you with goes: can you see any bugs that would cause it to stop running at the point I mentioned in the original post?
 
I don't use hashtables, as they are complicated to me, and I will give you vJass code. I will explain you everything. My system can do almost anything. Now I am working on homing movement.
 
I don't use hashtables, as they are complicated to me, and I will give you vJass code. I will explain you everything. My system can do almost anything. Now I am working on homing movement.

Don't worry about it then dude. I don't use vjass. There are already lots of systems out there, so I can just pick one up if I need it. Thanks though.
 
Ok, so I did some more testing and found that the problem is in the first trigger. NONE of my hashtable values are being saved.
 
Is the hashtable created in the first place? I had this kind of error once, until I realised I didn't have a Hashtable - Create Hashtable action.
 
Ok, so I did some more testing and found that the problem is in the first trigger. NONE of my hashtable values are being saved.

Rofl. You didn't create the hashtable. Initially I was going to suggest this but I decided not.
 
Yeah, major facepalm right there. Nobody is ever going to take me seriously again, lol...

Thanks guys, I love you! Hydra, I got rep coming at you when I can.

So, I have another part that uses set X/Y movement, rather than set position movement. I use:
Trigger:
  • Custom script: call SetUnitX (udg_TempUnit, GetLocationX(udg_TempPoint[2]) )

However, I'd like to replace the TempUnit variable with (Picked Unit). I'm not sure how to refer to this in JASS though. It's not GetPickedUnit(), and I can't find it on any tutorials here.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top