mob
proc
Damage()
//Rest of the proc, which works fine if I remove this bit. Will provide if necessary.
if(prob(100/15))
var/done = 0
var/injuryraffle = rand(1,100)
if(prob(80))
for(var/obj/Bodypart/Arm/C in B)
if(prob(50) && !done && C.equipped) // Want to choose one arm at random, only 1 arm, and be sure it isn't some random OTHER arm you've picked up. Gotta be your own actual arm.
if(injuryraffle <= 80)
C.Light += 1
C.Injuries += 1
if(!C.Recovering) // Want to avoid having the same proc running multiple times.
C.Recovering = 1
C.InjurySystem()
if(injuryraffle > 80 && injuryraffle <= 95)
C.Medium += 1
C.Injuries += 1
if(!C.Recovering)
C.Recovering = 1
C.InjurySystem()
if(injuryraffle > 95 && injuryraffle <= 99)
C.Heavy += 1
C.Injuries += 1
if(!C.Recovering)
C.Recovering = 1
C.InjurySystem()
if(injuryraffle == 100)
C.Critical += 1
C.Injuries += 1
if(!C.Recovering)
C.Recovering = 1
C.InjurySystem()
done = 1
else
for(var/obj/Bodypart/Torso/C in B)
if(C.equipped)
if(injuryraffle <= 80)
C.Light += 1
C.Injuries += 1
if(!C.Recovering)
C.Recovering = 1
C.InjurySystem()
if(injuryraffle > 80 && injuryraffle <= 95)
C.Medium += 1
C.Injuries += 1
if(!C.Recovering)
C.Recovering = 1
C.InjurySystem()
if(injuryraffle > 95 && injuryraffle <= 99)
C.Heavy += 1
C.Injuries += 1
if(!C.Recovering)
C.Recovering = 1
C.InjurySystem()
if(injuryraffle == 100)
C.Critical += 1
C.Injuries += 1
if(!C.Recovering)
C.Recovering = 1
C.InjurySystem()
DeathCheck()
obj
Bodypart
proc
InjurySystem()
while(Recovering)
if(Light) LightRecovery += rand(2,3)
if(LightRecovery >= 100)
Light -= 1
Injuries -= 1
LightRecovery = 0
if(Fatal)
if(prob(10)) FatalMagnitude += 1
var/damage = (Light + (Medium * 3) + (Heavy * 5) + (Critical * 30) + (Fatal * FatalMagnitude))
condition = 100 - damage
if(condition < 0) condition = 0
if(condition == 0)
Recovering = 0
Destruction()
if(Injuries == 0) Recovering = 0
sleep(50)
Destruction()
usr << "Oops." // Gonna finish this up later.
Problem description:
I have a perfectly functioning combat system, prior to adding this in. The problem is that after adding this in, mobs will freeze in place after dealing 1 injury to the player. I've done some testing and it seems like whatever the problem is has to do with what I'm sharing here. I could be wrong though, and will provide other possibly relevant pieces of code if nobody can help me with what I've already provided.
It's called in Damage() which I assume happens once before InjurySystem() is called and it becomes locked waiting for that while to finish.
[edit] A fast way to see if this is the case is to remove the sleep() in the while loop and if your game freezes up you know the issue lol.
[2nd edit] something I'm curious about is that you're looping through bodyparts inside of B is that a variable defined for the mobs? Just curious lol.
[3rd edit] Here's another way you can write it too, just to help.