Jump to content
The Dark Mod Forums

in script, $player1.getHealth() always shows no change when damage has been done


BlackMagic

Recommended Posts

In my mission, there is a script that is supposed to display a message if a player is damaged by an explosion. It didn't work because health stays at 100 even when the light gem shows damage was taken.  at the start of script I did this;

PlayerHealth = $player1.getHealth();
sys.print("Start health = " + PlayerHealth + "\n");

and it reports 100 (or less if player is damaged already)
after the explosion (more) damage is taken per light gem, but this;

PlayerHealth = $player1.getHealth();
sys.print("health now = " + PlayerHealth + "\n");

Still shows the value recorded before damage was taken. So how do I test for actual health?

Link to comment
Share on other sites

Can you show the actual script code? Is better to know what is really happening, at lest to me, because at first glance it should work.

But you should know that I'm not a TDM mission maker, even thou I do know a fair bit about idTech 4 scripting and c++ coding, but because of the changes done to TDM engine and scripting, what i know may not apply in TDM.

But in any case are you really sure you are calling

PlayerHealth = $player1.getHealth();
sys.print("health now = " + PlayerHealth + "\n");

after doing the damage?

I know you say the light gem shows new damage, so this is indeed strange.

Btw just to debug, try to manually set the player health with $player1.setHealth(value) and see if it prints the new value. If it still prints the wrong thing then there's something wrong, with how you are calling the code or some bug on how the explosion damage handles the player.

Also I would use sys.println instead, it does the same but includes the newline automatically less typing imo. :)  

Link to comment
Share on other sites

yes IO tried doing the following.

after first gethealth, setting variable Player Health to to, then doing another sysprint of the variable and console showed that is had changed to 2, but still showed same health after damage was taken that it showed before . Tried with full health at start as well as with pre existing damage of about 40% health (by using noclip to sky and dropping).

As far as my script, it is quite large, having force fields, explosions, smoke,dust, flying rocks, etc. but i will make a short test script and try that - and post here in a little bit.

Right now I have moved on to trying to figure out how to change player head in a script since it is not available in DR, at least as far as I can find. My cowboy + cowgirl hats on heads look good on AI but how can the Marshall walk around in thief guard?

Link to comment
Share on other sites

I'm not 100% sure how your script works, but I suspect it might just be too short a time interval between running sys.trigger($dynomite_hurts); and checking your health.

  • Like 1

My missions:           Stand-alone                                                      Duncan Lynch series                              

                                      Down and Out on Newford Road              the Factory Heist

                                                                                                  A House Call

                                                                                                  The House of deLisle                                                                                                  

                              

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
    • The Black Arrow

      Hope everyone has the blessing of undying motivation for "The Dark Mod 15th Anniversary Contest". Can't wait to see the many magnificent missions you all may have planned. Good luck, with an Ace!
      · 0 replies
×
×
  • Create New...