vJASS Problem

RaiJin

New Member
Reaction score
40
uh..maybe try using debug msgs :S? to show what the angle is and if its changing?

JASS:
scope WaveForm initializer WaveFormInit

globals
    private constant string  EFFECT        =                        "Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl" //Water effect used when dashing
    private constant real    DISTANCE      =                         30.00 //  DISTANCE
    private constant real    TIMERINTERVAL =                         0.03 //Perodic Timer interval
    private constant real    DMGCOUNT      =                         100.00 // DAMAGE PER LEVEL
    private constant real    MAXDISTANCE   =                         1100.00 //MAX DISTANCE ABLE TO TRAVEL
    private constant real    AOE           =                         200.00// MAX AOE OF THE SPELL
    private constant integer WAVEFORMID    =                         'WAV3' //SpellID NAME
endglobals

private struct data
    unit u
    location sl
    integer lvl
    real DAMAGE
    real dis
    real x
    real y
    real x2
    real y2
    real angle
    timer time
    group ug
    group ha
    static data temp
    
    method CleanUp takes nothing returns nothing
        call DestroyGroup(.ha)
        call DestroyGroup(.ug)
        call RemoveLocation(.sl)
    endmethod
endstruct

private function GroupDMGCheck takes nothing returns boolean
    local data d=data.temp
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(d.u)) and IsUnitInGroup(GetFilterUnit(), d.ha)
endfunction

private function WConditions takes nothing returns boolean
    return GetSpellAbilityId() == WAVEFORMID
endfunction

