• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Another what's wrong with this script question

Status
Not open for further replies.
Level 8
Joined
Dec 29, 2006
Messages
359
I am still fairly new at JASSing, and I am reasonably sure that my mistakes will be easily recognized by more advanced JASSers, but I cannot find out what I did wrong in this script.

function Trig_Dash_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'ACfb'
endfunction

function Dash_Dam_Cond takes nothing returns boolean
local string s = GetAttachmentTable(GetTriggeringTrigger() )
return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTableUnit(s,"u")))==true and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0
endfunction

function Dash_Dam takes nothing returns nothing
local string s = GetAttachmentTable)GetTriggeringTrigger()
local unit u = GetTableUnits(s,"u")
local unit v = GetTriggerunit()
local real dam = 5*GetHeroAgi(u,true)

call UnitDamageTarget(u,v,dam,false,false,ATTACK_TYPE_NOTMAL,DAMAGE_TYPE_NORMAL,null
call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+(.25*dam))
call DestroyEffet(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",v,"overhead"))

set u = null
set v = null
endfunction

function Dash_Effects takes nothing returns nothing
local timer t = GetExpiredTimer()
local string s = GetAttachmentTable(t)
local trigger trig
local string strig
local unit u = GetTableUnits (s,"u")
local real and = GetTableReal(s,"ang")
local real dist = GetTableReal(s,"dist")
local real moved = GetTableReal(s, "moved")

call SetUnitPosition(u,GetUnitX(u) + 30 * Cos(ang * bj_DEGTORAD, GetUnitY(u) + 20 * Sin(ang * bj_DEGTORAD) )
call SetUnitAnimationByIndex(u,1)
set moved = moved+30

if moved>=dist or GetUnitState(u,UNIT_STATE_LIFE<=0 then
set trig = GetTableTrigger(s,"trig")
set strig = GetAttTable(trig)
call TriggerRemoveAction(trig,GetTableTriggerAction(strig,"ta"))
call ClearTable(trig)
call DestroyTrigger(trig)
set trig = null
call SetUnitTimeScalePercent(u, 100)
call SetUnitPathing(u,true)
call SetUnitAnimationByIndex(u,0)
call ClearTable(s)
call PauseTimer(t)
call DestroyTimer(t)
else
call SetTableReal(s,"moved",moved)
endif

set u = null
endfunction

function Trig_Dash_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local location 1 = GetSpellTargetLoc()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real xtarg = GetLocationX(1)
local real ytarg = GetLocationY(1)
local real ang = bj__RADTODEG * Atan2(ytarg - y, xtarg - x)
local real dx = xtarg - x
local real dy = ytarg - y
local real dist =SquareRoot(dx * dx + dy * dy)
local trigger trig = CreateTrigger()
local string strig = GetAttachmenTable(trig)
local timer t = CreateTimer()
local string s = GetAttachmentTable(t)

call TriggerRegisterUnitinRange(trig,u,150,null)
call TriggerAddCondition( trig, Condition( function Dash_Dam_Cond ) )
call SetTableObject(strig,"ta", TriggerAddAction( trig, function Dash_Dam ))
call SetTableObject(strig,"u",u)

call SetTableReal(s,"and",ang)
call SetTableReal(s,:dist",dist)
call SetTableReal(s,"moved",0)
call SetTableObject(s,"u",u)
call SetTableObject(s,"trig",trig)
call TimerStart(t,.03,true,function Dash_Effects)

call SetUnitTimeScalePercent(u, 400)
call SetUnitPathing(u,false)
call SetUnitAnimationByIndex(u,1)

set u = null
call RemoveLocation(1)
set 1 = null
set trig = null
endfunction

endfunction

//===========================================================================
function InitTrig_Dash takes nothing returns nothing
set gg_trg_Dash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Dash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Dash, Condition( function Trig_Dash_Conditions ) )
call TriggerAddAction( gg_trg_Dash, function Trig_Dash_Actions )
call preload ("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl")
endfunction

my copy as text didnt go to well but the script is the same just some of the
functions go down an extra line, sorry if this is an inconvienance.
Overall question, what did i do wrong, i click test map and it comes up with
all sorts of errors, like expected a name and stuff like that, whats up with
this script?
 
Level 4
Joined
Sep 20, 2005
Messages
72
Off the bat from a brief glance, it appears you have random spaces littered all over the place which should not be there, such as:
" call preload ("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodEl fSpellThiefBlood.mdl")"
Not sure if thats a text copying problem though...hmm actually it looks like it

"if moved>=dist or GetUnitState(u,UNIT_STATE_LIFE<=0 then"
You opened a bracket for GetUnitState but never closed it =[

It appears that you are using Vexorian's caster system, but you call several functions with the wrong name, such as GetTableUnits (should be GetTableUnit) or SetTableObjects (should be SetTableObject). And that is just to name a few... theres other typos like GetAttachmenTable =/

I seriously recommend using JassCraft as it appears that you are not catching many of the typos. (JassCraft is a program which highlights text and also has a function lookup and Syntax checker, find it at wc3campaigns.net)
 
Level 8
Joined
Dec 29, 2006
Messages
359
All spaces were copy+paste errors and as for the rest of the script, it is from the simple dash spell tutorial on thehelper.net, i tried copy pasteing the entire finished trigger script but it still comes up with errors. Just a few example errors
Line 6: Undeclaired Function GetAttachmentTable local string s = GetAttachmentTable(GetTriggeringTrigger())
Line 32: Cannot convert null to real local real dist = GetTableReal(s,"dist")
Line 100: Undeclaired variable: gg_trg_Dash call TriggerRegisterAnyUnitEventBJ( gg_trg_Dash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
Line 103: Parse Error Preload("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl")
29 errors total. Idk if telling u these helps at all but they're there if u need em. Lemme know if u need me to post rest of the errors and ill edit them into this post.
 
Level 8
Joined
Dec 29, 2006
Messages
359
Like I said before im fairly new to JASS, although I know the basics, none of the tutorials I've read have covered a var engine. If possible, redirect me to a tutorial that covers it or explain it in this thread, thanks :)
 
Status
Not open for further replies.
Top