Using part of Wall04's selection demo, my own coding, and some help from others I put this together:
client
MouseDown(A,B)
src.Draw_Grid(A,A) // if nothing is selected.. draw the grid
return ..()
Click(A,B)
for(var/mob/Unit/M in Select)
if(M.player == usr.name)
if(length(Select)>1)
walk_to(M,B,1,3)
M.Attack()
else
walk_to(M,B,0,3)
Select -= M
for(var/I in src.imageslist)
del(I)
..()
mob/proc/Attack()
var/list/L = new
var/mob/K=locate() in oview(1,src)
if(K)
for(K in oview(1))
L+=K
var/mob/M = pick(L)
if(M.colour != usr.colour)
var/damage = usr.Attack - M.Defence
if(damage<=1)
M.Health -= 1
damage = 1
else
M.Health -= damage
view(6)<<"[usr] attack [M] for [damage] damage!"
var/damage2 = M.Attack - usr.Defence
if(damage2<=1)
M.Health -= 1
damage2 = 1
else
M.Health -= damage2
view(6)<<"[M] attack [usr] for [damage2] damage!"
Death()
Death()
mob/proc/Death()
if(src.Health <= 0)
if(!src.client)
view(6)<<"[src] has been killed!"
(src.player)<<"You have lost [src]!"
del(src)
else
src<<"You have been defeated!"
src<<"All your building are now destroyed!"
src<<"And all your men lay dead!"
for(var/mob/M in world)
if(M.player == src.name)
spawn()
del(M)
for(var/obj/O in world)
if(O.name != "Town Center")
if(O.player == src.name)
spawn()
del(O)
world<<"[src] has been defeated!"
alert("Please Wait!")
sleep(170)
src.Health = 1000
src.MaxHealth = 1000
src.Attack = 25
src.Defence = 25
src.Mesatta = 1500
src.Wood = 1200
src.Player = 1
world<<"[src] has started again!"
src<<"<B>You are back</B>!"
The selecting, and moving works fine, but the Attack bit doesn't!
If I want the Attack proc to "activate" I have to click on the mob I want to attack, then the mob I want to attack with, then I get this error:
runtime error: list index out of bounds
proc name: Attack (/mob/proc/Attack)
usr: Goku (/mob)
src: Peasant (/mob/Unit/Peasant)
call stack:
Peasant (/mob/Unit/Peasant): Attack()
Romkabant (/client): Click(Peasant (/mob/Unit/Peasant), Grass (46,16,1) (/turf/Grass))
So how can I get it so than once I have selected my men, and clicked on the thing I want to attack, they Attack it? And preferably until either they, or it die!
~GokuSS4Neo~
P.s. Sorry for the long post, and thank you for your time!
Lummox JR