ID:170544
 
I've been having trouble coming up with a good double click command. I want it so the person can double click a mob of a NPC and the NPC talks with that I told it to responde with. Any suggestions on a easy version of this.
mob/monster
var/speak
var/mob/owner
DblClick()
if(!src.owner==usr)
usr << "[src] says [src.speak]!"
else
usr.monster.speak = input("What would you like your monster to say"?)as text
usr << "You set your monster's text to [src.monster.speak]."

mob/verb/createmonster()
new var/mob/monster/M (src.loc) //This may not work, I suck at new commands
M.owner = src



[edit]There, try that
:p
Remember, it's okay to use "usr" since it's a click proc.
[edit]OOOOOHHH...
one sec, let me fix this
Here's a basic structure of NPC dialogue:

mob/NPC

var/dialogue

DblClick()
if(src.dialogue)
usr << "[src.dialogue]"


And an example:

mob/NPC/Cow
icon='Cow.dmi'
dialogue="Moo"


Now, when a player clicks on a cow, he will get "Moo"ed.

Depending on the complexity of your game, you probably would want a proc instead:

mob/NPC

var/dialogue

DblClick()
Dialogue(usr)

proc
Dialogue(mob/Player/target)
.=..()


And an example:

mob/NPC/Cow
icon='Cow.dmi'

Dialogue(mob/Player/target)
target << "Moo"


Although the latter may seem more cumbersome due to its slightly longer length, it's probably the better way. That way, if you want anything to happen when a player enters into a conversation with an NPC, it's much easier.

For example, if you wanted a player to be able to buy from a shopkeeper by double clicking on it:

mob/NPC/Shopkeeper

icon='shopeeeper.dmi'

Dialogue(mob/Player/target)
src.Sell(target)

proc

//Generate a list of things to sell
//From the shopkeeper's contents
Generate_toSell()

var/list/toSell=list()

for(var/obj/Inventory/S in src.contents)
toSell[S]=S.price

return toSell

//Actually sell the stuff
Sell(mob/Player/consumer)

if(!istype(consumer))
return

var/list
toSell=Generate_toSell()
interface=list()

for(var/obj/Inventory/S in toSell)
interface["[S.name] - [S.price]"]=S

var/obj/Inventory/buy=input(consumer,"What would you like to buy?","Buy")\
as null|anything in interface

if(!buy||consumer.gold<buy.price)
return

consumer.contents+=buy
consumer.gold-=buy.price
In response to Wizkidd0123
_>
He asked a question on DWSoE(Shadows of Erdrick), and it was basically another system.
_>
I think mine answers his question
In response to Hell Ramen
Hell Ramen wrote:
_>
He asked a question on DWSoE(Shadows of Erdrick), and it was basically another system.
_>
I think mine answers his question

I didn't actually see your post. I was busy writing the shopkeeper code =P.
In response to Wizkidd0123
Wizkidd0123 wrote:
Hell Ramen wrote:
_>
He asked a question on DWSoE(Shadows of Erdrick), and it was basically another system.
_>
I think mine answers his question

I didn't actually see your post. I was busy writing the shopkeeper code =P.

I know. :p
Your's was more wide-ranged, and better for other things. :p
I just had a bit better knowledge of what he wanted.
In response to Hell Ramen
Actually, I want the NPC to talk with what I coded it to say. Not input what I want it to say.
In response to SpeyMan
mob/Help
DblClick()
usr << "Bot: Hello [usr] I am the Helper Bot."

Does that help?
In response to SpeyMan
And what/how did you code what you wanted it to say?
In response to DeathAwaitsU
Just change set the speach var for each mob. =/
mob/monster
nub
speach = "plz giv itamz"