Need idea for Aggro System

Embrace_It

New Member
Reaction score
9
I'm currently working on an aggro system. So far, the system's core has been set up, but I need an idea on how to update the aggro.

When a unit damages another it generates aggro. A function that deals with this, has already been set up as well.

My idea:

1. Check every unit in the system (and thus in the map, since they have been added for the damage detection) to see if a registered unit has a higher aggro than its previous target. Data should be stored in either multiple hashtables or one hashtable with structs

Downsides to this approach are:
1. It will take a lot of CPU getting through all the units with an interval of ½-1 second.
2. A whole lot of data has to be stored for all non-player units in the map, imagine that in a big dungeon :(
 

Sungazer

New Member
Reaction score
0
I may not understand enough about your map for this to be feasible, but no matter how many units you have on the map, the player can only interact with what's in his/her viewable play area.

If the system only interacted with units within 'x' range of your hero or you only spawned units when you hero entered a region, this would greatly reduce the volume of data going into your system. Why would the aggro of a monster that your player's don't even know about on the other side of the map matter?

Just for clarification, your aggro system is supposed to work like traditional MMOs? i.e., the character with highest aggro becomes the monster's target and spells, healing and damage generate aggro?

1. It will take a lot of CPU getting through all the units with an interval of ½-1 second.

I don't get this... why add a 0.5-1.0 second interval to this? Are you saying it takes this long to run each unit through your system, or did you build this wait in there for some reason?
 

Embrace_It

New Member
Reaction score
9
It will work like a traditional MMO, yes.

The aggro/threat has to be update once in a while, the ½-1 seconds I suggested was the interval for this update.

I have come up with another idea, let me hear your thoughts:

When non-player units are damaged they are added to a group. When the system updates, it loops through each of these units checking if they are still alive, valid etc. Then it compares each units' target with the unit that is at the top of the aggro "list". If it is bigger then change target, else do nothing.

I like your idea, so I guess it is a choice between the above and yours.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
I would use an AIDS struct for all the non player units. Each struct has one real per player, and an AddAggro method. The AddAggro takes a real and a player number, returns nothing, and it runs a check to see if the new real is greater than all the other reals. If it is, attack the players unit (i'm assuming they only have one?).

I would do an AddAggro instead of an OnDamage because it allows more flexibility. Then you can have moves that generate a lot of aggro, or none at all. Hell, the AddAggro could also subtract aggro if you pass a negative int.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top