ID:1927810
 
(See the best response by Kaiochao.)
Code:
mob
var
takedamage=0
verb/Attack()
set category = "Skills"
for(var/mob/m in obounds(16,src))
if(dir == get_dir(src,m))
var/damage=max(0,usr.Strength+usr.Offense+usr.Energy-m.Defense-m.Resistance-m.Endurance)
flick(pick(list("punch", "punch2", "kick", "kick2")), usr)
flick("hit",src)
if(m.Speed>usr.Speed)
dodge()
m.takedamage(usr,damage)


proc
takedamage(mob/attacker,damage)
src.takedamage=1
usr.random = rand(1,15)
if(usr.random == 8)
usr.rightarmdamage()
if(usr.random == 3)
usr.stomachdamage()
if(usr.random == 5)
usr.chestdamage()
if(usr.random == 1)
usr.headdamage()
if(usr.random == 2)
usr.leftarmdamage()
if(usr.random == 4)
usr.leftlegdamage()
if(usr.random == 6)
usr.rightlegdamage()
if(usr.random == 7)
usr.regulardamage()
if(usr.random == 9)
usr.regulardamage()
if(usr.random == 10)
usr.regulardamage()
src.Deathcheck(attacker)
src.takedamage=0
Deathcheck(mob/M)
if(Vitals>0)return
if(src==M)
view(15) << "[src] has killed himself!"
view(15)<<"<font size=2><b><font color=yellow>[name] has been killed by [M.name]</b>"
src.loc=locate(25,41,2)
src.Vitals=src.MaxVitals
src.Energy=src.MaxEnergy

dodge()
if(prob(src.dodge))
view(15)<<"[src] dodges [usr]'s attack!"
return
else
src.takedamage()


