Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 07-05-2009, 02:45 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default New Rule: Flagging Hostile NPCs

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.



Required SQL:
Code:
INSERT INTO rule_values VALUES (1, 'World:FlagHostileNPCs', 'true', 'If true, hostile NPCs show (Hostile) beneath their name');
File - ruletypes.h (Line 105)
Code:
...
  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()
Code:
...
    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;
+   }
  }
...
Reply With Quote
  #2  
Old 07-05-2009, 01:21 PM
ChaosSlayerZ's Avatar
ChaosSlayerZ
Demi-God
 
Join Date: Mar 2009
Location: Umm
Posts: 1,492
Default

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.
Reply With Quote
  #3  
Old 07-06-2009, 05:32 PM
leslamarch
Discordant
 
Join Date: Sep 2006
Location: Green Bay, WI
Posts: 436
Default

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.
Reply With Quote
  #4  
Old 07-06-2009, 05:40 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

That's... odd... do pets somehow make use of the lastName field?
Reply With Quote
  #5  
Old 07-06-2009, 06:14 PM
ChaosSlayerZ's Avatar
ChaosSlayerZ
Demi-God
 
Join Date: Mar 2009
Location: Umm
Posts: 1,492
Default

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
Reply With Quote
  #6  
Old 07-06-2009, 06:28 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

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.
Reply With Quote
  #7  
Old 07-06-2009, 06:44 PM
Kobaz
Hill Giant
 
Join Date: Nov 2008
Location: Gold Coast, Oz
Posts: 119
Default

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.
Reply With Quote
  #8  
Old 07-06-2009, 07:50 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

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.
Reply With Quote
  #9  
Old 07-06-2009, 11:02 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

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()
Code:
  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.
Reply With Quote
  #10  
Old 07-06-2009, 11:21 PM
ChaosSlayerZ's Avatar
ChaosSlayerZ
Demi-God
 
Join Date: Mar 2009
Location: Umm
Posts: 1,492
Default

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
Reply With Quote
  #11  
Old 07-06-2009, 11:57 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

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.

Code:
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.
Reply With Quote
  #12  
Old 07-07-2009, 12:34 AM
ChaosSlayerZ's Avatar
ChaosSlayerZ
Demi-God
 
Join Date: Mar 2009
Location: Umm
Posts: 1,492
Default

hehe, but yeah this was a huge annoyance on LIVE, we realy need to get rid of it =P
Reply With Quote
  #13  
Old 07-07-2009, 01:09 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

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.
Reply With Quote
  #14  
Old 07-07-2009, 04:54 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

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?
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #15  
Old 07-07-2009, 09:57 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 09:18 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3