ID:176171
 
I need a little help with my code:

mob
verb
Challenge(mob/M in world)
set category = "Misc"
switch(input("Are you sure you wish to challenge [M.name]?","Challenge")in list("Yes","No"))
if("No")
usr << "You decided not to challenge [M.name]."
if("Yes")
switch(input(M,"[usr.name] has challenged you to a fight. Will you accept?","Challenge")in list("Yes","No"))
if("No")
M << "You declined the challenge."
if("Yes")
M << "You have accepted [usr.name]'s challenge!"
usr << "[M.name] has accepted your challenge!"
//here i would call the battle proc


I need to know how to make it so you cannot challenge yourself to a fight. Also, when i tested it sometimes it didn't work right. You would challenge the other guy but you would get every message. Any tips would be greatly appreciated :)
First, you could simply write in:

if(M.name == usr.name)
usr << "You cannot challenge yourself."

Of course, in my challenge code, I have it set so that you challenge the person directly in front of you, but I don't know how your game is set up. As far getting every message, I don't know. The code looks okay to me.
In response to Krosse
see... Im not sure if thats good advice... because if the other persons name is the same as yours you cant challenge them.. Id say
if(M.client == usr.client)
usr<< "you cant challenge yourself!"
return 0
ETG
In response to Erdrickthegreat2
Erdrickthegreat2 wrote:
see... Im not sure if thats good advice... because if the other persons name is the same as yours you cant challenge them.. Id say
if(M.client == usr.client)
usr<< "you cant challenge yourself!"
return 0
ETG

Wouldn't it just make sense to do this?:

if(M == usr)
In response to Skysaw
Yes it would. ;)
In response to tenkuu
cool thnks. Maybe it was my mistake on the getting all the messages. i was using 2 keys to test it and maybe i did it on the wrong window.. although i thought i double checked.
If you're talking of alert and input boxes, there's a not so hidden argument. Look up alert in the help file.
In response to Hazman
Now that we're on the subject of alert boxes, how do you make them disappear (sleep) after a set amount of time so that you don't have to press ok?
In response to KuckiemanJr
KuckiemanJr wrote:
Now that we're on the subject of alert boxes, how do you make them disappear (sleep) after a set amount of time so that you don't have to press ok?

There was a past thread on this about a year ago, so you should do some searching on the forums. Basically the idea is to create a datum for the box, and then delete it after a certain amount of time. That forces the box to go away.

Lummox JR
In response to Lummox JR
There was a slight addition needed beyond what was provided in the thread. But take a look here. But of course you'll have to tailor it to your needs by sending it to the right person. Just pass a parameter to new for the special alert signifying the recipient.
In response to Lummox JR
lol i searched for "alert sleep" and found tons of results so i asked :) oh well i wont use alert boxes than
In response to KuckiemanJr
KuckiemanJr wrote:
lol i searched for "alert sleep" and found tons of results so i asked :) oh well i wont use alert boxes than

Searching under "input timed" I finally found the thread I was looking for: [link]

Lummox JR
In response to Hazman
heh just one more question and i can move on to my battle system :) I need different characters to have different moves in battle. I tried making a list in each mob like this:
mob/human
icon = 'human.dmi'
var/list/fighting = newlist(/mob/proc/punch,/mob/proc/runaway)
mob/alien
icon = 'alien.dmi'
var/list/fighting = newlist(/mob/proc/kick,/mob/proc/runaway)

I just need to make it so that if both players accept the challenge then when they enter the fight, whatever mob they are playing as will get it's attacks. The procs are defined. Im thinking it has something to do with usr.verbs + but i checked the ref and searched the forums and found nothing. Thanks for any and all help in any way, shape or form
In response to KuckiemanJr
You can't really use newlist() in that way, because the lists are supposed to be type paths for objects to be instantiated with new(). Type paths that point to procs won't do you any good here.

Also, you should be declaring var/list/fighting for all mobs, and just changing it for the sub-types.
mob
var/list/fighting

human
...
New()
..()
fighting=list(/mob/proc/punch,/mob/proc/runaway)

alien
...
New()
..()
fighting=list(/mob/proc/kick,/mob/proc/runaway)

Lummox JR
In response to Skysaw
yep =) but M.client == usr.client doesn't cause any thing wrong like M.name == usr.name does.. so its the same as M == usr