09 Jan, 2008, Zeno wrote in the 1st comment:
Votes: 0
Has anyone dealt with or coded in a hate system? I'm considering it.
(If you're unsure of what hate is, see this: http://wiki.ffxiclopedia.org/wiki/Enmity )

My initial thoughts would be to use a parallel array. One to store the pointer of the target (that the mob hates) and the other to store the amount of hate.
10 Jan, 2008, tphegley wrote in the 2nd comment:
Votes: 0
Something like how wow works is for every point of damage, you get threat. Every point of healing you get threat. I'm thinking that once melee dps gets over 10% of the tank then the npc switches to them. For spell damage/heal I think it's like 20 or 30% over what the tank had before they pull.

Now i don't know how exactly you could store that but you'd have to store it for however many people there were.
10 Jan, 2008, Xalin wrote in the 3rd comment:
Votes: 0
Kinds of sounds like an interesting system to add….. though would it really impact a mud enough to bother taking the time to add it?

My thoughts would be that it would be pointless to add to a Hack'N'Slash mud but it might make an impact on a more roleplay themed mud where you have to fight mobs that are at least somewhat difficult to level instead of continously whiping out weak things.

Few questions for you though Zeno….. How would you make it work actually? I mean like would at some point a mob get so pissed at a player that it would chase it around the mud till it reached a dead end or would it just be aggressive towards the player when they go past the mob.

The 1st idea kind of sounds nifty to me if you ask. Say if you accidently piss something larger then you off and it got to the point where it chased you….. it would require you to know the area you in and how to get away from it before it catches you.

Of course that could take a lot of work. Plus it's 6 AM so my ideas are just kind of…. Foop…. lol

Anyway, looking forward to your reply.
10 Jan, 2008, Vladaar wrote in the 4th comment:
Votes: 0
We have done something like that, but it needs tweaking just works with a scale of like 1 - 10 based on who is doing most damage to mob, however have skills that melee types can do to increase their hatred.

Vladaar
10 Jan, 2008, Xalin wrote in the 5th comment:
Votes: 0
Wait a minute…. ya you have….. heh I remember always getting chased by that guy that started with M. It was very kewl… Heh Zeno if you want to take the time to add this I'm going to highly suggest it.
10 Jan, 2008, Zeno wrote in the 6th comment:
Votes: 0
Quote
though would it really impact a mud enough to bother taking the time to add it?

My thoughts would be that it would be pointless to add to a Hack'N'Slash mud but it might make an impact on a more roleplay themed mud where you have to fight mobs that are at least somewhat difficult to level instead of continously whiping out weak things.

Just because a MUD is Hack'N'Slash doesn't mean it has no tactics. A Hack'N'Slash MUD doesn't mean all you do is wipe out weak things. My MUD is a Hack'N'Slash MUD (as opposed to RP heavy), yet there are tons of difficult mobs you need to take down in a group. In fact, one of my long time players (and builder) requested to put a hate system in. I knew what it was, but didn't think about putting it in that much before it was mentioned.

Quote
Few questions for you though Zeno….. How would you make it work actually? I mean like would at some point a mob get so pissed at a player that it would chase it around the mud till it reached a dead end or would it just be aggressive towards the player when they go past the mob.

Each action you do would generate a certain amount of hate. So for example, if you heal someone (for 100hp) fighting the mob, you generate say 50 hate (the mob now has 50 hate for you). Or if someone does 100 dmg to the mob, the mob now has 200 hate for the player. Each round, hate would diminish. Also, hate will diminish when the mob does damage to someone it hates. Whoever the mob has the most hate for (and is in the room with), the mob will attack. An effective way to "tank", and would also create tactics to "manage hate".
10 Jan, 2008, Kayle wrote in the 7th comment:
Votes: 0
This would be an interesting addition, but how would one do it? I saw mention of parallel arrays, but would that really be the best way to do it?
10 Jan, 2008, Zeno wrote in the 8th comment:
Votes: 0
This is what the hate data would look like: (format=target hate_amt)
Quote
Zeno 45
Kayle 90
Samson 3
Samson_Pet 5

Sort of. I would most likely use pointers instead of names.

But yeah, a parallel array would probably not be efficient. You'd have to loop through it each round to check the hate. Maybe a linked list of hate structs?

(The link I posted in the first post is a bit more complicated. I don't need two types of hate.)

This is how I see a hate system working in my MUD:
3 players are fighting a mob. The healer is using weak heal spells on the tank to keep him alive. The tank is doing enough damage to keep his hate higher compared to the other two. The third person is using support skills (defense, enfeeble, etc) and is also keeping his hate low. Whoop! The mob uses a strong skill and hits the tank for a lot. The healer uses a strong heal spell, and enough gains hate from it to change the mobs attention. Now the tank has to manage hate to make it so his hate is more than the healers. He uses a few damaging skills while the healer waits on healing. The tank succeeds in gaining the mobs attention again by getting his hate up higher.
10 Jan, 2008, Xalin wrote in the 9th comment:
Votes: 0
I would definately code that if I was you. Sounds like a pretty good idea if you ask me. Makes people have to pay more attention during fights while in groups and adds more of a challenge.
10 Jan, 2008, David Haley wrote in the 10th comment:
Votes: 0
Zeno said:
But yeah, a parallel array would probably not be efficient. You'd have to loop through it each round to check the hate. Maybe a linked list of hate structs?

Same problem as the array, really; you'd still have to search it linearly. A better plan might be to stick the structs into a binary search tree, sorted by name of person hated. In C++ that would be very easy: you'd just use a std::map. :smile:
10 Jan, 2008, Zeno wrote in the 11th comment:
Votes: 0
Store the name and search by it? I can't see that working though. What if the mob hates another mob? Multiple of the same mob can be invoked at the same time, of course.

I have a feeling it'll have to use some sort of hashing.
10 Jan, 2008, Kayle wrote in the 12th comment:
Votes: 0
There seems to be a big enough following for it, once it gets all figured out, perhaps it should be released as a snippet? I'd already had half a mind to do this for MW when I revised the combat system, but that's a little ways off for me yet, I've still got lots of little things to do, and bugs to find before I can start on the major projects. :P
10 Jan, 2008, Zeno wrote in the 13th comment:
Votes: 0
I wouldn't mind releasing it, but I can see problems. Damage will be easy to generate hate, but doing support skills or healing is hard. For example, if there is a heal skill (not a spell), how do we code it in? Obviously for damage there is a generic top level function you can add one or two hate function calls in. But with skills, can we do that? Even if there is a top level skill fn, I doubt it knows the skill is healing or not. I have a feeling we'd have to code in a call to the hate fn in each skill.
10 Jan, 2008, David Haley wrote in the 14th comment:
Votes: 0
Zeno said:
Store the name and search by it? I can't see that working though. What if the mob hates another mob?
That's fine, index by char_data pointer then. Hashing is fine as long as you do it intelligently. (BSTs are easier to get right than hash tables since you don't have to choose a hash function.) The point is to avoid a linear search time.
10 Jan, 2008, Kayle wrote in the 15th comment:
Votes: 0
Zeno said:
But with skills, can we do that? Even if there is a top level skill fn, I doubt it knows the skill is healing or not. I have a feeling we'd have to code in a call to the hate fn in each skill.


Well, for MW I ripped out the retarded act and class types for skills and spells and replaced them with spell schools, similar to the schools of magic from D&D So for healing, any spell flagged as Restoration would be healing, and anything flagged as Abjuration would be support. If you can figure out what all the different act/class combinations for skills equal out to, you could probably do it that way, and just have all the hate determining code in the spell_smaug or whatever the generic spell/skill function is.
10 Jan, 2008, Zeno wrote in the 16th comment:
Votes: 0
DavidHaley said:
Zeno said:
Store the name and search by it? I can't see that working though. What if the mob hates another mob?
That's fine, index by char_data pointer then. Hashing is fine as long as you do it intelligently. (BSTs are easier to get right than hash tables since you don't have to choose a hash function.) The point is to avoid a linear search time.


