ID:146383
 
Code:
battlestart(mob/A,mob/B,mob/C,mob/D,mob/E,mob/F,mob/G,mob/H,mob/I,mob/J,mob/K,mob/L)
var/list/playerlist = list(A,B,C,D,E,F,G,H,I,J,K,L)
for(var/mob/M in playerlist)
if(M == null)
playerlist -= M
queue(playerlist,A,B,C,D,E,F,G,H,I,J,K,L)

queue(list/playerlist,mob/A,mob/B,mob/C,mob/D,mob/E,mob/F,mob/G,mob/H,mob/I,mob/J,mob/K,mob/L)
var/mob/fastest = playerlist[1]
if(playerlist.len > 1)
for(var/mob/M in playerlist)
if(M.agl>fastest.agl) //<--Line 609//
fastest=M
if(fastest.key)
fastest.battleprompt(A,B,C,D,E,F,G,H,I,K,J,K,L)
else
fastest.monbattleprompt(A,B,C,D,E,F,G,H,I,K,J,K,L)
playerlist -= fastest
if(playerlist.len == 0)
if(hpcheck(A,B,C,D,E,F,G,H,I,K,J,K,L))
spawn()
battlestart(A,B,C,D,E,F,G,H,I,J,K,L)
else
if(hpcheck(A,B,C,D,E,F,G,H,I,K,J,K,L))
spawn()
queue(playerlist,A,B,C,D,E,F,G,H,I,J,K,L)

battleprompt(mob/A,mob/B,mob/C,mob/D,mob/E,mob/F,mob/G,mob/H,mob/I,mob/J,mob/K,mob/L)
if(src.hp > 0)
var/attack = input(src,"What would you like to do?")in list("Attack","Spell","Item","Run")
if(attack == "Attack")
var/list/targets = list()
if(E != null)
targets += E
if(F != null)
targets += F
if(G != null)
targets += G
if(H != null)
targets += H
if(I != null)
targets += I
if(J != null)
targets += J
if(K != null)
targets += K
if(L != null)
targets += L
for(var/mob/M in targets)
if(M.hp <= 0)
targets -= M
if(targets.len == 0)
return
var/mob/target = input(src,"Attack who?")in targets//list(E,F,G,H,I,J,K,L)
var/damage = round((src.batatk-target.def)/2)
damage += rand(round(damage/100),-1*round(damage/100))
damage += rand(1,-1)
if(damage < 1)
var/superrandomnumber = rand(1,3)
if(superrandomnumber == 1)
damage = 1
if(src.chargeup == 1)
src.batatk = src.batatk/2
src.chargeup = 0
A << "[src] attacks!"
B << "[src] attacks!"
C << "[src] attacks!"
D << "[src] attacks!"
sleep(10)
var/randnum = rand(1,100)
if(randnum >= 97)
A << "[src] misses [target]"
B << "[src] misses [target]"
C << "[src] misses [target]"
D << "[src] misses [target]"
else
randnum = rand(1,100)
if(randnum > 95)
A << "Critical hit!"
B << "Critical hit!"
C << "Critical hit!"
D << "Critical hit!"
sleep(10)
damage = src.batatk+rand(-2,2)
if(damage > 0)
A << "[src] does [damage] damage to [target]!"
B << "[src] does [damage] damage to [target]!"
C << "[src] does [damage] damage to [target]!"
D << "[src] does [damage] damage to [target]!"
target.hp -= damage
if(target.hp <= 0)
target.hp = 0
target.invisibility = 1
if(damage <= 0)
A << "[src] fails to damage [target]!"
B << "[src] fails to damage [target]!"
C << "[src] fails to damage [target]!"
D << "[src] fails to damage [target]!"

//Attacking is the only available command so I haven't tried anything below this =P//