private function GroupDAMAGE takes nothing returns nothing
    local data d=data.temp
    call UnitDamageTargetBJ(d.u, GetEnumUnit(), d.DAMAGE, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
    call GroupAddUnit(d.ha, GetEnumUnit())
endfunction

private function Movement takes nothing returns nothing
    local data d = GetTimerData(GetExpiredTimer())
    local effect e
    local real xx
    local real yy
    local real newx
    local real newy
    local real nangle
    local location wl=GetUnitLoc(d.u)
    set d.x=GetUnitX(d.u)
    set d.y=GetUnitY(d.u)
    set xx=d.x - d.x2
    set yy=d.y - d.y2
    set d.dis=SquareRoot( xx * xx + yy * yy)
    set newx=d.x + DISTANCE * Cos(d.angle * bj_DEGTORAD)
    set newy=d.y + DISTANCE * Cos(d.angle * bj_DEGTORAD)
    if d.dis < MAXDISTANCE then
        call SetUnitX(d.u, newx)
        call SetUnitY(d.u, newy)
        set d.ug=CreateGroup()
        call GroupEnumUnitsInRange(d.ug, d.x, d.y, AOE, Condition(function GroupDMGCheck))
        set e=AddSpecialEffect(EFFECT, d.x, d.y)
        call DestroyEffect(e)
        call ForGroup(d.ug, function GroupDAMAGE)
    else
        call SelectUnitForPlayerSingle(d.u, GetOwningPlayer(d.u))
        call SetUnitFacing(d.u, d.angle)
        call ShowUnit(d.u, true)
        call d.CleanUp()
        call SetUnitInvulnerable(d.u, false)
        call ReleaseTimer(GetExpiredTimer())
        call SetUnitPathing(d.u, true)
        call d.destroy()
    endif
endfunction

private function WActions takes nothing returns nothing
    local data d = data.create()
    local timer t = NewTimer()
    local real xxx
    local real yyy
    set data.temp=d
    set d.u=GetTriggerUnit()
    set d.sl=GetSpellTargetLoc()
    set d.lvl=GetUnitAbilityLevel(d.u, WAVEFORMID)
    set d.DAMAGE=I2R(d.lvl)*DMGCOUNT
    set d.time=CreateTimer()
    set d.dis=0.00
    set d.x=GetUnitX(d.u)
    set d.y=GetUnitY(d.u)
    set d.x2=GetLocationX(d.sl)
    set d.y2=GetLocationY(d.sl)
    set xxx=d.x2 - d.x
    set yyy=d.y2 - d.y
    set d.angle=Atan2(yyy, xxx)
    call RemoveLocation(d.sl)
    call SetUnitInvulnerable(d.u, true)
    call SetUnitPathing(d.u, false)
    call ShowUnit(d.u, false)
    call SetTimerData(t, d)
    call TimerStart(t, TIMERINTERVAL, true, function Movement)
endfunction

public function WaveFormInit takes nothing returns nothing
    local trigger WaveForm = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( WaveForm, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( WaveForm, Condition( function WConditions ) )
    call TriggerAddAction( WaveForm, function WActions )
endfunction

endscope



btw how do u use those spoiler tags?

thats what i did :S the angle is the same thing though... its like a really weird angle.(and its not the right one)
 
Reaction score
86
slower as in more laggy? or slower as in the object is moving slower. And post the code again, because changing between Cos and Sin doesn't increase lag by a noticeable amount.
 

RaiJin

New Member
Reaction score
40
JASS:
scope WaveForm initializer WaveFormInit

globals
    private constant string  EFFECT        =                        "Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl" //Water effect used when dashing
    private constant real    DISTANCE      =                         30.00 //  DISTANCE
    private constant real    TIMERINTERVAL =                         0.03 //Perodic Timer interval
    private constant real    DMGCOUNT      =                         100.00 // DAMAGE PER LEVEL
    private constant real    MAXDISTANCE   =                         1100.00 //MAX DISTANCE ABLE TO TRAVEL
    private constant real    AOE           =                         200.00// MAX AOE OF THE SPELL
    private constant integer WAVEFORMID    =                         'WAV3' //SpellID NAME
endglobals

private struct data
    unit u
    location sl
    integer lvl
    real DAMAGE
    real dis
    real x
    real y
    real x2
    real y2
    real angle
    timer time
    group ug
    group ha
    static data temp
    
    method CleanUp takes nothing returns nothing
        call DestroyGroup(.ha)
        call DestroyGroup(.ug)
        call RemoveLocation(.sl)
    endmethod
endstruct

private function GroupDMGCheck takes nothing returns boolean
    local data d=data.temp
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(d.u)) and IsUnitInGroup(GetFilterUnit(), d.ha)
endfunction

private function WConditions takes nothing returns boolean
    return GetSpellAbilityId() == WAVEFORMID
endfunction

private function GroupDAMAGE takes nothing returns nothing
    local data d=data.temp
    call UnitDamageTargetBJ(d.u, GetEnumUnit(), d.DAMAGE, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
    call GroupAddUnit(d.ha, GetEnumUnit())
endfunction

private function Movement takes nothing returns nothing
    local data d = GetTimerData(GetExpiredTimer())
    local effect e
    local real xx
    local real yy
    local real newx
    local real newy
    local real nangle
    local location wl=GetUnitLoc(d.u)
    set d.x=GetUnitX(d.u)
    set d.y=GetUnitY(d.u)
    set xx=d.x - d.x2
    set yy=d.y - d.y2
    set d.dis=SquareRoot( xx * xx + yy * yy)
    set newx=d.x + DISTANCE * Sin(d.angle * bj_DEGTORAD)
    set newy=d.y + DISTANCE * Sin(d.angle * bj_DEGTORAD)
    if d.dis < MAXDISTANCE then
        call SetUnitX(d.u, newx)
        call SetUnitY(d.u, newy)
        set d.ug=CreateGroup()
        call GroupEnumUnitsInRange(d.ug, d.x, d.y, AOE, Condition(function GroupDMGCheck))
        set e=AddSpecialEffect(EFFECT, d.x, d.y)
        call DestroyEffect(e)
        call ForGroup(d.ug, function GroupDAMAGE)
    else
        call SelectUnitForPlayerSingle(d.u, GetOwningPlayer(d.u))
        call SetUnitFacing(d.u, d.angle)
        call ShowUnit(d.u, true)
        call d.CleanUp()
        call SetUnitInvulnerable(d.u, false)
        call ReleaseTimer(GetExpiredTimer())
        call SetUnitPathing(d.u, true)
        call d.destroy()
    endif
endfunction

private function WActions takes nothing returns nothing
    local data d = data.create()
    local timer t = NewTimer()
    local real xxx
    local real yyy
    set data.temp=d
    set d.u=GetTriggerUnit()
    set d.sl=GetSpellTargetLoc()
    set d.lvl=GetUnitAbilityLevel(d.u, WAVEFORMID)
    set d.DAMAGE=I2R(d.lvl)*DMGCOUNT
    set d.time=CreateTimer()
    set d.dis=0.00
    set d.x=GetUnitX(d.u)
    set d.y=GetUnitY(d.u)
    set d.x2=GetLocationX(d.sl)
    set d.y2=GetLocationY(d.sl)
    set xxx=d.x2 - d.x
    set yyy=d.y2 - d.y
    set d.angle=Atan2(yyy, xxx)
    call RemoveLocation(d.sl)
    call SetUnitInvulnerable(d.u, true)
    call SetUnitPathing(d.u, false)
    call ShowUnit(d.u, false)
    call SetTimerData(t, d)
    call TimerStart(t, TIMERINTERVAL, true, function Movement)
endfunction

public function WaveFormInit takes nothing returns nothing
    local trigger WaveForm = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( WaveForm, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( WaveForm, Condition( function WConditions ) )
    call TriggerAddAction( WaveForm, function WActions )
endfunction

endscope
 
Reaction score
86
try taking out the "*bj_DEGTORAD", Flare already said that the Atan2 returns radians =] I think it should be fine now.
 

Viikuna

No Marlo no game.
Reaction score
265
From Source to Target.
JASS:

local real sourceX = ...
local real sourceY = ...
local real targetX = ...
local real targetY = ...
local real dx = targetX - sourceX
local real dy = targetY - sourceY
local real angle = Atan2 (dy, dx)
set d.cos=Cos(angle) // save Cos and Sin to your struct,
set d.sin=Sin(angle) //  if angle does not change.

//......tiidudiiidudii

    set d.x=d.x + DISTANCE * d.cos  // calculate new x and y values.
    set d.y=d.y + DISTANCE * d.sín
 

RaiJin

New Member
Reaction score
40
how about this? i was fooling around with me old JASS meat hook

JASS:
private function TimerActions takes nothing returns nothing
    local hook h = hook.k
    local real newx
    local real newy
    local real xx
    local real yy
    set h.hookline = h.hookline + 1
    set h.offset = h.offset + DISTANCE
    set newx = h.x + h.offset * h.cos
    set newy = h.y + h.offset * h.sin
    set xx = h.x2 - h.x
    set yy = h.y2 - h.y
    set h.distance = SquareRoot( xx * xx + yy * yy)
    set h.snaggroup = CreateGroup()
    call GroupEnumUnitsInRange(h.snaggroup, newx, newy, COLLISION, Condition(function MeatHookCondition))
    set h.snagger = GroupPickRandomUnit(h.snaggroup)
endfunction

private function MActions takes nothing returns nothing
    local hook h = hook.create()
    local timer t = CreateTimer()
    local real tx
    local real ty
    set h.hooker = GetTriggerUnit()
    set h.s = GetSpellTargetLoc()
    set h.x = GetUnitX(h.hooker)
    set h.y = GetUnitY(h.hooker)
    set h.x2 = GetLocationX(h.s)
    set h.y2 = GetLocationY(h.s)
    set tx = h.x2 - h.x
    set ty = h.y2 - h.y
    set h.angle = Atan2(ty, tx)
    set h.sin = Sin(h.angle)
    call RemoveLocation(h.s)
    call TimerStart(t, INTERVAL, true, function TimerActions)
endfunction


??? did i do it right :S?

*NOTE - thats not the full code

and if i am checking distance between coords can i just do

if d.distance > 110.00 then
else
endif

?? will that work? the same as DistanceBetweenPoints?

EDIT: Forgot to pass structs from function to function. *FIXED THT
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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