ID:1621761
 
(See the best response by Kaiochao.)
Code:
Items
Jerky
icon='Items.dmi'
icon_state="Jerky"
density=0
name="Jerky"


Interact()
set src in oview(1)
usr << "You get the [src]!"
Move(usr)
verb
Throw()
usr <<"You throw the Beef Jerky onto the floor."
// How can I get this to distract enemies in the vicinity if thrown onto the floor?
//Basically, I want the option for players to throw it on the floor to distract enemies, or throw at another player and lures enemies towards that player.


Problem description:

My issue is described in the code above. I've been trying for countless hours today to figure out a code that causes the AI (enemies) to be attracted to the beef jerky.

If thrown on the floor, nearby enemies will swarm to it and avoid attacking the player for about thirty seconds, or they can throw it onto another nearby player and cause the enemies to swarm that player and attack them, until the effect wears off in 30 seconds.

Possible?

Best response
It depends on how you set up your AI. If your AI works on a loop to periodically check its surroundings and decide where to move, then you could make them check for nearby beef jerky. Or the beef jerky could broadcast its presence to nearby objects so that they can react to it by moving towards it.

After about 30 seconds, you could either delete the jerky or toggle a flag on it that makes AI stop reacting to it.

It's been done before, so of course it's possible.
In response to Kaiochao
Kaiochao wrote:
It depends on how you set up your AI. If your AI works on a loop to periodically check its surroundings and decide where to move, then you could make them check for nearby beef jerky. Or the beef jerky could broadcast its presence to nearby objects so that they can react to it by moving towards it.

After about 30 seconds, you could either delete the jerky or toggle a flag on it that makes AI stop reacting to it.

It's been done before, so of course it's possible.

So, the AI has a Look() proc. Should I define the beef jerky stuff there?

EDIT: I got it to work. Thanks a bunch.