Hello, I hope everyone on the boards is doing well. Im currently working on a new game and am trying to create a "unique" fighting system. Well atleast i hope its unique lol. Heres how its suppose to work: I have 3 vars such as combotech1, combotech2, and combotech3 in my game you get techs which you can assign to these vars. Now to attack I was going to have it when you click the mob it checks the tech 1 you have set and runs that proc. Here what i have for codes that i've been tryng to get to work.
Code A:
Click(mob/M)
if(M.icon_state=="male")
"[usr.combotech1]")()
Code B:
Click(mob/M)
if(M.icon_state=="male")
run(/mob/proc/"[usr.combotech1]")
I thought having it read the tech and then running that proc would work well for what im doing that way i don't get stuck having to make a ton of combinations codes like this:
Click(mob/M)
if(M.icon_state=="male"&&usr.combotech1=="Punch")
blah blah blah
Some of the errors i recieve with Code A are like this:
shicode.dm:79:text "[]":warning: statement has no effect
Errors from Code B look like so:
shicode.dm:79:error: "[usr.combotech1]": missing comma ',' or right-paren ')'
shicode.dm:79:error: "[usr.combotech1]": expected end of statement
shicode.dm:79:error: expected expression
shicode.dm:79:error: ): expected }
shicode.dm:78:error: location of top-most unmatched {
Well I hope its possible to get this code working and i appreciate those of you who take the time to read this and try to help me thank you.
-Kalzimere
ID:149342
May 18 2002, 4:04 pm
|
|
In response to Semaj
|
|
I thank you for taking your time on trying to help, i tried both your sugestions but got more errors:
Code A errors(new code): shicode.dm:79:error: expected expression shicode.dm:485:error: unbalanced } Code B errors(new code): shicode.dm:158:error:proc :bad constant shicode.dm:79:error::expected assignment I hope the movie was good haven't seen it yet and thanks for trying. -kalzimere |
Is usr.combotech1 a proc or a variable? If it is a proc: usr.combotech1 will execute it.
|
In response to Nova2000
|
|
Well combotech1 is a var. heres a quick over view of whats suppose to happen. lets say theres a verb punch or kick when you click it you are asked where you want it combotech1..2..3 so on. From there i wanted to have it when you click a mob it reads what combotech1 is and runs a proc with that same text. so i figured having "[usr.combotech1]" as a proc would go through and run the correctly matching proc name. I hope that makes sense if it doesn't i can clearify more thanks for the repsonses.
-Kalzimere |
In response to Kalzimere
|
|
You don't happen to have a proc on line 79, that deals with those two lines that are giving you an error with line 79, do you?
Semaj |
In response to Semaj
|
|
Well i showed you lines 79 and 78 i believe and that is this:
"[usr.combotech1]")() and maybe a line above and or below it i hope that helps. -Kalzimere |
In response to Kalzimere
|
|
Kalzimere wrote:
Well i showed you lines 79 and 78 i believe and that is this: Did you ever add the parenthesis at where I'm putting it in the quote... It's marked with ---- like I did it before. Semaj |
What you're looking for is the call() proc, which will call a proc by name. This is exactly what you want.
Lummox JR |
In response to Lummox JR
|
|
Thank you LummoxJR that was exactly wha i needed. The code i have now has no errors but when i try to use it, it doesn't run the proc. Heres the code:
Click(mob/M) if(M.icon_state=="male") call(M,"[usr.combotech1]")(M in oview(1)) lets say combotech1="Punch" so it calls this: Punch(mob/M) attzerocheck() usr.damage = (usr.strength)-(M.defense) M.health -= usr.damage M <<"<font color=red>[usr.name] punches you for [usr.damage]-damage!</font>" usr <<"<font color=blue>You punch [M.name] for [usr.damage]-damage!</font>" But when i go up and click the M with male as icon nothing happens most likely i have some args wrong of some sort i tried having the object as /mob/proc so the code looked like: Click(mob/M) if(M.icon_state=="male") call(/mob/proc,"[usr.combotech1]")(M in oview(1)) but that didn't work either.Any explinations or solutions would be appreciated and thank you again LummoxJR! -kalzimere |
In response to Kalzimere
|
|
Kalzimere wrote:
Thank you LummoxJR that was exactly wha i needed. The code i have now has no errors but when i try to use it, it doesn't run the proc. Heres the code: One problem you're having is with "M in oview(1)". This is valid for restricting a verb's input, but not for calling a proc. In essence, what's happening is that DM sees you using the in operator, and thinks you want to call the proc with an argument that tells whether M is in oview(1). But moreover, this form of Click() is no good to you. Click() doesn't work this way. This proc belongs to the target you click. Thus what you want is something more like this: mob In this Click() proc, the target being clicked is src, and the clicker is usr. Lummox JR |
In response to Lummox JR
|
|
I want to thank you lummoxJR for your help and Nova and Semaj for taking your time to answer my questions. My code is now working. HURRAY!
-Kalzimere |
---- Parenthesis Problem Again
Where the ----'s are is where I think the correction is needed, but then again I might be wrong, I still have a hype after I saw star wars: episode 2 clone wars just 20 minutes ago :). Oh yea, I'm also tired, so I'm probably wrong.
Semaj