PDA

View Full Version : Switch skill - C++


provocating
03-08-2016, 03:13 PM
Any idea why this would not work?

CastToNPC()->SetPrimSkill(SkillHandtoHand);

I know this code is firing but the NPC still is using a 1hs, but does not have it.

EDIT: So I went back and did a log.out on what skill the NPC was using after I switched it to h2h and it is showing skill 28 which is hand to hand correct? Then the NPC should not be slashing. Missing something here.

Shin Noir
03-08-2016, 05:27 PM
At a glance, SetPrimSkill just sets the prim_melee_type to the passed type inside npc.h.
In one of my code sets that sets prim_melee_type, I do it prior to the npc being instantiated/spawned, it's possible there's an appearance struct packet that needs to be sent.

I didn't look too deep, but just wanted to share my recent experience in this area. Hope it helps.

Uleat
03-08-2016, 05:36 PM
Might have something to do with what 'weapons' the NPC thinks it has equipped too..never messed with this, though.

provocating
03-08-2016, 05:37 PM
Yeah I found out the same thing. I know where my issue is now. When I thought the item was gone, it is not, just the appearance.

provocating
03-09-2016, 09:07 AM
Well it is almost like the title of the topic needs to change now. This has nothing to do with the NPC's attack type, which is 28 and never changed. So I hand an NPC a weapon and then iterate every single item in it's inventory, remove everything from the mob. I verify the mob has no items by iterating through the inventory again. It is still slashing and procing with the item. Even #npcstats shows no items on the mob. I could of course do a change appearance on the mob for the visual effect but that does not solve the issue of the mob procing the item or continuing to slash.

Uleat
03-09-2016, 05:16 PM
I think you're problem probably lies in two places:

skill_type: https://github.com/EQEmu/Server/blob/master/zone/spawn2.cpp#L218

weapons/procs: https://github.com/EQEmu/Server/blob/master/zone/loottables.cpp#L332 - and the surrounding code


NPCs are complex beasts..and most of the code is very old.

provocating
03-09-2016, 05:39 PM
I think you're problem probably lies in two places:

skill_type: https://github.com/EQEmu/Server/blob/master/zone/spawn2.cpp#L218

weapons/procs: https://github.com/EQEmu/Server/blob/master/zone/loottables.cpp#L332 - and the surrounding code


NPCs are complex beasts..and most of the code is very old.


Yep already been up and down those sections. I even remarked out where the procs are added under loottables and the mob still gets procs when handed the items. They are getting the procs from elsewhere, damned if I can find it. This is a bear to figure out so far. If I could find out out how the procs are added I may have a little better chance figuring it out. I have also messed with player states, setting them back to 0.

Uleat
03-09-2016, 06:05 PM
Handing an NPC an item and loading a spawn2 are different..lemme look for that.

(Might also want to check out the quest api..spawns loaded from quest scripts have different handlers as well.)


Try this one for npc trading: https://github.com/EQEmu/Server/blob/master/zone/trading.cpp#L909

Still calls the 'AddLootDrop' function..but, this is another way in.

provocating
03-10-2016, 12:23 PM
Okay I have what I wanted done accomplished. A few things I did not know that I know now. When an NPC's items are added to the loottable at spawn and it can equip them, the procs for the weapons appear to be permanent npc procs, at least they do for me. Second thing I noticed is that you can remove the items all day long and they still slash, you have to change the equipment MainPrimary to force it.... equipment[MainPrimary]=0;

That was my experience.