Game Development Community

[Help in Design]DOT / Buff System any ideas?

by elvince · in Torque 3D Professional · 11/16/2009 (3:31 am) · 7 replies

Hi,

I would like to implement a DoT (damage over time) / buff system in my game.
How would you implement it?

My constraints:
A dot has a damagetype
A dot has lifetime
a dot can be purged

I thought about using the same approach as Repairrate. One rate per type of damage. The lifetime of the dot is managed by a schedule.

How many tick per second do we have in T3D, is it 32 or 64? Could you confirm it's fix and there are no way that a tick is delayed?

For buff, what will you approach? Will you add a variable in the player to store what type of buff you have + time?

How do you manage the purge?

Thank for your idea!

#1
11/16/2009 (1:45 pm)
Quote:Could you confirm it's fix and there are no way that a tick is delayed?

It's more like ticks/frame. When you go into the game, do a metrics("fps gfx"); in the console and look at the mspf (milliseconds per frame) value. If you're throwing a lot at the game, you can bump this way up. Of course, a DOT function won't do that.

For a DOT, you can use a schedule, like this one:
//Damage over time function
function DOT(%source, %dmgType, %dmg, %target, %incTime, %totalTime, %timer, %action)
{
   if(((%totalTime - %incTime) > 0) && (%target.state !$= "Dead"))
   {
      %text = applyDamage(%dmgType, %dmg, %target, %action) SPC "from" SPC %action;
      if(%source.type == 2)
      {
         commandToClient(%source.client, 'PostMsg', %text);
         commandToClient(%source.client, 'UpdateNPCHud', %target);
      }
      if(%target.type == 2)
      {
         commandToClient(%source.client, 'PostMsg', %text);
         commandToClient(%source.client, 'UpdateBars', %target);
      }
      %totalTime = %totalTime - %incTime;
      %timer = schedule(%incTime*1000, %timer, "DOT", %source, %dmgType, %dmg, %target, %incTime, %totalTime, %timer, %action);
   }
   else
   {
      cancel(%timer);
      if(%source.type == 2)
      {
         %text = %action SPC "has expired on" SPC %target.cname;
         commandToClient(%source.client, 'PostMsg', %text);
      }
   }
}

I separated some functions out due to how I'm doing certain things, but the basic structure (and then some) is there. Hope that helps.
#2
11/16/2009 (4:16 pm)
Thanks for your sample. It's a Nice way to do that. If you want to be able to purge Some specific dot, how are you doing that? Do you keep a array per player with all the schedule id soyou CAN cancel them?

By the way, what the use of your cancel in the else block? In my opinion it is useless as you are already in the scheduled function.

Thanks
#3
11/17/2009 (12:41 am)
I cancel the timer if the target dies, or else it keeps running on a dead mob/npc, or a player who respawns might have DOTs attached.

Right now, I don't have any DOTs that are tracked per-player, but that's on the task list. Basically, how I'm looking at doing it is something like %player.dots being a string of dot IDs that get updated by the function.

Also this function is deprecated in favor of a DOTA function I wrote that handles almost all fighting actions in the game. Database variables are pulled and put into the arguments and sent through. The DOTA handles "single fire" actions like punches by sending the incremental and total times as the same value.
#4
11/17/2009 (12:41 am)
Oh, almost forgot. Buffs are just negative DOTs ;)
#5
11/20/2009 (4:15 am)
I'm not sure I understood :DOTA function??

What is it?
#6
11/20/2009 (1:59 pm)
DOTA: Damage Over Time/Area

So you take the Damage Over Time function and apply a min/max radius to it so that it does container checks for area of effect spells and just anything that affects an area (explosions, fire, swine flue, Amy Winehouse, etc).

A good primer on that is the radiusDamage.cs script. It does damage to objects in an area. But if you do DOTs to objects in an area, then you have a DOTA function. I generalized it a lot like the DOT I posted above so that I just pull info from a DB and drop it into the same function (because for an MMORPG, a gun shot is just like a spell, which is just like a heal, which is just like a fear, etc).
#7
11/27/2009 (8:04 am)
thanks for the explanation.