ID:160816
 
Code:
battle_sorters // these objects sort out battles, so it should only be deleted when the battle ends
parent_type = /obj
var

mob/A // player one is A, while player 2 is B (P1 would be you, and P2 would be the monster)
mob/B
mob/turn1
mob/turn2
mob/turn3
mob/turn4
mob/turn5
mob/turn6

New(location, mob/a, mob/b)
..()
src.A = a
src.B = b
if(A&&B) // if they are both there, start the battle
StartBattle(A,B)
StartChecking(A, B)


proc
StartChecking(mob/A, mob/B,mob/C,mob/D,mob/E,/mob/F) // this procedure checks if the people logged out of the battle or just
spawn while(src) // disappeared for some reason
if(!A) LogOutBattle(A, B)
else if(!B) LogOutBattle(B, A)
sleep(25) // we really don't need to loop it frequently, because it isn't really showable
StartBattle(mob/A, mob/B)
if(A.agi==B.agi)
/* // removed as of version 2, thanks Crispy
var/list/Rand = list(A, B)
var/a = rand(1,2)
while(a--)
Rand.Swap(1,2)
*/

if(prob(50)) // if a 1/2 chance is come
var/tempvar = A // save a temporary variable for A
A = B // and swap ahead
B = tempvar // and restore the A to the B, making a successful swap
EngageBattle(A, B) // let the battle begin
else
if(A.agi > B.agi) // the faster, the better
EngageBattle(A, B)
else
EngageBattle(B, A) // early bird gets to kill first


EngageBattle(mob/A,mob/B)
/* if(A.def) // defending only lasts one turn
A << "<font color = #9a5927>You stop defending."
B << "<font color = #9a5927>[A] stops defending."
A.def -= 50*/

if(A.stunned)
B<<"[A] is stunned!"
B<<"[A] is forced to skip his turn!"
FightBattle(B,A)
return

if(A.client) // if somebody is posessing A, let them control themselves

var/list/commands = list("Fight","Item","Run")

var/command = input(A, "Please select a command.","Command?") in commands // Base commands to use from
switch(command)
if("Fight")
FightBattle(A, B)

if("Item")
var/list/L = A.contents
if(L.len)
var/item/I = input(A, "Pick an item to use","Item") in L + "Back"
if(I=="Back")
EngageBattle(A, B)
else
I.BattleUse(A)

EngageBattle(B, A) // your turn is done, start the battle again, except backwards.


else
A << "You do not have any items to use."
EngageBattle(A, B)

if("Run")
RunFromBattle(A, B)
else // otherwise, do the monster intelligence
MonsterBattle(A, B)

FightBattle(mob/A, mob/B)

var/list/commands = list("Attack","Skill",/*"Defend",*/"Wait","Change Party Members")
var/command = input(A, "Please select a command.","Command?") in commands
switch(command)
if("Change Party Members")
if(A.party.len)
for(var/mob/M in A.party)
if(M.hp)
Partymember_forcecall(B,A)
else
A<<"Your other party members are all dead!"
else
A<<"You have no party members."
FightBattle(A,B)
if("Attack")
A.attack(B)
if(B.stunned)
B.stunturns += 1
if(B.stunturns == 5)
B.stunturns = 0
B.stunned = 0
A<<"[B] is no longer stunned!"
B<<"You are no longer stunned!"
if(B.DeathCheck(A))
EndBattle(A, B, "win")
else
EngageBattle(B, A)


if("Skill")
var/list/L = A.skills
if(L.len)
var/battle/battleskill/I = input(A, "Pick a skill to use","Skill") in L + "Back"
if(I=="Back")
EngageBattle(A, B)
else
var/path = I.skillpath
call(A,path)(B)
if(B.stunned)
B.stunturns += 1
if(B.stunturns == 5)
B.stunturns = 0
B.stunned = 0
A<<"[B] is no longer stunned!"
B<<"You are no longer stunned!" // the call() procedure saves the day so there is no long if() tree
if(B.DeathCheck(A)) // if they're dead, stop the battle
EndBattle(A, B, "win")
else
EngageBattle(B, A) // otherwise, keep on going


else
A << "You don't have any skills to use."
FightBattle(A, B)
/* if("Defend")
A << "<font color = #9a5927>You start to defend."
B << "<font color = #9a5927>[A] starts to defend."
A.def += 50 // half damage next turn
sleep(10)
EngageBattle(B, A)*/



if("Wait")
A << "You decide to wait the turn."
B << "[A] decides to wait the turn."
sleep(10)
EngageBattle(B, A)

