knockback question

XeNiM666

I lurk for pizza
Reaction score
138
i have a spell that knockbacks every units is front of the caster. but somehow, it knockbacks the unit instantly. It doesnt move.
Heres the code:

JASS:
scope Bash

    globals
        private constant integer BASH_ABILITY_ID = 'A008'
        
        private constant string BASH_CAST_EFFECT = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
        private constant string BASH_CAST_ATTACH_1 = "hand,left"
        private constant string BASH_CAST_ATTACH_2 = "hand,right"

        private constant string BASH_SLIDING_EFFECT = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl"
        private constant string BASH_SLIDING_ATTACH = "origin"
        
        private constant real MS_SLIDE_REDUCTION = 0.50 // IN PERCENTAGE //
        
        private constant attacktype ATTACK_TYPE = ATTACK_TYPE_SIEGE
        private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
        private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
        
        private constant integer MAXIMUM_PUSHED = 250
    endglobals
        
    private function Damage takes integer lvl returns real
        if lvl == 1 then
            return 120.00 // DAMAGE AT LEVEL 1 //
        elseif lvl == 2 then
            return 200.00 // DAMAGE AT LEVEL 2 //
        elseif lvl == 3 then
            return 320.00 // DAMAGE AT LEVEL 3 //
        elseif lvl == 4 then
            return 400.00 // DAMAGE AT LEVEL 4 //
        endif
        return 490.00 // DAMAGE AT LEVEL 5 //
    endfunction
    
    private function Distance takes integer lvl returns real
        if lvl == 1 then
            return 300.00 // KNOCKBACK DISTANCE AT LEVEL 1 //
        elseif lvl == 2 then
            return 350.00 // KNOCKBACK DISTANCE AT LEVEL 2 //
        elseif lvl == 3 then
            return 400.00 // KNOCKBACK DISTANCE AT LEVEL 3 //
        elseif lvl == 4 then
            return 450.00 // KNOCKBACK DISTANCE AT LEVEL 4 //
        endif
        return 500.00 // KNOCKBACK DISTANCE AT LEVEL 5 //
    endfunction

    private struct Bash
        unit caster
        real cx
        real cy
        integer num                             = 0
        unit array target [ MAXIMUM_PUSHED ]
        real array tx [ MAXIMUM_PUSHED ]
        real array ty [ MAXIMUM_PUSHED ]
        real array n [ MAXIMUM_PUSHED ]
        real array cos [ MAXIMUM_PUSHED ]
        real array sin [ MAXIMUM_PUSHED ]
        real array rate [ MAXIMUM_PUSHED ]
        real array dec [ MAXIMUM_PUSHED ]
        real distance
                
        static method Move takes nothing returns boolean
            local Bash b = TT_GetData()
                        
            local boolean flag = false
            
            local integer i = 0
            local real x
            local real y 
            local real nx
            local real ny
            
            loop
                set i = i + 1
                
                set x = GetUnitX( b.target[ i ] )
                set y = GetUnitY( b.target[ i ] )
                
                call DestroyEffect( AddSpecialEffectTarget( BASH_SLIDING_EFFECT, b.target[ i ], BASH_SLIDING_ATTACH ) )
                
                set nx = x + b.rate * b.cos[ i ]
                set ny = y + b.rate * b.sin[ i ]
                
                call SetUnitPosition( b.target[ i ], nx, ny )
                
                set b.n[ i ] = b.n[ i ] + b.rate
                set b.rate[ i ] = b.rate[ i ] - b.dec[ i ]
                                                           
                if b.rate[ i ] <= 0.00 or b.n[ i ] >= b.distance then
                    call PauseUnit( b.target[ i ], false )
                    set b.target[ i ] = null
                    set b.num = b.num - 1
                endif
                
                exitwhen i >= b.num
            endloop
            
            if b.num <= 0 then
                set flag = true
            endif
            
            return flag        
        endmethod
        
        static method Actions takes nothing returns nothing
            local Bash b = Bash.create()
            
            local real q = 1.00 / TT_PERIOD
            local group g = CreateGroup()
            local unit u = null
            local real angle
            
            local integer lvl
            local real damage

            set b.caster = GetTriggerUnit()
            set b.cx = GetUnitX( b.caster )
            set b.cy = GetUnitY( b.caster )
            
            set lvl = GetUnitAbilityLevel( b.caster, BASH_ABILITY_ID )
            set damage = Damage( lvl ) 
            set b.distance = Distance( lvl )           
            
            set g = UnitsInFront( b.caster, 225.00 )
            
            loop
                set u = FirstOfGroup( g )
                
                if IsUnitEnemy( u, GetOwningPlayer( b.caster ) ) == true and IsUnitType( u, UNIT_TYPE_STRUCTURE ) == false and IsUnitType( u, UNIT_TYPE_FLYING ) == false then
                    set b.num = b.num + 1
                    
                    set b.n[ b.num ] = 0.00
                                    
                    set b.target[ b.num ] = u
                    set b.tx[ b.num ] = GetUnitX( b.target[ b.num ] )
                    set b.ty[ b.num ] = GetUnitY( b.target[ b.num ] )
                
                    set angle = bj_RADTODEG * Atan2( b.ty[ b.num ] - b.cy , b.tx[ b.num ] - b.cx )
                
                    set b.cos[ b.num ] = Cos( angle * bj_DEGTORAD )
                    set b.sin[ b.num ] = Sin( angle * bj_DEGTORAD )
                    
                    set b.rate[ b.num ] = ( 2 * b.distance ) / ( q + 1 )
                    set b.dec[ b.num ] = b.rate[ b.num ] / q
                    
                    call BJDebugMsg( I2S( b.num ) + ", b.rate : " + R2S( b.rate[ b.num ] ) )
                    call BJDebugMsg( I2S( b.num ) + ", b.dec : " + R2S( b.dec[ b.num ] ) )
                    
                    call UnitDamageTarget( b.caster, b.target[ b.num ], damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE )
                    call PauseUnit( b.target[ b.num ], true )
                endif

                exitwhen u == null
                
                call GroupRemoveUnit( g, u )
            endloop
                                            
            call DestroyEffect( AddSpecialEffectTarget( BASH_CAST_EFFECT, b.caster, BASH_CAST_ATTACH_1 ) )
            call DestroyEffect( AddSpecialEffectTarget( BASH_CAST_EFFECT, b.caster, BASH_CAST_ATTACH_2 ) )

            call TT_Start( function Bash.Move, b )
            
            call DestroyGroup( g )
            set g = null
        endmethod
                
        static method Check_ID takes nothing returns boolean
            return GetSpellAbilityId() == BASH_ABILITY_ID
        endmethod

    //===========================================================================
       
        static method onInit takes nothing returns nothing
            local trigger B = CreateTrigger(  )
            local integer i = 0
            
            loop 
                exitwhen i > 15
                call TriggerRegisterPlayerUnitEvent( B, Player( i ), EVENT_PLAYER_UNIT_SPELL_EFFECT, Condition( function True ) )
                
                set i = i + 1
            endloop
            
            call TriggerAddCondition( B, Condition( function Bash.Check_ID ) )
            call TriggerAddAction( B, function Bash.Actions )
            
            set B = null
            
            call Preload( BASH_SLIDING_EFFECT )
            call Preload( BASH_CAST_ATTACH_1 )
            call Preload( BASH_CAST_ATTACH_2 )
            call Preload( BASH_CAST_EFFECT )
            call Preload( BASH_SLIDING_ATTACH )
        endmethod
    
    endstruct

endscope


The Debug Messages display the right thing but it knockbacks too fast, almost (actually really)instantly
 

Viikuna

No Marlo no game.
Reaction score
265
b.rate should probably be b.rate in your periodic function.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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