HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Knockback Troubles

01-24-2006, 12:21 PM#1
emjlr3
try to make a knockback that slowly slows to a stop, now this used to work fine, I went in and changed to try and make it slow to a stop, and now it dont work, then I tried changing it back to how I thought I had it, and still nothing

so this is what I am going for, and this is what I got, any ideas as to why nothin at all is happening?

Code:
function Trig_Beast_Axe_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000' 
endfunction

function Knockback takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit caster = GetHandleUnit(t, "caster")
local unit target = GetHandleUnit(t, "target")
local integer distance = GetHandleInt(t,"distance")
local integer change = GetHandleInt(t,"change")
local real angle = GetHandleReal(t,"angle")
local location l = GetUnitLoc(target)
local location m = PolarProjectionBJ(l, distance, angle)
call SetUnitPositionLoc( target, m )
call DestroyEffect(AddSpecialEffect( "Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.m  dl",GetLocationX(l), GetLocationY(l)) )
set distance = distance - change
call SetHandleInt(t,"distance",distance)

set t = null
set caster = null
set target = null
call RemoveLocation(l)
call RemoveLocation(m)
set l = null
set m = null
endfunction

function Execute_Knockback takes nothing returns nothing
local timer t = CreateTimer()
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
local real angle = GetUnitFacing(caster)
local integer distance = 15
local integer change =  15 / ( ( R2I(0.50) * ( R2I(0.50) * GetUnitAbilityLevelSwapped('A000', caster) ) ) / R2I(0.03) ) 
call UnitDamageTargetBJ( caster, target, I2R(GetHeroStatBJ(bj_HEROSTAT_STR, caster, true)), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
call SetHandleHandle(t, "caster", caster)
call SetHandleHandle(t, "target", target)
call SetHandleInt(t,"distance",distance)
call SetHandleInt(t,"change",change)
call SetHandleReal(t,"angle",angle)
call TimerStart(t, 0.03, true, function Knockback)
call TriggerSleepAction( ( 0.50 * ( 0.50 * I2R(GetUnitAbilityLevelSwapped('A000', caster)) ) ) )
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
set caster = null
set target = null
endfunction

//======================================================================  =====
function InitTrig_Beast_Axe takes nothing returns nothing
    set gg_trg_Beast_Axe = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Beast_Axe, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Beast_Axe, Condition( function Trig_Beast_Axe_Conditions ) )
    call TriggerAddAction( gg_trg_Beast_Axe, function Execute_Knockback )
endfunction

ty for the help
01-24-2006, 01:59 PM#2
Chuckle_Brother
Well dividing by a decimal value will realistically increase it
15 / (.5 * (.5 * 1)) = 15 / .25 = 60

So really what you want to do is muliply 15 by that decimal value.

15 * (.5 * (.5 * 1)) = 15 * .25 = 3.75

Of course that will totally slow the unit within 5 executions Knockback. So you may want to make it slow by a little bit less.
01-24-2006, 03:18 PM#3
emjlr3
heh I thought I had devised my equation to slow it depeiding on how long it lasts, since the times for the three levels are .25, .5 and .75

i start at a distance change of 15

15 / ( ( R2I(0.50) * ( R2I(0.50) * GetUnitAbilityLevelSwapped('A000', caster) ) ) / R2I(0.03) )

