ID:1636129
 
(See the best response by Vivalas.)
So, i'm trying to create a boxing game and i want to make a system where it's totally fair for both a newbie and a pro, since in UFC it doesn't matter if your the best player in the world, you can still lose versus the worst player in the world. My system right now is completely bias to the people with the least Strength and Endurance. I want to make a system where you need to time the attack at the same time as when you are being attacked to dodge the attack and when you dodge the attack your strength goes up. Can you guys please assist me?

My code right now:

var/Hitz = 'Graphics/Sounds/Hit.wav'
var/Mizz = 'Graphics/Sounds/Miss.wav'
mob
proc
Fight(mob/User,Type,mob/Target,Combo,Chance)
world <<"DEBUG"
var/damage
if(!prob(Chance))
if(Type == "Heavy")
world << "[User] missed the Heavy attack on [Target]"
if(Type == "Light")
world << "[User] missed the very light attack on [Target]"
if(Type == "Medium")
world << "[User] missed the shot at [Target]"
world << Mizz
return
else
switch(Type)
if("Heavy")
damage = 2*(User.Strength) - Target.Endurance
var/stemina = 0.5*(damage)
world << "DEBUG2"
User.Stamina -= stemina
//if(User.Stamina <= 0)
// User.Stamina = 1
if("Light")
damage = 1*(User.Strength) - Target.Endurance
var/stemina = 0.9*(damage)
world << "DEBUG3"
User.Stamina -= stemina
//if(User.Stamina <= 0)
// User.Stamina = 1
if("Medium")
damage = 1.50*(User.Strength) - Target.Endurance
var/stemina = 0.7*(damage)
world << "DEBUG4"
User.Stamina -= stemina
//if(User.Stamina <= 0)
// User.Stamina = 1
damage = max(0,damage)
world << "WAHTS UPZ"
world << "[User] Punches [Target] with a [Type] attack, doing [damage] damage."
world << Hitz
Target.Health -= damage
if(Target.TKOCheck(User)) return
if(Combo && prob(Combo))
world << "Unbelieveable he does a combo!"
Fight(User,Type,Target,Combo,Chance)

TKOCheck(mob/Attacker)
if(src.Health <= 0)
oview(10, src) << "[src] has been knocked out by [Attacker]!"
Attacker.Wins += 1
src.Lose += 1
Attacker.skillpoints += 2
src.skillpoints += 1
Bump
Well first of all, I can't think of a way to balance the system other than your dodge system. If you are going to add skill points, and base damage off of them, even with randomness, the higher skilled player will win most of the time. I can think of code that will help you though, hold on while I draft it.
From what I know about boxing, there are different weight classes. You could try something like that. Another option would be to make the skill point system purely aesthetic. That is, it is only used to differentiate noobs from long-time vets, with like a level system. There would be no actual bonus. Everyone who plays could start with the same amount of skill points, like a max cap. This cap never changes no matter what the level. Players get to allocate these points to stats, to create the player they want. Like high strength and low endurance, or high endurance, low strength, etc. The skill points actually earned form fighting could be used to re-allocate those, say, 10 points, if they don't like the setup. So one could have a boxer who is strong but with no stamina, or the other way around, and they get to choose who they want to be. You could also base stamina on endurance.
Best response
#define DODGE_WINDOW 3

/atom/Click(src, params, control)
usr.ClickOn(src, params)
return
/mob/ClickOn(src, params)
if(is_being_attacked)
blocked = 1
return
if(ChkStatus())
src.is_being_attacked
sleep(DODGE_WINDOW)
if(!src.blocked)
src.is_being_attacked = 0
Fight(src, etc. etc. etc.)
else
src.is_being_attacked = 0
src.blocked = 0
//insert dodge stuffs here
return
What this does is it allows the defender to click the attacker to try and dodge the attack. The time they have to dodge is defined by the dodge window, which in this case is 1/3rd of a second. You could add more to it if you like, like an animation that plays so that the user knows they are being attacked, or you could change DODGE_WINDOW so that it could be like 1/10th of a second, and the defender has to be a ninja. You could also make the dodge window longer, for say, a heavy attack.

The way this click hierarchy works is that when they click client.Click() is called, and then mob.ClickOn() is called, and then finally src.Click(), or in this case Fight(). This is so that th emob can handle checks on its own stats rather than the client. You can override this and change it as you see fit.

p.s. I'm just starting to muster the courage to help on this board rather than ask for help, so don't hate if this is totally wrong, as it might be.
What is Chkstatus() suppose to do again?
Bump
Oh sorry, I forgot to add that ChkStatus() is supposed to test if the user can actually carry out an attack (like if they are KO'd or not, etc.) I use it in my games to test if the user is dead, sleeping, stunned, handcuffed, etc.
so like my TKOCheck()?

What do i need to edit to make it like your ChkStatus?
No, you can use yours, it is a basic framework. Adapt it how you like.
Derp, I realized I shouldn't of used src in some of those var references. I hope you already caught this. Replace the src argument of ClickOn with a generic var like mob/M and replace instances of src with M and it should work. Sorry. :o
client/Click(src, params, control)
usr.ClickOn(src, params)
world << "[src]"
return
mob/proc/ClickOn(mob/M, params)
if(is_being_attacked)
world << "Test"
blocked = 1
return
//if(M.TKOCheck(src))
M.is_being_attacked = 1
sleep(DODGE_WINDOW)
if(!M.blocked)
M.is_being_attacked = 0
Fight(M)
else
M.is_being_attacked = 0
M.blocked = 0
//insert dodge stuffs here
return


Did some edits to the code. But now i need help inserting it in the game which from what i'm seeing looks pretty hard.
Necropost, extreme here, but all you do is attach it to your player mob, or wherever you want it to go, where ever it fits in.