ID:150050
 
I was wondering how i could make a list of mobs in view, who are loyal and not others, then having a mob be able to chose from that list.

example

mob/verb/Attack()
var/unloyal[] = newlist()
var/mob/monster/A
for(A in oview())
if(A.loyal != usr.key)
unloyal += A
else
return ..()
var/M = input("attack who?") in unloyal
M.life -= 10
M.death()


I did that but that doesnt seem to work.. any suggestions?
SonVegitto wrote:
I was wondering how i could make a list of mobs in view, who are loyal and not others, then having a mob be able to chose from that list.

example


mob/verb/Attack()
var/unloyal[] = newlist()
var/mob/monster/A
for(A in oview())
if(A.loyal != usr.key)
unloyal += A
else
<font color=cyan>return ..()</font>
var/M = input("attack who?") in unloyal
M.life -= 10
M.death()


I did that but that doesnt seem to work.. any suggestions?

With the highlighted return statement, this code stops and returns as soon as it encounters a loyal person. Is that what you want?
mob/var/loyal
mob/New()
src.loyal = rand(0,1)
proc/UnLoyals()
var/UnLoyals = list()
for(var/mob/M in view(world.view,usr))
if(!M.loyal)
UnLoyals += src
return UnLoyals
mob/verb/AttackUnloyal()
set name = "Attack unloyals in your view"
for(var/mob/M in UnLoyals())
del(M)


I think that would work. Try it out.
In response to Lord of Water
Lord of Water wrote:
if(!M.loyal)
UnLoyals += src

Two problems: You're using the loyal var as a boolean, whereas SonVegitto compares it to the attacker's key. Also, you've got +=src instead of +=M; src in this case would be the attacker. Thus the attacker would always attack himself, if any potential targets were available.

Lummox JR