Help by some scripts (game)

Hello, at first sorry for my english i’m German.
I want to make a multiplayer rpg with singleplayer mode. I’ve programmed a game in the bge once before and so i wanted to do a bigger project. At first i need a script that subtracts the property Damage (object Arrow) from the property Live (object Player).
Second, i need a script for maximal live. So the property Live (object Player) shouldnt be over the property livemax (object Player).
At first i thought about a intervall but this wouldn’t work.
Thanks for help.
P.S. the game is mixed between minecraft, some RPGs and league of legends.

If you’ve made a game in the BGE before, this should be relatively trivial.
And you can do all of this with logic bricks actually. The property actuator has ‘add’ mode, which can add negative numbers.

If you want to make sure that a player can’t go over a certain value health (interval from max to some huge number), then set up a sensor to detect when he is greater than the max, and set it back to the max.

Yes i know but in both cases there are only numbers, but the value of the property Livemax can change and in then there should be a other maximal live allowed, do you undertsand, the property can changes.

You can compare the values of two properties with an expression controller.

You can add/substract the value of another property with the property actuator.

But as you want to build an RPG I suggest to implement a damage handler with Python. This is because sooner or later you will need much more flexibility e.g. the combination of various resistences, bonus and malus to calculate the final damage. Do it in a way that it calculates the resulting health ONLY.

I made a script that may be helpful to you.
It gives rough examples of how I would write the script(s) that you seem to want.

Press d to deal damage, h to heal, i to increase max lives
Output displayed in console

Ask any questions you may have :yes:
livesExample.blend (436 KB)

Thanks for the feedback

Sorry if this is an stupid question but how can i set the variables (i mean something like properties) as an property in the game of the object Player.

To set a objects property in python, you can write the following:

obj[‘property’] = value

To get the object you might have to do:
scene = logic.getCurrentScene()
obj = scene.objects[‘objectName’]

I generally don’t use object properties because I think they make the python code less readable and needlessly complicated, but I do with text objects (they have a property named “Text” that is a string of the text they display.)

Hope that helps