mob
proc
headdamage(mob/attacker,damage)
if(usr.Offense>src.Offense)
if(prob(35))
src.takedamage=1
src.HeadDamage-=damage*2
usr.random = rand(1,10)
if(usr.random == 8)
usr.Strength += rand(0.50,5)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,5)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 3)
usr.Strength += rand(0.50,3)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,3)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 5)
usr.Strength += rand(0.50,4)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,4)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 1)
usr.Strength += rand(0.50,6)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,6)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
view(10)<<"<font size=1><font color=red>[usr.name] attacks [attacker] in the head([damage])!"
src.Deathcheck(attacker)
src.takedamage=0
chestdamage(mob/attacker,damage)
if(usr.Offense>src.Offense)
if(prob(45))
src.takedamage=1
src.ChestDamage-=damage*1.65
usr.random = rand(1,10)
if(usr.random == 8)
usr.Strength += rand(0.50,5)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,5)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 3)
usr.Strength += rand(0.50,3)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,3)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 5)
usr.Strength += rand(0.50,4)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,4)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 1)
usr.Strength += rand(0.50,6)
usr.Offense += rand(0.020,2)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,6)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
view(10)<<"<font size=1><font color=red>[usr.name] attacks [attacker] in the chest([damage])!"
src.Deathcheck(attacker)
src.takedamage=0
stomachdamage(mob/attacker,damage)
if(usr.Offense>src.Offense)
if(prob(40))
src.takedamage=1
src.StomachDamage-=damage*1.75
usr.random = rand(1,10)
if(usr.random == 8)
usr.Strength += rand(0.50,5)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,5)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 3)
usr.Strength += rand(0.50,3)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,3)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 5)
usr.Strength += rand(0.50,4)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,4)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 1)
usr.Strength += rand(0.50,6)
usr.Offense += rand(0.020,2)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,6)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
view(10)<<"<font size=1><font color=red>[usr.name] attacks [attacker] in the stomach([damage])!"
src.Deathcheck(attacker)
src.takedamage=0
leftarmdamage(mob/attacker,damage)
if(usr.Offense>src.Offense)
if(prob(55))
src.takedamage=1
src.LeftArmDamage-=damage*1.10
usr.random = rand(1,10)
if(usr.random == 8)
usr.Strength += rand(0.50,5)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,5)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 3)
usr.Strength += rand(0.50,3)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,3)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 5)
usr.Strength += rand(0.50,4)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,4)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 1)
usr.Strength += rand(0.50,6)
usr.Offense += rand(0.020,2)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,6)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
view(10)<<"<font size=1><font color=red>[usr.name] attacks [attacker] in the left arm([damage])!"
src.Deathcheck(attacker)
src.takedamage=0
rightarmdamage(mob/attacker,damage)
if(usr.Offense>src.Offense)
if(prob(55))
src.takedamage=1
src.RightArmDamage-=damage*1.10
usr.random = rand(1,10)
if(usr.random == 8)
usr.Strength += rand(0.50,5)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,5)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 3)
usr.Strength += rand(0.50,3)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,3)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 5)
usr.Strength += rand(0.50,4)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,4)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 1)
usr.Strength += rand(0.50,6)
usr.Offense += rand(0.020,2)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,6)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
view(10)<<"<font size=1><font color=red>[usr.name] attacks [attacker] in the right arm([damage])!"
src.Deathcheck(attacker)
src.takedamage=0
leftlegdamage(mob/attacker,damage)
if(usr.Offense>src.Offense)
if(prob(55))
src.takedamage=1
src.LeftLegDamage-=damage*1.05
usr.random = rand(1,10)
if(usr.random == 8)
usr.Strength += rand(0.50,5)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,5)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 3)
usr.Strength += rand(0.50,3)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,3)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 5)
usr.Strength += rand(0.50,4)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,4)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 1)
usr.Strength += rand(0.50,6)
usr.Offense += rand(0.020,2)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,6)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
view(10)<<"<font size=1><font color=red>[usr.name] attacks [attacker] in the left leg([damage])!"
src.Deathcheck(attacker)
src.takedamage=0
rightlegdamage(mob/attacker,damage)
if(usr.Offense>src.Offense)
if(prob(55))
src.takedamage=1
src.RightLegDamage-=damage*1.05
usr.random = rand(1,10)
if(usr.random == 8)
usr.Strength += rand(0.50,5)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,5)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 3)
usr.Strength += rand(0.50,3)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,3)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 5)
usr.Strength += rand(0.50,4)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,4)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 1)
usr.Strength += rand(0.50,6)
usr.Offense += rand(0.020,2)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,6)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
view(10)<<"<font size=1><font color=red>[usr.name] attacks [src] in the right leg([damage])!"
src.takedamage=0
regulardamage(mob/attacker,damage)
if(usr.Offense>src.Offense)
if(prob(80))
src.takedamage=1
src.RegularDamage-=damage
usr.random = rand(1,10)
if(usr.random == 8)
usr.Strength += rand(0.50,5)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,5)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 3)
usr.Strength += rand(0.50,3)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,3)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 5)
usr.Strength += rand(0.50,4)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.020,2)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,4)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
if(usr.random == 1)
usr.Strength += rand(0.50,6)
usr.Offense += rand(0.020,2)
usr.Energy += rand(200,1000)
usr.Offense += rand(0.010,1)
src.Strength += rand(0.50,6)
src.Energy += rand(200,1000)
src.Offense += rand(0.020,2)
src.Offense += rand(0.010,1)
view(10)<<"<font size=1><font color=red>[usr.name] attacks [src] for ([damage])!"
src.takedamage=0</b>


Problem description:Hey, am trying to work on this new game I'm making and I was wondering if anyone could help me figure out what's wrong with my attack system.. I'm blind to the fact of how I could make it better? I'm not that experience and I just need some assistance and a better way of doing this. I know my coding is terrible but bare with me, ha. Edit: As you can see there is a gain system along with the combat system giving users the opportunity to increase physique skills by doing something actively, also I'm not sure about the limb procs at all they don' seem to function.

The best improvement I can see is from using switch()
It's saying "error: src.dodge undefined var" :(
In response to Matokushin
Matokushin wrote:
It's saying "error: src.dodge undefined var" :(

I suspect that the variable dodge for the src isn't defined.
In response to Kozuma3
I'm skeptical on how to do that. Because I think of multiple ways and I'm not sure which one is correct ha.
I would personally make datums for each body part, like
part
head
chest
stomach
arm
leg