i find the length of the timer
( ( R2I(0.50) * ( R2I(0.50) * GetUnitAbilityLevelSwapped('A000', caster)
then how many exucitions will run in that amount of time
/ R2I(0.03) )
then take my distance to start and divide that by what I jsut go to get how much I should decrease it by for each execution for it to eventually stop in the time frame

atleast I think it should work

in ur example you forgot the divided by .03, which makes it no longer a decimal value, and actually makes it larger then 15( for levels 2 and 3), thus making the end value decimal less then 1( for levels 2 and 3)

for example

lets look at lvl 1

.5*(.5*1)=.25/.03=8.33=amount of executions for the function
15/8.33=1.8=the change needed to take the 15 down to around 0 in those 8.33 executions

so the first run moves 15, the next is 15-1.8=13.2, the next is 11.4, and so forth, for 8 executions, taking it down to .6 for the last execution

thus making it look like it slows to a stop

I think....

however nothing at all is happening

so im still at a loss :(
01-24-2006, 04:01 PM#4
Chuckle_Brother
hmm, didn't see that...oh well I'm stumped
01-24-2006, 04:25 PM#5
emjlr3
I just got some help from Daelin, ill see if it works ;)
01-24-2006, 05:50 PM#6
Vexorian
what exactly doesn't work? it is not moving correctly, disappearing or not moving at all?
01-25-2006, 12:08 PM#7
emjlr3
it was doing nothing at all, for reasons that are still beyond me, however I have since gotten it to work, although with different scripting

here it is, if anyone is interested

Code:
function Destroy_Trees takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction

function Knockback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit cast = GetHandleUnit(t, "cast")
    local unit targ = GetHandleUnit(t, "targ")
    local real dist = GetHandleReal(t,"dist")    
    local real angle = GetHandleReal(t,"angle")
    local location m = Location(GetUnitX(targ)+dist*CosBJ(angle),GetUnitY(targ)+dist*SinBJ(angle))        
    call SetUnitPositionLoc( targ, m )
    call DestroyEffect(AddSpellEffectByIdLoc('A00L',EFFECT_TYPE_SPECIAL,m))   
    call SetHandleReal(t,"dist",dist*.98)
    call EnumDestructablesInCircleBJ(150.,m,function Destroy_Trees)
    call UnitDamageTargetBJ( cast, targ, .33, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )

    set t = null
    set cast = null
    set targ = null     
    call RemoveLocation(m)    
    set m = null
endfunction

function Execute_Knockback takes nothing returns nothing
    local timer t = CreateTimer()
    local unit cast = GetAttacker()
    local unit targ = GetTriggerUnit() 
    local real angle = AngleBetweenPoints(GetUnitLoc(cast), GetUnitLoc(targ)) 
    local effect fx=AddSpecialEffectTargetUnitBJ("weapon",cast,"Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl")
    call DestroyEffect(fx)    
    call UnitDamageTargetBJ( cast, targ, 25 * GetUnitAbilityLevel(cast, 'A00L' ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
    call SetHandleHandle(t, "cast", cast)
    call SetHandleHandle(t, "targ", targ)
    call SetHandleReal(t,"dist",4.00)    
    call SetHandleReal(t,"angle",angle)
    call DisableTrigger(GetTriggeringTrigger())
    call TimerStart(t, 0.01, true, function Knockback)
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1254" )    
    call TriggerSleepAction( 0.4+( .2* I2R(GetUnitAbilityLevel(cast, 'A00L'))))
    call EnableTrigger(GetTriggeringTrigger())    
    
    call FlushHandleLocals(t)
    set fx = null
    call PauseTimer(t)
    call DestroyTimer(t)    
    set t = null
    set cast = null
    set targ = null
    call RemoveLocation(GetUnitLoc(cast))  
    call RemoveLocation(GetUnitLoc(targ))
endfunction
01-25-2006, 01:32 PM#8
Vexorian
can't believe people still use the slow handle variables
01-25-2006, 02:59 PM#9
qwertyui
Hmmmm???
You mean unit variables and such?
What do you use?
01-25-2006, 07:19 PM#10
emjlr3
if there is a better way Vex, I don't know of it

however if you'd be so kind as to point me in it's direction, there would possibly be one less person who uses the slow Handles... :)
01-25-2006, 07:28 PM#11
Blade.dk
There is his CSCache module, which is a part of the Caster System, it has tables which are faster.
01-26-2006, 11:34 AM#12
emjlr3
i see that he keeps writing that, ive used tables all over

any place I can actually learn how to use them?
01-26-2006, 11:39 AM#13
Blade.dk
The Caster System read me has some examples I think, also you can learn to use them by looking at the spells that uses them, Vexorian's spells does and all my new spells does too.