Problem description:
runtime error: Cannot read null.agl
proc name: queue (/mob/proc/queue)
source file: Complex Procs.dm,609
usr: Cowdude (/mob/player)
src: Cowdude (/mob/player)
call stack:
Cowdude (/mob/player): queue(/list (/list), Cowdude (/mob/player), Cowdude2 (/mob/player), null, null, the stagbeetle A (/mob/monsters/stagbeetle), Slime B (/mob/monsters/Slime), Red Slime C (/mob/monsters/Red_Slime), Slime D (/mob/monsters/Slime), null, null, null, null)
Cowdude (/mob/player): queue(/list (/list), Cowdude (/mob/player), Cowdude2 (/mob/player), null, null, the stagbeetle A (/mob/monsters/stagbeetle), Slime B (/mob/monsters/Slime), Red Slime C (/mob/monsters/Red_Slime), Slime D (/mob/monsters/Slime), null, null, null, null)

In the above code, A, B, C, D are players, and E->L are monsters (4 players, 8 monsters).

There is a proc before this btw, but it probably has nothing wrong.

This runtime error occurs when the slowest of A, B, C, and D attack (I've only tested this with two people in a party though; Byond 3.5 makes it hard to multikey =P)

If I think of anything else regaurding this I'll edit or something
You're still way off base by using that many arguments when clearly a list would be a much better way to go. Why are you sending up to 12 mobs when you should be using a list?

Lummox JR
In response to Lummox JR
That's just the way I had set it up in the beginning so I stuck with it. I do need to change the parts like

                        A << "[src] fails to damage [target]!"
B << "[src] fails to damage [target]!"
C << "[src] fails to damage [target]!"
D << "[src] fails to damage [target]!"


to "for(var/mob/M in A.party" so that's shortened though
In response to Cowdude
Cowdude wrote:
That's just the way I had set it up in the beginning so I stuck with it.

No you're not. Changing it is about the only hope you have of debugging this mess. This code is beyond salvaging in its current state.

Lummox JR
In response to Lummox JR
First of all I did find out what was wrong before; I just needed to move something.

Second, this is what's happening now:

The battle will FINALLY get through an entire round ^^

However, there's a problem: it won't loop to do another round =P

The playerlist var SHOULD be empty (look at the code at the beginning of the thread if you haven't yet to get an idea of what it looks like; all that's changed is the beginning is now like this:)

        var/mob/fastest
if(playerlist.len > 1)
for(var/mob/M in playerlist)
if(fastest == null)
fastest = M
else if(M.agl>fastest.agl)
fastest = M


That shouldn't matter too much, but oh well.

I'm certain that I posted the "battlestart()" proc in my first post, but the part from that I wanna remind you of is that it takes the null monsters/players out of "partylist", so the list isn't full of nulls (I'm not sure if you can add nulls to a list o_O oh well that's irrelevant to this)



Okay now that I typed a lengthy post accusing my "if(playerlist.len == 0)" line of not working, I found the REAL problem; so I deleted some of the above post and here's my new idea.

I threw in some checks to tell me what all is in the "Playerlist" var at the end of each combatant's turn. Here's what it turned up once:
~~~~~~~~~~~~~~~~~~~~~
Playerlist contains:
Cowdude



The stagbeetle B
Slime C
The stagbeetle D
Slime E
The stagbeetle G
Red Slime H
~~~~~~~~~~~~~~~~~~~~~
Three nulls where players 2, 3, and 4 are (aka B, C, and D in the code); so for some reason my Battlestart proc didn't remove them from the list... why would that be?

(Just for a bit of fun, I'll post the runtime error I get:)
runtime error: Cannot read null.key
proc name: queue (/mob/proc/queue)
source file: Complex Procs.dm,666

Line 666. Go figure XD
In response to Cowdude
talk to the person with the key Mega zero.. he is great at this stuff!
In response to Against_The_Odds
actually I figured this out already. At the part where I take out all the null'ed mobs from the list I used "for(var/mob/M" and I needed to change it to "for(var/M"

If something is null, it can't rightly be a mob, now can it? =P