HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with a Simple...ish Shock Spell

10-17-2006, 07:48 PM#1
aidan_124
Ok this spell does damage dependant on the level and moves the unit back for a certain length dependant on the level also. I used Blade.Dk s tutorial to help me with this trigger. I'm discovering a few difficulties:
Collapse JASS:
function InitTrig_InitCache takes nothing returns nothing
    call FlushGameCache(InitGameCache("abilitycache.w3v"))
    set udg_AbilityCache = InitGameCache("abilitycache.w3v")
endfunction
WEU decides this doesn't work...although as far as i can see from the tutorial it should be fine...whats wrong with it?

Main Trigger:
Collapse JASS:
function Shock_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'ANab'
endfunction

function Shock_Move takes nothing returns nothing
local string s = I2S(H2I(GetExpiredTimer())
local gamecacher gc = udg_AbilityCache
local real x = GetStoredReal(gc,s,"x")
local real y = GetStoredReal(gc,s,"y")
local integer i = GetStoredInteger(gc,s,"level")
local unit t = GetStoredUnit(gc,s,"target")
local real p = GetStoredReal(gc,s,"speed")-0.5/(1+0.5*i)
local real a
local real ux
local real uy
local real dur = GetStoredReal(gc,s,"dur")+0.05
local real fx = GetStoredReal(gc,s,"fx")+0.05

if dur<0.75*i then

set ux= GetUnitX(t)
set uy = GetUnitY(t)
set a = Atan2(uy-y,ux-x)
call SetUnitPosition(f,ux+p*Cos(a),uy+p*Sin(a)
if fx>=1 then
     call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",t,"origins"))
endif
call StoreReal(gc,s,"dur",dur)
call StoreReal(gc,s,"speed",p)
call StoreReal(gc,s,"fx",fx)
if fx>=1 then
call StoreReal(gc,s,"fx",0)
endif
endif
endfunction

function Shock_Actions takes nothing returns nothing
local unit c = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local real x = GetUnitX(c)
local real y = GetUnitY(c)
local integer i = GetUnitAbilityLevel(c, 'ANab')
local gamecache gc = udg_AbilityCache
local timer t = CreateTimer()
local string s = I2S(H2I(t))

call UnitDamageTarget(c,f,100*i,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,null)
call StoreInteger(gc,s,"level",i)
call StoreInteger(gc,s,"group",H2I(g))
call StoreReal(gc,s,"x",GetUnitX(GetSpellTargetUnit()))
call StoreReal(gc,s,"y",GetUnitY(GetSpellTargetUnit()))
call StoreReal(gc,s,"speed",50)
call StoreUnit(gc,s,"target",GetSpellTargetUnit())
call TimerStart(t,0.05,true,function Stomp_Move)
set c = null
set t = null
set g = null
set gc=null
endfunction


function InitTrig_Shock takes nothing returns nothing
    set gg_trg_Shock = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shock, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Shock, Condition( function Shock_Conditions ) )
    call TriggerAddAction( gg_trg_Shock, function Shock_Actions )
    call Preload("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl")
endfunction


Are there any memory leaks etc. or any reasons it shouldn't work and how would a JESP spell differ from how that is written, I've read all the stuff about it and I can't work out what I need to do to make it JESP.
10-17-2006, 07:51 PM#2
The)TideHunter(
Quote:
Originally Posted by aidan_124
Ok this spell does damage dependant on the level and moves the unit back for a certain length dependant on the level also. I used Blade.Dk s tutorial to help me with this trigger. I'm discovering a few difficulties:
Collapse JASS:
function InitTrig_InitCache takes nothing returns nothing
    call FlushGameCache(InitGameCache("abilitycache.w3v"))
    set udg_AbilityCache = InitGameCache("abilitycache.w3v")
endfunction
WEU decides this doesn't work...although as far as i can see from the tutorial it should be fine...whats wrong with it?

Main Trigger:
Collapse JASS:
function Shock_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'ANab'
endfunction

function Shock_Move takes nothing returns nothing
local string s = I2S(H2I(GetExpiredTimer())
local gamecacher gc = udg_AbilityCache
local real x = GetStoredReal(gc,s,"x")
local real y = GetStoredReal(gc,s,"y")
local integer i = GetStoredInteger(gc,s,"level")
local unit t = GetStoredUnit(gc,s,"target")
local real p = GetStoredReal(gc,s,"speed")-0.5/(1+0.5*i)
local real a
local real ux
local real uy
local real dur = GetStoredReal(gc,s,"dur")+0.05
local real fx = GetStoredReal(gc,s,"fx")+0.05

if dur<0.75*i then

set ux= GetUnitX(t)
set uy = GetUnitY(t)
set a = Atan2(uy-y,ux-x)
call SetUnitPosition(f,ux+p*Cos(a),uy+p*Sin(a)
if fx>=1 then
     call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",t,"origins"))
endif
call StoreReal(gc,s,"dur",dur)
call StoreReal(gc,s,"speed",p)
call StoreReal(gc,s,"fx",fx)
if fx>=1 then
call StoreReal(gc,s,"fx",0)
endif
endif
endfunction

function Shock_Actions takes nothing returns nothing
local unit c = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local real x = GetUnitX(c)
local real y = GetUnitY(c)
local integer i = GetUnitAbilityLevel(c, 'ANab')
local gamecache gc = udg_AbilityCache
local timer t = CreateTimer()
local string s = I2S(H2I(t))

call UnitDamageTarget(c,f,100*i,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,null)
call StoreInteger(gc,s,"level",i)
call StoreInteger(gc,s,"group",H2I(g))
call StoreReal(gc,s,"x",GetUnitX(GetSpellTargetUnit()))
call StoreReal(gc,s,"y",GetUnitY(GetSpellTargetUnit()))
call StoreReal(gc,s,"speed",50)
call StoreUnit(gc,s,"target",GetSpellTargetUnit())
call TimerStart(t,0.05,true,function Stomp_Move)
set c = null
set t = null
set g = null
set gc=null
endfunction


function InitTrig_Shock takes nothing returns nothing
    set gg_trg_Shock = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shock, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Shock, Condition( function Shock_Conditions ) )
    call TriggerAddAction( gg_trg_Shock, function Shock_Actions )
    call Preload("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl")
endfunction


Are there any memory leaks etc. or any reasons it shouldn't work and how would a JESP spell differ from how that is written, I've read all the stuff about it and I can't work out what I need to do to make it JESP.

Your line has a problem:

call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",t,"origins"))
Change "origins" to "origin".
Im to tired to look for anything else, maybe tomorrow for me..
10-17-2006, 08:14 PM#3
Anopob
I THINK, not sure, but isn't it spelled "gamecache", not "gamecacher"?

EDIT: I think that because of the way I think it's spelled, and because it's not in "blue" (unlike all the other variables).
10-17-2006, 09:20 PM#4
The)TideHunter(
Quote:
Originally Posted by Anopob
I THINK, not sure, but isn't it spelled "gamecache", not "gamecacher"?

EDIT: I think that because of the way I think it's spelled, and because it's not in "blue" (unlike all the other variables).

Yea, Anopob is right, its not turned blue and boldish by Wc3c's colour syntax, so its not right, as a variable type.

As he said, its "gamecache" and not "gamecacher".
10-18-2006, 01:28 PM#5
aidan_124
Changed the Cache Trigger to:
Collapse JASS:
function InitTrig_InitCache takes nothing returns nothing
    call InitGameCacheBJ( "AbilityCache.w3v" )
    set udg_Ability_Cache = InitGameCacheBJ("AbilityCache.w3v")
endfunction
which looks bollocks...but hopefully it works...should i be running Vex's caster system to use the syntax above...or does my PC just hate me?
Now the trigger is accepted but i need to test it.
Edit:
Ok..it hates me
This is the trigger:
Collapse JASS:
function Shock_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function H2I takes handle h returns integer
return h
return 0 
endfunction

function G2I takes group g returns integer
return g
return 0
endfunction

function I2G takes integer i returns group
return i
return null
endfunction

function Shock_Move takes nothing returns nothing
local string s = I2S(H2I(GetExpiredTimer()))
local gamecache gc = udg_Ability_Cache
local real x = GetStoredReal(gc,s,"x")
local real y = GetStoredReal(gc,s,"y")
local integer i = GetStoredInteger(gc,s,"level")
local unit t = GetSpellTargetUnit()
local real p = GetStoredReal(gc,s,"speed")-0.5/(1+0.5*i)
local real a
local real ux
local real uy
local real dur = GetStoredReal(gc,s,"dur")+0.05
local real fx = GetStoredReal(gc,s,"fx")+0.05

if dur<0.75*i then

set ux= GetUnitX(t)
set uy = GetUnitY(t)
set a = Atan2(uy-y,ux-x)
call SetUnitPosition(t,ux+p*Cos(a),uy+p*Sin(a))
    if fx>=1 then
    call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",t,"origin"))
    endif
call StoreReal(gc,s,"dur",dur)
call StoreReal(gc,s,"speed",p)
call StoreReal(gc,s,"fx",fx)
if fx>=1 then
call StoreReal(gc,s,"fx",0)
endif
endif 

if not(t==null) then
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_021" )
endif
endfunction

function Shock_Actions takes nothing returns nothing
local unit c = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local real x = GetUnitX(c)
local real y = GetUnitY(c)
local integer i = GetUnitAbilityLevel(c, 'A000')
local gamecache gc = udg_Ability_Cache
local timer time = CreateTimer()
local string s = I2S(H2I(t))
local group g


call UnitDamageTarget(c,t,100*i,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,null)
call GroupAddUnit(g,t)
call StoreInteger(gc,s,"level",i)
call StoreReal(gc,s,"x",GetUnitX(GetSpellTargetUnit()))
call StoreReal(gc,s,"y",GetUnitY(GetSpellTargetUnit()))
call StoreReal(gc,s,"speed",50)
call StoreUnit(gc,s,"target",GetSpellTargetUnit())
call StoreInteger(gc,s,"group",G2I(g))
call TimerStart(time,0.05,true,function Shock_Move)
set c = null
set t = null
set gc=null
call DestroyGroup(g)
set g=null
endfunction

//===========================================================================
function InitTrig_Shock takes nothing returns nothing
    local trigger gg_trg_Shock
    set gg_trg_Shock = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shock, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Shock, Condition( function Shock_Conditions ) )
    call TriggerAddAction( gg_trg_Shock, function Shock_Actions )
    call Preload("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl")
endfunction

As far as I can tell, it should move the unit, but it does the damage and the unit doesn't move...can anyone explain why?...the highlighted bit is the bit that doesn't work (the debug message doesn't appear either)