System Injury System

Hero

─║╣ero─
Reaction score
250
Injury System

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
-If a Unit If Mechanical the unit will spark and emit electricity
(thanks for that comment)

Injury System V.1.02

A simple injury system that displays a bleeding effect on a unit once it reaches less than 30% health (can be edited)

Code:
UPDATED:
-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:--

-Preload Trigger
-Pick Every Unit Trigger
-Show Blood Effect Trigger
-Remove Unit If Healed Trigger
-Blood on Dmg Trigger

------Required Script in Custom Header------
-Read Implementation Comment
______________________________________________
--Variables Used:--

Name:                                Type:            Array:            Size:
Human_BleedEffect             String               Yes                 4
Orc_BleedEffect                 String               Yes                 4
Undead_BleedEffect            String               Yes                 4
NightElves_BleedEffect        String               Yes                 4
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
______________________________________________
Ideal For:
Any-map
______________________________________________
Updates In Next Version:
-A Jass Script for this system (ex. call Injury_System (blah blah) )
-Make the whole system 1 Trigger

Credits 
              -Hero12341234 for the System
             -Emjlr3 for the DamDetect_Attacks System
             -Vexorian for the CS_Cache

Found Here: View attachment Injury System v1.02.w3x

Please Give Credits If You Use
 
T

Tyre.

Guest
This system 2 me is one of the best systems out. only problem im having with it is i cant get it 2 work when The caster system is on the same map
 

Hero

─║╣ero─
Reaction score
250
This system 2 me is one of the best systems out. only problem im having with it is i cant get it 2 work when The caster system is on the same map

Thanks for the feedback.

__________

I have no idea why that would happen.

Did you import everything correctly?
I have it implemented on my maps using the caster system.

The problem could be that the cs cache i have is probably old :p

If it is please tell me.
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
it's an excellent system that highly increases the fun factor of wc3 custom games. A+
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Why was this in the System section? I don't think it's been approved.... Though, it was before the forum rearragement. No matter.

It's been a while since it had an update. Why don't you post some of the actual code in the post?
 

RedSword

New Member
Reaction score
4
Whoaaa that's nice, more the unit is wounded, more it bleeds =D (bleed doesn't make lose hp though) nice system.
 
T

Tyre.

Guest
Thanks for the feedback.

__________

I have no idea why that would happen.

Did you import everything correctly?
I have it implemented on my maps using the caster system.

The problem could be that the cs cache i have is probably old :p

If it is please tell me.



I really dont no but I think you mite be right cuz it has somthing to do with cs cach.. it is problly wrong cuz i did somthing wrong tho but when i activate CSCAHE on caster system the injury system stops. this is what it says when i turn on CSCahe on caster system
 

Attachments

  • test.JPG
    test.JPG
    161.4 KB · Views: 304

Hatebreeder

So many apples
Reaction score
381
No just one of the CS_H2I functions

This System is really nice. Only thing what i didn't like too much is the massive blood spilling after each attack. IMO, it's enough if you make the Units bleed at 50%, then as the % value decends, let them Bleed a bit more, and slow their movement speed.
Anyways, +Rep from me ^^
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
new version, nice nice.

here's what you could do for improvement, especially in terms of performance:

*instead of using 4 different barely used string arrays, go for 1 single array:
fields 0-3 humans, 4-7 orc, 8-11 undead, etc.

*instead of adding and removing units to and from the bleeding group, simply have the bleeding group updated at your interval

*get rid of all the BJ function calls wherever they can be replaced with natives

*move away from gc based systems. I recently experienced a slight lag every 4 sec due to the damage system playing on my map with an extensive amount of units. Since I rewrote the ondamage functions to use a simple local trigger, I have not experienced this again.

*as a little extra - that's one of the changes I made - you could further have the blood effect shown longer when units are severly injured, and shorter when units are "normally" injured; just a suggestion.
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
OK, here's my suggestion for the injury system. It's already adopted to the needs of my map: 6 races including naga and the naga research "acid blood", no sparks on mechanical units as they're only catapults, and no effects on skeletons and mountain giants. The player race is already set in an integer player_stat to accomodate the extra races. The blood effects can be switched on and off.

JASS:
library InjurySystem initializer InjuriInit

	globals 
		group bleeding_group = CreateGroup()
		boolean blood_switch = true
                string array blood_model
	endglobals

function InjuriInit takes nothing returns nothing
    //human blood
    set blood_model[0]="Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl"
    set blood_model[1]="Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodRifleman.mdl"
    set blood_model[2]="Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodSorceress.mdl"
    set blood_model[3]="Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodKnight.mdl"
    //orc blood
    set blood_model[4]="Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodGrunt.mdl"
    set blood_model[5]="Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodHeadhunter.mdl"
    set blood_model[6]="Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodHeroFarSeer.mdl"
    set blood_model[7]="Objects\\Spawnmodels\\Orc\\Orcblood\\OrcBloodWitchDoctor.mdl"
    //undead blood
    set blood_model[8]="Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodAbomination.mdl"
    set blood_model[9]="Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodAcolyte.mdl"
    set blood_model[10]="Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodGhoul.mdl"
    set blood_model[11]="Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodGargoyle.mdl"
    //nightelf blood
    set blood_model[12]="Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodArcher.mdl"
    set blood_model[13]="Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodDruidBear.mdl"
    set blood_model[14]="Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodDruidoftheClaw.mdl"
    set blood_model[15]="Objects\\Spawnmodels\\NightElf\\NightElfBlood\\NightElfBloodHuntress.mdl"
    //16+17 acid blood; 18: naga blood
    set blood_model[16]="Objects\\Spawnmodels\\Demon\\DemonBlood\\DemonBloodPitlord.mdl"
    set blood_model[17]="Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodCryptFiend.mdl"
    set blood_model[18]="Objects\\Spawnmodels\\Naga\\NagaBlood\\NagaBloodWindserpent.mdl"
