Hero
─║╣ero─
- Reaction score
- 250
Injury System v.2.00
UPDATED v2.00
-Everything is ONE trigger now
-Nulled somethings that were not nulled
-Fixed some BJ's to natives
______________________________
UPDATED:v.1.02
Updates in v.1.02
-Dead Units do not spark
-Blood Hit trigger added in
-Optimized some of the code
-Added Poll Waits
-Made in [COMPLETE] JASS
________________________
UPDATED:v.1.01
Updates in v.1.01
-If a Unit If Mechanical the unit will spark and emit electricity
(thanks for that Aray (he's on wc3c dunno about here) comment)
________________________
Injury System V.2.00
A simple injury system that displays a bleeding effect on a unit once it reaches less than 30% health (can be edited)
Injury System v.2.00
__________________________________________
Code:
__________
Comments? Questions? Bugs? Suggestions? Leave Them All Here...I need them
UPDATED v2.00
-Everything is ONE trigger now
-Nulled somethings that were not nulled
-Fixed some BJ's to natives
______________________________
UPDATED:v.1.02
Updates in v.1.02
-Dead Units do not spark
-Blood Hit trigger added in
-Optimized some of the code
-Added Poll Waits
-Made in [COMPLETE] JASS
________________________
UPDATED:v.1.01
Updates in v.1.01
-If a Unit If Mechanical the unit will spark and emit electricity
(thanks for that Aray (he's on wc3c dunno about here) comment)
________________________
Injury System V.2.00
A simple injury system that displays a bleeding effect on a unit once it reaches less than 30% health (can be edited)
Injury System v.2.00
Code:
UPDATED v2.00
-Everything is ONE trigger now
-Nulled somethings that were not nulled
-Fixed some BJ's to natives
UPDATED v.1.02
-Dead Units do not spark
-Blood Hit trigger added in
-Optimized some of the code
-Added Poll Waits
-Made in JASS
UPDATED: v.1.01
-If a Unit If Mechanical the unit will spark and emit electricity
---------Requirements----------
V.1.02
******To Implement This Into Your Map The Easy Way Just Copy The Whole Injury System Folder and Paste It Into Your Triggers*****
--Required Triggers:--
-Injury System
------Required Script in Custom Header------
function IS_Human_Blood takes nothing returns string
local integer a=GetRandomInt(1,4)
if a==1 then
return "Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl"
elseif a==2 then
return "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodRifleman.mdl"
elseif a==3 then
return "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodSorceress.mdl"
elseif a==4 then
return "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodKnight.mdl"
else
return ""
endif
endfunction
function IS_Orc_Blood takes nothing returns string
local integer a=GetRandomInt(1,4)
if a==1 then
return "Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodGrunt.mdl"
elseif a==2 then
return "Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodHeadhunter.mdl"
elseif a==3 then
return "Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodHeroFarSeer.mdl"
elseif a==4 then
return "Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodWitchDoctor.mdl"
else
return ""
endif
endfunction
function IS_Undead_Blood takes nothing returns string
local integer a=GetRandomInt(1,4)
if a==1 then
return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodAbomination.mdl"
elseif a==2 then
return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodAcolyte.mdl"
elseif a==3 then
return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodGhoul.mdl"
elseif a==4 then
return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodGargoyle.mdl"
else
return ""
endif
endfunction
function IS_NightElf_Blood takes nothing returns string
local integer a=GetRandomInt(1,4)
if a==1 then
return "Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodArcher.mdl"
elseif a==2 then
return "Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodDruidBear.mdl"
elseif a==3 then
return "Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodDruidoftheClaw.mdl"
elseif a==4 then
return "Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodHuntress.mdl"
else
return ""
endif
endfunction
//##############################
//*****************************************************************************************************
//##Begining of CS Gamecache engine##
function CS_H2I takes handle h returns integer
return h
return 0
endfunction
//=================================================================================================
// Main Gamecache handler
//
function CSCache takes nothing returns gamecache
if udg_cscache==null then
call FlushGameCache(InitGameCache("CasterSystem.vx"))
set udg_cscache=InitGameCache("CasterSystem.vx")
call StoreInteger(udg_cscache,"misc","TableMaxReleasedIndex",100)
endif
return udg_cscache
endfunction
function GetAttachmentTable takes handle h returns string
return I2S(CS_H2I(h))
endfunction
//============================================================================================================
function ClearTable takes string table returns nothing
call FlushStoredMission(CSCache(),table)
endfunction
//============================================================================================================
function SetTableInt takes string table, string field, integer val returns nothing
if (val==0) then
call FlushStoredInteger(CSCache(),table,field)
else
call StoreInteger(CSCache(),table,field,val)
endif
endfunction
function GetTableInt takes string table, string field returns integer
return GetStoredInteger(CSCache(),table,field)
endfunction
//============================================================================================================
function SetTableReal takes string table, string field, real val returns nothing
if (val==0) then
call FlushStoredReal(CSCache(),table,field)
else
call StoreReal(CSCache(),table,field,val)
endif
endfunction
function GetTableReal takes string table, string field returns real
return GetStoredReal(CSCache(),table,field)
endfunction
//============================================================================================================
function SetTableBoolean takes string table, string field, boolean val returns nothing
if (not(val)) then
call FlushStoredBoolean(CSCache(),table,field)
else
call StoreBoolean(CSCache(),table,field,val)
endif
endfunction
function GetTableBoolean takes string table, string field returns boolean
return GetStoredBoolean(CSCache(),table,field)
endfunction
//============================================================================================================
function SetTableString takes string table, string field, string val returns nothing
if (val=="") or (val==null) then
call FlushStoredString(CSCache(),table,field)
else
call StoreString(CSCache(),table,field,val)
endif
endfunction
function GetTableString takes string table, string field returns string
return GetStoredString(CSCache(),table,field)
endfunction
function SetTableObject takes string table, string field, handle val returns nothing
local gamecache g=CSCache()
if (val==null) then
call FlushStoredInteger(g,table,field)
else
call StoreInteger(g,table,field,CS_H2I(val))
endif
set g=null
endfunction
function GetTableObject takes string table, string field returns handle
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableWidget takes string table, string field returns widget
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableRect takes string table, string field returns rect
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableRegion takes string table, string field returns region
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTimerDialog takes string table, string field returns timerdialog
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableUnit takes string table, string field returns unit
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableItem takes string table, string field returns item
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableEffect takes string table, string field returns effect
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableDestructable takes string table, string field returns destructable
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTrigger takes string table, string field returns trigger
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTimer takes string table, string field returns timer
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableGroup takes string table, string field returns group
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTriggerAction takes string table, string field returns triggeraction
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableLightning takes string table, string field returns lightning
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableImage takes string table, string field returns image
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableUbersplat takes string table, string field returns ubersplat
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableSound takes string table, string field returns sound
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableWeathereffect takes string table, string field returns weathereffect
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableLocation takes string table, string field returns location
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
//##End of CS Gamecache engine##
//##############################
//**Damage Detection System**\\
constant function DamDetect_Abil takes nothing returns integer
return 'A000' //This is the orb ability that ALL units will be given when the system is
endfunction //initialized and when new units arrive into the game
constant function DamDetect_Buff takes nothing returns integer
return 'B000' //This is the buff the orb ability (DamDetect_Abil) will give to damaged units
endfunction
//**********Main function to runs the triggers that need to be ran for each damage type
function DamDetect_Damaged takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i
local integer j = 1
local string funcName
if GetTableInt(GetAttachmentTable(u),"DamDetect_Dummy")==0 then
if GetUnitAbilityLevel(u, DamDetect_Buff()) > 0 then
call UnitRemoveAbility(u, DamDetect_Buff())
call SetTableString("[GenericDamage_State]","DamageType", "ATTACK")
set i = GetTableInt("[DamDetect_Table]", "FuncCountAttack")
loop
exitwhen j > i
set funcName=GetTableString("[DamDetect_Table]", "AttackFunc_" + I2S(j))
call ExecuteFunc(funcName)
set j = j + 1
endloop
else
call SetTableString("[GenericDamage_State]","DamageType", "SPELL")
set i = GetTableInt("[DamDetect_Table]", "FuncCountSpell")
loop
exitwhen j > i
set funcName = GetTableString("[DamDetect_Table]", "SpellFunc_" + I2S(j))
call ExecuteFunc(funcName)
set j = j + 1
endloop
endif
endif
set u = null
endfunction
//Returns the damage cause, incase you need to know
function GetDamageEventCause takes nothing returns string
return GetTableString("[DamDetect_State]","DamageType")
endfunction
//Use this to ignore the damage done by the unit, avoids infinite loops in some cases
function DamDetect_Dummy takes unit u, string whichState returns nothing
if whichState=="Ignore" then
call SetTableInt(GetAttachmentTable(u),"DamDetect_Dummy",1)
elseif whichState=="Allow" then
call SetTableInt(GetAttachmentTable(u),"DamDetect_Dummy",0)
endif
endfunction
//**********Sets up the triggers to run when a unit takes damage, call either of these in the triggers init trigger
//for it to run when a unit takes damage
function DamDetect_Attacks takes string funcName returns nothing
//used for attack damage
local integer i = GetTableInt("[DamDetect_Table]", "FuncCountAttack") + 1
call SetTableString("[DamDetect_Table]", "AttackFunc_" + I2S(i), funcName)
call SetTableInt("[DamDetect_Table]", "FuncCountAttack", i)
endfunction
function DamDetect_Spells takes string funcName returns nothing
//used for spell damage
local integer i = GetTableInt("[DamDetect_Table]", "FuncCountSpell") + 1
call SetTableString("[DamDetect_Table]", "SpellFunc_" + I2S(i), funcName)
call SetTableInt("[DamDetect_Table]", "FuncCountSpell", i)
endfunction
//**********Base functions for the system
//Add damage triggers for units who enter map
function DamDetect_AddTriggers takes nothing returns nothing
local unit u = GetTriggerUnit()
local trigger dam_trig = CreateTrigger()
local string s = GetAttachmentTable(dam_trig)
call UnitAddAbility(u, DamDetect_Abil())
call TriggerRegisterUnitEvent(dam_trig, u,EVENT_UNIT_DAMAGED)
call SetTableObject(s,"dam_trig_ta",TriggerAddAction(dam_trig,function DamDetect_Damaged))
call SetTableObject("DamDetect_"+GetAttachmentTable(u),"dam_trig",dam_trig)
set dam_trig = null
set u = null
endfunction
//Remove triggers from units who die
function DamDetect_RemoveTriggers takes nothing returns nothing
local unit u = GetTriggerUnit()
local string s = GetAttachmentTable(u)
local trigger trig = GetTableTrigger("DamDetect_"+s,"dam_trig")
local string strig = GetAttachmentTable(trig)
call TriggerRemoveAction(trig,GetTableTriggerAction(strig,"dam_trig_ta"))
call ClearTable(strig)
call DestroyTrigger(trig)
call ClearTable("DamDetect_"+s)
set u = null
set trig = null
endfunction
//Call this on map init to start the system, basically just sets up the system for all units preplaced that may be used,
//for units the ever enter the map, and removes triggers when units die
function DamDetect_Init takes nothing returns nothing
local trigger entmap_trig = CreateTrigger()
local trigger dam_trig
local string s
local trigger death_trig = CreateTrigger()
local group g = CreateGroup()
local unit u
call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,null)
loop
set u = FirstOfGroup(g)
exitwhen u==null
set dam_trig = CreateTrigger()
set s = GetAttachmentTable(dam_trig)
call UnitAddAbility(u, DamDetect_Abil())
call TriggerRegisterUnitEvent(dam_trig,u,EVENT_UNIT_DAMAGED)
call SetTableObject(s,"dam_trig_ta",TriggerAddAction(dam_trig,function DamDetect_Damaged))
call SetTableObject("DamDetect_"+GetAttachmentTable(u),"dam_trig",dam_trig)
call GroupRemoveUnit(g,u)
endloop
call TriggerRegisterEnterRectSimple(entmap_trig, bj_mapInitialPlayableArea)
call TriggerAddAction(entmap_trig,function DamDetect_AddTriggers)
call TriggerRegisterAnyUnitEventBJ(death_trig,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction(death_trig,function DamDetect_RemoveTriggers)
set entmap_trig = null
set dam_trig = null
set death_trig = null
call DestroyGroup(g)
set g = null
endfunction
//=============================================================================
-Read Implementation Comment
______________________________________________
--Variables Used:--
Name: Type: Array: Size:
BleedingGroup Unit Group No --
cscache Game Cache No --
______________________________________________
--Features:--
-Easily Editable by changing some strings for the blood and some small triggers
-Covers the 4 main races
-Should not lag if so preload all the effect strings
-Should not contain leaks
-Shows the blood on a 2 second
-Shows blood type for that specific race (Ex. Orcs will bleed orc blood not human)
-Shows different types of blood effects 4 for each race
-If a Unit If Mechanical the unit will spark and emit electricity
-Easily Editable for different races
-NOW features blood on dmg script...which creates blood depending on the race everytime a unit is damaged
-1 Trigger
-ALL JASS
Credits
-Hero12341234 for the System
-Emjlr3 for the DamDetect_Attacks System
-Vexorian for the CS_Cache
Code:
Code:
function IS_Human_Blood takes nothing returns string
local integer a=GetRandomInt(1,4)
if a==1 then
return "Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl"
elseif a==2 then
return "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodRifleman.mdl"
elseif a==3 then
return "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodSorceress.mdl"
elseif a==4 then
return "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodKnight.mdl"
else
return ""
endif
endfunction
function IS_Orc_Blood takes nothing returns string
local integer a=GetRandomInt(1,4)
if a==1 then
return "Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodGrunt.mdl"
elseif a==2 then
return "Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodHeadhunter.mdl"
elseif a==3 then
return "Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodHeroFarSeer.mdl"
elseif a==4 then
return "Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodWitchDoctor.mdl"
else
return ""
endif
endfunction
function IS_Undead_Blood takes nothing returns string
local integer a=GetRandomInt(1,4)
if a==1 then
return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodAbomination.mdl"
elseif a==2 then
return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodAcolyte.mdl"
elseif a==3 then
return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodGhoul.mdl"
elseif a==4 then
return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodGargoyle.mdl"
else
return ""
endif
endfunction
function IS_NightElf_Blood takes nothing returns string
local integer a=GetRandomInt(1,4)
if a==1 then
return "Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodArcher.mdl"
elseif a==2 then
return "Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodDruidBear.mdl"
elseif a==3 then
return "Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodDruidoftheClaw.mdl"
elseif a==4 then
return "Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodHuntress.mdl"
else
return ""
endif
endfunction
Code:
function Remove_Unit_When_Healed takes nothing returns nothing
local unit a=GetEnumUnit()
if GetUnitLifePercent(a) >= 30.00 or IsUnitDeadBJ(a) == true then
call GroupRemoveUnitSimple( a, udg_BleedingGroup )
endif
set a=null
endfunction
function Trig_Remove_Unit_If_Healed_JASS_Actions takes nothing returns nothing
call ForGroup( udg_BleedingGroup, function Remove_Unit_When_Healed)
endfunction
function Trig_Show_Blood_Effect_JASS takes nothing returns nothing
local effect h
local effect b
local unit a=GetEnumUnit()
if IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == false and GetUnitRace(a) == RACE_HUMAN and IsUnitAliveBJ(a) == true then
set h=AddSpecialEffectTargetUnitBJ( "origin", a, IS_Human_Blood() )
call PolledWait( 2 )
call DestroyEffect (h)
elseif IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == false and GetUnitRace(a) == RACE_ORC and IsUnitAliveBJ(a) == true then
set h=AddSpecialEffectTargetUnitBJ( "origin", a, IS_Orc_Blood() )
call PolledWait( 2 )
call DestroyEffect (h)
elseif IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == false and GetUnitRace(a) == RACE_UNDEAD and IsUnitAliveBJ(a) == true then
set h=AddSpecialEffectTargetUnitBJ( "origin", a, IS_Undead_Blood() )
call PolledWait( 2 )
call DestroyEffect (h)
elseif IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == false and GetUnitRace(a) == RACE_NIGHTELF and IsUnitAliveBJ(a) == true then
set h=AddSpecialEffectTargetUnitBJ( "origin", a, IS_NightElf_Blood() )
call PolledWait( 2 )
call DestroyEffect (h)
elseif IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == true and IsUnitAliveBJ(a) == true then
set h=AddSpecialEffectTargetUnitBJ( "origin", a, "Abilities\\Spells\\Orc\\LightningBolt\\LightningBoltMissile.mdl" )
set b=AddSpecialEffectTargetUnitBJ( "chest", a, "Abilities\\Weapons\\FlyingMachine\\FlyingMachineImpact.mdl" )
call DestroyEffect (h)
call PolledWait( 2 )
call DestroyEffect (b)
endif
endfunction
function Trig_Show_Blood_Effect_JASS_Actions takes nothing returns nothing
call ForGroup( udg_BleedingGroup, function Trig_Show_Blood_Effect_JASS )
endfunction
function Add_Unit_Hurt takes nothing returns nothing
local unit a=GetEnumUnit()
if IsUnitType(a, UNIT_TYPE_STRUCTURE) == false and GetUnitLifePercent(a) <= 30.00 and IsUnitInGroup(a, udg_BleedingGroup) == false then
call GroupAddUnit(udg_BleedingGroup,GetEnumUnit() )
endif
set a=null
endfunction
function Trig_Pick_Every_Unit_Hurt_JASS_Actions takes nothing returns nothing
set bj_wantDestroyGroup=true
call ForGroup( GetUnitsInRectAll(GetPlayableMapRect()), function Add_Unit_Hurt )
endfunction
function Trig_Melee_Initialization_Actions takes nothing returns nothing
call DamDetect_Init()
endfunction
function Blood_On_Dmg takes nothing returns nothing
local effect h
local unit a=GetTriggerUnit()
if IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == false and GetUnitRace(a) == RACE_HUMAN then
set h=AddSpecialEffectTargetUnitBJ( "origin", a, IS_Human_Blood() )
call PolledWait( 2 )
elseif IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == false and GetUnitRace(a) == RACE_ORC then
set h=AddSpecialEffectTargetUnitBJ( "origin", a, IS_Orc_Blood())
call PolledWait( 2 )
elseif IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == false and GetUnitRace(a) == RACE_UNDEAD then
set h=AddSpecialEffectTargetUnitBJ( "origin", a, IS_Undead_Blood() )
call PolledWait( 2 )
elseif IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == false and GetUnitRace(a) == RACE_NIGHTELF then
set h=AddSpecialEffectTargetUnitBJ( "origin", a, IS_NightElf_Blood() )
call PolledWait( 2 )
endif
call DestroyEffect (h)
set a=null
set h=null
endfunction
function InitTrig_Blood_On_Dmg takes nothing returns nothing
call DamDetect_Attacks("Blood_On_Dmg")
endfunction
//===========================================================================
function InitTrig_Injury_System takes nothing returns nothing
local trigger a=CreateTrigger()
local trigger b=CreateTrigger()
local trigger c=CreateTrigger()
set gg_trg_Injury_System = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( a, 0.05 )
call TriggerAddAction( a, function Trig_Pick_Every_Unit_Hurt_JASS_Actions )
call TriggerRegisterTimerEventPeriodic( b, 2 )
call TriggerAddAction( b, function Trig_Show_Blood_Effect_JASS_Actions )
call TriggerRegisterTimerEventPeriodic( c, 1.00 )
call TriggerAddAction( c, function Trig_Remove_Unit_If_Healed_JASS_Actions )
call InitTrig_Blood_On_Dmg()
call TriggerAddAction( gg_trg_Injury_System, function Trig_Melee_Initialization_Actions )
endfunction
Comments? Questions? Bugs? Suggestions? Leave Them All Here...I need them