Battle System

Hi everyone,

Can I see someone else’s codes, a released or WIPs game, with a battle system that considered “successful” or “got potential” ?

is that an appropriate thing to ask?

the battle system in my mind is not a battle which options are predefined like “Attack with my Sword” even when I forget that I carry a sword with me or “Cast a Fireball” even when I don’t know if I got a talent in magic, and anything you choose only affect the sugary words on the story and doesn’t do anything to the end result.

thanks in advance

1 Like

I have one that’s from a game that I didn’t release yet. I still need to work on it a bit more.
Test it out.

*set ph - m_attack
*set mh - p_attack
*set health  m_attack
*set health1  p_attack
*if health = 0
    *set health health
*if health > 0
    *set ph_percent round(10 *(ph / health))
*if health1 = 0
    *set health1 health1
*if health1 > 0
    *set mh_percent round(10 *(mh / health1))
*if ph_percent > 100
    *set ph_percent 100
    *set ph_percent - 1
*if mh_percent > 100
    *set mh_percent 100
    *set mh_percent - 1
*if p_attack >= number
    *set p_attack - number
*if p_attack < number
    *set number - p_attack
*if p_defense >= number
    *set p_defense - number
*if p_defense < number
    *set number - p_defense
*if p_agility >= number
    *set p_agility - number
*if p_agility < number
    *set number - p_agility
*if m_attack >= number1
    *set m_attack - number1
*if m_attack < number1
    *set number1 - m_attack
*if m_defense >= number1
    *set m_defense - number1
*if m_defense < number1
    *set number1 - m_defense
*if m_agility >= number1
    *set m_agility - number1
*if m_agility < number1
    *set number1 - m_agility
*choice
    #Attack.
        *goto attack
    #Run away.
        *if m_agility = 0
            *set p_attack attack
            *set p_defense defense
            *set p_agility agility
            *set ph 10
            *set mh 10
            *set health 0
            *set health1 0
            You managed to escape.
            *goto_scene start start1
        *set r_chance round(p_agility / m_agility)
        *rand number 1 100
        *if r_chance <= 10
            *if number <= 20
                *set p_attack attack
                *set p_defense defense
                *set p_agility agility
                *set ph 10
                *set mh 10
                *set health 0
                *set health1 0
                You managed to escape.
                *goto_scene start start1
            *else
                You failed to escape.
                *goto attack
        *if r_chance <= 20
            *if number <= 40
                *set p_attack attack
                *set p_defense defense
                *set p_agility agility
                *set ph 10
                *set mh 10
                *set health 0
                *set health1 0
                You managed to escape.
                *goto_scene start start1
            *else
                You failed to escape.
                *goto attack
        *if r_chance >= 21
            *if number <= 60
                *set p_attack attack
                *set p_defense defense
                *set p_agility agility
                *set ph 10
                *set mh 10
                *set health 0
                *set health1 0
                You managed to escape.
                *goto_scene start start1
            *else
                You failed to escape.
                *goto attack
        *else
            You failed to escape.
            *goto attack
*label attack
*stat_chart
    percent ph_percent Health
Your health ${ph} - ${health}
*stat_chart
    percent mh_percent Health
${d_name}'s health ${mh} - ${health1}
*if ph > 0
    *if mh > 0
        *goto combat
    *else
        
        [b]You Win.[/b]
        *set ph 10
        *set p_attack attack
        *set p_defense defense
        *set p_agility agility
        *set ph * p_level
        *set mh 10
        *set health 0
        *set health1 0
        *goto results
*else
    
    [b]You died.[/b]
    *set p_attack attack
    *set p_defense defense
    *set p_agility agility
    *set ph 10
    *set mh 10
    *set health 0
    *set health1 0
    *page_break
    *goto m_name
1 Like

If you want to view the code of someone’s game, just add /scenes to the end of the WIP link.

https://dashingdon.com/playgalavantic/gametitle/mygame/scenes.

I’d recommend I, the forgotten one. It’s a good example of a properly done fight system that takes into account player’s chosen attributes like height and fighting style. Also I don’t think the author minds code divers.

8 Likes

Huh, it Kind of reminds me a bit of Pokemon. Maybe you should consider allowing a choice of different “moves” which would have different effects on the opponent?

