• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

So what's wrong with this code

Status
Not open for further replies.
Level 2
Joined
Jan 30, 2006
Messages
12
Can anyone tell me what's wrong with this JASS code? It's a spell, based off of aerial shackles, that's supposed to drag a unit toward the caster. "Slayer's Web".

It has the unit starts the effect of an ability spell, checks to see if it's Slayer's Web, and creates local variables for the caster and the target. It creates a local timer and starts it repeating every 0.05 seconds, calling function web_drag, which checks to see if the target is within 100 units of the caster. If it is, it does nothing, but if it's further away than that, it pulls the target 10 units toward the caster, and deals 3 damage to it. (The effect is supposed to drag the target 200 units per second, and deal 30% of the distance dragged in damage.) There's one compile error, though. It's at the area where web_drag is called in the timer. It's says, "Line 95: Expected '". Anyone know what the problem is?

--------

function web_cond takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A0AL' ) ) then
return false
endif
return true
endfunction

function web_drag takes unit web_caster, unit web_target returns nothing
if (DistanceBetweenPoints(GetUnitLoc(web_caster), GetUnitLoc(web_target)) < 100.00) then
call SetUnitPositionLoc( web_target, PolarProjectionBJ(GetUnitLoc(web_caster), ( DistanceBetweenPoints(GetUnitLoc(web_caster), GetUnitLoc(web_target)) - 10.00 ), AngleBetweenPoints(GetUnitLoc(web_target), GetUnitLoc(web_target))) )
call UnitDamageTargetBJ( web_caster, web_target, 3.00, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_ACID )
else
call DoNothing()
endif
endfunction

function web_action takes nothing returns nothing
local timer t
local unit web_caster
local unit web_target
set web_caster = GetTriggerUnit()
set web_target = GetSpellTargetUnit()
set t = CreateTimer()
call TimerStart(t, 0.05, true, function web_drag( web_caster , web_target ))
call TriggerSleepAction( ( 2.00 + ( 0.38 * I2R(GetUnitAbilityLevelSwapped('A0AL', web_caster)) ) ) )
call DestroyTimer(t)
set web_caster = null
set web_target = null
set t = null
endfunction

//===========================================================================
function InitTrig_Slayer_Web takes nothing returns nothing
local trigger web
set web = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ (web, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(web, Condition(function web_cond))
call TriggerAddAction( web, function web_action )
endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
few things

first, off topic, but why did you say

local trigger web
set web = CreateTrigger()

you can either use local trigger web = CreateTrigger()

or

set gg_trg_Slayer_Web = CreateTrigger()

( the gg_trg vars are auto-created with each trigger )

second, you should post JASS on wc3jass.com, youll get more feedback there

third, you cant give variables to a function called by a timer. Instead, try using KaTTaNa's local handle vars

SetHandleHandle( t, "caster", web_caster )

and

SetHandleHandle( t, "target", web_target )

and then

GetHandleHandle( t, "caster" )
GetHandleHandle( t, "target" )

these do not come in wc3. they are available at wc3jass.com or in many JASS-enhanced spells ( as they use them )

if you do this, and do not fully understand how to use them, PM me and i probably will be able to help.
 
Status
Not open for further replies.
Top