- Joined
- May 16, 2012
- Messages
- 644
The DDS market is already full, and Damage Engine by Bribe will always be king for GUI users, but i just want to make my contribution and receive honest feedback.
I present to you the Damage Library and Damage Event Library, two light weight, easy to import library's. Damage Library is targeted towards GUI users. It allows them to utilize the GUI functions to do stuff instead of variables. I think it's fun and more intuitive.
The Damage Event Library is targeted towards Jassers. It allows them do register specific damage events, like on attack damage or on spell damage. I've only mapped 4 damage types, the most commonly used (attack, spell, cleave and universal), but it can easily but upscaled. It works similar to the RegisterPlayerUnitEvent and SpellEffectEvent.
Both Library's do not allow TriggerSleepAction calls, so learn timers!!
Damage Event:
Damage:
Again, i know that there is a lot of DDS already and that this 2 are nowhere near been complete damage systems with tons of tools like Damage Engine, but i hope they help someone.
I present to you the Damage Library and Damage Event Library, two light weight, easy to import library's. Damage Library is targeted towards GUI users. It allows them to utilize the GUI functions to do stuff instead of variables. I think it's fun and more intuitive.
The Damage Event Library is targeted towards Jassers. It allows them do register specific damage events, like on attack damage or on spell damage. I've only mapped 4 damage types, the most commonly used (attack, spell, cleave and universal), but it can easily but upscaled. It works similar to the RegisterPlayerUnitEvent and SpellEffectEvent.
Both Library's do not allow TriggerSleepAction calls, so learn timers!!
Damage Event:
JASS:
Damage Event will help you turn this:
private function OnDamage takes nothing returns nothing
local boolean isSpell = BlzGetEventAttackType() == ATTACK_TYPE_NORMAL
if isSpell then
//do stuff
endif
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DAMAGED)
call TriggerAddCondition(t, Condition(function OnDamage))
endfunction
into this:
private function OnDamage takes nothing returns nothing
//Do Stuff
endfunction
private function Init takes nothing returns nothing
call RegisterSpellDamage(Condition(function OnDamage))
endfunction
JASS:
library DamageEvent
/* --------------------- Damage Event v1.0 by Chopinski --------------------- */
//
// Allows for easy registration of specific damage type events like on attack
// damage or on spell damage, etc...
//
// How To Use?
// It works very similar to the RegisterPlayerUnitEvent and SpellEffectEvent
// library's, it's intended to turn this?
//
// private function OnDamage takes nothing returns nothing
// local boolean isSpell = BlzGetEventAttackType() == ATTACK_TYPE_NORMAL
//
// if isSpell then
// //do stuff
// endif
// endfunction
//
// private function Init takes nothing returns nothing
// local trigger t = CreateTrigger()
// call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DAMAGED)
// call TriggerAddCondition(t, Condition(function OnDamage))
// endfunction
//
// Into this:
//
// private function OnDamage takes nothing returns nothing
// //Do Stuff
// endfunction
//
// private function Init takes nothing returns nothing
// call RegisterSpellDamage(Condition(function OnDamage))
// endfunction
//--------------------------------------------------------------------------------
private struct DamageEvent
static trigger Attack = CreateTrigger()
static trigger Spell = CreateTrigger()
static trigger Pure = CreateTrigger()
static trigger Cleave = CreateTrigger()
static trigger Damage = CreateTrigger()
static method OnDamage takes nothing returns nothing
local boolean isAttack = BlzGetEventIsAttack()
local boolean isSpell = BlzGetEventAttackType() == ATTACK_TYPE_NORMAL
local boolean isPure = BlzGetEventDamageType() == DAMAGE_TYPE_UNIVERSAL
local boolean isCleave = BlzGetEventDamageType() == DAMAGE_TYPE_ENHANCED
//----------------------------------------------
if isAttack then
call TriggerEvaluate(Attack)
elseif isSpell then
call TriggerEvaluate(Spell)
elseif isCleave then
call TriggerEvaluate(Cleave)
elseif isPure then
call TriggerEvaluate(Pure)
endif
endmethod
static method RegisterAttackDamage takes boolexpr cond returns nothing
call TriggerAddCondition(Attack, cond)
endmethod
static method RegisterSpellDamage takes boolexpr cond returns nothing
call TriggerAddCondition(Spell, cond)
endmethod
static method RegisterPureDamage takes boolexpr cond returns nothing
call TriggerAddCondition(Pure, cond)
endmethod
static method RegisterCleaveDamage takes boolexpr cond returns nothing
call TriggerAddCondition(Cleave, cond)
endmethod
static method onInit takes nothing returns nothing
call TriggerRegisterAnyUnitEventBJ(Damage, EVENT_PLAYER_UNIT_DAMAGED)
call TriggerAddCondition(Damage, Condition(function thistype.OnDamage))
endmethod
endstruct
/* -------------------------------------------------------------------------- */
/* Public JASS API */
/* -------------------------------------------------------------------------- */
function RegisterAttackDamageEvent takes boolexpr cond returns nothing
call DamageEvent.RegisterAttackDamage(cond)
endfunction
function RegisterSpellDamageEvent takes boolexpr cond returns nothing
call DamageEvent.RegisterSpellDamage(cond)
endfunction
function RegisterPureDamageEvent takes boolexpr cond returns nothing
call DamageEvent.RegisterPureDamage(cond)
endfunction
function RegisterCleaveDamageEvent takes boolexpr cond returns nothing
call DamageEvent.RegisterCleaveDamage(cond)
endfunction
endlibrary
Damage:
JASS:
library Damage
/* --------------------- Damage v1.0 by Chopinski --------------------- */
//
// Allows GUI users to take full advantage of the GUI damage functions
// that are present in the editor but cannot be used because there is no
// Generic Unit Event - A Unit Takes Damage.
//
// How To Import?
// Just copy the Damage folder over to your map.
//
// How To Use?
// In the event block of a trigger just add a real variable event
// for the variable Damage that was created when the map was ported.
// the value it is equal to is whatever, but people usualy uses 1.0,
// but the only thing important is that is is registered to the Damage
// variable.
//
// Once you did that you can start using the functions that exists in the
// GUI list, like:
//
// Event Response - Damage Source
// Event Response - Damage Target
// Event Response - Damage Taken
// Event Response - Set Damage of Unit Damaged Event
// etc....
//
// You can also utilize the 4 boolean variables IsAttackDamage, IsSpellDamage
// IsCleaveDamage and IsPureDamage to quickly create a trigger that will only
// when its a dmage provinient from an auto attack, or spell type damage etc...
//
// WARNING*: Do not use Waits() inside Damage triggers.
//--------------------------------------------------------------------------------
private struct Damage
readonly static trigger Damage = CreateTrigger()
//Dynamic Indexing
static integer didx = -1
static thistype array data
trigger t
static method OnDamage takes nothing returns nothing
local integer i = 0
//----------------------------------------------
local damagetype dmg_type = BlzGetEventDamageType()
//----------------------------------------------
local attacktype atk_type = BlzGetEventAttackType()
//----------------------------------------------
local boolean isAttack = BlzGetEventIsAttack()
//----------------------------------------------
local thistype this
//----------------------------------------------
if dmg_type != DAMAGE_TYPE_UNKNOWN then
loop
exitwhen i > didx
set this = data[i]
if IsTriggerEnabled(this.t) then
set udg_IsAttackDamage = isAttack
set udg_IsSpellDamage = atk_type == ATTACK_TYPE_NORMAL
set udg_IsCleaveDamage = dmg_type == DAMAGE_TYPE_ENHANCED
set udg_IsPureDamage = dmg_type == DAMAGE_TYPE_UNIVERSAL
if TriggerEvaluate(this.t) then
call TriggerExecute(this.t)
endif
endif
set i = i + 1
endloop
endif
endmethod
static method RegisterTriggers takes trigger t returns nothing
local thistype this = thistype.allocate()
set this.t = t
set didx = didx + 1
set data[didx] = this
endmethod
static method onInit takes nothing returns nothing
call TriggerRegisterAnyUnitEventBJ(Damage, EVENT_PLAYER_UNIT_DAMAGED)
call TriggerAddCondition(Damage, Filter(function thistype.OnDamage))
endmethod
endstruct
private function RegisterGUITriggers takes trigger t, string var, limitop op, real value returns nothing
if var == "udg_Damage" then
call Damage.RegisterTriggers(t)
endif
endfunction
hook TriggerRegisterVariableEvent RegisterGUITriggers
endlibrary
-
Dagger
-
Events
-
Game - Damage becomes Equal to 1.00
-
-
Conditions
-
IsSpellDamage Equal to True
-
((Damage source) has an item of type Kelen's Dagger of Escape) Equal to True
-
-
Actions
-
Event Response - Set Damage of Unit Damaged Event to ((Damage taken) + 100.00)
-
-
Again, i know that there is a lot of DDS already and that this 2 are nowhere near been complete damage systems with tons of tools like Damage Engine, but i hope they help someone.