ID:180552
 

just wondering how to do a basic trigger for text seen by the NPC like if the NPC sees says: xenomorph oxidation compleate the NPC will say "GET THE HELL AWAY FROM THAT!" and attack the mob who said it.. (becase that mob would have to be in view... i guess. ok i know how to target mobs i just dont know how to make it triggered by text and not vars or procs... is there any way to do this? could you give me an example?
On 5/19/01 1:30 pm jobe wrote:
just wondering how to do a basic trigger for text seen by the NPC like if the NPC sees says: xenomorph oxidation compleate the NPC will say "GET THE HELL AWAY FROM THAT!" and attack the mob who said it.. (becase that mob would have to be in view... i guess. ok i know how to target mobs i just dont know how to make it triggered by text and not vars or procs... is there any way to do this? could you give me an example?


noone knows?
In response to jobe
On 5/20/01 8:37 am jobe wrote:
On 5/19/01 1:30 pm jobe wrote:
just wondering how to do a basic trigger for text seen by the NPC like if the NPC sees says: xenomorph oxidation compleate the NPC will say "GET THE HELL AWAY FROM THAT!" and attack the mob who said it.. (becase that mob would have to be in view... i guess. ok i know how to target mobs i just dont know how to make it triggered by text and not vars or procs... is there any way to do this? could you give me an example?


noone knows?

I started to reply but couldn't finish.

You can't have an NPC directly intercept text sent through the << approach, such as

view(src) << "What I'm saying"

Perhaps you should be able to, but you can't. So you have to add your own thing to let NPCs know what is said, which can be done in many ways. One would be like this:

mob/verb/say(msg as text)
for (var/mob/listener in view(src))
if (listener.client)
// This is a player.
listener << "[src] says: [msg]"
else
// This is an NPC.
listener.ProcessStatement(msg)

mob/proc/ProcessStatement(msg)
if (msg == "Want a date?")
say("Get out of my face!)
In response to Deadron

mob/verb/say(msg as text)
for (var/mob/listener in view(src))
if (listener.client)
// This is a player.
listener << "[src] says: [msg]"
else
// This is an NPC.
listener.ProcessStatement(msg)

mob/proc/ProcessStatement(msg)
if (msg == "Want a date?")
say("Get out of my face!)

Is there any way to have the ProcessStatement(msg) thing detect whether certain words are in the msg?
In response to Foomer
On 5/20/01 12:11 pm Foomer wrote:
Is there any way to have the ProcessStatement(msg) thing detect whether certain words are in the msg?

Yep. Check out findText() and findtext() in the reference link to the left.
In response to jobe
On 5/20/01 8:37 am jobe wrote:
On 5/19/01 1:30 pm jobe wrote:
just wondering how to do a basic trigger for text seen by the NPC like if the NPC sees says: xenomorph oxidation compleate the NPC will say "GET THE HELL AWAY FROM THAT!" and attack the mob who said it.. (becase that mob would have to be in view... i guess. ok i know how to target mobs i just dont know how to make it triggered by text and not vars or procs... is there any way to do this? could you give me an example?


noone knows?

I have some code that MadhatZero made a LOOOOOONG time ago, but it is still relevant... will upload.