ID:169775
 
I'm trying to make a game and I wanted it to have a Random Battle System as well as having party memebers with you in the fight and I can't figure out how I would be able to do that. Can anyone lead me some Help please?
ForsakenSoul wrote:
I'm trying to make a game and I wanted it to have a Random Battle System

Look up one of the battle system demos. This part is simple, as you just have a set probability every step to execute a battle_setup function. So you need to overwrite Move, use prob inside of it, and create the new function to call.

as well as having party memebers with you in the fight and I can't figure out how I would be able to do that. Can anyone lead me some Help please?

Keep a list of everyone in the party, and locate them all into the battlefield when a battle starts.
mob
New()
party=list(src)
var/list/party[0]
proc/battle_setup()
var/list/L=create_random_enemies()
var/list/combatants=party+L
goto_battlefield(combatants)
battle(combatants)
proc/goto_battlefield(list/combatants)
//if you have a battlefield area on the map...
for(var/mob/M in combatants)
//put M on the battlefield
//if you are drawing a battlefield view onto the screen
var/list/L=draw_battlefield()
for(var/obj/O in L)
for(var/mob/M in combatants)
if(!M.client)continue
M.client.screen+=O
//As you can see, all I did was loop through all the\
combatants and do for all of them what would otherwise\
have been done only for a single player.


proc/battle(list/combatants)
var
attack
list/defeated[0]
while(!battle_win_check(combatants))
for(var/mob/M in combatants)
attack=M.choose_attack_type()
var/list/L=M.attack(attack)
//attack() returns all mobs M defeated
if(L)
combatants.Remove(L)
defeated.Add(L)
//anything that happens when the battle is finished goes here\
at this point, combatants should only contain the victors

proc/battle_win_check(combatants)
for(var/mob/M in combatants)
for(var/mob/M2 in combatants)
if(!(M2 in M.party))return 0
return 1

You could pass two lists to the battle function, a list/group1 and list/group2, and then would have no need for a battle_win_check function. However, the way it is done there instead allows you to have more than two parties to a battle if you so wish. For instance, you could have a three mob free-for-all.

As you can see, the basic idea is to simply loop through all mobs involved and do to them what you would normally have done to a pair of mobs. This applies to everything except targeting for the average game. Normally you just have two variables when you don't have partying, mob/attacker and mob/defender. Now, instead of referencing the opposite mob, you give the attacker the option to choose whom the mob wishes to attack, probably done with a call to input.