Again thinking of Pokemon, you’d have an opening choice of either Attack, Use an Item or Run Away. Choosing “Attack” gives you a few options for the type of attack… Choosing “Use an Item” would obviously open up an inventory of consumables… and Run Away is just… well yeah.

You could go all Rock-Paper-Scissors style of fighting. Attack 1 beats Attack 2, Attack 2 beats Attack 3, and Attack 3 beats Attack 1.

Could use RNG to decide the opponent’s attack.

Edit: Typo

2 Likes

I should note: using the stats menu to assign attributes doesn’t work. The attributes reset upon exiting the stats menu.

(Anything done in the stats menu isn’t permanent. The stats menu doesn’t affect the game, the game is supposed to affect the stats menu)

So you’ll want to make a scene outside the stats scene for assigning skill-points instead.

I would put it after the “Combat” choice in the “Combat, Story, or Quest” choice block. Then the Next scene after that would be the fighting.

The stats are only reset temporarily until you advance a page.

1 Like

Oh I see. Kinda an annoying bug that it doesn’t update until the next scene but I guess that’s choicescript’s fault

It sounds like what you mean is, you want a system where what happens in each battle will affect your character. So like, what? If you get injured the injury is relevant to the rest of the game?

It’s all about variables and accounting for player choices.

Like you could absolutely make it possible to lose a limb in a fight and then have that loss affect the player-character for the rest of the game… but you’ll have to write it all in.

*choice
 #Dodge the axe
  *if (agility >= 15)
   You successfully dodge the axe
   *goto twoyearslater
  *else
   The axe cuts clean through your arm, amputating it comepletely
   *set arm_status “Amputated”
   *goto twoyearslater
 #Block the axe
  *if (strength >= 15)
   You raise your shield and successfully block the axe swing
   *goto twoyearslater
  *else
   The axe cuts clean through your arm, amputating it completely
   *set Arm_status “amputated”
   *gototwoyearslater

*label twoyearslater
You finish your breakfast, and think about the next battle to come.
*if (arm_status = “Amputated”)
  You look over your mechanical arm, thinking back to when you lost the original during that fight with the Axe-wielding assassin. The wound still itches, sometimes.
*else
  You look over your arm, strong and ready to win yet another battle.

In this case, you can potentially lose your arm if you fail the choice in the fight against the “Axe”. And losing that arm could have further effects throughout the rest of the story… but you have to write all of it, and you also have to write what happens if you never lost the arm at all, because that’s also possible.

Ensuring choices have lasting consequences is limited entirely to how far you’re willing to see those consequences through, as a writer.

This is why many prefer to write “false” choices where, what happens doesn’t significantly affect the plot… because it’s incredibly tedious to create entire plot tangents for every conceivable choice the player might make.

thanks man, I’ll use this to construct the system I want

Oh I didn’t know it was possible, thank you
but nobody would sue me for peeking at their WIP codes, right?

that’s even better, a completely different story path and choices because of something you did or let happened on yourself or the world.

technically, I want to imitate suikoden battle system, where I can use skills ( either learnable or pre-determined on the character ), using items I carry with me, but also the freedom of stats build like common MMORPGs, yeah it sounds hard but that’s what I love, I can’t really enjoy clicking nexts without ever thinking and then the story simply reached the end.

it feels so wrong to progressing the story without ever get the feeling that I need to understand whats going on.

1 Like

Can’t sue someone just for peeking at their code. Copying code on the otherhand is a different story, but I don’t think most people on here mind if you do.

The way I see it, in text games there is a dichotomy for how to go about writing combat.

Option one is “Literal”. You make a choice for every action the player will do. Hit with sword. Block with shield, repeat until enemy is defeated or you died.

Option two is “narrative”. You make a choice for a general approach to combat: will the player be Evasive? Stealthy? Straightforward? Then you write out a long narrative description of where that approach leads the player when they take it.

Option one sort of removes you from the narrative of the world and places you into a semi-generic combat scenario. When it’s over, you return to the narrative. They’re two separate, but co-dependent entities; combat and narrative. It’s like the difference between a story-cutscene and the gameplay in Call of Duty or something similar.

In Option two, the combat is part of the narrative. They’re intertwined. You leave the actual choice vague so that you, the author can write up an interesting “story” about the result of that choice.

