ID:148630
 
What ive got here, is a code which checks the mobs in view, and when it finds one, it puts it as Monster, then if it finds another, it puts it as Monster2, and so on. I cant seem to find a way to do this. Can anyone help my partially completed code?


mob/proc/Attack()
var/list/AttackList = new()
var/Monster//Define Monsters
var/Monster2
var/Monster3
var/mob/Defender
for (var/mob/M in view(usr))
if (M.BattleNumber == usr.BattleNumber && M != usr)
AttackList += M
for(var/mob/M1 in view(usr))//Find First monster
Monster = M1
M1.done = 1
for(var/mob/M2 in view(usr))//Second Monster
Monster = M2
M2.done = 1
for(var/mob/M3 in view(usr))//Third Monster
Monster = M3
M3.done = 1
usr.questioned("Attack Who?","[Monster]","[Monster2]","[Monster3]","Cancel")//Add them to a custom made proc!
Instead of using vars named Monster, Monster2, Monster3, etc. can't you just add them to a list?
I'm not sure what exactly you are trying to do. But you add mobs in view to the attack list, then you find three monsters and assign them to three vars. Couldn't you just, when you loop through all mobs in view, check if its a monster, and if so add it to a list of monsters. You could either then change your 'questioned' proc to accept a list, or send the monsters one by one to the proc.
<code> mob/proc/Attack() var/list/AttackList = New/list() var/list/Monsters = new/list() for( var/mob/M as mob in view(src) ) if (M.BattleNumber == usr.BattleNumber && M != src) AttackList += M if(!M.client) Monsters += M src.questioned("Attack Who?","[Monsters[1]]","[Monsters[2]]","[Monsters[3]]","Cance l") </code>
Again, I don't ompletely understand what you are trying to accomplish, but repetitive code, using M1, M2, etc. means that there's probably a better way. I hope that helps.
In response to OneFishDown
Thanks, thats just what im looking for.