ID:174360
 
I am really sorry about all these questions I keep asking. I have just started a new type of game, that I have never tried before, so it is ALL new to me :(.

But this is what I have:
mob/proc/Attack()
for(/mob/Units/M in oview(1)
if(M.player != usr.player)
var/damage = usr.Attack - M.Defence
M.Health -= damage
var/damage = M.Attack - usr.Defence
usr.Health -= damage


I get the error :
Fighting.dm:2:error: list started here

But that's not what I am posting about. I want to know how to make it automatically choose the one with the highest Defence, and if there is more than one, the highest Health, and if there is more than one with both these, make it random.

I know it's quite a lot, but I bet it is really simple for some of the experts we have on here! You guys are the best!

~GokuSS4Neo~
Gokuss4neo wrote:
I am really sorry about all these questions I keep asking. I have just started a new type of game, that I have never tried before, so it is ALL new to me :(.

But this is what I have:
> mob/proc/Attack()
> for(/mob/Units/M in oview(1)
> if(M.player != usr.player)
> var/damage = usr.Attack - M.Defence
> M.Health -= damage
> var/damage = M.Attack - usr.Defence
> usr.Health -= damage
>

I get the error :
Fighting.dm:2:error: list started here

But that's not what I am posting about. I want to know how to make it automatically choose the one with the highest Defence, and if there is more than one, the highest Health, and if there is more than one with both these, make it random.

I know it's quite a lot, but I bet it is really simple for some of the experts we have on here! You guys are the best!

~GokuSS4Neo~

i know its not what you wanted, but you left out an extra ) in your for statement at the end.
for(/mob/Units/M in oview(1))
In response to Lazyboy
Thank you anyway!

~GokuSS4Neo~
In response to Gokuss4neo
Gokuss4neo wrote:
Thank you anyway!

~GokuSS4Neo~

with a for() loop that will attack every thing beside it, if you want it to only attack a certain thing make a list and use the pick() on it
In response to Wanabe
Thankz!

~GokuSS4Neo~

P.s. I can probably work out how to do all that after a couple hours, but if anyone can tell me specifically and simply that would be great!
In response to Gokuss4neo
After many, MANY attempts, the best I could do was make it randomly pick someone. And after a few mroe attempts, I lost the code for even that!

Can someone please help me?

~GokuSS4Neo~
In response to Gokuss4neo
Gokuss4neo wrote:
After many, MANY attempts, the best I could do was make it randomly pick someone. And after a few mroe attempts, I lost the code for even that!

Can someone please help me?

~GokuSS4Neo~

                var/list/L = new
var/mob/K=locate() in oview(1,src)
if(K)
for(K in oview(1))
L+=K
var/mob/p = pick(L)
then use 'p' for using stuff (example: p.health-=1)
In response to Wanabe
Thank you!

~GokuSS4Neo~