In my experience “literal” combat is tricky to keep interesting in a longer game. Since all the combat is pretty much “use attack” until the enemy is dead, it will feel very repetitive.

That said, “narrative” combat can be hard to write. Sure, it maintains a consistent flow between the story and the combat, but man it can really be a slog writing “interesting” results for every possible move a player might make, twice over because you also have to account for whether they pass or fail.

But ultimately, those are your options as far as formats for writing combat. At least from my perspective.

2 Likes

impressive, I was so absored into making a battle system that I can use on my current project and future ones, I never realized this terms before.

from what I can learn from suikoden games, there are random encounters ( repetitive yes, and sometimes annoying ), and major battles ( narrative with scenes and dialogues, affecting story ), so I think it is possible to combine the two depending on the story progression.

1 Like

It’s definitely possible to use both in one game.

It would make sense to make smaller fights that have less plot impact more “literal” and have major fights be more narrative oriented. I think that would be a good way to balance it.

1 Like

The Suikoden games also have 1-on-1 duels, where the enemy says something that hints at making a move (attack, defend, deathblow), and then you decide which action will suit best, in a rock-paper-scissors manner. Since I saw a script in RPG Maker that does just that, it’s also doable in ChoiceScript.

1 Like

People on this thread might be interested to read a Dev post I put up on Tumblr, about how I’m approaching combat in my current project, Shadowrun: Neon Fire. The game is intended to be a cross between if and tabletop RPG, and I’m mixing up combat so that some fights are more “narrative” (which I call “directed” in the Dev post) and some are more open and ttrpg-style. I’m going to make all compulsory fights more narrative, but also include more open fights for players who want them, but make them avoidable for players who don’t.

Here’s the post: James Shaw Games on Tumblr

And feel free to check out the WIP and see what you think about how combat is handled!

1 Like

am I allowed to bump up this thread?

still trying to find how to properly write codes for battle system in choicescript, just scrapped mine 3 days ago because I got so stressed, I forgot that values stored in temp variables won’t persist if we switched files

now I’m rewriting it all again, all logics of battle mechanism in a single file, it looks horrible, lengthy, my eyes hurt looking at them and navigating through it all to find typos really sucks, but at least my temps didn’t get cleared anymore

today’s question [ April 12th, 2023 ]: do you guys think a stealth-themed game can be written in text-based medium like choicescript? I got stories about playing as a ninja in feudal japan or some fantasy world, something like that, but making a stealth mechanism in text is unthinkable for me right now, might need to read and play similar games for references, lol

sorry if you feel this has become my personal diary, but i plan to use this thread to test my own battle system and find some testers to give feedbacks, I don’t even mind if someone post their own battle system here to be tested, but if you think its inapproriate let me know, thank you

Many of my games have such systems… They are all slightly different in how the systems work, but check Tokyo Wizard, Highway Wars, Raiders of Icepeak, or Hero or Villain series… Let me know if you have any questions! (I think somebody pointed out how to check the code)

2 Likes

Hi Adrao, I’m trying Raiders of Icepeak and something bothers me, what stat defines my hit rate or opponent’s hit rate, so many misses in most rounds from either me or the opponents, makes battle longer that it should be.

also, if you don’t mind helping, I’m looking for ideas or suggestions on how to do party battle on choicescript, my primary reference is always suikoden series and other JRPG titles played in console, but they got images, animations, voices, effects, and other things that tells you what’s happening each round, but here, all we have is text

Raiders of Icepeak is a good example and I’m learning from it, but I don’t think it has party system
Life of Mercenary is 3-man party but everything is so randomized I don’t think I can rely on that

thank you and sorry for the trouble

1 Like

Hi… yes, I think this can be a problem, but I am not so sure how to fix it. I based my battle system on the old Fighting Fantasy series, so… it is what it is. As in, I know it may not necessarily be the best system, but it is what I set out to do. About how to implement a party system… well, indeed this makes the coding even more complicated. The problem being that already in a fight you end up with a long list of options, so if you have more members and each has a number of spells, etc… then you end up with a very clunky interface (choicescript has its limits in that sense, right?). I mean, you could have everything in submenus, but then I guess it takes forever to do things? (mind you, as you say, fights already take too long sometimes).