MonsterBattle(mob/A, mob/B) // fun monster AI
if(A.stunned)
B<<"[A] is stunned!"
B<<"[A] is forced to skip his turn!"
FightBattle(B,A)
return
if(A.hp<=A.maxhp/4) // if the monster is low on HP
var/list/L = A.skills // get the skills list
for(var/battle/battleskill/item in L) // remove all non-support items
if(!item.supportuse)
L -= item
if(L.len) // if there are any support skills
var/battle/battleskill/I = pick(L) // use a random one
var/path = I.skillpath
call(A,path)(B)
if(B.stunned)
B.stunturns += 1
if(B.stunturns == 5)
B.stunturns = 0
B.stunned = 0
A<<"[B] is no longer stunned!"
B<<"You are no longer stunned!"
if(B.DeathCheck(A))
EndBattle(A, B, "win")
else
EngageBattle(B, A)
else // otherwise, the monster will attempt to run
RunFromBattle(A, B)

else // if they are all alright
var/list/L = A.skills
for(var/battle/battleskill/item in L)
if(item.supportuse) // remove all support spells. no need for any of them.
L -= item
if(L.len) // check if they have any
var/battle/battleskill/I = pick(L)
var/path = I.skillpath
call(A,path)(B)
if(B.stunned)
B.stunturns += 1
if(B.stunturns == 5)
B.stunturns = 0
B.stunned = 0
A<<"[B] is no longer stunned!"
B<<"You are no longer stunned!"
if(B.DeathCheck(A))
if(B.party.len)
for(var/mob/N in B.party)
if(N.hp >= 0)
Partymember_forcecall(A,B)
else
EndBattle(A,B, "win")
else
EndBattle(A,B, "win")
else
EngageBattle(B, A)
else // otherwise attack normally
A.attack(B)
if(B.DeathCheck(A))
if(B.party.len)
for(var/mob/M in B.party)
if(M.hp >= 0)
Partymember_forcecall(A,B)
else
EndBattle(A,B, "win")
else
EndBattle(A,B, "win")
else
EngageBattle(B, A)

Question
I am trying to make an MMO where joining parties is almost Necessary to defeat monster and enemies.But how would i make it so its more of a team battle then a 1v1 duel
for instance something along the lines of...
mob/turn1
mob/turn2
mob/turn3
mob/turn4
mob/turn5
mob/turn6
//battle proc
proc
Battle(mob/a,mob/d,mob/e,mob/f)
//and you mob/a attacks mob/d||e||f

Hello..?
I'm too lazy to understand the whole code but from I've seen, I assume that this is a turn based game. Everything would be easier if you would use lists for teams.
In response to Choka
The way I see it is, using a List for the team is good when initializing the battle process, however, when sorting out damage and all that, I find an interesting way to set up damage with or without animation is with a moving object with Bump()

Basically, if it's turn based and your fighters are frozen in place they will fire invisible (or visible) homing objects to strike the enemy and when the enemy attacks it selects a random mob from the list you set up earlier to choose who to attack.


also if you want to make it team based and not just one player Vs. the monster, you could set it up so that the monster you fight has an incredibly large amount of health and attacks that would take down a player instantly from time to time. This makes it so that if one player starts taking it up for themselves instead of relying on the team, they will be knocked down and need a revive. This keeps it team based and also makes battles more interesting. (just make sure to include a good revive system)
In response to Bravo1
Bravo1 wrote:
The way I see it is, using a List for the team is good when initializing the battle process, however, when sorting out damage and all that, I find an interesting way to set up damage with or without animation is with a moving object with Bump()

Basically, if it's turn based and your fighters are frozen in place they will fire invisible (or visible) homing objects to strike the enemy and when the enemy attacks it selects a random mob from the list you set up earlier to choose who to attack.

There's no need for moving invisible objects to strike the enemy and Bump() is inappropriate to use for this case. If effects would be needed, you can use the missile() proc and after a few ticks, call an Attack proc.


also if you want to make it team based and not just one player Vs. the monster, you could set it up so that the monster you fight has an incredibly large amount of health and attacks that would take down a player instantly from time to time. This makes it so that if one player starts taking it up for themselves instead of relying on the team, they will be knocked down and need a revive. This keeps it team based and also makes battles more interesting. (just make sure to include a good revive system)

In addition, I suggest that the monster should always choose the player with the lowest survival rate to attack.
In response to Jemai1
i did
In response to Jemai1
Indeed Jemai, but then again, it should only attack them 50% of the time, considering it may cause the other team members to want to boot the other since they die so much XD
I wrote up an implementation of a turn-based battle system here.
In response to Bravo1
Bravo1 wrote:
Indeed Jemai, but then again, it should only attack them 50% of the time,

Well, okay.. "almost always" then.

considering it may cause the other team members to want to boot the other since they die so much XD

If you're a good teammate you should help someone who's in trouble, not boot him >.>
In response to Jemai1
Indeed, but that's not the mentality of most Byond players if you've noticed.