Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Script to regenerate health overtime

Recommended Posts

So as the title says, is it possible to make a script that will regenerate health over time? Like in FPS games, once damaged after 3-5 seconds health will gain 1%/sec ? Thanks in advance

Share this post

Link to post

I don't know, but I'm sure if you posted this on the skulltag forum, you'd have 3 answers within 5 minutes.

Share this post

Link to post

Yes sir. What you can do is set up a loop to constantly monitor the player's health and if it ever drops below 100 (but is above 0, meaning he's still alive), you force a delay for just a few seconds then refill his health until either he's hit again (causing yet another delay) or his health tops off at 100.

I whipped up a quick example and it seems to work really well. Here's the code itself, followed by an example WAD:

#include "zcommon.acs"

int health = 100;

script 999 ENTER
    //Assign yourself an ID

script 1 ENTER
        //Constantly work while health is under 100
        While(GetActorProperty(1337,APROP_Health)<100 && GetActorProperty(1337,APROP_Health)>0)
            //After each hit you take, wait for regeneration
                health = GetActorProperty(1337,APROP_Health);
                Delay(105);//Determines how long you must wait until regeneration begins
            //Perform the regeneration one hit point at a time
            health = GetActorProperty(0, APROP_Health);
            SetActorProperty(1337, APROP_Health, health + 1);
            Delay(2);//Determines how quickly health is restored during regeneration

Share this post

Link to post

thanks a lot for the script, I'll have a look on it and will use it in my wad, hopefully I will post my WIP in a few weeks, since I'm doing it alone and I want lots of stuff in it it will take a while, but I'm making some progress

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now