Need Help

tuantai120

Cool Member
Reaction score
1
JASS:
scope Ice initializer Init

globals
    private constant integer Spell_ID = 'A000'
    private constant integer Dummy_ID = 'h000'
    private constant string SFX = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
    private constant real dist = 800.
endglobals

struct Ice
    unit caster
    unit dummy
    real x
    real y
    real facing 
    integer ticks
endstruct

private function GetX takes real x , real facing , real dist returns real
    return x + dist * Cos ( facing * bj_DEGTORAD )
endfunction

private function GetY takes real y , real facing , real dist returns real
    return y + dist * Sin ( facing * bj_DEGTORAD )
endfunction

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Spell_ID
endfunction

function callback takes nothing returns nothing
    local Ice data = GetCSData (GetExpiredTimer())
    call data.destroy()
endfunction

function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit d
    local integer tick 
    local timer t = CreateTimer()
    local Ice data = Ice.create()
    set data.ticks = tick
    set data.caster = u
    set data.facing = GetUnitFacing(u)
    set data.x = GetUnitX(u)
    set data.y = GetUnitY(u)
    set data.dummy = d
    call SetCSData (t,data)
    call TimerStart ( t, 10. , false , function callback)
    call CreateUnit(GetOwningPlayer(u),Dummy_ID,data.x,data.y,data.facing)
    call DestroyEffect(AddSpecialEffect(SFX,GetUnitX(d),GetUnitY(d)))
    call UnitApplyTimedLife(d,'BLTF',5.0)
    call SetUnitX(d,GetX)
    call SetUnitY(d,GetY)
    set tick = tick -1
    if (tick == 0) then
    set t = null
    call DestroyTimer(t)
    endif
    set t = null
    set u = null
    set d = null
    call BJDebugMsg( " actions done ")
endfunction

//===========================================================================
function Init takes nothing returns nothing
    local trigger ice = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( ice , EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction( ice , function Actions )
    call TriggerAddCondition ( ice , Condition ( function Conditions ) ) 
endfunction

endscope

why dont have unit , effect , text ????
i use CSData
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
remove that unit d variable and just do:

JASS:
set data.dummy = CreateUnit(GetOwningPlayer(u),Dummy_ID,data.x,data.y,data.facing)


call SetUnitX(d,GetX)
call SetUnitY(d,GetY)


GetX() and GetY() takes arguments and you didn't wrote anything

function callback takes nothing returns nothing
local Ice data = GetCSData (GetExpiredTimer())
call data.destroy()
endfunction

I don't get it...

why did you used the struct and a timer attachment system if you just gonna destroy it after x seconds and do nothing???
what are you trying to do anyway?
 

tuantai120

Cool Member
Reaction score
1
JASS:
scope Ice initializer Init

globals
    private constant integer Spell_ID = 'A000'
    private constant integer Dummy_ID = 'h000'
    private constant string SFX = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
    private constant real dist = 800.
endglobals

struct Ice
    unit caster
    unit dummy
    real x
    real y
    real GetX
    real GetY
    real facing 
    integer ticks 
endstruct


private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Spell_ID
endfunction

function callback takes nothing returns nothing
    local Ice data = GetCSData (GetExpiredTimer())
    call data.destroy()
endfunction

function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit d
    local integer tick 
    local timer t = CreateTimer()
    local Ice data = Ice.create()
    set data.ticks = tick
    set data.caster = u
    set data.facing = GetUnitFacing(u)
    set data.x = GetUnitX(u)
    set data.y = GetUnitY(u)
    set data.GetX = data.x + dist * Cos ( data.facing * bj_DEGTORAD )
    set data.GetY = data.y + dist * Sin ( data.facing * bj_DEGTORAD )
    call SetCSData (t,data)
    call TimerStart ( t, 10. , false , function callback)
    set data.dummy = CreateUnit(GetOwningPlayer(u),Dummy_ID,data.x,data.y,data.facing)
    call DestroyEffect(AddSpecialEffect(SFX,GetUnitX(data.dummy),GetUnitY(data.dummy)))
    call UnitApplyTimedLife(data.dummy,'BLTF',5.0)
    call SetUnitX(data.dummy,data.GetX)
    call SetUnitY(data.dummy,data.GetY)
    set tick = tick -1
    if (tick == 0) then
    set t = null
    endif
    set t = null
    set u = null
    set data.dummy = null
    call BJDebugMsg( " actions done ")
endfunction

//===========================================================================
function Init takes nothing returns nothing
    local trigger ice = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( ice , EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction( ice , function Actions )
    call TriggerAddCondition ( ice , Condition ( function Conditions ) ) 
endfunction

endscope

it still not work :banghead:
i dont no why , help me please
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
it still not work

what doesn't work?? :confused:
do you get any syntax errors?

you didn't even said what are you trying to do and what's the actual problem
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
JASS:
    local integer tick


You seem to be using this uninitialized variable quite a lot.

JASS:
    set data.ticks = tick

//...
    set tick = tick -1
    if (tick == 0) then
    set t = null     //This part doesn't make any sense at all...
    endif


Care to explain what this is supposed to do and what's not working maybe?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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