- Joined
- Dec 9, 2007
- Messages
- 3,096
Hey there.
I am still working on my n00b fire bolt spell, and I have another difficulty.
Well, I mixed all the scopes and their functions in one trigger to make importing easier and I still have one damned global variable and I want to get rid of it.
I have two scopes, FireBoltsCreation and FireBoltsMovement.
I use a global in the FireBoltsMovement wich is initialized inside the scope, and it works. but I need one global in both scopes, FireBolts.
If I try to initialize it outside the scopes, it doesn't work.
Should I initialize it in both scopes? (One time in each?)
For those who want to know the code...
I am still working on my n00b fire bolt spell, and I have another difficulty.
Well, I mixed all the scopes and their functions in one trigger to make importing easier and I still have one damned global variable and I want to get rid of it.
I have two scopes, FireBoltsCreation and FireBoltsMovement.
I use a global in the FireBoltsMovement wich is initialized inside the scope, and it works. but I need one global in both scopes, FireBolts.
If I try to initialize it outside the scopes, it doesn't work.
Should I initialize it in both scopes? (One time in each?)
For those who want to know the code...
JASS:
//~~~ Starting Scopes
//~~~~~~ Star of Creation
scope FireBoltsCreation initializer Init
private function Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A001' ) ) then
return false
endif
return true
endfunction
private function Actions takes nothing returns nothing
local location p1 = GetUnitLoc(GetSpellAbilityUnit())
local location p2 = GetSpellTargetLoc()
local location pp = PolarProjectionBJ(p1, 15.00, AngleBetweenPoints(p1, p2))
call CreateUnitAtLocSaveLast( GetOwningPlayer(GetSpellAbilityUnit()), 'u000', pp, AngleBetweenPoints(p1, p2) )
call GroupAddUnit( udg_FireBolts, bj_lastCreatedUnit )
call SetWidgetLife( bj_lastCreatedUnit, 3.00 )
call SetUnitUserData( bj_lastCreatedUnit, ( GetHeroInt(GetSpellAbilityUnit(), true) * GetUnitAbilityLevel(GetSpellAbilityUnit(), 'A001') ) )
call RemoveLocation(p1)
call RemoveLocation(p2)
call RemoveLocation(pp)
endfunction
//===========================================================================
private constant function AntiLeak takes nothing returns boolean
return true
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local filterfunc f = Filter(function AntiLeak)
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, f)
set i = i + 1
exitwhen i >= 16
endloop
call TriggerAddCondition(t, Condition( function Conditions ) )
call TriggerAddAction(t, function Actions )
call DestroyFilter(f)
set f = null
endfunction
endscope
//~~~~~~ End of creation
//~~~Switching Scopes
//~~~~~~ Start of Movement
scope FireBoltsMovement initializer Init
globals
private group Targets
endglobals
function Trig_Fireball_Movement_Func001Func003002003001 takes nothing returns boolean
return ( GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 )
endfunction
function Trig_Fireball_Movement_Func001Func003002003002 takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) == true )
endfunction
function Trig_Fireball_Movement_Func001Func003002003 takes nothing returns boolean
return Trig_Fireball_Movement_Func001Func003002003001() and Trig_Fireball_Movement_Func001Func003002003002()
endfunction
function Trig_Fireball_Movement_Func001Func004Func001C takes nothing returns boolean
if ( ( CountUnitsInGroup(Targets) >= 1 ) ) then
return true
endif
if ( ( GetUnitState(GetEnumUnit(), UNIT_STATE_LIFE) <= 0.00 ) ) then
return true
endif
return false
endfunction
function Trig_Fireball_Movement_Func001Func004C takes nothing returns boolean
if ( not Trig_Fireball_Movement_Func001Func004Func001C() ) then
return false
endif
return true
endfunction
function Trig_Fireball_Movement_Func001A takes nothing returns nothing
local location p = GetUnitLoc(GetEnumUnit())
local location pp = PolarProjectionBJ(p, 7.00, GetUnitFacing(GetEnumUnit()))
local effect boom
local real dmg = I2R(GetUnitUserData(GetEnumUnit()))
local real radiustargets = 50.00
local real radiusdmg = 120.00
local string sfxpath = "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl"
//Done with locals.
//Done with setup.
call SetWidgetLife( GetEnumUnit(), ( GetUnitState( GetEnumUnit(), UNIT_STATE_LIFE ) - 0.01 ) )
call SetUnitPositionLoc( GetEnumUnit(), PolarProjectionBJ(GetUnitLoc(GetEnumUnit()), 7.00, GetUnitFacing(GetEnumUnit())) )
set Targets = GetUnitsInRangeOfLocMatching(radiustargets, GetUnitLoc(GetEnumUnit()), Condition(function Trig_Fireball_Movement_Func001Func003002003))
if ( Trig_Fireball_Movement_Func001Func004Func001C() ) then
call UnitDamagePoint( GetEnumUnit(), 0.00, radiusdmg, GetLocationX(p), GetLocationY(p), dmg, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS )
set boom = AddSpecialEffectLoc( sfxpath, p )
call RemoveUnit( GetEnumUnit() )
call DestroyEffect(boom)
else
endif
call DestroyGroup(Targets)
call RemoveLocation(p)
call RemoveLocation(pp)
endfunction
private function Actions takes nothing returns nothing
call ForGroup( udg_FireBolts, function Trig_Fireball_Movement_Func001A )
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterTimerEvent( trg, 0.01, true )
call TriggerAddAction( trg, function Actions )
endfunction
endscope
//~~~~~~ End of Movement
//~~~ Ending Scopes