ID:1117298
 
(See the best response by Jemai1.)
proc/newturnstwo()
var/counter=0
for(var/mob/m in view(10))
counter+=1
if(m.partyleader==TRUE && m.newwturn<counter)
m.newwturn+=1
world << m.newwturn
world << counter
break
else if(m.partyleader==TRUE && m.newwturn>=counter)
m.newwturn=1
world << m.newwturn
world << counter
return


Problem description: EDIT: I fixed a problem on here but I have another problem. The for(var/mob/m in view(10)) doesn't see the mobs there and so the counter doesn't go above 1, why?
view() takes two arguments: the distance, and the center object. By default, view() uses usr as the center object, but since newturnstwo() looks to be a global procedure, usr isn't valid so no center object is present. You need to supply some sort of center object in order for it to find things in view.

Another note: You don't need to do m.partyleader==TRUE, you can just do if(m.partyleader && etc).

Oh, and for() isn't an operator. It's a statement. ;)
What kind of an object should I supply and how should I do it?
In response to TheDarkChakra
How is newturnstwo() called? What calls it?
Move() proc is the first one to call it
In response to TheDarkChakra
You could specify Move()'s src as the center object for newturnstwo(). You'd just give newturnstwo() an argument and supply src.
I did that and it didn't work unless I misunderstood you. Under Move() in the parenthesis of newturnstwo() I wrote src and in the proc newturnstwo() inside the parenthesis I wrote mob/M and put it as an argument in view() but it didn't work.
F1 and look up view()
In response to Yusuke13
I did and it didn't help
Show the code for Move() and newturnstwo() please.
mob/Move()
if(src.inbattle)//this stops the movement of people on the team
return
else if(usr in usr.allies)
..()
var/tmp/turf/Grass/c=locate(/turf/Grass)
if(c.Enter(src))
if(prob(3) && src.partyleader==TRUE)
usr.prevloc=src.loc // remember previous location if you were to choose run
if(prob(50))
if(usr.allies.len>0)//makes sure there is someone in the party greater than the number written so it won't give an error
var/mob/x=usr.allies[1]
x.loc=locate(12,6,1)
x.inbattle=1
if(usr.allies.len>1)
var/mob/y=usr.allies[2]
y.loc=locate(12,3,1)
y.inbattle=1
if(usr.allies.len>2)
var/mob/z=usr.allies[3]
z.loc=locate(11,9,1)
z.inbattle=1
else
if(usr.allies.len>0)
var/mob/x=usr.allies[1]
x.loc=locate(70,10,1)
x.inbattle=1
if(usr.allies.len>1)
var/mob/y=usr.allies[2]
y.loc=locate(70,5,1)
y.inbattle=1
if(usr.allies.len>2)
var/mob/z=usr.allies[3]
z.loc=locate(70,1,1)
z.inbattle=1
for(var/mob/m in view(10))//add all mobs to a list, check if it exists to not double add them and assign each mob in the list a turn
if(!usr.totallist.Find(m))
usr.totallist.Add(m)
if(usr.totallist.len>0)
var/mob/first=usr.totallist[1]
first.turn=1
if(usr.totallist.len>1)
var/mob/second=usr.totallist[2]
second.turn=2
if(usr.totallist.len>2)
var/mob/third=usr.totallist[3]
third.turn=3
if(usr.totallist.len>3)
var/mob/fourth=usr.totallist[4]
fourth.turn=4
if(usr.totallist.len>4)
var/mob/fifth=usr.totallist[5]
fifth.turn=5
if(usr.totallist.len>5)
var/mob/sixth=usr.totallist[6]
sixth.turn=6
for(var/mob/enemy/en in view(10))
if(!usr.enemies.Find(en))
usr.enemies.Add(en)
newturnstwo(src)
else
..()

proc/newturnstwo(mob/M)
var/counter=0
for(var/mob/m in view(10,M))
counter+=1
if(m.partyleader==TRUE && m.newwturn<counter)
m.newwturn+=1
world << m.newwturn
world << counter
break
else if(m.partyleader==TRUE && m.newwturn>=counter)
m.newwturn=1
world << m.newwturn
world << counter
return
In response to TheDarkChakra
You really shouldn't be using both src and usr in Move().

Is newturnstwo() actually being called?
In response to LordAndrew
Yes.
In response to TheDarkChakra
Is the line for(var/mob/m in view(10,M)) finding anything? You could try adding world << m directly after it to see if it outputs anything.

As an aside, your system is extremely rigid and you're hardcoding every value. A datum would be better suited to handle all of this information.
world << m outputs me
In response to TheDarkChakra
Are there other mobs present that would be detected in view()? What exactly is the issue you're experiencing?
Yes there are other mobs around me but view() doesn't pick them up
In response to TheDarkChakra
Are the lines world << m.newwturn and world << counter outputting anything? If so, your procedure hitting the break/return statements, which will end the for() call immediately. This would explain why its only seeing one mob and nothing else.
I deleted break and return statements but world << m.newwturn and world << counter still both output 1.
What is the newturnstwo proc supposed to do?
Page: 1 2