Author Topic: The Unregen or Damage to Player over period of time  (Read 333 times)

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« on: October 17, 2012, 08:55:20 pm »


               I'm sure their is a better way to do this, but I'm trying to come up with a direct way to constantly deal damage to a player, much like regenerate except it would be -2 damage every 10 seconds in stead of +2 Health.

I've tried a using a While statement with a delay in it, but the while overrides the delay. So how can I solve this?
((note that this is a function called from another script))



void castcard152(object oPC, int addToSwampPool)
{
    SendMessageToPC(oPC, "card152 triggered...next should be the damage " + IntToString(addToSwampPool));

 int x = 0;
 while( x < 100)
 {
   DelayCommand(10.0, SendMessageToPC(oPC, "Deal 2 points of damage"));
   x++;
 }
 
}

               
               

               
            

Legacy_jackkel dragon

  • Full Member
  • ***
  • Posts: 178
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« Reply #1 on: October 17, 2012, 09:18:22 pm »


               Looks like you may have made a mistake I made a while back... basically, each delay command is triggering 10.0 seconds after they get queued, and the script is queueing around 100 of them nearly instantly. If you ran this, it'd probably wait for those ten seconds and then spam you with all 100 messages at once.

A better idea would be to make it "DelayCommand(10.0 * (x + 1), SendMessageToPC(oPC, "Deal 2 points of damage"));". This way, each trigger is spaced 10 seconds apart, like you seem to be trying to do. And since you start the count at 0, you want the + 1 to keep the first from triggering instantly.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« Reply #2 on: October 17, 2012, 09:19:42 pm »


               damn, someone brought this up earlier than I :/

I was up to present the re-implementation of the Wounding itemproperty which works exactly as "unregen" in my next community patch release
               
               

               
            

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« Reply #3 on: October 17, 2012, 09:31:35 pm »


               

jackkel dragon wrote...

Looks like you may have made a mistake I made a while back... basically, each delay command is triggering 10.0 seconds after they get queued, and the script is queueing around 100 of them nearly instantly. If you ran this, it'd probably wait for those ten seconds and then spam you with all 100 messages at once.

A better idea would be to make it "DelayCommand(10.0 * (x + 1), SendMessageToPC(oPC, "Deal 2 points of damage"));". This way, each trigger is spaced 10 seconds apart, like you seem to be trying to do. And since you start the count at 0, you want the + 1 to keep the first from triggering instantly.


That did it. Thanks Jackkel!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« Reply #4 on: October 17, 2012, 09:46:02 pm »


               Try something like this. 

void DealDamage( float fInterval, int nDamgPer, int nTotalDamage)
{
     SendMessageToPC(OBJECT_SELF, "Deal "+IntToString(nDamgPer) +" points of damage");
     /** Place effect to damage OBJECT_SELF here. **/
     nTotalDamage -= nDamgPer;

    if ( nTotalDamage >0 )
   {
       DelayCommand(fInterval, DealDamage( fInterval, nDamgPer, nTotalDamage));
       SpeakString( IntToString( nTotalDamage) +" Points left to deal");
   }
   else SpeakString( "Damage Finished") ;

 }
 
void castcard152(object oPC, int addToSwampPool)
{
    SendMessageToPC(oPC, "card152 triggered...next should be the damage " + IntToString(addToSwampPool));

   AssignCommand(oPC, DealDamage( 10.0, 2, 200)) ;
}
 

Edit:  It is really not  good  to place 100 delayed commands on a target all at once. 
EDIT2:  OOps forgot to assign the function to the PC.  Fixed.  
               
               

               


                     Modifié par Lightfoot8, 17 octobre 2012 - 11:23 .
                     
                  


            

Legacy_jackkel dragon

  • Full Member
  • ***
  • Posts: 178
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« Reply #5 on: October 18, 2012, 12:35:35 am »


               

Lightfoot8 wrote...

Try something like this. 

void DealDamage( float fInterval, int nDamgPer, int nTotalDamage)
{
     SendMessageToPC(OBJECT_SELF, "Deal "+IntToString(nDamgPer) +" points of damage");
     /** Place effect to damage OBJECT_SELF here. **/
     nTotalDamage -= nDamgPer;

    if ( nTotalDamage >0 )
   {
       DelayCommand(fInterval, DealDamage( fInterval, nDamgPer, nTotalDamage));
       SpeakString( IntToString( nTotalDamage) +" Points left to deal");
   }
   else SpeakString( "Damage Finished") ;

 }
 
void castcard152(object oPC, int addToSwampPool)
{
    SendMessageToPC(oPC, "card152 triggered...next should be the damage " + IntToString(addToSwampPool));

   AssignCommand(oPC, DealDamage( 10.0, 2, 200)) ;
}
 

Edit:  It is really not  good  to place 100 delayed commands on a target all at once. 
EDIT2:  OOps forgot to assign the function to the PC.  Fixed.  


While the edit I made to the original script probably works (didn't test it myself), this is probably a better way to do it. I can't imagine putting a lot of delayed commands at once will help performance, while this DealDamage function can achieve the same thing (or other similar damage over time effects) without causing as much performance loss.
               
               

               
            

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« Reply #6 on: October 18, 2012, 02:41:57 pm »


               agreed on the delay. Thanks for the assistance guys. The functions work great!
               
               

               
            

Legacy_Daybringer

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« Reply #7 on: October 22, 2012, 01:07:38 pm »


               Degeneration is the word you guys are looking for '<3'
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« Reply #8 on: October 23, 2012, 01:37:15 am »


               <just can't seem...>

That would make it a degenerate script? =)

<...to help himself>
               
               

               
            

Legacy_Daybringer

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
The Unregen or Damage to Player over period of time
« Reply #9 on: October 23, 2012, 07:11:30 am »


               *Snicker*