ID:825408
 
(See the best response by Alathon.)
Code:
    punch
name = "punch"
desc = "Unleashes an melee attack"
template = "punch high or low, mob in view"
category = "combat"
alias = list("p")
function(adverb, mob/M)
if("high")
mb_msgout("<font color=red><b>You bring back your fist and prepare to attack [M.Name]!</font>")
M << mb_msgout("<font color=red><b>[usr.Name] brings back their fist!</font>")
mb_msgout("<font color=red><b>[usr.Name] bring back their fist and prepare to attack [M.Name]!</font>",view())
var/damage = round(usr.PowerLevel - M.PowerLevel + M.PowerLevel / 16)
sleep(15)
if(damage < 1) damage = round(usr.PowerLevel / 50) //checks if user has too low of damage
if(M.IsParryHigh == 1) damage = 0
if(M.IsParryHigh == 1) M.BlockedYes = 1
M.PowerLevel -= damage
mb_msgout("<font color=red><b>[usr.Name] has punched you for <font color=lime>[jru_Commafy(damage)]</font><font color=red><b>!</font>",view())
M.Death() // checks if victim powerlevel is below 0 to determine death
if("low")
mb_msgout("<font color=red><b>You bring back your fist and prepare to attack [M.Name]!</font>")
M << mb_msgout("<font color=red><b>[usr.Name] brings back their fist!</font>")
mb_msgout("<font color=red><b>[usr.Name] bring back their fist and prepare to attack [M.Name]!</font>",view())
var/damage = round(usr.PowerLevel - M.PowerLevel + M.PowerLevel / 16)
sleep(15)
if(damage < 1) damage = round(usr.PowerLevel / 50) //checks if user has too low of damage
if(M.IsParryLow == 1) damage = 0
if(M.IsParryLow == 1) M.BlockedYes = 1
M.PowerLevel -= damage
mb_msgout("<font color=red><b>[usr.Name] has punched you for <font color=lime>[jru_Commafy(damage)]</font><font color=red><b>!</font>",view())
M.Death() // checks if victim powerlevel is below 0 to determine death
else
return mb_msgout("What?")


Problem description:

Command works but not against mobs/players it just prints out
Usage: punch high or low [target]

any ideas D:?
You can try something like this:
punch(var/atom/A in get_step(src,src.dir))
if(ismob(A)
var/mob/M=A //Then you can do this so that you dont have to change all the M's in your code.
i forgot to mention this is for telnet clients not byond.
Best response
One thing that immediately stands out to me is that those if() statements are always true. I believe you probably meant if(adverb == "high") and if(adverb == "low").

I don't know Ebonshadow's parser very well, but if its failing to match the argument to the template 'mob in view', I suggest experimenting a little. Try using some of the demo commands he has and see if they work in the game, for example.

I can heartily suggest AbyssDragon's Parser, and if you need help with it I should probably still be able to find my way around it. Its a good deal more flexible, if slightly more complicated. If you do decide to give it a try, note that there's a small bug with number-arguments that AbyssDragon never fixed. Let me know if you give it a whirl here, and I'll dig the code and related fix (Its a single line) up for you :)
Alright thanks Alathon you're so helpful ill give it a try here in a bit.
Alright so im trying out his but uhm where is the bug located ;o
In response to Gokussj99
If I remember right, change line #248 in Parser.dm to be:

cont = (!temp_list || temp_list.Find(match) || List == "world")
Alright well so far that should be fixed i hope but now its not parsing commands at all T.T

var/Parser/Parser = new

client/Command(cmd)
Parser.Parse(cmd, mob)
command_prompt=mb_msgout("<[usr.ClassColor]Energy : [jru_Commafy(usr.Energy)]% - Power Level : [jru_Commafy(usr.PowerLevel)] / [jru_Commafy(usr.MaxPowerLevel)][usr.Reset]>")
In response to Gokussj99
Gokussj99 wrote:
Alright well so far that should be fixed i hope but now its not parsing commands at all T.T

>
> var/Parser/Parser = new
>
> client/Command(cmd)
> Parser.Parse(cmd, mob)
> command_prompt=mb_msgout("<[usr.ClassColor]Energy : [jru_Commafy(usr.Energy)]% - Power Level : [jru_Commafy(usr.PowerLevel)] / [jru_Commafy(usr.MaxPowerLevel)][usr.Reset]>")
>
>
>


You'll need to be a bit more specific here :) How is it not parsing commands? What commands do you currently have?
Command
say
format = "'say'; text"
priority = 1
Process(mob/user, T)
world << "[user.name]: [T]"

straight from his readme to test doesnt work.
In response to Gokussj99
Command
say
format = "'say'; text"
priority = 1
Process(mob/user, T)
world << "[user.name]: [T]"

var/Parser/parser = new()
client/Command(T) {
src << T
parser.Parse(T, mob)
}


This in a project by itself works. Do keep in mind that the 'text' argument in AbyssDragon.Parser must be surrounded by "'s. You probably want:

format = "'say'; anything"

Anything will basically swallow all text from that token and onwards.
In response to Alathon
Alathon wrote:
> Command
> say
> format = "'say'; text"
> priority = 1
> Process(mob/user, T)
> world << "[user.name]: [T]"
>
> var/Parser/parser = new()
> client/Command(T) {
> src << T
> parser.Parse(T, mob)
> }
>

This in a project by itself works. Do keep in mind that the 'text' argument in AbyssDragon.Parser must be surrounded by "'s. You probably want:

format = "'say'; anything"

Anything will basically swallow all text from that token and onwards.

yeah it seems that the client command is working fine but abyssdragons parser isnt parsing anything. hmm
In response to Gokussj99
If it doesn't parse anything, there is no command matching the input given. With your Command, try typing: say "Hello"

Typing say Hello won't work, because text arguments expect " to surround the text. The alternative is to do as I mentioned, and use format = "'say'; anything" instead.
okay i got that to work but um how would i make it so that commands with no text work like "look" because i have to include a space when i try that >.<

or who commands like that lol.
In response to Gokussj99
Gokussj99 wrote:
okay i got that to work but um how would i make it so that commands with no text or arguments work like "look" because i have to include a space when i try that >.<

Not as far as I can tell??

Command
look
format = "'look'"
priority = 1
Process(mob/user)
world << "Looked"


Works just fine without a space.
Alright i got it working thanks yeah i think this parser should work a lot better ^_^

Thanks so much for your help.
http://forbiddenduel.net/progress.html working good ^_^

i just now have to figure out how to add some sort of combat with that lol im new to creating muds T.T
In response to Gokussj99
Cool! Looking forward to seeing what you end up doing :)
EDIT: nevermind i figured it out ^_^
Another problem the ignorecase in the parser doesnt seem to be working correctly :/ it is apparently case sensitive and just throws errors if not typed correctly D: hmm!