Targetting System

Hey guys, im a long time lurker on these forums and thought if dive in for a first post :). Im currently attempting some kind of offline rpg type (i expect more tech demo then full game) with a WoW-esque targetting system. This is my first attempt at python so i do apologise for the appauling mess ive made of it. so far i have got it working so if you mouse over + click an object with the property “enemy” it selects the object (the empty named Target has a property named Target wich shows the name of currently selected object if you debug the property).

Where im hitting trouble is trying to make it so if you press spacebar, it takes 10 damage (HP property on all “enemy” objects) off the currently selected object, and also so that it requires a seperate press for each minus of health (ie, you cant hold down space and it ticks down the health continuously).

The script is scratch written by me from tutorials etc so as i said, its messy, nasty, and probably full of bad practice, but if anyone could give me a hand with this, id be most greatful.

Targetting test.blend (283 KB)

Ive included a .Blend (if the attachment thing worked). to test what ive done, simply press P and click on the different objects on screen. you should see the name of the object appear in the debug property and for unknown reasons, the current objects health going down.

Some ppl might say, dont be too optamistic, but that targeting system is legend… pretty good yh. Keep going :smiley:

Hey, thanks for the kind words. Ive done plenty with the logic bricks before now but i wanted to try extending into the more complex with python. Anyone else with further comments / help in the matter is more then welcome to post, in the mean time i shall continue to work on this.