PDA

View Full Version : New Rule: Flagging Hostile NPCs


Shendare
07-05-2009, 02:45 AM
Some server admins might like this idea and some might not, but I figured it was worth putting out there as an option.

When exploring areas with multiple factions, some of which may be hostile, it can be stressful to need to manually con each and every NPC you come across to see whether it's on a hostile faction or not.

I have created a rule that, when activated, changes the title of any hostile NPC to "(Hostile)" when sending NPC spawns to the client, causing it to appear beneath the name of the NPC.

I would have preferred to be able to make the name a different color, but it looks like this will have to do.

http://www.jondjackson.net/eq/emu/images/FlagHostileNPCs.png

Required SQL:

INSERT INTO rule_values VALUES (1, 'World:FlagHostileNPCs', 'true', 'If true, hostile NPCs show (Hostile) beneath their name');


File - ruletypes.h (Line 105)

...
RULE_INT ( World, SoFStartZoneID, -1 ) //Sets the Starting Zone for SoF Clients separate from Titanium Clients (-1 is disabled)
+ RULE_BOOL ( World, FlagHostileNPCs, false) // Shendare: If true, displays (Hostile) under names of hostile NPCs
RULE_CATEGORY_END()
...


File - mob.cpp (Line 813) - Mob::FillSpawnStruct()

...
memset(ns->spawn.set_to_0xFF, 0xFF, sizeof(ns->spawn.set_to_0xFF));

+ switch ((ForWho && RuleB(World, FlagHostileNPCs)) ? ForWho->GetReverseFactionCon(this) : 0)
+ {
+ case FACTION_THREATENLY:
+ case FACTION_SCOWLS:
+ memcpy_s(ns->spawn.lastName, sizeof(ns->spawn.lastName), "Hostile", 8);
+ break;
+ }
}
...

ChaosSlayerZ
07-05-2009, 01:21 PM
this is very interesting approach!

Personaly I prefer how they did it in EQ2 - where name color showed the level con of the mob, but RED outline around the name showed whenever its KOS or not (and if you were invised the outline would go away since mob can't see you), but I guess this is the luxury we don't have.

On other hand I was planning to use the (***) space to put indication of a power rank (again like in eq2, where they used Up Arrows to indicate if mob is solo, heroic or raid class)

Eitherway - this is a great innovation! I am sure some custom servers would like it.

leslamarch
07-06-2009, 05:32 PM
I really like the idea of this, I found a problem with it and really didnt look to much further. With this code added in pet classes will no longer be able to raise a pet, The spell goes off just as it should but the pet just never appears, and the regent is also consumed. I Ran out of time to do any further testing on this, sorry :(

*edit* this patch maybe fine for the stock source, I do have some custom code. The only thing i tested was pets work with the patch commented out, but with this active again pets no longer work.

Shendare
07-06-2009, 05:40 PM
That's... odd... do pets somehow make use of the lastName field?

ChaosSlayerZ
07-06-2009, 06:14 PM
technicly pets should not be using the "hosile" tag. Even if its an npc's pet, the npc should be taged "hostile" , not pet. Pet is just pet

Shendare
07-06-2009, 06:28 PM
Right, and pets generally con as indifferent anyway, which would prevent them from ever getting to the tagging portion, which only activates for Glares Threateningly or Ready to Attack.

Kobaz
07-06-2009, 06:44 PM
Testing with an otherwise stock server, this change does indeed stop pets being raised. It's a shame, as it's the kind of thing that would make the game more friendly for very young players.

Shendare
07-06-2009, 07:50 PM
Roger that.

I'll have to take a deeper look to figure out what could possibly be going wrong with such a simple little piece of code.

Shendare
07-06-2009, 11:02 PM
Okay, apparently the problem was caused by a call to GetReverseFactionCon() for a non-player entity.

Fixed with the following code change:

File: mob.cpp, Line 817 - mob::FillSpawnStruct()

if (ForWho && ForWho->IsClient() && RuleB(World, FlagHostileNPCs))
{
switch (ForWho->CastToClient()->GetReverseFactionCon(this))
{
case FACTION_THREATENLY:
case FACTION_SCOWLS:
memcpy_s(ns->spawn.lastName, sizeof(ns->spawn.lastName), "Hostile", 8);
break;
}
}


On an unrelated note, I found that if you have a pet, you can aggro hostile NPCs even with the GM flag on. LOL.

It's hard to tell whether the pet's aggroing the NPC or the NPC is aggroing on the pet.

ChaosSlayerZ
07-06-2009, 11:21 PM
hmm thats bad. I remember when back on the day your pet shared your faction - it was a nightmare. Since my pet was always lower level than my necro I could not just walk through a dungeon where mobs were allreday green - I had to kill every darn thing cuase it kept agroing on my pet.

But back in 2001 they finaly made it so your pet does not have a faction at all, so mobs never agro on the pet. So once mobs are green, you can walk around with lev 1 pet totaly safe

Shendare
07-06-2009, 11:57 PM
Apparently we could use the same change.

I just did some testing, and while a grey-con Level 40 hostile NPC will not attack a Level 75 character, it will attack its Level 2 pet, and then turn to the owner once the pet is dead.


Guard Legver glares at you threateningly -- You could probably win this fight.
Guard Legver hits Zarartik for 120 points of damage.
Zarartik has been slain by Guard Legver!
Guard Legver tries to hit YOU, but misses!
Zarartik tells you, 'Attacking Guard Legver Master.'
Guard Legver bashes YOU for 33 points of damage.


Also, pets can speak from beyond the grave. OooooOOOOOoooooh. Heh heh.

ChaosSlayerZ
07-07-2009, 12:34 AM
hehe, but yeah this was a huge annoyance on LIVE, we realy need to get rid of it =P

Shendare
07-07-2009, 01:09 AM
Grr. There's still a slight problem with this feature.

It does the proper processing when a player zones in, FillSpawnStruct(&ns, Client) gets called for the particular client entering the zone, so they get the customized version of the NPC's lastname.

However, any new NPC spawn packets that get sent to the client after zoning in don't get processed in the same way... the same spawn packet gets sent to all clients in the zone, so NPCs that spawn after zoning in, via normal respawn cycles or #repop, won't have the customized lastname.

I'll have to do a little more work before this is 100% functional.

I'll probably have to move the processing into the QueuePacket() function, and things will get a little more complicated.

trevius
07-07-2009, 04:54 AM
Definitely an interesting option once the code issues are all worked out. Can you maybe just do an IsPet check before doing the case switch?

Shendare
07-07-2009, 09:57 AM
The pet problem isn't actually related to this at all, I just noticed it while testing. An IsPet check isn't part of the hostile NPC flagging.