ondrawscript regen

The_Gambit

New member
Trying to give Wolverine a constant +1 health per second no matter what animation. I am currently trying "ondrawscript  data/scripts/regen1.c"

regen1.c

void main()
{// Spend some life
    void self = getlocalvar("self");// get caller
void MaxHP = getentitypropery(self, "maxhealth"); //get max health
    void Life = getentityproperty(self,"health"); //get health
if (Life=<MaxHP){
    changeentityproperty(self, "health", Life+1); //add health
delay 1000; // wait 1 second
}

 
I dont think there is a script command called delay.  I wrote this on my mobile so it might have errors i have not checked. 1000 might be too high play with the figure until u get the desired results.

Code:
void main()
{// life regen
void self = getlocalvar("self");// get caller
void Life = getentityproperty(self,"health"); //get health
Int time = openborvariant("elapsed_time"); //get current time
Int timer;

   if (timer <time){
   changeentityproperty(self, "health", Life+1); //add health
   Timer = time+1000; // wait 1000 tics
   }
 
Here is the code I use. Save this as healing.c and call it in ondrawscript:

Code:
void main(){
   void self = getlocalvar("self"); //Get calling entity.
   void health = getentityproperty(self,"health"); //get health
   int time = openborvariant("elapsed_time");// get time

   if ( time % 300 == 0 && getentityproperty(self, "exists") && !getentityproperty(self, "dead"))
   {
   changeentityproperty(self, "health", health+5);//add health
   }
}
 
that is a very good use of the modulus operator saves having a timer check I might update some of my current scripts to use this method. " !time%300 " should work too.
 
"elapsed_time", - gets the elapsed time until the moment
% its the Modulo math operation https://en.wikipedia.org/wiki/Modulo_operation

"time % 300 == 0 " means "everytime time divided by 300 is 0"
 
Careful about Elapsed Time, it is reset when a new level is started. For a script like this it doesn't matter, but if you are making a global timer or some such, you'll need to keep track of the time with variables.

DC
 
Back
Top Bottom