So when I'm doing a lookup in the BST, how am I comparing the data (pointer)? Can I just do a greater than or less than? Gotta get down the right subtree somehow.
10 Jan, 2008, David Haley wrote in the 17th comment:
Votes: 0
Zeno said:
So when I'm doing a lookup in the BST, how am I comparing the data (pointer)? Can I just do a greater than or less than? Gotta get down the right subtree somehow.

Yes, you'd be comparing on the char_data pointer, which is guaranteed to be unique to the character you're searching for. Numeric comparison would be fine.

Of course if you ever need the data to persist across reboots you'll have to do something else too, like save the player names or something. Saving mob data across reboots might be interesting but is still feasible.
10 Jan, 2008, Zeno wrote in the 18th comment:
Votes: 0
*nod* The only thing I can think of to save mobs correctly is to use a hash. Saving hate data over a reboot/hotboot doesn't seem to be a high priority, especially considering fighting has to be stopped before you can hotboot. I may consider saving hate vs players (and not mobs) over hotboots.
10 Jan, 2008, David Haley wrote in the 19th comment:
Votes: 0
I'm not sure why you say that a hash table can save mobs but a BST can't, but as I said a hash table will work too. You just need to use a good hash function for it to be useful.
10 Jan, 2008, Zeno wrote in the 20th comment:
Votes: 0
Er, this is still using a BST. I mean in order to save hate that targets a mob, I'd have to hash the mob name/vnum/etc to save a fingerprint to the file.
0.0/77