ID:139771
 
Code:
newbattle(mob/personone,monster_statue/ms, init,id)
var/swapmap/zz = SwapMaps_Find(id)
var/list/unspawns = list()
var/list/Participants = list()
var/vv = 0
if(personone.partyname != "")
for(var/mob/m in world)
if(m.partyname == personone.partyname)
vv = 1
m.prebattle_x = m.x
m.prebattle_y = m.y
m.prebattle_z = m.z
while(vv == 1)
m.loc = locate(rand(zz.x1,zz.x2),rand(zz.y1,zz.y2),zz.z1)
if(m.loc in unspawns)
vv = 1
else
vv = 0
unspawns += m.loc
m.inbattle = 1
else
vv = 1
while(vv == 1)
personone.prebattle_x = personone.x
personone.prebattle_y = personone.y
personone.prebattle_z = personone.z
personone.inbattle = 1
personone.loc = locate(rand(zz.x1,zz.x2),rand(zz.y1,zz.y2),zz.z1)
if(personone.loc in unspawns)
vv = 1
else
vv = 0
for(var/I = 1, I <= length(ms.mobs), I++)
var/v = ms.mobs[I]
var/mob/AI/a1 = new v(locate(rand(zz.x1,zz.x2),rand(zz.y1,zz.y2),zz.z1))
vv = 1
while(vv == 1)
if(a1.loc in unspawns)
vv = 1
else
vv = 0
unspawns += a1.loc
var/list/mobs = list()
var/list/plays = list()
for(var/mob/m in world)
if(m.z == src.z)
if(m.client)
plays += m
if(!(m.client))
mobs += m
for(var/mob/m in plays)
Participants += m
for(var/mob/m in mobs)
Participants += m
if(init == 0)
for(var/I=1,I<=length(Participants),I++)
Participants.Swap(rand(1,length(Participants)),I)
src.PlayerBattle = 0
src.participants = Participants
var/mob/first = src.participants[1]
first.turn = 1
spawn() first.IsTurn()
del ms

    
nextturn()
src.DetermineOutcome()
src.current_turn += 1
if(src.current_turn > length(src.participants))
src.current_turn = 1
for(var/mob/m in src.participants)
m.turn = 0
var/mob/m = participants[src.current_turn]
m.turn = 1
m.IsTurn()


Problem description:
Okay, so, when I start a battle with init set to 0, the goblins (when they go first) take their turn. Then, instead of it being my turn, I get a bad client error in Action() and nextturn()
Action:
Action()
var/input = input("Please select an action to do.") in list("Attack", "Spells", "Prepare", "Move", "Pass")
switch(input)
if("Attack")
src.Attack()
if("Spells")
src.PickSpell()
if("Move")
src.Movement()
if("Prepare")
src.SpellPreperation()
if("Pass")
for(var/battle_controller/b in world)
if(b.z == src.z)
b.nextturn()

input() takes a first argument of who to send the input to. If it's not specified, then it defaults to usr.

Don't use usr in procs.
In response to Garthor
Garthor wrote:
input() takes a first argument of who to send the input to. If it's not specified, then it defaults to usr.

Don't use usr in procs.

I'm testing it now. But, why would it work fine if the User goes first, but not if it doesn't?