Health!

Hi! I have a health property on player and I want to make there appear a blood splash when player get’s hurt. However, using a sensor that checks if proprty changed would be wrong as the health slowly restores and can be restored quiclky using medicine. How do I test if that property reduced instead of checking so it changed?

The cause is that the player gets hurt. This causes two things:
A) dropping health
B) showing the splatter

You could use the dropping health as cause of the splatter. The consequence is that there is no splatter if the health does not drop. Additionally you will get splatter regardless why the health drops (e.g. when getting poisoned, burned or whatever).

You need to measure the event of getting hurt (or dropping health). When that happen you show the splatter regardless if there are subsequent events. They might refresh the splatter. This way the splatter remains even if there is no subsequent cause.

I hope this is understandable in any way
Monster

Well, is there a way to test if health property dropped? I am asking exactly that…

Usually you know it when you reduce it (health = health - x). I really do not know how you implemented that.
You could send a message “health dropped” so any interested listener can act accordingly.

OK! After taking a look at my fall damage script I relaised that that is possible…

For something like this, I would use a switch. This could be a booleen property on the player, or a booleen variable in your script.

For example, let’s say your player has a property called ‘PAIN’, which is switched on whenever you take damage. Whatever call registers the action of dealing damage to the player also makes player[‘PAIN’] = True.

In your player’s script, make a check every cycle to see if PAIN is True:

if own[‘PAIN’]:
drawBloodSplat()
own[‘PAIN’] = False

If PAIN is True, conjure your blood splats, then switch PAIN back off. This doesn’t have to be tied to the player’s health at all.

A property is possible but not really sufficient in this situation.

It is sufficient if you want to express “pain over time” = a duration. So you mark the object with a “receiving pain” state. The problem with the property is you need to reset it later.

Usually receiving damage is an event. It can happen again and again. But these are separate events. It does not happen because the object causes it, it happens because something else causes it.

Nevertheless when the object registers “hurt” others might register it too or (as suggested) get notified.

What I do with health is this.

I give the player a float property called hp, and set the float for however many hits I want my player to take before he dies. 5.000000 means he can take 5 hits.

(Might be able to use an integer, I always use a float)

I give the player an Always sensor, True pulse checked. Instead of an “And” I use an “expression” hp<=0. and whatever actuator you want to activate your death scene, and restart scene.

I use a message to reduce health, called “health”

Message, “health”-------and-------property, hp, add -1.
or if hit by a grenade, Near, property “grenade”------and-------property, hp, add -5

(This works well with that bullet damage script I posted, (BulletAdd))

Now you can use the property, less than, sensor, to check if your player has a health property less than 5.

If property, hp, less than 5-----and------add object, blood spatter.
As he heals, maybe you could remove the blood spatter, or reduce it’s size to make it appear that he is healing.

Hope this helps.
Mark

I resolved it different way, because I needed it to appear only when player gets hurt and imediatly disappear…

How did you do it? I would like to try it out.