PDA

View Full Version : way to check if mob has an item


noudess
08-24-2014, 10:09 AM
Is there a way I can check whether or not a mob has a particular item on it in the .pl file?

When a certain mob dies I want to code up an EVENT_DEATH that checks his drops/possessions and says different things based on what he has.

I think hasitem is only to check PC inventory?

wolfwalkereci
08-24-2014, 12:20 PM
Not sure about this. Quick look at perl_npc.cpp I only see NPC::CountLoot
but that doesn't return item info.
I thought I saw a quest somewhere that did something like this but I cant find it. Any copy I had was probably lost on the last HD failure.

Wonder if Akk or Nate have something like this they could show you.

noudess
08-27-2014, 11:08 AM
It's a silly quest, but the http://www.runen.co.uk/Everquest/Zones/Quests/SQeynos/TabureAhendle2.htm quest calls for this and I was trying to add the finishing touches.

Kingly_Krab
08-27-2014, 03:11 PM
I took a look in perl_npc.cpp, questmgr.cpp, and perl_mob.cpp and couldn't seem to find anything for pulling an item from an NPC's loot. There is NPC::QueryLoot in npc.cpp, but it's only used for #npcstats. It may be possible to write something for Perl that allows you to check for certain items in the NPC's current loot though.

wolfwalkereci
08-27-2014, 04:43 PM
Temporary work around if you only had one or two mobs that you wanted to use this on would be to use perl to assign loot. That way you would have direct knowledge in the quest file of what it has.

noudess
08-27-2014, 05:23 PM
Temporary work around if you only had one or two mobs that you wanted to use this on would be to use perl to assign loot. That way you would have direct knowledge in the quest file of what it has.

Great idea. Simple. Thanks.

noudess
08-28-2014, 01:25 PM
Here is my quest file if you want it.

You'd want to take the blurred map out of this mob's loottables as I roll and assign in the pl file. This is the mob in erudsxing (a_zombie_sailor).

sub EVENT_SPAWN
{
# use entity variable so each instance has his own copy.
# Also because var{$mobid} does not work in EVENT_DEATH
plugin::SEV($npc, "hasmap", 0);

# Check to see if he should have the blurred map. 3.5%
# Assigning loot locally since I can't find a way to see if he has
# one if I let the loottables do this.
$roll=plugin::RandomRange(1,200);
if ($roll <= 7)
{
quest::addloot(13423, 1, 0); #Blurred Map
plugin::SEV($npc, "hasmap", 1);
}
}

sub EVENT_COMBAT
{
# Talkative when he enters combat IF he has the map.
$myhasmap=plugin::REV($npc, "hasmap");
if ($myhasmap && $combat_state == 1)
{
quest::say("Join.. Glug.. Tombor in his.. watery grave!!");
$classplural = "${class}s";
quest::say("$classplural like you always bring out the worst in me.");
}
}

sub EVENT_DEATH
{
# Talkative when he dies IF he has the map.
$myhasmap=plugin::REV($npc, "hasmap");
if ($myhasmap)
{
quest::say("My map!! You have my.. map.");
}
}