cr4xzZz
Also known as azwraith_ftL.
- Reaction score
- 51
Damage Per Second System v2.5
A system that allows you to damage a unit every second for a specific duration. Has a normal and an extended function. If the target does not recieve the assigned buff in 5 seconds, DPS that was called is canceled. This will not screw in any way the instant appliement of a buff (such as frost nova). The system checks every .1 seconds if the target has that buff. If it does then everything works normally. I think 5 seconds is fair enough for some spells to travel and apply the buff (such as Acid Bomb). Thanks to Cohadar for this tip. If you want to stop the damaging then just remove the buff from the target. DPS stops if the target has the buff dispelled, too.
Test map includes Frost Nova and Acid Bomb test.
Requires: JASS NewGen, ABCT v1.2
Code:
JASS:
//==============================================================================
// Damage Per Second System by cr4xzZz v2.5
//==============================================================================
//
// PURPOSE:
// - Creating dps spells or other same stuff the easy way
// - Save you time from repeating the same timer/loop method over and over
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// HOW TO USE:
// call DPS_Start(which damager, which target, damage (NOT dps!), duration, buff raw code, show effect or not (true or false) )
// call DPS_StartEx(which damager, which target, damage (NOT dps!), duration, buff raw code, attack type, damage type, string effect, attachment point, show effect or not (true or false) )
//
// * As you can see you can use a normal function and an extended function.
// The extended function has more arguments to add. If you are still confused
// how to use it I'll explain a bit more with the functions' arguments.
//
// whichUnit - the unit which will damage something
// whichTarg - the target that is going to be damaged
// whichDmg - the full damage dealt for the specific period (NOT the damage per second)
// * damage per second is calculated by the system
// whichDur - the duration of the damaging
// whichBuff - the buff that the target has to have it so it can be damaged
// * if the target does not have that buff the damaging will stop
// whichAttackType - the attack type used for damaging
// whichDamageType - the damage type used for damaging
// whichFx - the special effect string
// whichPoint - where the effect will be attached (head, chest, etc.)
// whichBool - should an effect be shown? MUST be true or false
// * if the boolean flag is true then the special effect WILL appear
// * if the boolean flag is false then the special effect WON'T appear
//
// - If you want to stop the buff damaging then remove the
// buff you assigned with the Buff functions from the target unit
// - If the target does not recieve the buff in 5 seconds from
// calling Buff/BuffEx then the function is cancelled
//
// The non-extended function uses some arguments from the system's configuration menu.
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// HOW IT WORKS:
// When you start one of the functions a periodic timer
// will run for 5 seconds, checking each .1 seconds if
// the target has the specific buff you chose. This is
// used because some spells have a missile to travel
// before the buff actually appears. 5 seconds should be enough
// for a missile to travel and hit a unit.Remember that this
// system works only for a single unit. If the unit recieves the buff
// instantly or in the 5 seconds the DPS starts. These 5 seconds
// can be increased/decreased but it's recommended to
// keep them this way.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// PROS:
// - Easy to use
// - A lot customizeable (has extended functions)
// - Won't mess up with other systems
// - Stackable damage (not like slow poison)
//
// CONS:
// - A bit difficult to use
// - Requires another system to work
// - Stackable damage (not like slow poison)
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// HOW TO USE:
// - Copy the ABCT system if you don't have them
// - Create a trigger named DPS
// - Convert it to custom text and replace the text with this one
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// CREDITS TO:
// - Cohadar for ABCT and some help
// - 0zaru and ~GaLs~ for some help
//
//==============================================================================
library DPS uses ABCT
globals
private constant real INTERVAL = 1.
private constant real CHECK_PERIOD = 0.1
private constant attacktype ATTACK = ATTACK_TYPE_MAGIC
private constant damagetype DAMAGE = DAMAGE_TYPE_MAGIC
private constant string EFFECT = "Abilities\\Spells\\Orc\\FeralSpirit\\feralspirittarget.mdl"
private constant string POINT = "chest"
endglobals
private struct Config
unit cast
unit targ
real dps
integer ticks
string effe
string point
attacktype attack
damagetype damage
integer buffz
boolean check
integer temp = 0
static method create takes unit whichUnit, unit whichTarg, real whichDmg, real whichDur, integer whichBuff, attacktype whichAttackType, damagetype whichDamageType, string whichFx, string whichPoint, boolean whichBool returns Config
local Config store = Config.allocate()
set store.cast = whichUnit
set store.targ = whichTarg
set store.dps = ((whichDmg / whichDur) * INTERVAL)
set store.effe = whichFx
set store.point = whichPoint
set store.attack = whichAttackType
set store.damage = whichDamageType
set store.buffz = whichBuff
set store.check = whichBool
set store.ticks = R2I(whichDur)
return store
endmethod
endstruct
private function DPZ takes nothing returns boolean
local Config store = ABCT_GetData()
if GetWidgetLife(store.targ) >= 0.405 and GetUnitAbilityLevel(store.targ, store.buffz) > 0 and store.ticks > 0 then
call UnitDamageTarget(store.cast, store.targ, store.dps, true, true, store.attack, store.damage, null)
if store.check == true then
call DestroyEffect(AddSpecialEffectTarget(store.effe, store.targ, store.point))
endif
else
call store.destroy()
//call BJDebugMsg("|cffffcc00[DPS]Message|r - Dps stops")
return true
endif
set store.ticks = store.ticks - 1
return false
endfunction
private function Check takes nothing returns boolean
local Config store = ABCT_GetData()
if GetUnitAbilityLevel(store.targ, store.buffz) > 0 then
call ABCT_Start(function DPZ, store, INTERVAL)
//call BJDebugMsg("|cffffcc00[DPS]Message|r - Dps starts")
return true
endif
set store.temp = store.temp + 1
if store.temp > 50 then //10 checks in a second (0.1 period) for 4 seconds
call store.destroy()
//call BJDebugMsg("|cffffcc00[DPS]Message|r - Dps cancelled")
return true
endif
return false
endfunction
public function StartEx takes unit whichUnit, unit whichTarg, real whichDmg, real whichDur, integer whichBuff, attacktype whichAttackType, damagetype whichDamageType, string whichFx, string whichPoint, boolean whichBool returns nothing
local Config store = Config.create(whichUnit, whichTarg, whichDmg, whichDur, whichBuff, whichAttackType, whichDamageType, whichFx, whichPoint, whichBool)
call ABCT_Start(function Check, store, CHECK_PERIOD)
endfunction
public function Start takes unit whichUnit, unit whichTarg, real whichDmg, real whichDur, integer whichBuff, boolean whichBool returns nothing
local Config store = Config.create(whichUnit, whichTarg, whichDmg, whichDur, whichBuff, ATTACK, DAMAGE, EFFECT, POINT, whichBool)
call ABCT_Start(function Check, store, CHECK_PERIOD)
endfunction
endlibrary
//==============================================================================
// End of Damage Per Second System
//==============================================================================
Previous Version:
JASS:
//==============================================================================
// Damage Per Second System by cr4xzZz v2.4
//==============================================================================
//
// PURPOSE:
// - Creating dps spells or other same stuff the easy way
// - Save you time from repeating the same timer/loop method over and over
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// HOW TO USE:
// call DPS_Start(which damager, which target, damage (NOT dps!), duration, show effect or not (true or false) )
// call DPS_StartEx(which damager, which target, damage (NOT dps!), duration, attack type, damage type, string effect, attachment point, show effect or not (true or false) )
// call DPS_Buff(which damager, which target, damage (NOT dps!), duration, buff raw code, show effect or not (true or false) )
// call DPS_BuffEx(which damager, which target, damage (NOT dps!), duration, buff raw code, attack type, damage type, string effect, attachment point, show effect or not (true or false) )
//
// * As you can see you can use a normal function and an extended function. The extended function
// has more arguments to add. If you are still confused how to use it I'll explain a bit more with
// the functions' arguments.
// * Every time the unit is damaged you can choose if you want a effect to be shown or not
//
// whichUnit - the unit which will damage something
// whichTarg - the target that is going to be damaged
// whichDmg - the full damage dealt for the specific period (NOT the damage per second)
// * damage per second is calculated by the system
// whichDur - the duration of the damaging
// whichBuff - the buff that the target has to have it so it can be damaged
// * if the target does not have that buff the damaging will stop (only for DPS_Buff and DPS_BuffEx functions)
// whichAttackType - the attack type used for damaging
// whichDamageType - the damage type used for damaging
// whichFx - the special effect string
// whichPoint - where the effect will be attached (head, chest, etc.)
// whichBool - should an effect be shown? MUST be true or false
// * if the boolean flag is true then the special effect WILL appear
// * if the boolean flag is false then the special effect WON'T appear
//
// If you want to stop the buff damaging then remove the buff you assigned with the Buff functions from the target unit
// If you want to stop the normal Start/StartEx function then use:
// call DPS_Stop(whichTarg) /unit argument/
// - This stops all DPS_Start and DPS_StartEx functions used on that unit
//
// If you want to increase the duration of the damaging then use:
// call DPS_IncreaseDur(whichDur) /integer argument/
// - This works only for DPS_Start and DPS_StartEx !!
//
// The non-extended functions uses some arguments from the system's configuration menu.
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// PROS:
// - Easy to use
// - A lot customizeable (has extended functions)
// - Won't mess up with other systems
// - Stackable damage (not like slow poison)
//
// CONS:
// - A bit difficult to use
// - Requires another system to work
// - Stackable damage (not like slow poison)
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// HOW TO USE:
// - Copy the ABCT and PUI systems if you don't have them
// - Create a trigger named DPS
// - Convert it to custom text and replace the text with this one
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// CREDITS TO:
// - Cohadar for ABCT, PUI and some help
// - 0zaru and ~GaLs~ for some help
//
//==============================================================================
library DPS uses ABCT, PUI
globals
private constant real INTERVAL = 1.
private constant attacktype ATTACK = ATTACK_TYPE_NORMAL
private constant damagetype DAMAGE = DAMAGE_TYPE_MAGIC
private constant string EFFECT = "Abilities\\Spells\\Orc\\FeralSpirit\\feralspirittarget.mdl"
private constant string POINT = "chest"
private integer array PUI_TICKS
endglobals
private struct Config
unit cast
unit targ
real dps
integer ticks
string effe
string point
attacktype attack
damagetype damage
integer buffz
boolean check
static method create takes unit whichUnit, unit whichTarg, real whichDmg, real whichDur, integer whichBuff, attacktype whichAttackType, damagetype whichDamageType, string whichFx, string whichPoint, boolean whichBool returns Config
local Config store = Config.allocate()
set store.cast = whichUnit
set store.targ = whichTarg
set store.dps = ((whichDmg / whichDur) * INTERVAL)
set store.effe = whichFx
set store.point = whichPoint
set store.attack = whichAttackType
set store.damage = whichDamageType
set store.buffz = whichBuff
set store.check = whichBool
set store.ticks = R2I(whichDur)
return store
endmethod
endstruct
private function CheckDPS takes nothing returns boolean
local Config store = ABCT_GetData()
if GetWidgetLife(store.targ) >= 0.405 and GetUnitAbilityLevel(store.targ, store.buffz) > 0 and store.ticks > 0 then
call UnitDamageTarget(store.cast, store.targ, store.dps, true, true, store.attack, store.damage, null)
if store.check == true then
call DestroyEffect(AddSpecialEffectTarget(store.effe, store.targ, store.point))
endif
else
call store.destroy()
//call BJDebugMsg("|cffffcc00[DPS]Message|r - Dps stops")
return true
endif
set store.ticks = store.ticks - 1
return false
endfunction
private function NormalDPS takes nothing returns boolean
local Config store = ABCT_GetData()
local integer pui = GetUnitIndex(store.targ)
if GetWidgetLife(store.targ) >= 0.405 and PUI_TICKS[pui] > 0 then
call UnitDamageTarget(store.cast, store.targ, store.dps, true, true, store.attack, store.damage, null)
if store.check == true then
call DestroyEffect(AddSpecialEffectTarget(store.effe, store.targ, store.point))
endif
else
call store.destroy()
//call BJDebugMsg("|cffffcc00[DPS]Message|r - Dps stops")
return true
endif
set PUI_TICKS[pui] = PUI_TICKS[pui] - 1
return false
endfunction
public function Stop takes unit whichTarg returns nothing
local integer pui = GetUnitIndex(whichTarg)
if PUI_TICKS[pui] <= 0 then
call BJDebugMsg("|cffffcc00[DPS]Error|r - Cannot stop DPS for unit that has no DPS_Start/DPS_StartEx")
return
else
set PUI_TICKS[pui] = 0
endif
endfunction
public function IncreaseDur takes unit whichTarg, real whichDur returns nothing
local integer pui = GetUnitIndex(whichTarg)
local integer inc = R2I(whichDur)
if PUI_TICKS[pui] <= 0 then
call BJDebugMsg("|cffffcc00[DPS]Error|r - Cannot increase duration for a unit with no DPS_Start/DPS_StartEx")
return
else
set PUI_TICKS[pui] = PUI_TICKS[pui] + inc
endif
endfunction
public function BuffEx takes unit whichUnit, unit whichTarg, real whichDmg, real whichDur, integer whichBuff, attacktype whichAttackType, damagetype whichDamageType, string whichFx, string whichPoint, boolean whichBool returns nothing
local Config store = Config.create(whichUnit, whichTarg, whichDmg, whichDur, whichBuff, whichAttackType, whichDamageType, whichFx, whichPoint, whichBool)
call ABCT_Start(function CheckDPS, store, INTERVAL)
//call BJDebugMsg("|cffffcc00[DPS]Message|r - Dps starts")
endfunction
public function Buff takes unit whichUnit, unit whichTarg, real whichDmg, real whichDur, integer whichBuff, boolean whichBool returns nothing
call DPS_BuffEx(whichUnit, whichTarg, whichDmg, whichDur, whichBuff, ATTACK, DAMAGE, EFFECT, POINT, whichBool)
endfunction
public function StartEx takes unit whichUnit, unit whichTarg, real whichDmg, real whichDur, attacktype whichAttackType, damagetype whichDamageType, string whichFx, string whichPoint, boolean whichBool returns nothing
local Config store = Config.create(whichUnit, whichTarg, whichDmg, whichDur, 0, whichAttackType, whichDamageType, whichFx, whichPoint, whichBool)
local integer pui = GetUnitIndex(store.targ)
set PUI_TICKS[pui] = PUI_TICKS[pui] + R2I(whichDur / INTERVAL)
call ABCT_Start(function NormalDPS, store, INTERVAL)
//call BJDebugMsg("|cffffcc00[DPS]Message|r - Dps starts")
endfunction
public function Start takes unit whichUnit, unit whichTarg, real whichDmg, real whichDur, boolean whichBool returns nothing
call DPS_StartEx(whichUnit, whichTarg, whichDmg, whichDur, ATTACK, DAMAGE, EFFECT, POINT, whichBool)
endfunction
endlibrary
//==============================================================================
// End of Damage Per Second System
//==============================================================================
Changelog:
JASS:
v1.0 - First release
v1.1 - Shortened code and removed buff check. Added extended function
v1.2 - Added stop and increase duration functions which require a target (refer only on a target from dps)
v2.0 - Fixed increase and stop functions
v2.1 - Minor code fixes
v2.2 - Added buff check again
v2.3 - Simplified a little. Removed non-buff check function and left it with a buff check one
v2.4 - Added normal dps again (non-buff check) (omg..). Returned Stop and Increase Duration functions. Uses ABCT and PUI
v2.5 - Removed non-buff check (again.. omg wtf!). Uses only ABCT. Now, if the target does not recieve the assigned buff in
5 seconds, DPS is canceled. This is because some spells have a missile to travel before they apply a buff (thanks,
Cohadar, for this tip).