yeah so I decided to learn JASS finally.
Yeah so I was like 5 minutes into a tutorial by Daelin and I decided to make a simple spell.
All it does is kill the caster and heal all allies around the caster for 50 hp making some nice eye candy in the process.
So I couldn't find any beginner tutorials on how to use natives so all I did was use BJ's (at least I think I did?).
So go ahead, tell me what I did wrong and if it has leaks, and how to make it 10x more efficient.
oh and btw the function "damage" is the main actions
Yeah so I was like 5 minutes into a tutorial by Daelin and I decided to make a simple spell.
All it does is kill the caster and heal all allies around the caster for 50 hp making some nice eye candy in the process.
JASS:
function Cond takes nothing returns boolean
return GetSpellAbilityId() == 039;A003039;
endfunction
function group_stuff takes nothing returns nothing
//Var declaration
local unit gunit
local real gx = GetUnitX(gunit)
local real gy = GetUnitY(gunit)
local real glife
local real hlife
//Gets picked unit
set gunit = GetEnumUnit()
//Gets the picked unit's life
set glife = GetUnitStateSwap(UNIT_STATE_LIFE, gunit)
//Adds 50 to the picked units live
set hlife = glife + 50.00
//Sets the life
call SetWidgetLife(gunit, hlife)
//Creates SFX
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl",gx,gy))
//Sets variables back
set hlife = 0
set glife = 0
set gunit = null
set gx = 0
set gy = 0
endfunction
function damage takes nothing returns nothing
//Var declaration
local unit caster
local group g
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local location p = GetUnitLoc(caster)
local unit gunit
//Sets the caster
set caster = GetTriggerUnit()
//Makes & Destroys special effect
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectCaster.mdl",x,y))
//Kills the caster
call KillUnit(caster)
//Sets the group to units around caster
set g = GetUnitsInRangeOfLocAll(500.00, p)
//Adds health to units in group
call ForGroupBJ( g, function group_stuff)
//Destroys the group for reuse later.
set caster = null
set x = 0
set y = 0
call DestroyGroup(g)
set g = null
endfunction
function InitTrig_Sacrifice_JASS takes nothing returns nothing
set gg_trg_Sacrifice_JASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Sacrifice_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Sacrifice_JASS, Condition( function Cond ) )
call TriggerAddAction( gg_trg_Sacrifice_JASS, function damage )
endfunction
So I couldn't find any beginner tutorials on how to use natives so all I did was use BJ's (at least I think I did?).
So go ahead, tell me what I did wrong and if it has leaks, and how to make it 10x more efficient.
oh and btw the function "damage" is the main actions