So I have this code for a spell, and I need to use Global Variables in order to make it work (at least thats the only way I can think of)
Anyway, maybe I'm initializing them wrong and I don't realize it but this is how the tutorials told me to do it....
If someone could figure out why they don't work that would be great! Thanks
I am using vJASS
Anyway, maybe I'm initializing them wrong and I don't realize it but this is how the tutorials told me to do it....
If someone could figure out why they don't work that would be great! Thanks
I am using vJASS
JASS:
globals
unit Hero_Caster
integer Jump_Number
endglobals
function HauntJASS_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A01G039;
endfunction
function CheckGroup takes nothing returns boolean
return IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy(GetFilterUnit() , GetOwningPlayer(GetTriggerUnit())) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE)>0
endfunction
//function Everlasting_Horrors takes unit Target returns nothing
// local group Everlasting_Group = CreateGroup()
// local boolexpr Group_Check = Condition (function CheckGroup)
// local unit DCS
// if(Jump_Number > 0)then
// call GroupEnumUnitsInRangeOfLoc(Everlasting_Group, GetUnitLoc(Target), 600, Group_Check )
// set DCS = CreateUnit(GetOwningPlayer(Hero_Caster),'e001',GetUnitX(Target),GetUnitY(Target),270) // DCS = Dummy Caster Sleep
// call UnitApplyTimedLife(DCS,'BTLF',.25)
// call UnitAddAbility(DCS,'A01G')
// call SetUnitAbilityLevel(DCS,'A01G',GetUnitAbilityLevel(Hero_Caster, 'A01G'))
// set Target = GroupPickRandomUnit(Everlasting_Group)
// call IssueTargetOrderById(DCS,OrderId("thunderbolt"),Target)
// call SetUnitPathing(DCS,false)
// call SetUnitInvulnerable(DCS,true)
// set Jump_Number = Jump_Number - 1
// endif
// call DestroyGroup(Everlasting_Group)
// call DestroyBoolExpr(Group_Check)
// set DCS = null
// set Target = null
// endfunction
function Return_Caster takes unit Target, unit Caster, integer Count returns nothing
local unit DCS = CreateUnit(GetOwningPlayer(Hero_Caster),039;e001039;,GetUnitX(Target),GetUnitY(Target),270) // DCS = Dummy Caster Sleep
call UnitApplyTimedLife(DCS,039;BTLF039;,0.25)
call UnitAddAbility(DCS,039;A01I039;)
call SetUnitAbilityLevel(DCS,039;A01I039;,Count)
call SetUnitScale(DCS, 1.20, 1.20, 1.20)
call SetUnitState(Caster, UNIT_STATE_LIFE, GetUnitState(Hero_Caster, UNIT_STATE_LIFE) - 1)
call IssueTargetOrderById(DCS,OrderId("deathcoil"),Hero_Caster)
call SetUnitPathing(DCS,false)
call SetUnitInvulnerable(DCS,true)
set Count = 0
set Caster = null
set Target = null
set Hero_Caster = null
endfunction
function Sleep_Damage takes unit Target, unit Caster, unit DCS returns nothing
local integer Count = 1
loop
exitwhen (GetUnitAbilityLevel(Target, 039;B00I039;) > 0) == false and (GetUnitAbilityLevel(Target, 039;B00J039;) > 0) == false
call TriggerSleepAction (1.)
if (GetUnitAbilityLevel(Target, 039;B00I039;) > 0) then
if(GetUnitState(Target,UNIT_STATE_LIFE)>50)then
call SetUnitState(Target,UNIT_STATE_LIFE,GetUnitState(Target,UNIT_STATE_LIFE)-50)
set Count = Count + 1
else
call UnitDamageTarget(DCS,Target,100,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
set Count = Count + 1
endif
endif
exitwhen (GetUnitAbilityLevel(Target, 039;B00I039;) > 0) == false and (GetUnitAbilityLevel(Target, 039;B00J039;) > 0) == false
endloop
call Return_Caster(Target, Caster, Count)
set Caster = null
set Target = null
set Hero_Caster = null
set DCS = null
endfunction
function Cast_Sleep takes unit Target, unit Caster, integer AL returns nothing
local unit DCS // Dummy Caster
loop
if(GetUnitAbilityLevel(Target, 039;B00J039;) > 0) then
set DCS = CreateUnit(GetOwningPlayer(Caster),039;e001039;,GetUnitX(Caster),GetUnitY(Caster),270) // DCS = Dummy Caster Sleep
call UnitApplyTimedLife(DCS,039;BTLF039;,10)
call UnitAddAbility(DCS,039;A01H039;)
call SetUnitAbilityLevel(DCS,039;A01H039;,AL)
call IssueTargetOrderById(DCS,OrderId("sleep"),Target)
call SetUnitPathing(DCS,false)
call SetUnitInvulnerable(DCS,true)
endif
exitwhen GetUnitAbilityLevel(Target, 039;B00J039;) > 0
call TriggerSleepAction( 0.01 )
endloop
call Sleep_Damage(Target, Caster, DCS)
if(GetUnitAbilityLevel(Caster, 039;A01M039;)>0)then
set Jump_Number = GetUnitAbilityLevel(Caster, 039;A01M039;) + 1
//call Everlasting_Horrors(Target)
endif
set DCS = null
set Caster = null
set Target = null
set Hero_Caster = null
set AL = 0
endfunction
function Trig_HauntJASS_Actions takes nothing returns nothing
local unit Caster = GetTriggerUnit()
local unit Target = GetSpellTargetUnit()
local integer AL = GetUnitAbilityLevel(Caster, 039;A01G039;) //ability level
if( IsUnitType(Caster, UNIT_TYPE_HERO)) then
set Hero_Caster = Caster
endif
call Cast_Sleep(Target, Caster, AL)
set Caster = null
set Target = null
set AL = 0
endfunction
//===========================================================================
function InitTrig_HauntJASS takes nothing returns nothing
local trigger gg_trg_HauntJASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_HauntJASS, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition ( gg_trg_HauntJASS, Condition (function HauntJASS_Conditions) )
call TriggerAddAction( gg_trg_HauntJASS, function Trig_HauntJASS_Actions )
endfunction