ID:162192
 
Okay, for speed and agility, I have a Stat known as Agility Points or (ap) for short. And for Accuracy I have a stat known as Dexterity or (dp) for short.

I was wondering if there was some type of proc that I could create that comes up with an Accuracy and Dodging Rate?
Format:

pick(Val1,Val2,...)

Returns:

One of the given values randomly chosen.

To make a particular value more or less likely to be chosen, a relative probability may be specified like this:
prob(P); Val
Or
P; Val

A value for P of 200 makes it twice as likely as the norm, 50 half as likely, and so on.

Example:
obj/food
verb/eat()
usr << pick (
"[usr] eats \a [src].",
prob(50)
"[usr] devours \a [src].",
prob(25)
"[usr] wolfs down \a [src]."
)
del(src)

In response to Curzon
Wait, so basically I have to use Probabilities? That makes everything much simpler.

Are prob() allowed within Proc's?

Also, do you know how to load images from your desktop to the Dream Maker?
In response to Jamora1124
Yes, and you can upload them at imageshack.us and use html format to impliment them, or if you ment as a icon,
icon='image.format'
icon='Batman.bmp'
icon='Batman.png'
icon='Batman.jpg'
In response to Curzon
Uh, okay, you'll have to explain that to me more later, but back on topic.

Here's my attack verb coding WITH the Prob info you gave me, think it'll work?

        Attack()
for(var/mob/M in get_step(src,src.dir))//If anybody is right next to them...
var/damage = rand(1,stp)
usr << "You attack [M] for [damage] damage!"
M << "[src] hits you doing [damage] damage!"
M.HP -= damage// Takes Hp away.
M.Death()//Calls the Death Proc, which checks if the player is dead.
usr.Check()
var/dodge = prob(usr.ap*5)
usr << "[M] dodges your attack"
M.HP = M.HP


To tell the truth, I'm not too sure about this code, infact, it doesn't work at all. Is there another way to revise it?

But perhaps, if I can do a code with Math like this(dodge= ap/stp), is it possible that it could work?
In response to Jamora1124
    Attack()
for(var/mob/M in get_step(src,src.dir))//If anybody is right next to them...
var/damage = rand(1,stp)
src << "You attack [M] for [damage] damage!"
M << "[src] hits you doing [damage] damage!"
M.HP -= damage// Takes Hp away.
M.Death()//Calls the Death Proc, which checks if the player is dead.
src.Check()
var/dodge = prob(100)
if(dodge > 90)
dodge = 90
if(prob(dodge))
src << "[M] dodges your attack"
In response to Curzon
Yes, that code might work, however, I want someone's dodging and accuracy to be based off of their Agility and Dexterity. For instance, based off of your code, how would I be able to implement this into mine. Here's a shortly revised version of mine.

Attack()
for(var/mob/M in get_step(src,src.dir) var/damage = rand(1,stp)
src << "You attack [M] for [damage] damage!"
M << "[src] hits you doing [damage] damage!"
M.HP -= damage
M.Death()
src.Check()
var/dodge = prob(usr.stp/M.ap = 10)
if(dodge > 7)
dodge = 7
if(prob(dodge))
src << "[M] dodges your attack"


Somethign more of the lines of that. Not exactly that but that's just a rough draft. Think you can lend a hand?
In response to Jamora1124
Attack()
for(var/mob/M in get_step(src,src.dir)
var/damage = src.stp * 0.5 * (src.stp/m.ap) + 1
src << "You attack [M] for [damage] damage!"
M << "[src] hits you doing [damage] damage!"
M.HP -= damage
M.Death()
src.Check()
var/dodge = prob(src.stp/M.ap = 10)
if(dodge > 7)
dodge = 7
if(prob(dodge))
src << "[M] dodges your attack"


Looks good try it out.

In response to Jamora1124
Heres how i would do it
 Attack()
for(var/mob/M in get_step(src,src.dir)
var/dodge=rand(0,M.ap)
var/attack=rand(0,usr.stp)

if(dodge<attack)
src << "You attack [M] for [damage] damage!"
M << "[src] hits you doing [damage] damage!"
M.HP -= damage
M.Death()
src.Check()
else

src << "[M] dodges your attack"

</dm>
In response to Curzon
Curzon wrote:
> Attack()
> for(var/mob/M in get_step(src,src.dir)
> var/damage = src.stp * 0.5 * (src.stp/m.ap) + 1
> src << "You attack [M] for [damage] damage!"
> M << "[src] hits you doing [damage] damage!"
> M.HP -= damage
> M.Death()
> src.Check()
> var/dodge = prob(src.stp/M.ap = 10)
> if(dodge > 7)
> dodge = 7
> if(prob(dodge))
> src << "[M] dodges your attack"
>
>

Looks good try it out.
It actually wont work that one, because unfortunately the damage is dealt before the dodge check is done. The end result would be

You attack Bob for 100 damage!
Bob dodges your attack

See thats an issue :)
In response to Masterdan
I'm watching a movie not paying attention xD
In response to Masterdan
Masterdan wrote:
Heres how i would do it
>  Attack()
> for(var/mob/M in get_step(src,src.dir)
> var/dodge=rand(0,M.ap)
> var/attack=rand(0,usr.stp)
>
> if(dodge<attack)
> src << "You attack [M] for [damage] damage!"
> M << "[src] hits you doing [damage] damage!"
> M.HP -= damage
> M.Death()
> src.Check()
> else
>
> src << "[M] dodges your attack"

</dm>

Wow, this one here worked out perfectly. Thanks alot Masterdan and well, I've seen your work as a programmer and I was wondering if I can be mentored under you?

Here's my MSN: [email protected]
And my email: [email protected]
In response to Jamora1124
Jamora1124 wrote:
Masterdan wrote:
Heres how i would do it
> >  Attack()
> > for(var/mob/M in get_step(src,src.dir)
> > var/dodge=rand(0,M.ap)
> > var/attack=rand(0,usr.stp)
> >
> > if(dodge<attack)
> > src << "You attack [M] for [damage] damage!"
> > M << "[src] hits you doing [damage] damage!"
> > M.HP -= damage
> > M.Death()
> > src.Check()
> > else
> >
> > src << "[M] dodges your attack"

</dm>

Wow, this one here worked out perfectly. Thanks alot Masterdan and well, I've seen your work as a programmer and I was wondering if I can be mentored under you?

Here's my MSN: [email protected]
And my email: [email protected]

I prefer to use my msn for IRL personal contacts, bounce coding questions off me whenever you want at [email protected] though :)
It's called "math."