Results 1 to 3 of 3

Thread: Strategizing a rather involved project: scripted battle system

  1. #1

    Strategizing a rather involved project: scripted battle system

    I have a game. I'm wanting to pull as much of the arithmetic as possible out of the player's hands and put it into the capable hands of lua scripts. I'm an extremely novice scripter. I recently completed a very simple project involving a bag that added up values of its contents and displayed it. That's the full extent of my lua experience.

    The game is a pretty simple tabletop RPG. What I want to do is automate pretty much everything about the game except for the player's actions, and use that as a platform to implement a more complicated battle system.

    Players have three main and two minor character related cards: their masteries and knowledges (like characteristics and proficiencies), their suit (like armor), their weapon, their ship (like space armor), and their hardpoint (a ship weapon).
    Players also have tokens: a token to represent their person (the combination of masteries and suit), a token to represent themselves in a ship (masteries and ship), as well as a token to represent where they're attacking (weapon and hardpoint). More on that last bit later.

    I want values from the character cards to be passed to and displayed as button labels on their respective tokens. If I'm understanding how it works correctly, this sounds pretty straightforward. I just have the tokens reference the appropriate GUID values of whatever specific cards they're wanting to pull values from.

    However, I don't know if it would instead be better to store all the player character's stats in Global as HarveyDent.stats for example. The character cards would change Harvey Dent's stats in Global, and Harvey's tokens ask Global for what they should be displaying. If I'm understanding how this might work correctly, then it'll mean that no object will have to talk to any other object, and thus no object would need to reference any other object's GUID. Instead, each object would be referencing a characterName.stats in Global. Which could potentially end up being cleaner and better, lest a card or token ever find its GUID different than what I specified other ones to look for in the script and it break. It will also be great because I can potentially use something similar if not identical to the player character cards for generating enemies under their own names.

    Then again, maybe I completely misunderstand the scope at which objects (or Global) can possibly interact with each other. This is all theory to me, I've not worked on this kind of scale before. That's the point of this thread I guess, I wanna know if I should pursue a different and potentially less headache inducing direction before starting.

    -------------------------

    The second section of this is the (future) battle system. In this game there are four battle stats: Attack, Speed, Durability, and Utility. Attack is added to Hit, Speed determines Stamina, Durability is added to Resist, and Utility determines Energy. Hit is added to offensive rolls, Stamina acts as a buffer before you start actually taking damage (think: number of attacks that can be evaded before tiring), Resist is added to any defensive rolls (once Stamina is depleted), and Energy is the special resource (mana, fuel, etc).

    In battle, each team has three positions called 'zones', and the any combatant can be in any one of their team's zones: Foreguard, Fallback, or Flank. When attacks are made, they are made against the entire zone of an enemy team. All enemies inside the zone will pool their defensive stats, and all allies attacking the zone will pool their offensive stats. Enemies hit all take a point of damage to their stamina, or their durability if out of stamina. Characters in the foreguard zone can boost the defensive stats of characters in the fallback zone. Characters in the fallback zone slowly recover stamina. Characters in the flank zone get bonuses to Hit. Here's a graphic. When everyone has moved and decided where they want to attack, the turn is resolved (simultaneously for all players) and passes to the other team.

    The first aspect I want to script is the 'all enemies inside the zone pool their defensive stats' part. I want the zone to display the total defensive stats of all the tokens currently presently inside the zone. I would assume this would be an update on the onObjectEnterScriptingZone/onObjectLeaveScriptingZone functions. However, I'm wondering if I should be utilizing Global for this, per the section above. If Global can store everything about Harvey Dent, then can we tell the scripting zone to apply Harvey's defensive stats to the zone whenever a token named 'Harvey Dent' enters the zone, and subtract it when it leaves? And of course, the scripting zone will need to total up the defensive stats of other characters in the zone and display that in a button label, though I think this is going to be simple enough. Oh, and let's not forget characters in the foreguard zone boosting the defenses of characters in the fallback zone! I'm hoping to represent that dynamically too. I think I'd need to get the scripting zones to talk to each other to get that working. The zones should never be duplicated or destroyed, so I don't see that as an issue.

    The second aspect I want to script is the 'all allies attacking the zone will pool their offensive stats', and this is slightly more involved I think. In my mind the attack token object in an of itself is nothing special - it's just a piece with the character's name on it. The important part is the specifics of the player's weapon which may be stored in Global, ideally. A player chooses which enemy zone they are going to attack by dropping their attack token into it. This will update the incoming-attack-button-label of the attacked zone to read whatever that player's Hit will be before the roll (and perhaps what the roll's range would be). Other players can compare that with the label that shows the defensive stats of the enemies inside the zone, and make a decision about how they want to attack. Perhaps another player wants to attack with the first, and they will drop their attack token into the zone as well. Now the zone totals up the Hit values and displays that as the incoming-attack-button-label. I'm hoping this can be extended to consumable items in the game, called deployables. Deployables are things like grenades or shield generators and what not that will apply extra effects or attacks. I actually I think this is a bit more complicated and might involve special cases that tell the game what to do when each deployable is present.

    The third aspect I want to script is the turn resolution part. When I click a big shiny 'PROCESS TURN' button, it looks at all zones that have attack tokens inside them, looks at the offensive stats of the characters they belong to, throws a bunch of dice, and gets the offensive grand total. Similarly, it adds up the defensive stats of the character tokens in the target zone, throws a bunch of dice for them, gets the defensive grand total and compares that against the offensive grand total. If attacks are successful, it reduces the defenders stamina or durability accordingly. The result is outputted to either a big index card, or into the chat window, or the notepad, or something. Who knows, maybe we can get fancy - after clicking the PROCESS TURN button, any grenades on the field will explode into a shower of marbles that expire after a few seconds.

    -------------------------

    One of the most painful elements of this game is the card system. It used to be the inventory system, but I fixed that with my scripted loot bag! Now, the card system is really cool. Think gemstones or runes that you would slot into gear - that's cards. Gear has slots, cards go into slots, stats page profits. I've made a deck of literal cards to represent the cards in the current game. Currently, when you have them slotted into equipment you're currently wielding, you put them into your player hand. I found this to be the best way to keep them organized and help players not forget to apply their benefits to your character when they're called.

    I want cards to be read from the player hand and dynamically added to the character stats. The way I was thinking of doing this was by having a simple formula to describe the effects of each card, and put that formula in the card's description. For example, a simple card might have ATK+1, UTL-1, ENE+1. I actually made a simple script at work today that can parse these keywords and operators from a getDescription() and apply the values to the appropriate stats, so I don't think this will be terribly hard, assuming I can get the cards in the player hand talking to the character stats in a reliable way.

    However I'd also like the possibility of adding more complicated cards, for example, +Hit when attacking the foreguard zone, -Hit when attacking fallback zone. I'd probably represent this with a simple but unique keyword in the card description, such as GUARDSTRIKE+, BACKSTRIKE- (don't want to use the word 'HIT' as that'll likely be a keyword for the standard +Hit bonus). I think in reality this might be quite simple and I'm scaring myself, but based on my limited understanding, it looks like there's going to need to be some complicated conversation between the subject of the special conditions (zones, target number, attack element, etc) and the character's attack token. Overall this third section of scripting is something I'm willing to hang off on until later - I can simply use a much simpler DM Audit kind of mechanic and manually input any of the special bonuses/maluses talked about within this section of the post.

    -------------------------

    Sorry for the long post and anything that might be confusing. I'm currently working on this game as a portfolio centerpiece. I want to get this much done before the end of this year, and next year I plan to use it to get into the game industry. I really appreciate any help, feedback, or tips regarding how I should approach this project.

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    This is a very complex bit of scripting. Each new element you add is 5-60+ minutes of coding. If you want to add me on steam (id/MrStump) you could show me some stuff, we could talk about it and I wouldn't mind helping you write it. Sounds like a neat game.

  3. #3
    Thanks for the generous offer. I will get a few of the character sheets drawn up and then get in contact with you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •