//TESH.scrollpos=0
//TESH.alwaysfold=1
library FireAllCannon initializer int
// Fire All Cannon spell created by Dr Super Good.
// Automatically sets up appon map int (no pesky int trigger needed).
// Refer to the controle trigger of this system as "FireAllCannon_MAIN". This is to let one turn this system off, on or destroy it.
globals
// Set below to the raw data value of the spell it is to be triggered by.
private constant integer ACTIVATOR_SPELL = 'A001'
// Set below to the raw data value of the spell that is to be fired (must target location).
private constant integer EFFECT_SPELL = 'A000'
// Set below to the raw data value of a dummy unit (can be any dummy unit as long as it is invisable and has no collision).
private constant integer DUMMY_ID = 'h000'
// Bellow can be used to enable or disable this system using other functions (defaults to enabled).
public trigger MAIN = CreateTrigger()
// Below controles how many shots are fired in even angles appart.
public constant integer SHOTS = 4
endglobals
private function condition takes nothing returns boolean
return GetSpellAbilityId() == ACTIVATOR_SPELL
endfunction
private function action takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real face = GetUnitFacing(u)*bj_DEGTORAD
local integer level = GetUnitAbilityLevel(u,ACTIVATOR_SPELL)
local player p = GetOwningPlayer(u)
local unit d
local integer i = 0
loop
exitwhen i == SHOTS
set d = CreateUnit(p,DUMMY_ID,x,y,face*bj_RADTODEG)
call UnitAddAbility(d,EFFECT_SPELL)
call SetUnitAbilityLevel(d,EFFECT_SPELL,level)
call IssuePointOrder(d,"shockwave",x+Cos(face)*10,y+Sin(face)*10)
call UnitApplyTimedLife(d,0,0.01)
set face = face+6.28318/SHOTS
set i = i+1
endloop
set u = null
set p = null
set d = null
endfunction
private function int takes nothing returns nothing
call TriggerAddAction(MAIN,function action)
call TriggerAddCondition(MAIN,Condition(function condition))
call TriggerRegisterAnyUnitEventBJ(MAIN,EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction
endlibrary
//Spells for Royal Defender
library Attract initializer int requires Common
//This ability requires Dr Super Good's TimerBank system to opperate.
globals
//Set below to the raw code of the spell you want to have trigger this ability.
private constant integer ACTIVATOR_SPELL = 'A005'
//Set below to the raw code of the spell you want to have effected this ability (level up).
private constant integer EFFECTED_SPELL = 'A004'
//Set below to the duration you want the ability to last.
private constant real DURATION = 15
//Below are variables used by the ability's engine.
//The spell ID is used by the universal hash system to identify data stored on a non local source.
//This is to prevent collisions with other spells.
private constant integer SPELL_ID = StringHash("Attract")
public trigger MAIN = CreateTrigger()
endglobals
private function condition takes nothing returns boolean
return GetSpellAbilityId() == ACTIVATOR_SPELL
endfunction
private function end takes nothing returns nothing
//Set up locals.
local timer t = GetExpiredTimer()
//Load the corrosponding unit which accompanies the timer.
local unit u = LoadUnitHandle(Chash,GetHandleId(t),0)
//Clean revert spell affect.
call SetUnitAbilityLevel(u,EFFECTED_SPELL,1)
//Clean up all attached data.
call FlushChildHashtable(Chash,GetHandleId(t))
call RemoveSavedHandle(Chash,GetHandleId(u),SPELL_ID)
//Destroy and free handles.
call DestroyTimer(t)
set t = null
set u = null
endfunction
private function action takes nothing returns nothing
//Set up locals.
local unit u = GetSpellAbilityUnit()
//Load the timer for the spell which gets attached to the unit when casting.
local timer t = LoadTimerHandle(Chash,GetHandleId(u),SPELL_ID)
//Check if there was a timer attached to the casting unit.
if t == null then
//If not then make one and attach it.
set t = CreateTimer()
call SaveUnitHandle(Chash,GetHandleId(t),0,u)
call SaveTimerHandle(Chash,GetHandleId(u),SPELL_ID,t)
endif
//Start the timer and do the trigered spell effect.
call TimerStart(t,DURATION,false,function end)
call SetUnitAbilityLevel(u,EFFECTED_SPELL,GetUnitAbilityLevel(u,ACTIVATOR_SPELL)+1)
//Clean up locals so no leaks occur.
set u = null
set t = null
endfunction
private function int takes nothing returns nothing
call TriggerAddAction(MAIN,function action)
call TriggerAddCondition(MAIN,Condition(function condition))
call TriggerRegisterAnyUnitEventBJ(MAIN,EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction
endlibrary
library ProtectiveField initializer int requires DamageShield
//This ability requires Dr Super Good's DamageShield system to opperate.
globals
//Set below to the raw code of the spell you want to have trigger this ability.
private constant integer ACTIVATOR_SPELL = 'A006'
//Set below to the percentage of the caster's HP (multiple form) you want to be added as a shield.
private constant real HP_MULTIPLYER = 0.2
//Set below to the ammount of base absorb * spell level you want.
private constant real LEVEL_MULTIPLYER = 200
//Set below to the percentage (multiple) of hp ammount of maximum absorb * spell level you want.
private constant real LEVEL_HP_MAX_MULTIPLYER = 0.5
//Set below to the model path that you want the created effect to use.
private constant string SHIELD_EFFECT = "Abilities\\Spells\\Undead\\DarkSummoning\\DarkSummonMissile.mdl"
//Below are variables used by the ability's engine.
public trigger MAIN = CreateTrigger()
endglobals
private function condition takes nothing returns boolean
return GetSpellAbilityId() == ACTIVATOR_SPELL
endfunction
private function action takes nothing returns nothing
//Get all units and data needed for the ability.
local unit u = GetSpellAbilityUnit()
local real hp = GetUnitState(u,UNIT_STATE_MAX_LIFE)
local integer l = GetUnitAbilityLevel(u,ACTIVATOR_SPELL)
//Calculate the ammount of absorb to add (a) and the maximum ammount of absorb this ability allows (m).
local real a = hp*HP_MULTIPLYER+l*LEVEL_MULTIPLYER
local real m = l*LEVEL_HP_MAX_MULTIPLYER*hp
//Get any damage shield object the unit may already have.
local DamageShield shield = DamageShield.get(u)
//Check if it found an existing shield object.
if shield == 0 then
//If shield object number is equal the next asigned shield object number than make a shield object.
set shield = DamageShield.create(u)
endif
call shield.addeffect(SHIELD_EFFECT,"origin")
//Check if the current absorb is less than the maximum (if not, no absorb is added or removed).
if shield.AbsorbQuantity-shield.AbsorbQuantityTemp < m then
//Check if the addition will excede max and if so set it to the max.
if shield.AbsorbQuantity-shield.AbsorbQuantityTemp+a > m then
set shield.AbsorbQuantity = m+shield.AbsorbQuantityTemp
else
//If it does not exceed max then the absorb is added.
//call DamageShield_AbsorbAdd(shield,a)
set shield.AbsorbQuantity = shield.AbsorbQuantity+a
endif
call DamageShield.TextTag(u,I2S(R2I(shield.AbsorbQuantity)))
endif
//Remove handle leaks.
set u = null
endfunction
private function int takes nothing returns nothing
//Sets up the ability on map int using this.
call TriggerAddAction(MAIN,function action)
call TriggerAddCondition(MAIN,Condition(function condition))
call TriggerRegisterAnyUnitEventBJ(MAIN,EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction
endlibrary
library DefenseMatrix initializer int requires DamageShield
//This ability requires Dr Super Good's DamageShield system to opperate.
globals
//Set below to the raw code of the spell you want to have trigger this ability.
private constant integer ACTIVATOR_SPELL = 'A007'
//Set below to the percentage (multiple) of HP you want the caster to get in bonous to his shield.
private constant real HP_MULTIPLYER_CASTER = 0.75
//Set below to the percentage (multiple) of HP you want normal units to get in bonous absorb.
private constant real HP_MULTIPLYER = 0.1
//Set below to the base ammount you want the shields made to absorb.
private constant real ABSORB_BASE = 100
//Set below to the ammount of bonous absorb per point of caster's str * ability level.
private constant real ABSORB_STR_LEVEL_MULTIPLYER = 2
//Set below to the duration you want the ability to last.
private constant real DURIATION = 45
//Set below to the radius around the caster that you want to be affected.
private constant real AOE = 500
//Set below to the model path that you want the created effect to use.
private constant string SHIELD_EFFECT = "Abilities\\Spells\\NightElf\\TargetArtLumber\\TargetArtLumber.mdl"
//Below are variables used by the ability's engine.
public trigger MAIN = CreateTrigger()
endglobals
private function condition takes nothing returns boolean
return GetSpellAbilityId() == ACTIVATOR_SPELL
endfunction
private function TRUEFILTER takes nothing returns boolean
return true
endfunction
private function action takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local player owner = GetOwningPlayer(u)
local real hp = GetUnitState(u,UNIT_STATE_LIFE)
local integer l = GetUnitAbilityLevel(u,ACTIVATOR_SPELL)
local group g = CreateGroup()
local real base = GetHeroStr(u,true)*ABSORB_STR_LEVEL_MULTIPLYER*l+ABSORB_BASE
local DamageShield shield
local unit enum
call GroupEnumUnitsInRange(g,GetUnitX(u),GetUnitY(u),AOE,Condition(function TRUEFILTER))
loop
set enum = FirstOfGroup(g)
call GroupRemoveUnit(g,enum)
exitwhen enum == null
if IsPlayerAlly(owner,GetOwningPlayer(enum)) == true and GetUnitState(enum,UNIT_STATE_LIFE)>0 then
set shield = DamageShield.get(enum)
if shield == 0 then
set shield = DamageShield.create(enum)
endif
call shield.settime(DURIATION)
call shield.addtimedeffect(SHIELD_EFFECT,"origin")
if enum == u then
call shield.addtimedabsorb(base+GetUnitState(u,UNIT_STATE_MAX_LIFE)*HP_MULTIPLYER_CASTER)
else
call shield.addtimedabsorb(base+GetUnitState(enum,UNIT_STATE_MAX_LIFE)*HP_MULTIPLYER)
endif
call DamageShield.TextTag(enum,I2S(R2I(shield.AbsorbQuantity)))
endif
endloop
call DestroyGroup(g)
set u = null
set owner = null
set g = null
endfunction
private function int takes nothing returns nothing
call TriggerAddAction(MAIN,function action)
call TriggerAddCondition(MAIN,Condition(function condition))
call TriggerRegisterAnyUnitEventBJ(MAIN,EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction
endlibrary
//Spells for Black Mage
library Fireaga initializer int requires TimerBank, FloatingTextEmulation
//This ability requires Dr Super Good's TimerBank system and FloatingTextEmulation system to opperate.
//A sneak peak at one of the abilities that my next hero will have.
//Curently this ability is in beta phase so lacks documentation and may contain bugs but is fully useable.
private struct Fireaga
timer time
group affected
unit from
real damage
real chance
real x
real y
endstruct
globals
//Set below to the raw code of the spell you want to have trigger this ability.
private constant integer ACTIVATOR_SPELL = 'A008'
private constant real RADIUS = 400
private constant real LEVEL_MULTIPLAYER_BASE = 0.5
private constant real LEVEL_MULTIPLAYER_LEVEL = 0.5
private constant real LEVEL_BASE_LEVEL = 5
private constant real DAMAGE_BASE_LEVEL = 75
private constant real DAMAGE_INT = 1.5
private constant real DELAY_MAIN = 2
private constant real DELAY_LOOP = 0.5
private constant string EFFECT_PATH = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl"
//Below are variables used by the ability's engine.
private constant real RADIUS_SQUARED = RADIUS*RADIUS
private player owner
private integer counter = 0
private Fireaga array instances
public integer n = 0
public trigger MAIN = CreateTrigger()
endglobals
private function condition takes nothing returns boolean
return GetSpellAbilityId() == ACTIVATOR_SPELL
endfunction
private function Effect takes nothing returns nothing
local timer time = GetExpiredTimer()
local integer i = 0
local real x
local real y
local real damage
local unit u
local Fireaga instant
loop
exitwhen instances[i].time == time
set i = i+1
endloop
set instant = instances[i]
set u = FirstOfGroup(instant.affected)
if u != null then
call GroupRemoveUnit(instant.affected,u)
set x = GetUnitX(u)
set y = GetUnitY(u)
if instant.chance>GetRandomReal(0,1) and GetUnitState(u,UNIT_STATE_LIFE)>0 then
set damage = instant.damage*GetRandomReal(0.8,1.2)
if instant.chance > 1 then
set damage = damage*GetRandomReal(1,instant.chance)
endif
if RADIUS_SQUARED>(instant.x-x)*(instant.x-x)+(instant.y-y)*(instant.y-y) then
set damage = damage*1.5
endif
call DestroyEffect(AddSpecialEffectTarget(EFFECT_PATH,u,"origin"))
call UnitDamageTarget(instant.from,u,damage,false,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
call FloatingTextEmulation_Damage(u,damage)
else
call DestroyEffect(AddSpecialEffect(EFFECT_PATH,x,y))
call FloatingTextEmulation_Evade(u)
endif
else
call TimerBank_Deposit(time)
call DestroyGroup(instant.affected)
call instant.destroy()
set n = n-1
set instances[i] = instances[n]
endif
set time = null
endfunction
private function Count takes nothing returns nothing
set counter=counter+GetUnitLevel(GetEnumUnit())
endfunction
private function EnumFilter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(),owner) and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0
endfunction
private function Delay takes nothing returns nothing
call TimerStart(GetExpiredTimer(),DELAY_LOOP,true,function Effect)
endfunction
private function action takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local location target = GetSpellTargetLoc()
local integer level = GetUnitAbilityLevel(u,ACTIVATOR_SPELL)
local real chance
local Fireaga instant = Fireaga.create()
set instances[n] = instant
set n = n+1
set instant.affected = CreateGroup()
set owner = GetOwningPlayer(u)
call GroupEnumUnitsInRangeOfLoc(instant.affected,target,RADIUS,Condition(function EnumFilter))
set counter = 0
call ForGroup(instant.affected,function Count)
set chance = level*LEVEL_BASE_LEVEL+GetHeroLevel(u)*(LEVEL_MULTIPLAYER_BASE+LEVEL_MULTIPLAYER_LEVEL*level)
set instant.chance = 2*chance/(chance+counter)
set instant.damage = DAMAGE_BASE_LEVEL*level+DAMAGE_INT*GetHeroInt(u,true)
set instant.x = GetLocationX(target)
set instant.y = GetLocationY(target)
call RemoveLocation(target)
set instant.from = u
set instant.time = TimerBank_Withdraw()
call TimerStart(instant.time,DELAY_MAIN,false,function Delay)
set target = null
set u = null
endfunction
private function int takes nothing returns nothing
call TriggerAddAction(MAIN,function action)
call TriggerAddCondition(MAIN,Condition(function condition))
call TriggerRegisterAnyUnitEventBJ(MAIN,EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction
endlibrary
//Systems used
library Common
globals
constant hashtable Chash = InitHashtable()
endglobals
endlibrary
library TimerBank
//-------------------Timer Bank-------------------//
//This system is offically released and may be used and edited as long as . . .
// - You do not blame me for bugs that occure as a fault of you using this system.
//
//------------------User manual-------------------//
//The system basically acts as a method to store timers and fetch them later to prevent leaks or bugs.
//You can fetch an infinate number of timers from this system but can only store a maximum of 8192 timers at once.
//I saw no need to put any support for more than that number of timers since I see no way a normal map will rach that limate.
//
//You can use the following functions to interface with this.
// Withdraw - Fetches a unique timer from the system.
// Deposit - Deposits a timer into the system and pauses it.
// Only use this on a timer when you do no longer need it and will not be using it any more.
//------------------------------------------------//
globals
private timer array timers
private integer n=0
endglobals
public function Withdraw takes nothing returns timer
if n==0 then
return CreateTimer()
endif
set n=n-1
return timers[n]
endfunction
public function Deposit takes timer t returns nothing
call PauseTimer(t)
set timers[n] = t
set n=n+1
set t = null
endfunction
endlibrary
library DamageShieldRegen requires Common
//This system requires Dr Super Good's TimerBank system to opperate.
//This system is used by the DamageShield library to reheal the damage that was received
//Also prevents unit death when the shield is on.
globals
private constant integer DEATH_STOP = 'A002'
private constant integer SYSTEM_ID = StringHash("Damage Shield Regen")
private constant group units = CreateGroup()
private constant timer time = CreateTimer()
private boolean off = true
endglobals
private function DamageRegen takes nothing returns nothing
//Loops through all heal requests that still need to be healed and preforms them.
local unit u
local integer hash
loop
set u = FirstOfGroup(units)
exitwhen u == null
call GroupRemoveUnit(units,u)
call UnitRemoveAbility(u,DEATH_STOP)
set hash = GetHandleId(u)
call SetWidgetLife(u,LoadReal(Chash,hash,SYSTEM_ID))
call SaveReal(Chash,hash,SYSTEM_ID,0)
call RemoveSavedReal(Chash,hash,SYSTEM_ID)
endloop
set off = true
endfunction
public function Add takes unit u, real a returns nothing
//Adds a heal request to the request list and orders it to be done as soon as possiable.
//This system needs to store multiple heal requests as although the timer should
//have no delay, it does have a slight delay. Thus it orders a timer to fire as soon
//as it can and ques up the heal requests for when the timer fires.
local real life
local integer hash = GetHandleId(u)
if LoadReal(Chash,hash,SYSTEM_ID) != 0 then
set life = LoadReal(Chash,hash,SYSTEM_ID)+a
if life < 0.405 then
call GroupRemoveUnit(units,u)
call SaveReal(Chash,hash,SYSTEM_ID,0)
call RemoveSavedReal(Chash,hash,SYSTEM_ID)
call UnitRemoveAbility(u,DEATH_STOP)
call SetWidgetLife(u,life-a)
else
call SaveReal(Chash,hash,SYSTEM_ID,life)
endif
else
set life = GetWidgetLife(u)+a
if life >= 0.405 then
call GroupAddUnit(units,u)
call SaveReal(Chash,hash,SYSTEM_ID,life)
call UnitAddAbility(u,DEATH_STOP)
call SetWidgetLife(u,2147483647)
endif
endif
if off then
call TimerStart(time,0,false,function DamageRegen)
set off = false
endif
set u = null
endfunction
endlibrary
library DamageShield requires Common, DamageShieldRegen
//This system requires Dr Super Good's DamageShieldRegen system to opperate.
//---------------Damage Shield V3.0---------------//
//A redesigned lower level of my first and second system for better speed and customizability.
//
//This system is offically released and may be used and edited as long as . . .
//1. Credit is given to me "DrSuperGood".
//2. No edited versions are publicaly redistributed without credits.
//3. You do not blame me for bugs that occure as a fault of you using this system.
//
//------------------User manual-------------------//
//The system is object orientated and thus you have to create and destroy instances of the shield.
//Shield objects are structs and thus can be manipulated like structs.
//
//You can access the folowing variables within the struct.
// n - The number of shield objects currently created.
// units - The unit that a shield object is attached to.
// absorbs - The amount of damage the shield can still absorb before it is destroyed.
//
//You can use the following methods to interface with this struct.
// Create - Initilizes a shield object. Takes the unit then special effect path and returns the created shield object ID number.
// TimeRemove - Removes the timer from the passed shield object meaning that it nolonger can be time expiring.
// AbsorbAdd - Adds to the first parameter shield object the second parameter ammount of absorb.
// AbsorbSet - Sets the first parameter shield object to the second parameter ammount of absorb.
// TimeAdd - Adds to the first parameter shield object the second parameter ammount of duration before shield expires.
// TimeSet - Sets the first parameter shield object to the second parameter ammount of duration before shield expires.
// Can not be used to reduce shield duration.
// Get - Returns the shield object ID number that the passed unit uses.
// Returns the current number of shields (n) if the unit has no attached shield yet.
//------------------------------------------------//
globals
//The system ID is used by the universal hash system to identify data stored on a non local source.
//This is to prevent collisions with other spells.
private constant integer SYSTEM_ID = StringHash("Damage Shield")
endglobals
struct DamageShield
trigger DamageTrigger = CreateTrigger()
unit Affected
real AbsorbQuantity = 0
real AbsorbQuantityTemp
timer DurationTimer
static method TextTag takes unit u, string s returns nothing
local texttag tag = CreateTextTag()
call SetTextTagText(tag,s,0.023)
call SetTextTagColor(tag,0,255,255,255)
call SetTextTagLifespan(tag,2)
call SetTextTagFadepoint(tag,1)
call SetTextTagPermanent(tag,false)
call SetTextTagPosUnit(tag,u,0)
call SetTextTagVelocity(tag,0,0.1)
if not IsUnitVisible(u,GetLocalPlayer()) then
call SetTextTagVisibility(tag,false)
endif
set u = null
set tag = null
endmethod
method onDestroy takes nothing returns nothing
local integer temphash = GetHandleId(.Affected)
local integer temphash2 = GetHandleId(.DamageTrigger)
local integer temphash3
local integer effectnum = LoadInteger(Chash,temphash2,0)
local integer i = 0
call DestroyTrigger(.DamageTrigger)
set .DamageTrigger = null
call SaveInteger(Chash,temphash,SYSTEM_ID,0)
call RemoveSavedInteger(Chash,temphash,SYSTEM_ID)
loop
exitwhen i == effectnum
set i = i+1
set temphash3 = LoadInteger(Chash,temphash2,i)
call DestroyEffect(LoadEffectHandle(Chash,temphash,temphash3))
call RemoveSavedHandle(Chash,temphash,temphash3)
endloop
call FlushChildHashtable(Chash,temphash2)
if .DurationTimer != null then
call PauseTimer(.DurationTimer)
set i = 1
set temphash2 = GetHandleId(.DurationTimer)
call DestroyTimer(.DurationTimer)
set .DurationTimer = null
set effectnum = LoadInteger(Chash,temphash2,1)
loop
exitwhen i == effectnum
set i = i+1
set temphash3 = LoadInteger(Chash,temphash2,i)
call DestroyEffect(LoadEffectHandle(Chash,temphash,temphash3))
call RemoveSavedHandle(Chash,temphash,temphash3)
endloop
call FlushChildHashtable(Chash,temphash2)
endif
call DamageShield.TextTag(.Affected,"0")
set .Affected = null
endmethod
method timerdestroy takes nothing returns nothing
local integer temphash = GetHandleId(.Affected)
local integer temphash2 = GetHandleId(.DurationTimer)
local integer temphash3
local integer effectnum = LoadInteger(Chash,temphash2,1)
local integer i = 1
call PauseTimer(.DurationTimer)
call DestroyTimer(.DurationTimer)
set .DurationTimer = null
loop
exitwhen i == effectnum
set i = i+1
set temphash3 = LoadInteger(Chash,temphash2,i)
call DestroyEffect(LoadEffectHandle(Chash,temphash,temphash3))
call RemoveSavedHandle(Chash,temphash,temphash3)
endloop
call FlushChildHashtable(Chash,temphash2)
set .AbsorbQuantity = .AbsorbQuantity - .AbsorbQuantityTemp
call DamageShield.TextTag(.Affected,I2S(R2I(.AbsorbQuantity)))
endmethod
static method ontimer takes nothing returns nothing
local timer t = GetExpiredTimer()
local DamageShield shield = LoadInteger(Chash,GetHandleId(t),0)
if shield.AbsorbQuantityTemp >= shield.AbsorbQuantity then
call shield.destroy()
else
call shield.timerdestroy()
endif
set t = null
endmethod
static method ondamage takes nothing returns boolean
local real d = GetEventDamage()
local unit u = GetTriggerUnit()
local DamageShield shield = LoadInteger(Chash,GetHandleId(u),SYSTEM_ID)
if d > 0 then
if d < shield.AbsorbQuantity then
set shield.AbsorbQuantity = shield.AbsorbQuantity-d
if shield.DurationTimer != null then
set shield.AbsorbQuantityTemp = shield.AbsorbQuantityTemp-d
if shield.AbsorbQuantityTemp <= 0 then
call shield.timerdestroy()
endif
endif
call DamageShieldRegen_Add(u,0)
call DamageShield.TextTag(u,I2S(R2I(shield.AbsorbQuantity)))
else
call DamageShieldRegen_Add(u,shield.AbsorbQuantity-d)
call shield.destroy()
endif
endif
set u = null
return false
endmethod
method timersetup takes nothing returns nothing
local integer hash
set .DurationTimer = CreateTimer()
set hash = GetHandleId(.DurationTimer)
call SaveInteger(Chash,hash,0,this)
call SaveInteger(Chash,hash,1,1)
set .AbsorbQuantityTemp = 0
endmethod
method addtime takes real duration returns nothing
if .DurationTimer == null then
call .timersetup()
call TimerStart(.DurationTimer,duration,false,function DamageShield.ontimer)
else
call TimerStart(.DurationTimer,TimerGetRemaining(.DurationTimer)+duration,false,function DamageShield.ontimer)
endif
endmethod
method settime takes real duration returns nothing
if .DurationTimer == null then
call .timersetup()
call TimerStart(.DurationTimer,duration,false,function DamageShield.ontimer)
elseif TimerGetRemaining(.DurationTimer) < duration then
call TimerStart(.DurationTimer,duration,false,function DamageShield.ontimer)
endif
endmethod
method addtimedabsorb takes real ammount returns nothing
//call BJDebugMsg("addtimedabsorb")
set .AbsorbQuantity = .AbsorbQuantity + ammount
set .AbsorbQuantityTemp = .AbsorbQuantityTemp + ammount
endmethod
method addtimedeffect takes string path, string attachment returns nothing
local integer stringhash = StringHash(path)
local integer hash = GetHandleId(.DurationTimer)
local integer i = LoadInteger(Chash,hash,1)+1
if not HaveSavedHandle(Chash,GetHandleId(.Affected),stringhash) then
call SaveEffectHandle(Chash,GetHandleId(.Affected),stringhash,AddSpecialEffectTarget(path,.Affected,attachment))
call SaveInteger(Chash,hash,1,i)
call SaveInteger(Chash,hash,i,stringhash)
endif
endmethod
method addeffect takes string path, string attachment returns nothing
local integer stringhash = StringHash(path)
local integer hash = GetHandleId(.Affected)
local integer i = LoadInteger(Chash,hash,0)+1
if not HaveSavedHandle(Chash,hash,stringhash) then
call SaveEffectHandle(Chash,hash,stringhash,AddSpecialEffectTarget(path,.Affected,attachment))
set hash = GetHandleId(.DamageTrigger)
call SaveInteger(Chash,hash,0,i)
call SaveInteger(Chash,hash,i,stringhash)
endif
endmethod
static method get takes unit whichunit returns DamageShield
//call BJDebugMsg("get")
return LoadInteger(Chash,GetHandleId(whichunit),SYSTEM_ID)
endmethod
static method create takes unit whichunit returns DamageShield
local DamageShield shield = DamageShield.allocate()
//call BJDebugMsg("create")
set shield.Affected = whichunit
call TriggerRegisterUnitEvent(shield.DamageTrigger,whichunit,EVENT_UNIT_DAMAGED)
call TriggerAddCondition(shield.DamageTrigger,Condition(function DamageShield.ondamage))
call SaveInteger(Chash,GetHandleId(whichunit),SYSTEM_ID,shield)
set whichunit = null
return shield
endmethod
endstruct
endlibrary
library FloatingTextEmulation
//This system provides useful text tag opperations that are easy to use and check line of site.
//
//Evade - Emulates a miss style evade tag for a target of a spell.
//Damage - Emulates a critical strike style damage tag without the "!" for a more generic spell damage.
public function Evade takes unit u returns nothing
local texttag tag = CreateTextTag()
call SetTextTagText(tag,"evade",0.023)
call SetTextTagColor(tag,255,0,0,255)
call SetTextTagLifespan(tag,3)
call SetTextTagFadepoint(tag,1)
call SetTextTagPermanent(tag,false)
call SetTextTagPosUnit(tag,u,0)
call SetTextTagVelocity(tag,0,0.03)
if not IsUnitVisible(u,GetLocalPlayer()) then
call SetTextTagVisibility(tag,false)
endif
set tag = null
set u = null
endfunction
public function Damage takes unit u, real damage returns nothing
local texttag tag = CreateTextTag()
call SetTextTagText(tag,I2S(R2I(damage)),0.023)
call SetTextTagColor(tag,255,0,0,255)
call SetTextTagLifespan(tag,5)
call SetTextTagFadepoint(tag,2)
call SetTextTagPermanent(tag,false)
call SetTextTagPosUnit(tag,u,0)
call SetTextTagVelocity(tag,0,0.04)
if not IsUnitVisible(u,GetLocalPlayer()) then
call SetTextTagVisibility(tag,false)
endif
set tag = null
set u = null
endfunction
endlibrary
Name | Type | is_array | initial_value |
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local location l
local integer i = 0
loop
set l = Location(0,0)
call BJDebugMsg(I2S(GetHandleId(l)))
call RemoveLocation(l)
set l = null
set i = i+1
exitwhen i == 10
endloop
endfunction
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
set gg_trg_Untitled_Trigger_001 = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Untitled_Trigger_001, Player(0), "-LC", true )
call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction