- Joined
- Aug 1, 2013
- Messages
- 4,658
Hi all.
This might sound weird but yes I want beta testers for my new Damage Detection System.
I am very new to WC3 triggering and JASS. (I started about august 2014.)
And I don't really know what should work wrong and what not.
I am very good at logics and I am learning game development but next to that I am a total noob.
So I made this DDS... No it is not a normal DDS.
This one was designed to change a unit's attack-type and even damage-type for basic attacks and change them for spells.
It is also designed to know how much damage the attacker wanted to deal to the targeted unit.
But as I said I am a very noob, I cannot test it and this is something that has to be finished.
I see a lot of people asking how to change a unit's attack-type for example.
Or change the damage-type of spells.
Now I hope I didn't scare you off with that I am a very noob because (imo) this system is very good and there is a lot of explaination within it.
And the map is in the attachments.
Don't mind the Game Time System.
That is merely for testing.
I hope I said everything that I wanted to say.
Thanks in advantage.
EDIT: Woops... wanted to post it in Project Recruitment... can someone place it there?
This might sound weird but yes I want beta testers for my new Damage Detection System.
I am very new to WC3 triggering and JASS. (I started about august 2014.)
And I don't really know what should work wrong and what not.
I am very good at logics and I am learning game development but next to that I am a total noob.
So I made this DDS... No it is not a normal DDS.
This one was designed to change a unit's attack-type and even damage-type for basic attacks and change them for spells.
It is also designed to know how much damage the attacker wanted to deal to the targeted unit.
But as I said I am a very noob, I cannot test it and this is something that has to be finished.
I see a lot of people asking how to change a unit's attack-type for example.
Or change the damage-type of spells.
Now I hope I didn't scare you off with that I am a very noob because (imo) this system is very good and there is a lot of explaination within it.
-
DDS Initialize Global Variables
- Events
- Conditions
-
Actions
- -------- ------------------------------------------------------------------------------------------- --------
- -------- This must be the ability that has 2 spell damage reduction. --------
- Set DDS_Ability_Revert_Spell_Dmg = DDS_Ability_Revert_Spell_Dmg
- -------- ------------------------------------------------------------------------------------------- --------
- -------- --------------------------------------------------------------------------- --------
- -------- This must be the ability that gives infinite health. --------
- Set DDS_Ability_Cheat_Death = DDS_Ability_Cheat_Death
- -------- --------------------------------------------------------------------------- --------
- -------- --------------------------------------------------------------------------- --------
- -------- This will be the duration between each cleanup. --------
- Set DDS_Reset_Interval = 5.00
- -------- --------------------------------------------------------------------------- --------
- -------- ------------------------------------------------------------------------------------------------------------------ --------
- -------- Here you can change the effect type integers. --------
- -------- There is no real benefit of what numbers they are. --------
- -------- It is just for comfort and to easily see what damage effect types there are. --------
- -------- DO NOT SET ANY OF THESE TO 0!!! --------
- Set DDS_DET_Physical = 1
- Set DDS_DET_Spell = 2
- Set DDS_DET_Coded = 3
- -------- ------------------------------------------------------------------------------------------------------------------ --------
-
DDS Initialize Standard Attack Damage Types
- Events
- Conditions
-
Actions
- Set DDS_Unit_Type = Mortar Team
- Set DDS_New_Attack_Type = Siege
- Trigger - Run DDS_Trigger_Save_AT_DT (ignoring conditions)
- Set DDS_Unit_Type = Siege Engine
- Set DDS_New_Attack_Type = Siege
- Trigger - Run DDS_Trigger_Save_AT_DT (ignoring conditions)
- Set DDS_Unit_Type = Sorceress
- Set DDS_New_Attack_Type = Magic
- Trigger - Run DDS_Trigger_Save_AT_DT (ignoring conditions)
- Set DDS_Unit_Type = Priest
- Set DDS_New_Attack_Type = Magic
- Trigger - Run DDS_Trigger_Save_AT_DT (ignoring conditions)
- Set DDS_Unit_Type = Phoenix
- Set DDS_New_Attack_Type = Magic
- Trigger - Run DDS_Trigger_Save_AT_DT (ignoring conditions)
- Set DDS_Unit_Type = Siege Engine (Barrage)
- Set DDS_New_Attack_Type = Siege
- Trigger - Run DDS_Trigger_Save_AT_DT (ignoring conditions)
JASS:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Wietlol's Damage Detection System 1.4b 24/01/2015
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Description:
// This is a normal Damage Detection System that has the best features and most GUI friendly configuration.
// The idea to create this system is to change a unit's attack-type or damage-type
// and know how much damage a unit actually wanted to deal.
// All standard functions of a decent DDS are included together with the special features designed by Wietlol.
// To make use of this system, you are required to follow some rules. Every rule has his reasons why it exists.
// Most rules are made because some features rely on that some things are just how they should be.
// There is no ability or effect that is not supported or is no workaround for.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// How to install:
// 1. Copy or create all variables that are used in this map into your map.
// 2. Copy all triggers from the Damage Detection System (DDS) category and paste it into your map.
// 3. Create or copy the 2 custom abilities that are used in this map.
// The Ability Cheat Death has a value that exceeds the standard maximum.
// To increase the max life above the standard maximum open the field by pressing shift + enter.
// Then set the value to 1.000.000
// 4. Set the abilities to their global variables in the Initialize Global Variable trigger.
// 5. Enjoy your Damage Detection System.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Feature list:
// This system:
// - allows you to change a unit-type's attack-type and damage-type of basic attacks through triggers. (In general.)
// - allows you to change the attack-type and damage-type of spells on certain conditions. (On the OnDamage event.)
// - allows you to change the attack-type and damage-type of unit's basic attacks on certain conditions. (On the OnDamage event.)
// - allows you to create the following events:
// - A unit takes physical damage -> Game - DDS_Event_Unit_Takes_Damage becomes Equal to 1 (By default*)
// - A unit takes spell damage -> Game - DDS_Event_Unit_Takes_Damage becomes Equal to 2 (By default*)
// - A unit takes coded damage -> Game - DDS_Event_Unit_Takes_Damage becomes Equal to 3 (By default*)
// - A unit takes any damage -> Game - DDS_Event_Unit_Takes_Damage becomes Equal to 0
// - A unit has taken physical damage -> Game - DDS_Event_Unit_Took_Damage becomes Equal to 1 (By default*)
// - A unit has taken spell damage -> Game - DDS_Event_Unit_Took_Damage becomes Equal to 2 (By default*)
// - A unit has taken coded damage -> Game - DDS_Event_Unit_Took_Damage becomes Equal to 3 (By default*)
// - A unit has taken any damage -> Game - DDS_Event_Unit_Took_Damage becomes Equal to 0
// * The values can be changed for the comfort of the map maker.
// They can also be changed during gametime but that is dangerous and I don't know why you would do that.
// - allows you to know the amount of damage, the attacker wanted to deal.
// - allows you to modify that damage. (Only before damage.)
// - allows you to change the attacker or target of the damage. (Only before damage.)
// - allows you to know the amound of damage, the target has taken. (Only after damage.)
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Rules:
// To make the features and the calculations work, you must follow some rules to use this system properly.
// First of all, all units must have a default attack-type:
// - Heroes must have Hero as attack-type.
// - Melee units must have Normal as attack-type.
// - Ranged units must have Pierce as attack-type.
// You can modify the standard attack-type of units in the Initialize Standard Attack Damage Types.
// You can also change the unit's damage type there and you can also change a unit's attack-type and damage-type
// during gametime. These rules sounds fair.
// Next to that, you may not use standard abilities that have a random effect on a unit's attacks.
// These abilities must be triggered. Otherwise the calculations of original damage and actual damage dealt will fail.
// There are examples of how you can trigger the abilities that are not allowed.
// Remember only random effects are not allowed.
// If you have an ability with 100% change, then you can use it.
// You are also not allowed to use the standard spell damage reduction abilities. They won't work anyway.
// These must also be made via triggers and there is a trigger that shows how you can do it.
// Also triggered damage must be done via the DealDamage trigger.
// This is because triggered damage is different from normal damage.
// Therefor the system must know what you have used as damage modifiers to have a standard.
// It is not hard to change and you have a lot of examples. So everyone can do it.
// Last but not least. You are not allowed to play a map with this system without having fun.
// I have my reasons. - Wietlol
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Variable explaination:
//////////////////////////
// Map Initialization:
// - DDS_Ability_Cheat_Death - ability (integer in JASS)
// This variable refers to the ability "Ability Cheat Death"
// Ability id's can change between maps so this must be configurated on initialization.
//
// - DDS_Ability_Revert_Spell_Dmg - ability (integer in JASS)
// This variable refers to the ability "Ability Revery Spell Dmg"
// Ability id's can change between maps so this must be configurated on initialization.
//
// - DDS_Hashtable - hashtable
// This variable refers to the hashtable that is used to store data.
//
// - DDS_Reset_Interval - real
// This variable is set to a duration.
// It is the duration between each re-initialization.
// The lower, the more cleanups but don't set it too low.
// A 60 seconds cleanup is about the minimum.
// A 900 seconds cleanup is about the maximum.
//
// - DDS_Trigger_On_Damage - Trigger
// This is the trigger that runs the damage events.
// This variable is modified and used within the system.
// Don't change anything on it.
//
//////////////////////////
// Event Response:
// - DDS_Source - unit
// This unit refers to the unit that deals the damage.
// This variable can be changed on the before damage event.
//
// - DDS_Target - unit
// This unit refers to the unit that will take the damage.
// This variable can be changed on the before damage event.
//
// - DDS_Attack_Type - attack-type
// This is the attack type of the attack
// This variable can be changed on the before damage event.
//
// - DDS_Damage_Type - damage-type
// This is the damage type of the attack.
// This variable can be changed on the before damage event.
//
// - DDS_Weapon_Type - combat sound (aka weapon-type)
// This is the weapon type of the attack.
// It only creates a sound but that could be nice too.
// This variable can be changed on the before damage event.
//
// - DDS_Requested_Damage - real
// This is the amount of damage that a unit wants to deal.
// This variable can be changed on the before damage event.
//
// - DDS_Dealt_Damage - real
// This is the damage that a unit has taken.
// This variable can be read on the after damage event.
// Modifying anything on the after damage event has no effect.
//
// - DDS_Damage_Effect_Type - integer
// This is an integer that tells what damage effect type the attack is.
// If the attack is a basic attack then this is equal to DDS_DET_Physical
// If the attack is from a spell then this is equal to DDS_DET_Spell
// If the attack is coded then this is equal to DDS_DET_Coded
//
// - DDS_DET_Physical - integer
// This is the variable that refers to damage from basic attacks.
//
// - DDS_DET_Spell - integer
// This is the variable that refers to damage from spells.
//
// - DDS_DET_Coded - integer
// This is the variable that refers to coded damage.
//
//////////////////////////
// Events
// - DDS_Event_Unit_Takes_Damage - real
// This event is called before damage is dealt. It is also known as the onDamage event.
// When this variable becomes equal to DDS_DET_Physical, a unit is hit by a basic attack.
// When this variable becomes equal to DDS_DET_Spell, a unit is hit by a spell.
// When this variable becomes equal to DDS_DET_Coded, a unit is hit by a coded attack.
// When this variable becomes equal to 0, a unit is hit by any form of damage.
//
// - DDS_Event_Unit_Took_Damage - real
// This event is called after damage is dealt. It is also known as the after damage event.
// When this variable becomes equal to DDS_DET_Physical, a unit is hit by a basic attack.
// When this variable becomes equal to DDS_DET_Spell, a unit is hit by a spell.
// When this variable becomes equal to DDS_DET_Coded, a unit is hit by a coded attack.
// When this variable becomes equal to 0, a unit is hit by any form of damage.
//
//////////////////////////
// Orders
// - DDS_Trigger_Deal_Coded_Damage - Trigger (use TriggerExecute())
// This trigger runs coded damage. It must be called instead of "damage target" for example.
// It required the following variables to run:
// - DDS_New_Source - unit
// The source of the coded damage.
// - DDS_New_Target - unit
// The target of the coded damage.
// - DDS_New_Damage - real
// The damage the source wants to deal.
// - DDS_New_Attack_Type - attack-type
// The attack type that is used to deal the damage.
// - DDS_New_Damage_Type - damage-type
// The damage type that is used to deal the damage.
// (optional)
// - DDS_New_Weapon_Type - combat sound (aka weapon-type)
// The sound that is played when you deal the damage.
// This variable is optional.
//
// - DDS_Trigger_Save_AT_DT - Trigger (use TriggerExecute() or Run (Trigger) (ignoring conditions))
// This trigger saves a unit's attack type and/or damage type in the hashtable.
// It requires the following variables to run:
// - DDS_Unit_Type - unit-type (integer in JASS)
// The unit type on which the new attack-type or damage-type is saved.
// (optional)
// - DDS_New_Attack_Type - attack type
// The attack type that the unit will use with basic attacks from now.
// This variable is optional.
// (optional)
// - DDS_New_Damage_Type - damage type
// The damage type that the unit will use with basic attacks from now.
// This variable is optional.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Changelog:
// 1.4a - Upload on the Hive for concept display.
// - First release.
//
// 1.4b - Upload on the Hive for beta test.
// Documentation:
// - Added the complete documentation.
//
// Added Features:
// - Deal coded damage.
// - Change unit's standard attack-type and damage-type
//
// Bug Fixes:
// - Fixed a bug where new damage would occur before the timer on that unit expired. Resulting in infinite health for the unit.
// - Fixed a lot of leaks and stupid code.
//
// Upcoming release:
// - Be able to tell the difference between ranged and melee units properly.
// - Finish the spell reduction workaround. (Yes I said in the description that this already exist :D )
// - Make examples for ability workarounds. (Yes I said in the description that they already exist :D )
// - Adding all standard units in the Initialize Standard Attack Damage Types
// - Create new features.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Known bugs:
// - The check if a unit is melee bugs if a ranged unit will attack it,
// then transform to a melee unit and then attacks a unit before the missile hits its target.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// This code is handling the damage events and health resets.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function resets the unit's health to the proper value after the WC3 standard damage is taken.
function Trig_DDS_Remove_Standard_Damage takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit u = LoadUnitHandle(udg_DDS_Hashtable, id, 0)
local real health = LoadReal(udg_DDS_Hashtable, id, 1)
//Set unit's health back to normal.
call UnitRemoveAbility(u, udg_DDS_Ability_Cheat_Death)
call SetUnitState(u, UNIT_STATE_LIFE, health)
//Remove stuff
call DestroyTimer(t)
call FlushChildHashtable(udg_DDS_Hashtable, id)
call FlushChildHashtable(udg_DDS_Hashtable, GetHandleId(u))
set t = null
set u = null
endfunction
//This function is reverting the damage to what the attacker wanted to deal.
function Get_Original_Damage takes nothing returns nothing
local real originalHealth = GetUnitState(udg_DDS_Target, UNIT_STATE_LIFE)
local real health = originalHealth
local real totalFactor
call UnitRemoveAbility(udg_DDS_Target, udg_DDS_Ability_Revert_Spell_Dmg)
if health < 25 then
call SetUnitState(udg_DDS_Target, UNIT_STATE_LIFE, 25)
set health = GetUnitState(udg_DDS_Target, UNIT_STATE_LIFE)
endif
call UnitDamageTarget(udg_DDS_Target, udg_DDS_Target, 10, true, false, udg_DDS_Attack_Type, udg_DDS_Damage_Type, WEAPON_TYPE_WHOKNOWS)
set totalFactor = (health - GetUnitState(udg_DDS_Target, UNIT_STATE_LIFE)) / 10
call SetUnitState(udg_DDS_Target, UNIT_STATE_LIFE, originalHealth)
call UnitAddAbility(udg_DDS_Target, udg_DDS_Ability_Revert_Spell_Dmg)
set udg_DDS_Requested_Damage = udg_DDS_Requested_Damage / totalFactor
endfunction
//This function calculates the damages, calls the events and deals the actual damage.
function Trig_DDS_On_Damage takes unit source, unit target, real damage returns nothing
//Set some required variables
local boolean coded
local boolean timerNotExpired
local integer i
local integer id = GetUnitTypeId(source)
local real health
local timer t
local unit u
//These variables are used to restore onDamage events that made this damage event.
local unit oldSource
local unit oldTarget
local real oldRequestedDamage
local real oldDealtDamage
local integer oldDamageEffectType
local attacktype oldAttackType
local damagetype oldDamageType
local weapontype oldWeaponType
//Removing 0. damage attacks.
//Attacks that deal 0 damage are ussually buff placers.
//For abilities that have a 0 damage and triggered damage can be changed so they will use this system instead.
if damage == 0. then
return
endif
//If the timer of the last OnDamage event of this unit did not expire yet.
//Run the actions and make sure that there will be a new timer.
set t = LoadTimerHandle(udg_DDS_Hashtable, GetHandleId(target), 0)
if t != null then
set timerNotExpired = true
call UnitRemoveAbility(u, udg_DDS_Ability_Cheat_Death)
set health = LoadReal(udg_DDS_Hashtable, GetHandleId(t), 1)
call SetUnitState(u, UNIT_STATE_LIFE, health)
call DestroyTimer(t)
call FlushChildHashtable(udg_DDS_Hashtable, id)
call FlushChildHashtable(udg_DDS_Hashtable, GetHandleId(u))
endif
//Make sure that the old values are correctly set to the variables before changing any.
set oldSource = udg_DDS_Source
set oldTarget = udg_DDS_Target
set oldRequestedDamage = udg_DDS_Requested_Damage
set oldDealtDamage = udg_DDS_Dealt_Damage
set oldDamageEffectType = udg_DDS_Damage_Effect_Type
set oldAttackType = udg_DDS_Attack_Type
set oldDamageType = udg_DDS_Damage_Type
set oldWeaponType = udg_DDS_Weapon_Type
//Now we set the new values.
set udg_DDS_Source = source
set udg_DDS_Target = target
set udg_DDS_Requested_Damage = damage
//Determine what damage effect type the attack is.
if udg_DDS_Damage_Effect_Type == udg_DDS_DET_Coded then
set coded = true
set udg_DDS_Attack_Type = udg_DDS_New_Attack_Type
set udg_DDS_Damage_Type = udg_DDS_New_Damage_Type
set udg_DDS_Weapon_Type = udg_DDS_New_Weapon_Type
else
set coded = false
if damage < 0. then
//Spell attacks are always NORMAL (Spell) and MAGIC (Magic).
//Spell damage is reverted by the Spell Resistant ability and must be re-reverted to positive damage again.
set udg_DDS_Attack_Type = ATTACK_TYPE_NORMAL
set udg_DDS_Damage_Type = DAMAGE_TYPE_MAGIC
set udg_DDS_Damage_Effect_Type = udg_DDS_DET_Spell
set udg_DDS_Requested_Damage = udg_DDS_Requested_Damage * -1
else
//Normal attacks are basic attacks.
//According to the rules, Heroes deal HERO (Hero) damage,
//Melee units deal MELEE (Normal) damage and ranged units deal PIERCE (Pierce) damage.
if IsUnitType(udg_DDS_Source, UNIT_TYPE_HERO) then
set udg_DDS_Attack_Type = ATTACK_TYPE_HERO
else
if IsUnitType(udg_DDS_Source, UNIT_TYPE_RANGED_ATTACKER) then
set udg_DDS_Attack_Type = ATTACK_TYPE_PIERCE
else
set udg_DDS_Attack_Type = ATTACK_TYPE_MELEE
endif
endif
set udg_DDS_Damage_Type = DAMAGE_TYPE_NORMAL
set udg_DDS_Damage_Effect_Type = udg_DDS_DET_Physical
endif
//Non-coded damage is already reduced. With this function, the DDS_Requested_Damage will restore to the original damage.
//This trigger must be disabled of course. Enabling it again after the calculation does not need explaination does it?
call DisableTrigger(udg_DDS_Trigger_On_Damage)
call Get_Original_Damage()
call EnableTrigger(udg_DDS_Trigger_On_Damage)
set udg_DDS_Weapon_Type = WEAPON_TYPE_WHOKNOWS
endif
//Set the attack-type and damage-type to the attack and damage type that is specified in the hashtable.
//These are configurable by the DDS_Trigger_Save_AT_DT trigger.
set i = LoadInteger(udg_DDS_Hashtable, id, 0)
if i > 0 then
set udg_DDS_Attack_Type = ConvertAttackType(i - 1)
endif
set i = LoadInteger(udg_DDS_Hashtable, id, 1)
if i > 0 then
set udg_DDS_Damage_Type = ConvertDamageType(i - 1)
endif
//Fire the before damage events.
set udg_DDS_Event_Unit_Takes_Damage = udg_DDS_Damage_Effect_Type
set udg_DDS_Event_Unit_Takes_Damage = 0
//Deal the damage and calculate the difference for the Dealt Damage variable.
set health = GetUnitState(udg_DDS_Target, UNIT_STATE_LIFE)
if udg_DDS_Requested_Damage > 0 then
call DisableTrigger(udg_DDS_Trigger_On_Damage)
call UnitRemoveAbility(udg_DDS_Target, udg_DDS_Ability_Revert_Spell_Dmg)
call UnitDamageTarget(udg_DDS_Source, udg_DDS_Target, udg_DDS_Requested_Damage, true, false, udg_DDS_Attack_Type, udg_DDS_Damage_Type, udg_DDS_Weapon_Type)
call UnitAddAbility(udg_DDS_Target, udg_DDS_Ability_Revert_Spell_Dmg)
call EnableTrigger(udg_DDS_Trigger_On_Damage)
endif
set udg_DDS_Dealt_Damage = health - GetUnitState(udg_DDS_Target, UNIT_STATE_LIFE)
//Fire the after damage event.
set udg_DDS_Event_Unit_Took_Damage = 1
set udg_DDS_Event_Unit_Took_Damage = 0
//Create a 0 second timer.
//This timer calls a function that will remove the WC3 standard attacks.
//Coded damage has not ran a standard attack so then it will not create this action.
if not(coded) or timerNotExpired then
//Create the timer.
set t = CreateTimer()
call TimerStart(t, 0, false, function Trig_DDS_Remove_Standard_Damage)
//Save the variables.
set id = GetHandleId(t)
set health = GetUnitState(target, UNIT_STATE_LIFE)
//Save stuff to timer.
call SaveUnitHandle(udg_DDS_Hashtable, id, 0, target)
call SaveReal(udg_DDS_Hashtable, id, 1, health)
//Save the timer to the unit.
//If the unit is attacked before the timer expires, this will refer to the required data.
call SaveTimerHandle(udg_DDS_Hashtable, GetHandleId(target), 0, t)
//The unit may not die from that damage.
call UnitAddAbility(target, udg_DDS_Ability_Cheat_Death)
endif
//Reset the values to the original damage source.
set udg_DDS_Source = oldSource
set udg_DDS_Target = oldTarget
set udg_DDS_Requested_Damage = oldRequestedDamage
set udg_DDS_Dealt_Damage = oldDealtDamage
set udg_DDS_Damage_Effect_Type = oldDamageEffectType
set udg_DDS_Attack_Type = oldAttackType
set udg_DDS_Damage_Type = oldDamageType
set udg_DDS_Weapon_Type = oldWeaponType
//Fixing leaks... again.
set source = null
set target = null
set t = null
set u = null
set oldSource = null
set oldTarget = null
set oldAttackType = null
set oldDamageType = null
set oldWeaponType = null
endfunction
//The function via the "(unit) takes damage" events.
function Trig_DDS_Taking_Damage takes nothing returns boolean
call Trig_DDS_On_Damage(GetEventDamageSource(), GetTriggerUnit(), GetEventDamage())
return false
endfunction
function Trig_DDS_Deal_Coded_Damage takes nothing returns nothing
//Make sure that the events are properly executed.
set udg_DDS_Event_Unit_Takes_Damage = 0
set udg_DDS_Event_Unit_Took_Damage = 0
//Deal the damage.
call Trig_DDS_On_Damage(udg_DDS_New_Source, udg_DDS_New_Target, udg_DDS_New_Damage)
//Don't force people to set a combat sound for each coded damage event.
set udg_DDS_Weapon_Type = WEAPON_TYPE_WHOKNOWS
endfunction
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// This code creates the onDamage handler and add events to it.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function runs for every unit that enters the map.
function Trig_DDS_Add_Entering_Units takes nothing returns boolean
local unit u = GetEnteringUnit()
//Add the entering unit to the onDamage trigger.
call TriggerRegisterUnitEvent(udg_DDS_Trigger_On_Damage, u, EVENT_UNIT_DAMAGED)
call UnitAddAbility(u, udg_DDS_Ability_Revert_Spell_Dmg)
//Leak fixes.
set u = null
return false
endfunction
//This function adds all units on the map to the onDamage trigger.
function Trig_DDS_Add_Unit_From_Group takes nothing returns nothing
local unit u = GetEnumUnit()
//Add the picked unit to the onDamage trigger.
call TriggerRegisterUnitEvent(udg_DDS_Trigger_On_Damage, u, EVENT_UNIT_DAMAGED)
call UnitAddAbility(u, udg_DDS_Ability_Revert_Spell_Dmg)
set u = null
endfunction
//This function (re)creates the onDamage trigger.
function Trig_DDS_Init_Damage_System takes nothing returns boolean
local group g = CreateGroup()
//Create a clean trigger.
call DestroyTrigger(udg_DDS_Trigger_On_Damage)
set udg_DDS_Trigger_On_Damage = CreateTrigger()
//Add the events to the trigger.
call GroupEnumUnitsInRect(g, GetWorldBounds(), null)
call ForGroup(g,function Trig_DDS_Add_Unit_From_Group)
call DestroyGroup(g)
set g = null
//Add the action to the clean trigger.
call TriggerAddCondition(udg_DDS_Trigger_On_Damage, Filter(function Trig_DDS_Taking_Damage))
//Well it is still a condition ya know.
return false
endfunction
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// This part is for saving the attack-type and damage-type of basic attacks on a unit-type.
//
// In normal Warcraft, every unit-type can have its own attack-type.
// With this system you can change the attack-type via triggers and even change the damage-type of basic attacks too.
// What you have to do is set udg_DDS_Unit_Type to the unit that you want to give a different stat.
// Then set udg_DDS_New_Attack_Type to the attack-type that you want your unit to have.
// And set udg_DDS_New_Damage_Type to the damage-type that you want your unit to have.
// After that, you run udg_DDS_Trigger_Save_AT_DT "TriggerExecute()".
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function is saving a unit-type's basic attack-type and damage-type.
function Trig_DDS_Save_AT_DT_Actions takes nothing returns nothing
if udg_DDS_Unit_Type > 0 then
if udg_DDS_New_Attack_Type != null then
call SaveInteger(udg_DDS_Hashtable, udg_DDS_Unit_Type, 0, ConvertAttackTypeReverse(udg_DDS_New_Attack_Type) + 1)
set udg_DDS_New_Attack_Type = null
endif
if udg_DDS_New_Damage_Type != null then
call SaveInteger(udg_DDS_Hashtable, udg_DDS_Unit_Type, 1, ConvertDamageTypeReverse(udg_DDS_New_Damage_Type) + 1)
set udg_DDS_New_Damage_Type = null
endif
set udg_DDS_Unit_Type = 0
endif
endfunction
//This function is making the trigger that runs the Trig_DDS_Save_AT_DT_Actions function.
function Trig_DDS_Initialize_Save_AT_DT takes nothing returns nothing
set udg_DDS_Trigger_Save_AT_DT = CreateTrigger()
call TriggerAddAction(udg_DDS_Trigger_Save_AT_DT, function Trig_DDS_Save_AT_DT_Actions)
endfunction
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// This code is the initialization of the triggers.
//
// On map Initialization, the global variables are set in the gg_trg_DDS_Initialize_Global_Variables.
// Every variable that can change between maps is set there next to some user preferences.
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function runs the configuration and initializes the system.
function Trig_DDS_System_Initialize takes nothing returns boolean
local region rectRegion = CreateRegion()
local trigger t = CreateTrigger()
//Runs the configuration trigger. (gg_trg_DDS_Initialize_Global_Variables)
set udg_DDS_Hashtable = InitHashtable()
call TriggerExecute(gg_trg_DDS_Initialize_Global_Variables)
//Create the attack-type and damage-type saving trigger. Then run the standard attack-type configuration trigger.
call Trig_DDS_Initialize_Save_AT_DT()
call TriggerExecute(gg_trg_DDS_Initialize_Standard_Attack_Damage_Types)
//Initialize the Deal Coded Damage trigger.
//This trigger is runned to deal coded damage.
set udg_DDS_Trigger_Deal_Coded_Damage = CreateTrigger()
call TriggerAddAction(udg_DDS_Trigger_Deal_Coded_Damage, function Trig_DDS_Deal_Coded_Damage)
//Create the cleaning scedule and create the first system.
call TriggerRegisterTimerEvent(t, udg_DDS_Reset_Interval, false)
call TriggerAddCondition(t, Filter(function Trig_DDS_Init_Damage_System))
call Trig_DDS_Init_Damage_System()
//Create the handler for units that enter the entire map.
set t = CreateTrigger()
call RegionAddRect(rectRegion, GetWorldBounds())
call TriggerRegisterEnterRegion(t, rectRegion, null)
call RemoveRegion(rectRegion)
call TriggerAddCondition(t, Filter(function Trig_DDS_Add_Entering_Units))
//Some data leak fixes.
set rectRegion = null
set t = null
call DestroyTrigger(gg_trg_DDS_System)
return false
endfunction
//This is the initial function.
function InitTrig_DDS_System takes nothing returns nothing
set gg_trg_DDS_System = CreateTrigger()
call TriggerAddCondition(gg_trg_DDS_System, Filter(function Trig_DDS_System_Initialize))
endfunction
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// End of the gg_trg_DDS_System trigger.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Don't mind the Game Time System.
That is merely for testing.
I hope I said everything that I wanted to say.
Thanks in advantage.
EDIT: Woops... wanted to post it in Project Recruitment... can someone place it there?