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
889
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: 305

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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top