and apply variables for all the parts
part
var
health = 100


that way when they take damage, it will run a proc under the parts
part
proc
takedamage(mob/attacker,dmg = 0)
health -= dmg


and under that proc you can perform even further checks by using istype() or just checking for the name


And when a mob is created simply do

mob
var
part
head/head
chest/chest
stomach/stomach
arm/left_arm
arm/right_arm
leg/left_leg
leg/right_leg
New()
head = new()
chest = new()
stomach = new()
left_arm = new()
right_arm = new()
left_leg = new()
right_leg = new()
..()


I personally like this method as it's a nice way of dealing with organization. I'm sure further optimization can be made from here but it should be a good start.

EDIT:
when you need to deal damage you would do
src.left_arm.takedamage(attacker,12)


attacker would have to be defined of course.
Here is my way as well just to show that there isn't just a single way to do things, even tho similar.

body_part
var health = 100
mob
var/list/body
New()
body = list(
"Head" = new/body_part,
"Torso" = new/body_part,
"Legs" = new/body_part,
)
..()
proc
inflictDMG(int=0)
if(int)
var/body_part/BP = body[pick(body)]
BP.health -= int
return 1
return 0
Thanks im going to implement this now
In response to Kozuma3
I used Ishuri's code because he used the same damage proc that im using and I don't want to confuse myself so
Code
src.left_arm.takedamage(attacker,12)

I'm trying to figure out how to make it do damage depending on the players stats also do Vital damage which is regular health. But also the user will have a way to negate some of the damage depending on their defensive stats.

Something like this..
Code
var/damage=max(0,usr.Strength+usr.Offense+usr.Energy-m.Defense-m.Resistance-m.Endurance)


But also I want the user to only hit limbs with they have higher Offense than the user like I was doing in the random pulls

Code
if(usr.Offense>src.Offense)
if(prob(35))//head damage, each one is suppose to grow at a higher probability.. since no one will easily let you hit them in the face they'll more likely let you hit them in the leg or the arm

if(usr.Offense>src.Offense)
if(prob(55))//arm damage the highest chance I want to give players to hit a limb so it won't be a consistent thing..


if(usr.Offense>src.Offense)
if(prob(80))//last but not least regular damage this I aim for it to hit your Vitals your actual health points instead of your body damage. I'm sure you need the variables for the player in a whole.

mob
var
Vitals=20000
MaxVitals=20000
Energy=100
MaxEnergy=100
Strength=0
Endurance=0
Speed=0
Force=0
Resistance=0
Offense=0
Defense=0
Lift=0
Experience=0


