On_EntityHurt

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Method:
On_NPCHurt

Description:
Runs when an Entity gets damage. WARNING: See PROPERTIES.


Argument(s):
HurtEvent he

Properties:
HurtEvent.IsDecay()
HurtEvent.GetTakeDamage().health
HurtEvent.DamageAmount

No Name, Attacker, or Victim.

Examples:
Python:

Python:

def On_EntityHurt(self, HurtEvent):
Server.Broadcast(HurtEvent.GetTakeDamage().health + " hp")

Javascript:
JavaScript:

function On_EntityHurt(HurtEvent) {
Server.Broadcast(HurtEvent.GetTakeDamage().health + " hp");
}

C#:
C#:
...
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
So I made houses stronger with this thing:

Code:
health = (Hurt.DamageAmount/100)*50
Hurt.Entity.GetTakeDamage().health=Hurt.Entity.GetTakeDamage().health+health
/100 * 50 may look idiot, but I'm still evaluating.
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Remember that it's hard to overpass taken damage. In above code I'm showing how to do Entities stronger. You wont do this that way:
Code:
    #  EntityHurt Hook:
    #- receiving: HurtEvent
    def On_EntityHurt(self, Hurt):
        real_damage = Hurt.DamageAmount #                 checking real damage made by C4
        (Hurt.DamageAmount/100)*50 #                      /100*50 because I want to keep this in percentage value (50%)
        damage = (Hurt.DamageAmount/100)*50 #             checking "new" damage
        health = (Hurt.Entity.GetTakeDamage().health) #   getting healh
        Server.Broadcast(str(real_damage)+" | "+str(damage)+" | "+str(health)) # converting damage (float) to string
Debug showed me:
Code:
[First C4]
Fougerite: 0 | 0 | 5000
Fougerite: 74 | 37 | 535
Fougerite: 600 | 300 | 1000
[Second C4]
Fougerite: 0 | 0 | 5000
Fougerite: 235 | 117 | 461
Are you surprised? Don't look at the numbers, as you probably can't check real damage and health of entity. The point is real damage is 74 + 600 + 235. Damage what you would want is 37 + 300 + 117. So why it's not working?

I destroyed wall with 2 C4. 50% stronger should make them strong for 3C4.

Code will not set DamageAmount, as Fougerite is only plugin, scripting system what FOR game, not IN game. It's always after game.

Rust -> Fougerite -> Rust -> Fougerite

Rust first making damage, then let Fougerite check it amount.

How to do it properly? My code is.

Code:
#  EntityHurt Hook:
    #- receiving: HurtEvent
    def On_EntityHurt(self, Hurt):
        real_damage = Hurt.DamageAmount #                 checking real damage made by C4
        health = (Hurt.Entity.GetTakeDamage().health) #   getting healh
        add_health = (Hurt.DamageAmount/100)*50 #         how many health we want to add? 50%
        Hurt.Entity.GetTakeDamage().health=Hurt.Entity.GetTakeDamage().health+add_health # adding health
        new_health = (Hurt.Entity.GetTakeDamage().health) #   getting new healh
        Server.Broadcast(str(real_damage)+" | "+str(health)+" | "+str(new_health)) # converting damage (float) to string
First debug:
Code:
[First C4]
Fougerite: 0 | 5000 | 5000
Fougerite: 0 | 5000 | 5000
Fougerite: 6 | 225 | 228
Fougerite: 1 | 1000 | 1000.5
Fougerite: 600 | 1000 | 1300
[Second C4]
Fougerite: 0 | 5000 | 5000
Fougerite: 140 | 222 | 292
[Third C4]
Fougerite: 0 | 5000 | 5000
Fougerite: 600 | 700 | 1000
Fougerite: 0 | 5000 | 5000
And again, don't focus on numbers, because Rust is crazy. Best way to do this would be to set max health for wall, but it will still work like it's now.

You don't change DamageAmount - because it is made before Fougerite. But you can change health, because it can be made after making damage.

If you don't believe, just make your debugs.

