Cohadar
master of fugue
- Reaction score
- 209
JASS:
//===========================================================================
// Demo spell for use of ABC timer attaching and PUI unit attaching
// Author: Cohadar.
// Date: 01.December.2007
//
// How to implement:
// Copy triggers ABC, PUI, CSSafety, and this trigger in your map
// Copy all units and abilities into your map, then change raw codes in triggers
// Make sure your trigger names are the same as scope names
// or spells will not work. (I used local triggers)
//===========================================================================
scope Immolation
globals
private constant real PERIOD = 1.0
private constant integer AID_IMMOLATION = 'A000'
private constant integer AID_DUMMY_BURNING = 'A001'
private constant integer OID_flamestrike = 852488
private constant integer OID_immolation = 852177
private constant integer OID_unimmolation = 852178
private constant integer UID_DUMMY = 'h000'
private constant integer GENERIC_EXPIRATION_TIMER = 'BTLF'
endglobals
//===========================================================================
// Struct containing immolation data attached to our firelord heroes
//===========================================================================
private struct Data
unit hero
static Data array PUI
private timer tim
// instances of this struct are created with Get method
// This ensures that if hero does not use immolaton,
// he has no unneded stuff attached
private static method create takes unit hero returns Data
local Data ret = Data.allocate()
set ret.hero = hero
set ret.tim = NewTimer() // CSSafety
call SetTimerStructA(ret.tim, ret) // ABC
set Data.PUI[GetUnitIndex(hero)] = ret // PUI
return ret
endmethod
static method Get takes unit hero returns Data
local integer index
set index = GetUnitIndex(hero) // PUI
if Data.PUI[index] == 0 then
debug call BJDebugMsg("|c00FFCC00"+"Immolation struct created on first use for hero: " + GetHeroProperName(hero))
return Data.create(hero)
endif
return Data.PUI[index]
endmethod
// You should destroy instances of this struct
// only if hero is removed from game
// and before hero is removed from game
// In standard maps heroes are never removed
// so you basically don't have to worry about this
method onDestroy takes nothing returns nothing
call ClearTimerStructA(.tim) // ABC
call ReleaseTimer(.tim) // CSSafety
set Data.PUI[GetUnitIndex(.hero)] = 0 // PUI
endmethod
static method periodic takes nothing returns nothing
local Data dat = GetTimerStructA(GetExpiredTimer()) // ABC
// dummy casting flame strike
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(dat.hero), UID_DUMMY, 0, 0, 0)
call UnitAddAbility(bj_lastCreatedUnit, AID_DUMMY_BURNING)
call SetUnitAbilityLevel(bj_lastCreatedUnit, AID_DUMMY_BURNING, GetUnitAbilityLevel(dat.hero, AID_IMMOLATION))
call UnitApplyTimedLife(bj_lastCreatedUnit, GENERIC_EXPIRATION_TIMER, 1.0)
call IssuePointOrderById(bj_lastCreatedUnit, OID_flamestrike, GetUnitX(dat.hero), GetUnitY(dat.hero))
endmethod
method start takes nothing returns nothing
call TimerStart(.tim, PERIOD, true, function Data.periodic)
endmethod
method stop takes nothing returns nothing
call PauseTimer(.tim)
endmethod
endstruct
//===========================================================================
public function ActionON takes nothing returns nothing
//call DisplayTextToForce( GetPlayersAll(), "ON" )
call Data.Get(GetOrderedUnit()).start()
endfunction
//===========================================================================
public function ActionOFF takes nothing returns nothing
//call DisplayTextToForce( GetPlayersAll(), "OFF" )
call Data.Get(GetOrderedUnit()).stop()
endfunction
//===========================================================================
public function ConditionON takes nothing returns boolean
return GetIssuedOrderId() == OID_immolation
endfunction
public function ConditionOFF takes nothing returns boolean
return GetIssuedOrderId() == OID_unimmolation
endfunction
//===========================================================================
public function InitTrig takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( trig, Condition( function ConditionON ) )
call TriggerAddAction( trig, function ActionON )
set trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( trig, Condition( function ConditionOFF ) )
call TriggerAddAction( trig, function ActionOFF )
endfunction
endscope
It also destroys trees and such....Firelord starts to radiate massive amounts of heat from his body scourching everything in his path.
Enemies who stand on burning ground will be cought on fire.
While this destoys his enemies loss of heat weakens Firelord and he loses hit points.
Attachments
-
54 KB Views: 472
-
362.2 KB Views: 827