And then I have a a messy experience system as you can see the experience variable is at the bottom barely working :( It supposed to increase overtime as you train throughout your little life of playing. It works for meditating "sometimes" but I will show you the code also since this is what we are here for to help each other haha.

Code:
atom/movable
var
random
meditate
shadowspar

mob
proc
meditate()
if(usr.medtime == 0)
usr.Vitals += 0
if(usr.medtime == 1)
usr.random = rand(1,10)
if(usr.random == 8)
usr.MaxEnergy += (rand(50,73))
usr.Strength += (rand(0.0050,0.010))
usr.Endurance += (rand(0.0040,0.50))
usr.Speed += (rand(0.001,0.003))
usr.Force += (rand(0.50,2.7))
usr.Resistance += (rand(0.50,5.2))
if(usr.random == 4)
usr.MaxEnergy += (rand(2,26))
usr.Strength += (rand(0.0070,0.7))
usr.Endurance += (rand(0.020,0.8))
usr.Speed += (rand(0.0001,0.050))
usr.Force += (rand(0.25,5.2))
usr.Resistance += (rand(0.25,3.8))
if(usr.random == 6)
usr.MaxEnergy += (rand(35,68))
usr.Strength += (rand(0.0030,0.0050))
usr.Endurance += (rand(0.0010,0.045))
usr.Speed += (rand(0.01,1))
usr.Force += (rand(0.50,4.6))
usr.Resistance += (rand(0.20,4.5))
if(usr.random == 7)
usr.MaxEnergy += (rand(14,45))
usr.Strength += (rand(0.0020,0.10))
usr.Endurance += (rand(0.0040,0.50))
usr.Speed += (rand(0.01,0.03))
usr.Force += (rand(0.50,3.9))
usr.Resistance += (rand(0.10,29))
sleep(25)
usr.meditate()
if(usr.Vitals>usr.MaxVitals)
usr.Vitals+=rand(100,500)
usr.Energy+=rand(100,500)
sleep(30)
else
if(usr.Vitals<usr.MaxVitals)
usr.Vitals += 0
usr.Energy += 0
usr.meditate()
return..()

mob
proc
shadowspar()
if(usr.spartime == 0 )
usr.Vitals += 0
if(usr.spartime == 1)
usr.random = rand(1,10)
if(usr.random == 8)
usr.MaxEnergy += (rand(50,73))
usr.Strength += (rand(0.50,2.5))
usr.Endurance += (rand(0.40,3.2))
usr.Speed += (rand(0.001,0.003))
usr.Force += (rand(0.0050,0.2))
usr.Resistance += (rand(0.050,0.5))
usr.Energy -= (rand(5,15))
flick("t1",src)
if(usr.random == 4)
usr.MaxEnergy += (rand(2,26))
usr.Strength += (rand(0.70,4.01))
usr.Endurance += (rand(0.20,2.8))
usr.Speed += (rand(0.0001,0.050))
usr.Force += (rand(0.025,0.5))
usr.Resistance += (rand(0.025,0.3))
usr.Energy -= (rand(5,15))
flick("t2",src)
if(usr.random == 6)
usr.MaxEnergy += (rand(35,68))
usr.Strength += (rand(0.30,5.2))
usr.Endurance += (rand(0.10,5.4))
usr.Speed += (rand(0.01,1))
usr.Force += (rand(0.050,0.4))
usr.Resistance += (rand(0.020,0.4))
usr.Energy -= (rand(5,15))
flick("t3",src)
if(usr.random == 7)
usr.MaxEnergy += (rand(14,45))
usr.Strength += (rand(0.20,4.4))
usr.Endurance += (rand(0.40,5.2))
usr.Speed += (rand(0.01,0.03))
usr.Force += (rand(0.050,0.3))
usr.Resistance += (rand(0.010,0.2))
usr.Energy -= (rand(5,15))
flick("t4",src)
sleep(25)
usr.shadowspar()

mob
proc
experienceUp()
if(usr.medtime == 0 || usr.meditating == 0)
usr.Vitals += 0
if(usr.medtime == 1 || usr.meditating == 1)
usr.Energy += (rand(5,15))
usr.random = rand(1,10)
if(usr.random == 8)
usr.Experience += (rand(80,200))
if(usr.random == 4)
usr.Experience += (rand(90,375))
if(usr.random == 6)
usr.Experience += (rand(100,425))
if(usr.random == 7)
usr.Experience += (rand(25,184))
sleep(25)
usr.experienceUp()
mob
proc
experienceUp2()
if(usr.spartime == 0 || usr.shadowsparring == 0)
usr.Vitals += 0
if(usr.spartime == 1 || usr.shadowsparring == 1)
usr.Energy += (rand(5,15))
usr.random = rand(1,10)
if(usr.random == 8)
usr.Experience += (rand(80,200))
if(usr.random == 4)
usr.Experience += (rand(90,375))
if(usr.random == 6)
usr.Experience += (rand(100,425))
if(usr.random == 7)
usr.Experience += (rand(25,184))
sleep(25)
usr.experienceUp2()


And you obviously have to look at the verb that works with this so here it goes.

Code:
mob
verb
Meditate()
set category = "Skills"
if(usr.shadowsparring == 1)
return
if(usr.meditating == 0)
usr << "You sit down to meditate."
usr.icon_state = "Meditate"
usr.meditating = 1
usr.freeze = 1
usr.medtime = 1
usr.meditate()
usr.experienceUp()
else
if(usr.medtime == 0|| usr.medtime == null||usr.meditating == 1)
usr << "You have stopped meditating."
usr.meditating = 0
usr.medtime = 0
usr.freeze = 0
usr.icon_state = ""
sleep(100)
Train()
set category = "Skills"
if(usr.shadowsparring == 1)
return
if(usr.shadowsparring == 0)
usr << "You start to train."
usr.shadowsparring = 1
usr.freeze = 1
usr.spartime = 1
usr.shadowspar()
usr.experienceUp()
else
if(src.Energy <= 0 || usr.spartime == 0 || usr.spartime == null || usr.shadowsparring == 1)
usr << "You have stopped training."
usr.shadowsparring = 0
usr.spartime = 0
usr.freeze = 0
usr.icon_state = ""
sleep(100)

I apologize for my bad coding, hehe.
Oh god, what hideous source is this from? It's like some of these zeta sources code I've seen, but it's taken a step further. You're adding the the same variable multiple times, you're checking the same if statement three times just to do probability checks, when you should be using pick() and a single if statement, you're uselessly using extra vars you don't need(ie: usr.random, no need for that. switch(rand(num1,num2)) works SO much better; then you have a infinite-"shadow sparring" going on, where instead of checking if the player is meditating and returning, you're checking if they're sparing.). Then you have experienceup2, which is a infinite loop calling itself over and over, when it should be a simple while() loop.

Oh, and sleeping the end of a verb/proc, outside of a loop, does nothing but increase the run-time of the proc/verb.
In response to NNAAAAHH
I love your professional criticism thanks, I really do. :D I'm going to fix it.
Honestly, I know you are new to this, but you've got a lot of stuff that just can't be fixed because I can't understand the logic of why you are doing a bunch of stuff.

A few notable examples:

You need to learn the difference between greater than and less than.
                if(usr.Vitals>usr.MaxVitals)
usr.Vitals+=rand(100,500)
usr.Energy+=rand(100,500)
sleep(30)
else
if(usr.Vitals<usr.MaxVitals)
usr.Vitals += 0
usr.Energy += 0
usr.meditate()
return..()

The above code snippet is only adding health and energy to the player if they are already above max health.

You should never add 0 to something. It does nothing. If it does nothing, why do it? This is all over your source code.

You also have all this:
if(random==8)
if(random==4)
if(random==6)
if(random==7)

You need to start using switch statements. Also, you need to learn the difference between greater and equal. Right now, nothing happens on 9, 10, 5, 3, 2, and 1 in many parts of your code. There's all kinds of stuff that's just straight up broken because you aren't testing for several cases.

You need to learn how to use loops.
meditate()
sleep(25)
meditate()

The above code will cause a stack overflow. This is bad. You need to use loops instead.

You need to learn the difference between usr and src. A significant portion of your code is running on the wrong objects because you are switching between mobs without knowing that m is not usr, and that src is not m, and that usr is not src. You should also never use usr in a proc unless it's a mouse proc or intended to be used like a verb. The only kind of verbs that you should use usr in would be verbs that have a non-default src setting.

You need to get rid of a ton of unnecessary variables:
medtime
meditating
spartime
shadowsparring
freeze

The above variables can all be replaced by exactly two variables.

proc
melee_bounds(atom/movable/ref,dir,dist,width,align=0)
var/w,h

if(istype(ref))
w = ref.bound_width
h = ref.bound_height
else
w = TILE_WIDTH
h = TILE_HEIGHT

switch(dir)
if(NORTH)
. = bounds(ref,floor((w-width)/2)+align,h,width-w,dist-h)
if(NORTHEAST)
. = bounds(ref,bound_width,bound_height,dist-w,dist-h)
if(NORTHWEST)
. = bounds(ref,-dist,bound_height,dist-w,dist-h)
if(SOUTH)
. = bounds(ref,floor((w-width)/2)+align,-dist,width-w,dist-h)
if(EAST)
. = bounds(ref,w,floor((h-width)/2)+align,dist-w,width-h)
if(WEST)
. = bounds(ref,-dist,floor((h-width)/2)+align,dist-w,width-h)
if(SOUTHEAST)
. = bounds(ref,bound_width,-dist,dist-w,dist-h)
if(SOUTHWEST)
. = bounds(ref,-dist,-dist,dist-w,dist-h)

#define BODY_HEAD 1
#define BODY_CHEST 2
#define BODY_STOMACH 3
#define BODY_LEFT_ARM 4
#define BODY_RIGHT_ARM 5
#define BODY_LEFT_LEG 6
#define BODY_RIGHT_LEG 7

body
var
name
hit_chance = 80
health = 100
max_health = 100
damage_mod = 1
New(name)
if(name) src.name = name

head
name = "head"
hit_chance = 35
damage_mod = 2
chest
name = "chest"
hit_chance = 45
damage_mod = 1.65
stomach
name = "stomach"
hit_chance = 40
damage_mod = 1.75
arm
name = "arm"
hit_chance = 55
damage_mod = 1.1
leg
name = "leg"
hit_chance = 55
damage_mod = 1.05

mob
var
list/attack_states = list("punch","punch2","kick","kick2")
list/body_parts = list(new/body/head(),new/body/chest(),new/body/stomach(),new/body/arm("left arm"),new/body/arm("right arm"),new/body/leg("right leg"),new/body/leg("left leg"))
tmp/action
tmp/action_time = 0
verb
Attack()
set category = "Skills"
flick(pick(attack_states),src)
for(var/mob/m in melee_bounds(src,dir,16,bound_width,0))
if(m.Speed>Speed)
m.dodge()
else
m.takeDamage(src,max(0,Strength+Offense+Energy-m.Defense-m.Resistance-m.Endurance))

Meditate()
set category = "Skills"
var/time = world.time
switch(action)
if("meditate")
src << "You stop meditating."
icon_state = ""
action = null
action_start = time
return
if(null,"shadowspar")
if(action_start>=time)
return
src << "You sit down to meditate."
icon_state = "meditate"
action = "meditate"
action_start = time
else
return
sleep(25)
while(action=="meditate"&&action_start==time)
//FUBAR
switch(rand(1,10))
if(8)
MaxEnergy += rand(50,73)
Strength += rand(0.005,0.01)
Endurance += rand(0.004,0.5)
Speed += rand(0.001,0.003)
Force += rand(0.5,2.7)
Resistance += rand(0.5,5.2)
Experience += rand(80,200)
if(7)
MaxEnergy += rand(14,45)
Strength += rand(0.002,0.01)
Endurance += rand(0.004,0.5)
Speed += rand(0.01,0.03)
Force += rand(0.5,3.9)
Resistance += rand(0.1,29)
Experience += rand(100,425)
if(6)
MaxEnergy += rand(35,68)
Strength += rand(0.003,0.005)
Endurance += rand(0.001,0.045)
Speed += rand(0.01,1)
Force += rand(0.5,4.6)
Resistance += rand(0.2,4.5)
Experience += rand(100,425)
if(4)
MaxEnergy += rand(2,26)
Strength += rand(0.007,0.7)
Endurance += rand(0.02,0.8)
Speed += rand(0.0001,0.05)
Force += rand(0.25,5.2)
Resistance += rand(0.25,3.8)
Experience += rand(25,184)
if(Vitals<MaxVitals)
Vitals = min(MaxVitals,Vitals+rand(100,500))
if(Energy<MaxEnergy)
Energy = min(MaxEnergy,Energy+rand(100,500))
sleep(25)

ShadowSpar()
set category = "Skills"
var/time = world.time
switch(action)
if("shadowspar")
src << "You stop training."
icon_state = ""
action = null
action_start = time
return
if(null,"meditate")
if(action_start>=time)
return
src << "You start to train."
action = "shadowspar"
action_start = time
else
return
sleep(25)
while(action=="shadowspar"&&action_start==time)
//FUBAR
if(Energy<10)
action = null
action_start = time
else
Energy -= 10
switch(rand(1,10))
if(8)
MaxEnergy += rand(50,73)
Strength += rand(0.5,2.5)
Endurance += rand(0.4,3.2)
Speed += rand(0.001,0.003)
Force += rand(0.005,0.2)
Resistance += rand(0.05,0.5)
Experience += rand(80,200)
flick("t1",src)
if(7)
MaxEnergy += rand(14,45)
Strength += rand(0.2,4.4)
Endurance += rand(0.4,5.2)
Speed += rand(0.01,0.03)
Force += rand(0.05,0.3)
Resistance += rand(0.01,0.2)
Experience += rand(100,425)
flick("t4",src)
if(6)
MaxEnergy += rand(35,68)
Strength += rand(0.3,5.2)
Endurance += rand(0.1,5.4)
Speed += rand(0.01,1)
Force += rand(0.05,0.4)
Resistance += rand(0.02,0.4)
Experience += rand(100,425)
flick("t3",src)
if(4)
MaxEnergy += rand(2,26)
Strength += rand(0.7,4.01)
Endurance += rand(0.2,2.8)
Speed += rand(0.0001,0.05)
Force += rand(0.025,0.5)
Resistance += rand(0.025,0.3)
Experience += rand(25,184)
flick("t2",src)
sleep(25)
proc
takedamage(mob/attacker,damage)
if(attacker.Offense>Offense)
flick("hit",src)
var/part = rand(1,15)
//FUBAR
switch(part)
if(1 to 7)
var/body/body = body_parts[part]
if(prob(body.hit_chance))
word = body_words[name]
body.health = max(0,body.health - damage * body.damage_mod)
view(10) << "<font size=1 color=red>[attacker] attacks [src] in the [body.name]([damage])"
. = 1
if(8 to 10)
if(prob(80))
Vitals = max(0,Vitals-damage)
view(10) << "<font size=1 color=red>[attacker] attacks [src]([damage])"
. = 1
if(.)
//FUBAR
switch(rand(1,10)
if(8)
attacker.Strength += rand(0.5,5)
if(5)
attacker.Strength += rand(0.5,3)
if(3)
attacker.Strength += rand(0.5,4)
if(1)
attacker.Strength += rand(0.5,6)
else
return
attacker.Energy += rand(200,1000)
attacker.Offense += rand(0.02,2)


The above code will need some serious TLC to actually work. It's so broken I don't even know if it'll compile, but take a close look at what was changed. I cleaned up as much as I could, but it's just... really broken.


Also, your design needs some definite work. The fact that players can't even possibly damage anything stronger than them even by a little bit? That's kind of messed up. Also, your progression values feel completely random to the point of absurdity, and a large number of them are probably below the floating point threshold to make a bit of difference.

My advice would be to not start from stolen source code, because this stuff is so bad that you'll learn really bad habits that will take years for you to unlearn.

Please for the love of all that is holy, start with the guide and make your own starter project. Almost everything in your rip codebase is certainly wrong. There were maybe 2-3 lines in the code you supplied that didn't show some kind of misunderstanding or error.
Best response
Also, rand(a, b) only works with integers, so rand(0.2,4.4) is just gonna get you 0, 1, 2, 3, or 4 (it floors its arguments). You could replace all of those with this randn() (place this in a code file included before any others):
// linear interpolation
proc/lerp(a, b, c) return a*(1-c) + b*c

// random real number between a and b
#define randn(a, b) lerp(a, b, rand())
^I was uncertain whether that'd even work. I avoid the use of rand() ever since I wrote my own PRNG object in BYOND.
In response to Ter13
I never tried to use fractional numbers in rand() either, though it's common in Zeta sources. Never paid much mind, I guess.

I caught the self-calling experienceup2, but not meditate :'(. I was going to mention meditate and medtime, but ain't must've forgot when covering the if statement checking wrong variables.

@OP I am glad you're taking this all well, a lot of members on a similar level as you are currently refuse advice and criticism, to the point they take offense if you give it to them, no matter how 'right' you are.
Thanks guys I appreciate all of your help and I've surely learned something from this.

Thank you all.
In response to Kozuma3
Kozuma3 wrote:
Here is my way as well just to show that there isn't just a single way to do things, even tho similar.

body_part
> var health = 100
> mob
> var/list/body
> New()
> body = list(
> "Head" = new/body_part,
> "Torso" = new/body_part,
> "Legs" = new/body_part,
> )
> ..()
> proc
> inflictDMG(int=0)
> if(int)
> var/body_part/BP = body[pick(body)]
> BP.health -= int
> return 1
> return 0



Probably the simplest way.