endfunction

function Blood_On_Unit takes unit a, real r returns nothing  
  local integer j=player_stat[GetPlayerId(GetOwningPlayer(a))] //player race
  local integer k=-1
  local integer l=-1
  if (GetWidgetLife(a)>0.4) and not IsUnitIllusion(a) and not IsUnitType(a, UNIT_TYPE_MECHANICAL) then
    if  (j==0) then  //race human
        set k=0
        set l=3
    elseif  (j==1) or (j==5) then  //race orc or outlaws
        set k=4
        set l=7
    elseif (j==2) and (GetUnitTypeId(a)=='uC19' or GetUnitTypeId(a)=='u007' or IsUnitType(a, UNIT_TYPE_HERO)) then  //race undead
        set k=8
        set l=11
    elseif (j==3) and not IsUnitType(a, UNIT_TYPE_GIANT) then  //race nightelf
        set k=12
        set l=15
    elseif (j==4) and (GetUnitAbilityLevel(a,'A023')<=1) then  //race naga normal
        set k=18
        set l=18
    elseif (j==4) and (GetUnitAbilityLevel(a,'A023')>1) then  //race naga acid
        set k=16
        set l=17
    endif
   endif
   if (k>=0) then
      call DestroyEffectTimed(AddSpecialEffectTarget(blood_model[GetRandomInt(k,l)],a,"origin"),r)
   endif
   set a=null
endfunction

function IsUnitHurt takes nothing returns boolean
    local unit u=GetFilterUnit()
    local boolean b=not (IsUnitType(u, UNIT_TYPE_STRUCTURE) or IsUnitType(u, UNIT_TYPE_SUMMONED)) and ((GetUnitState(u,UNIT_STATE_LIFE)/GetUnitState(u,UNIT_STATE_MAX_LIFE))<=0.35) and GetWidgetLife(u)>0.4
    set u=null
    return b
endfunction

function ShowBlood takes nothing returns nothing
    local unit u=GetEnumUnit()
    call Blood_On_Unit(u,(0.35-GetUnitState(u,UNIT_STATE_LIFE)/GetUnitState(u,UNIT_STATE_MAX_LIFE)*40/7+0.5)) //moderate damage: short effect duration (>0.5 sec) ; severe damage: long effect duration (<2.5 sec); 
    set u=null
endfunction

function InjuryDetect_Condition takes nothing returns boolean
    return not IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE)
endfunction

function InjuryExe takes nothing returns nothing
    call Blood_On_Unit(GetTriggerUnit(),0.45)
endfunction

function InjuryExe_Condition takes nothing returns boolean
    return blood_switch
endfunction

function InjuryDetect takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterUnitEvent(t , GetTriggerUnit() , EVENT_UNIT_DAMAGED)
    call TriggerAddCondition(t, Condition(function InjuryExe_Condition))
    call TriggerAddAction(t, function InjuryExe)
    set t=null
endfunction

public function ShowBloodEffects takes nothing returns nothing
    call ForGroup(bleeding_group, function ShowBlood)
endfunction

public function PickHurtUnits takes nothing returns nothing
    call GroupClear(bleeding_group)
	call GroupEnumUnitsInRect(bleeding_group,bj_mapInitialPlayableArea,Filter(function IsUnitHurt))
endfunction

public function InitInjury takes nothing returns nothing
    local region r=CreateRegion()
    local trigger t=CreateTrigger()
    call RegionAddRect(r, bj_mapInitialPlayableArea)
    call TriggerRegisterEnterRegion(t,r,null )
    call TriggerAddCondition(t,Condition(function InjuryDetect_Condition))
    call TriggerAddAction(t , function InjuryDetect)
    set t=null
endfunction

endlibrary

//===========================================================================
function InitTrig_InjurySystem takes nothing returns nothing
endfunction


that's my background checks including the checks for the InjurySystem

JASS:
function OneSecChecks takes nothing returns nothing
    call BoardRefresh()
    if blood_switch then
        call InjurySystem_PickHurtUnits()
    endif
    call InvisibilityAura()
endfunction

function TwoSecChecks takes nothing returns nothing
    call Insurance()
    call Coefficients()
    call CustomMotions_TimerControl()
    if blood_switch then
        call InjurySystem_ShowBloodEffects()
    endif
endfunction

function InitCalculations takes nothing returns nothing
    call TimerStart(NewTimer(),1.0,true, function OneSecChecks)
    call TimerStart(NewTimer(),2.0,true, function TwoSecChecks)
endfunction


about the destroyeffecttimed: there are several options how to get there
1) global + polled wait
2) timer + gc
3) timer + struct + ABC

summing up there are already a lot of extras in it which make it solely fit to my map; yet all the other changes should be worthwhile to be considered as further improvement of your system.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top