Aller au contenu

Photo

The Unregen or Damage to Player over period of time


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
Buddywarrior

Buddywarrior
  • Members
  • 256 messages
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++;
 }
 
}


#2
jackkel dragon

jackkel dragon
  • Members
  • 2 047 messages
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.

#3
Shadooow

Shadooow
  • Members
  • 4 471 messages
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

#4
Buddywarrior

Buddywarrior
  • Members
  • 256 messages

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!

#5
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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 .


#6
jackkel dragon

jackkel dragon
  • Members
  • 2 047 messages

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.

#7
Buddywarrior

Buddywarrior
  • Members
  • 256 messages
agreed on the delay. Thanks for the assistance guys. The functions work great!

#8
Daybringer

Daybringer
  • Members
  • 14 messages
Degeneration is the word you guys are looking for <3

#9
Rolo Kipp

Rolo Kipp
  • Members
  • 2 791 messages
<just can't seem...>

That would make it a degenerate script? =)

<...to help himself>

#10
Daybringer

Daybringer
  • Members
  • 14 messages
*Snicker*