EDIT:
Oh and of course final script:
Code:
def On_EntityHurt(self, Hurt):
        add_health = (Hurt.DamageAmount/100)*50
        Hurt.Entity.GetTakeDamage().health=Hurt.Entity.GetTakeDamage().health+add_health
 
Last edited:

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Remember that it's hard to overpass taken damage. In above code I'm showing how to do Entities stronger. You wont do this that way:
Code:
    #  EntityHurt Hook:
    #- receiving: HurtEvent
    def On_EntityHurt(self, Hurt):
        real_damage = Hurt.DamageAmount #                 checking real damage made by C4
        (Hurt.DamageAmount/100)*50 #                      /100*50 because I want to keep this in percentage value (50%)
        damage = (Hurt.DamageAmount/100)*50 #             checking "new" damage
        health = (Hurt.Entity.GetTakeDamage().health) #   getting healh
        Server.Broadcast(str(real_damage)+" | "+str(damage)+" | "+str(health)) # converting damage (float) to string
Debug showed me:
Code:
[First C4]
Fougerite: 0 | 0 | 5000
Fougerite: 74 | 37 | 535
Fougerite: 600 | 300 | 1000
[Second C4]
Fougerite: 0 | 0 | 5000
Fougerite: 235 | 117 | 461
Are you surprised? Don't look at the numbers, as you probably can't check real damage and health of entity. The point is real damage is 74 + 600 + 235. Damage what you would want is 37 + 300 + 117. So why it's not working?

I destroyed wall with 2 C4. 50% stronger should make them strong for 3C4.

Code will not set DamageAmount, as Fougerite is only plugin, scripting system what FOR game, not IN game. It's always after game.

Rust -> Fougerite -> Rust -> Fougerite

Rust first making damage, then let Fougerite check it amount.

How to do it properly? My code is.

Code:
#  EntityHurt Hook:
    #- receiving: HurtEvent
    def On_EntityHurt(self, Hurt):
        real_damage = Hurt.DamageAmount #                 checking real damage made by C4
        health = (Hurt.Entity.GetTakeDamage().health) #   getting healh
        add_health = (Hurt.DamageAmount/100)*50 #         how many health we want to add? 50%
        Hurt.Entity.GetTakeDamage().health=Hurt.Entity.GetTakeDamage().health+add_health # adding health
        new_health = (Hurt.Entity.GetTakeDamage().health) #   getting new healh
        Server.Broadcast(str(real_damage)+" | "+str(health)+" | "+str(new_health)) # converting damage (float) to string
First debug:
Code:
[First C4]
Fougerite: 0 | 5000 | 5000
Fougerite: 0 | 5000 | 5000
Fougerite: 6 | 225 | 228
Fougerite: 1 | 1000 | 1000.5
Fougerite: 600 | 1000 | 1300
[Second C4]
Fougerite: 0 | 5000 | 5000
Fougerite: 140 | 222 | 292
[Third C4]
Fougerite: 0 | 5000 | 5000
Fougerite: 600 | 700 | 1000
Fougerite: 0 | 5000 | 5000
And again, don't focus on numbers, because Rust is crazy. Best way to do this would be to set max health for wall, but it will still work like it's now.

You don't change DamageAmount - because it is made before Fougerite. But you can change health, because it can be made after making damage.

If you don't believe, just make your debugs.

EDIT:
Oh and of course final script:
Code:
def On_EntityHurt(self, Hurt):
        add_health = (Hurt.DamageAmount/100)*50
        Hurt.Entity.GetTakeDamage().health=Hurt.Entity.GetTakeDamage().health+add_health
What I could dig out about this that the damage is not the real damage. The reason is because when the event runs, Fougerite bypasses the Rust Event to run. Basically modifies the parameters before the actual event would run. After that, Rust runs them as received. Which means the damage is always the same. If you hit a guy in the head while he has kevlar, the damage is still the same, but It gets modified after checking what armor does the player have.

Besides, I don't get what do you mean by for game and in game.