Checking if an actor has an item is simple with the latest version of trigedit. has_item() can search via vnum or keyword.
Code:
Name: 'Check for treats - 207', VNum: [ 155], RNum: [ 155]
Trigger Intended Assignment: Mobiles
Trigger Type: Greet , Numeric Arg: 100, Arg list: None
Commands:
* By Rumble of The Builder Academy tbamud.com 9091
* My dog is looking if people have some beggin strips.
if %actor.has_item(164)%
wait 1 sec
%send% %actor% %self.name% sits down and stands up on %self.hisher% hind legs, then starts whining pitifully staring at you.
%echoaround% %actor% %self.name% sits down and stands up on %self.hisher% hind legs, then starts whining pitifully staring at %actor.name%.
* Or if they have her rubber chicken.
elseif %actor.has_item(172)%
wait 1 sec
emote sniff %actor.name%
wait 1 sec
growl %actor.name%
%send% %actor% %self.name% tries to get at something you are carrying.
%echoaround% %actor% %self.name% tries to get at something %actor.name% is carrying.
end
On older versions of trigedit you had to do a lot more work. But, it is a good example of how to use a loop to look
through a players inventory, equipment, and containers.
Code:
Name: 'Mob Checks Player Inventory', VNum: [ 32], RNum: [ 32]
Trigger Intended Assignment: Mobiles
Trigger Type: Greet , Numeric Arg: 100, Arg list: None
Commands:
* By Rumble of The Builder Academy tbamud.com 9091
* This trigger has been replaced by the has_item variable. But this is still a
* good example. if %actor.has_item(1300)% does the same thing.
if %actor.eq(wield)%
eval wep %actor.eq(wield)%
if %wep.vnum%==1300
set has_it 1
end
end
* Checks the actors inventory if not wielding it.
if !%has_it%
eval i %actor.inventory%
while %i%
set next %i.next_in_list%
if %i.vnum%==1300
set has_it 1
break
end
* checks inside containers
if %i.type% == CONTAINER
while %i.contents%
if %i.contents.vnum%==1300
set has_it 1
break
end
done
end
set i %next%
done
end
*
if %has_it%
say %actor.name% has that special item.
else
say %actor.name% doesnt have that crappy item.
end
If this was helpful please
vote
or leave a
review
for TBA.