ID:161028
 
Is this possible?

I want to use a certain damage formula in my game, but I can't figure out how to make a var equal a proc.

Here's the proc:
mob/proc // damage(mob/M in oview(1)) // usr.damage = usr.patk / M.pdef * usr.pdef / M.patk * 8

And here's the verb attempting to use the proc:

mob/verb Attack(mob/M in oview(1)) var/damage = damage() M.HP -= damage usr.levelup() usr.deathcheck()
I know in C# and I think C++ you would have to use the line
return damage


I'm not sure if it would be the same on BYOND though.
In response to Upinflames
Nope, I still get the same error with or without it. =/
The way you're calling the proc will require you to return a value. It'll also require you to specify more information, since the proc, as you defined it, only has access to src, which isn't enough if you want damage to consider the person who is attacking src.

To simplify this, I suggest renaming your proc from damage() into something that makes more sense (and won't conflict with variable names), like calculateDamage().

mob/proc
// return the amount of damage that 'src' will have on 'M'
// let M be the victim
calculateDamage(mob/M)
return src.patk / M.pdef * src.pdef / M.patk * 8
// and of course, we don't use usr in a proc

mob/verb
Attack(mob/M in oview(1))
var/damage = src.calculateDamage(M)
...


If you don't know what return does, I suggest looking it up and reading about it in the DM Guide.
In response to Stereo
So you have:
mob/proc
Damage(mob/M in oview(1))
var/damage = usr.patk / M.pdef * usr.pdef / M.patk * 8
return damage

In response to Upinflames
Thanks a bunch, Unknown.
I can finally work on something other than the Combat system now. xD