How To Do Simple, Turn-Based Combat?

I know this is the umpteenth time a post about combat has been made, but I am absolutely failing to absorb any information along the lines of creating a very simplistic combat system with basic attributes. Not having combat alone is the biggest reason why I haven't committed to a project or decided to create anything using Quest 5, despite the fact that it can do virtually everything that I want my game to have.

Please note that anything I do that's video game-related is from a point of writing, design, and artistic direction. In no way am I a programmer or coder.

I am also super bad at asking for help since I can't seem to articulate very well what it is I want. So, forgive me for that. However, here's a list of "game play qualities" that I want to have in my game. This is not an RPG, as the game will not have any kind of leveling system. These are some of the things that particularly effect the game's core design:

  • Hit Points/HP
  • Guns
  • Ammunition (Can be combined to take up less inventory blocks)
  • Reload Function/Attribute
  • Melee Weapons
  • Combat (RNG + Specific weapons affect DMG and CRIT chances)
  • Combat Range System (Close/Far)
  • Melee Combat (Close)
  • Gun Combat (Far)
  • Grenades/Explosives (Far)
  • Inventory Space (Not influenced by weight/Resident Evil-styled where items take up "blocks")
  • Wearables (Can be equipped and increase inventory space)
  • "Examine" Verb/Attribute
  • Puzzles/Key Items/Door Codes, etc.
  • Enemy/Environmental Loot (ex; Health items, ammo, weapons, etc.)

I will write an example of what I'm looking to achieve and, hopefully, someone kind and knowledgeable can guide me in the right direction here:

Example does not include details or make an accurate reflection of a finalized experience.

>> Inventory

You are carrying '5 pistol ammo', '1 ration', and a 'Beretta 92FS'.

You have 3 inventory spaces to work with.

>> Look

You can see a 'table', a 'locker', an 'electronic door' on the east end of the room, and an 'electronic door' on the west end of the room.

>> Look table

On the table's surface is a 'piece of paper' and '7 pistol ammo'.

>> Look paper

It's a piece of notebook paper. Looks like there's something written on it.

>> Take paper

You have picked up the 'piece of paper'.

>> Inventory

You are carrying '5 pistol ammo', '1 ration', a 'Beretta 92FS', and a 'piece of paper.'

You have 2 inventory spaces to work with.

>> Take ammo

You pick up '7 pistol ammo'.

>> Inventory

You are carrying '5 pistol ammo', '7 pistol ammo', '1 ration', a 'Beretta 92FS', and a 'piece of paper.'

You have 1 inventory space to work with.

>> combine pistol ammo

You have combined your pistol ammo.

>> Inventory

You are carrying '12 pistol ammo', '1 ration', a 'Beretta 92FS', and a 'piece of paper.'

You have 2 inventory spaces to work with.

>> Reload

You must equip a firearm first!

>> Equip beretta

You ready your reliable Beretta 92FS.

>> Look beretta

A good gun. It's loaded with 3 rounds.

>> Reload

You lace up your piece with new rounds, loaded and ready.

>> Look Beretta

A good gun. It's loaded with 10 rounds. 

>> Inventory

You are carrying '9 pistol ammo', '1 ration', a 'Beretta 92FS', and a 'piece of paper.' 

>> Examine paper

The paper reads the code "0640". 

>> Look

You can see a 'table', a 'locker', an 'electronic door' on the east end of the room, and an 'electronic door' on the west end of the room.

>> Open locker

It's locked, electronically. 

>> Unlock locker

ENTER 4-DIGIT CODE

>> 0640

The locker beeps as the lock releases.

>> Open locker

You open the locker. 

It houses an 'H&K MP5K-PDW', '20 SMG ammo', and a 'keycard.'

>> Drop paper

You have dropped the 'piece of paper'. 

>> Take mp5

You take the 'H&K MP5K-PDW'. [[trigger enemy script]]

The 'electronic door' on the east end of the room beeps with an unlock!

A Hunter appears! He notices you!

The Hunter fires at you!

MISS

The Hunter grunts irritatingly.

>> shoot hunter

You fire your 'Beretta 92FS' at the Hunter!

HIT 

CRITICAL

The Hunter slumps for a moment, but doesn't croak just yet.

The Hunter fires at you!

HIT

20 DMG

>> shoot hunter

MISS

The Hunter grins, noticing your poor gunplay. 

The Hunter fires at you!

MISS

The Hunter grits his teeth.

>> use ration

You use your 'ration', regaining 15 HP.

>> shoot hunter

HIT

The Hunter crashes, his corpse thumping to the floor.

>> look self

You're doing alright. 95 HP.

>> check hunter

He's carrying '3 pistol ammo', and an 'M-61 Frag Grenade'.

Sorry for it being overblown, but I wanted it to seem like what an experience would actually look like. If anyone could help me achieve this kind of game, any help would be appreciated. Very greatly appreciated. I've had the idea in my head for a few years now, but the most I can do is write it out this way. If there are any inconsistencies with the provided example, please let me know so I can make it as clean and consistent as possible for the understanding of other users. Thank you.


Io
In no way am I a programmer or coder.

Then that's really unfortunate, because to do this you really have to code. At the very least you need the visual-code blocks. There's a ton of different ways to do what you're describing, but you really do need to understand how to give objects Attributes, and how to use Expressions. Remember: Computers are like those little children who always follow your orders, but only to the letter. It will do EXACTLY what you tell it to do, but not necessarily what you want it to.

Again, there's lots of ways to do this, but I'll push you in the direction I would take: You can 'nest' attributes, have them inside each other. For example the 'Object Type' attribute 'CurrentGun' for the player can be set to the Beretta, which has its own attributes Ammo and Damage. So you can have code like:

Player.OutgoingDamage=Player.CurrentGun.Damage

Hope this helps.


Hey, thanks. All help is good help, in my opinion.


A lot of what you want to do is already built into Quest, so won't be hard to make it work.

I notice that in your example, the huntyer doesn't shoot at you while you're eating a ration. If he only shoots when you're shooting at him, that will make the code a lot simpler because you can make the "shoot" command trigger both attacks. The most complex part of a combat system's code often turns out to be working out whether or not an enemy will attack the player.


Writing a transcript of what you are hoping to do is an excellent approach!

There is a tutorial that will give you most of what you want here:
http://docs.textadventures.co.uk/quest/zombie-apocalypse-1.html

If you are using the desktop version, there is a library here, though it is more swords and spells than guns.
https://github.com/ThePix/quest/wiki/CombatLib


@mrangel

Yeah, I want to be able to use items without being attacked in between turns.

@The Pixie

Thanks, I'm not the best at absorbing this stuff, but I want to try anyway.


your combat system seems pretty similar to Fallout 1 and 2 (PC) and/or Parasite Eve 1 (PS1) --- you might want to check out these games, as they might give you some ideas or be helpful for you

for the game mechanics/formulas/equations:

  1. if you're able to (good at math, and then with game balancing, too, lol), you can create your own
  2. study/use other games' mechanics for ideas for doing your own mechanics
  3. directly use other games' mechanics

here's just a quick simple example of what the coding/scripting will look like

(using fallout 1 and 2 games for an example)

(WiP, as it's going to take awhile, lol, but you got somewhat of the ideas of/with the coding involved and how to do various things, hopefully)

<delegate name="combat_delegate" parameters="party_objectlist_parameter;enemy_objectlist_parameter" />

<object name="combat_object">

  <attr name="combat_script_attribute" type="combat_delegate">
  </attr>

  <targetted_stringlist_attribute type="stringlist">

    <value>body</value>
    <value>head</value>
    <value>eyes</value>
    <value>groin</value>
    <value>armLeft</value>
    <value>armRight</value>
    <value>legLeft</value>
    <value>legRight</value>

  </targetted_stringlist_attribute">

  <actions_stringlist_attribute type="stringlist">

    <value>move</value>
    <value>strike</value>
    <value>shoot</value>
    <value>reload</value>
    <value>item</value>
    <value>equip</value>
    <value>unequip</value>
    <value>inventory</value>
    <value>endTurn</value>
    <value>endCombat</value>

  </actions_stringlist_attribute>

  <damage_types_stringlist_attribute type="stringlist">

    <value>normal</value>
    <value>explosive</value>
    <value>fire</value>
    <value>laser</value>
    <value>plasma</value>
    <value>electrical</value>

  </damage_types_stringlist_attribute>

</object>

<object name="character_object">

  <primary_attribute_stringlist_attribute type="stringlist">

    <value>strength</value>
    <value>perception</value>
    <value>endurance</value>
    <value>charisma</value>
    <value>intelligence</value>
    <value>agility</value>
    <value>luck</value>

  </primary_attribute_stringlist_attribute>

  <condition_stringlist_attribute type="stringlist">

    <value>normal</value>
    <value>dead</value>
    <value>blinded</value>
    <value>crippled</value>
    <value>grounded</value>
    <value>poisoned</value>
    <value>radiated</value>

  </condition_stringlist_attribute>

  <skills_stringlist_attribute type="stringlist">

    <value>sneak</value>
    <value>lockpick</value>
    <value>steal</value>
    <value>traps</value>
    <value>firstAid</value>
    <value>doctor</value>
    <value>science</value>
    <value>repair</value>

  </skills_stringlist_attribute>

</object>

<type name="character_type">

  <attr name="x_coordinate_integer_attribute" type="int">0</attr>
  <attr name="y_coordinate_integer_attribute" type="int">0</attr>

  <attr name="primary_item_slot_object_attribute" type="object">unarmed</attr>
  <attr name="secondary_item_slot_object_attribute" type="object">unarmed</attr>
  <attr name="armor_slot_object_attribute" type="object">unarmored</attr>

  <attr name="level_integer_attribute" type="int">0</attr>
  <attr name="experience_integer_attribute" type="int">0</attr>
  <attr name="currency_integer_attribute" type="int">0</attr>

  <attr name="life_string_attribute" type="string">unknown</attr>

  <attr name="current_life_integer_attribute" type="int">0</attr>
  <attr name="maximum_life_integer_attribute" type="int">0</attr>
  <attr name="minimum_life_integer_attribute" type="int">0</attr>

  <attr name="current_action_points_integer_attribute" type="int">0</attr>
  <attr name="maximum_action_points_integer_attribute" type="int">0</attr>
  <attr name="minimum_action_points_integer_attribute" type="int">0</attr>

  <attr name="sequence_integer_attribute" type="int">0</attr>

  <attr name="healing rate_integer_attribute" type="int">0</attr>

  <attr name="poison_resistance_integer_attribute" type="int">0</attr>

  <attr name="radiation_resistance_integer_attribute" type="int">0</attr>

  <attr name="strength_integer_attribute" type="int">0</attr>
  <attr name="perception_integer_attribute" type="int">0</attr>
  <attr name="endurance_integer_attribute" type="int">0</attr>
  <attr name="charisma_integer_attribute" type="int">0</attr>
  <attr name="intelligence_integer_attribute" type="int">0</attr>
  <attr name="agility_integer_attribute" type="int">0</attr>
  <attr name="luck_integer_attribute" type="int">0</attr>

</type>

<type name="action_type">

  <attr name="action_point_cost" type="int">0</attr>

</type>

<type name="item_type">
</type>

<type name="consumable_type">
</type>

<type name="weapon_type">

  <inherit name="action_type" />

</type>

<type name="nonprojectile_type">

  <inherit name="weapon_type" />

</type>

<type name="unarmed_type">

  <inherit name="nonprojectile_type" />

</type>

<type name="punch_type">

  <inherit name="unarmed_type" />

</type>

<type name="kick_type>

  <inherit name="unarmed_type" />

</type>

<type name="knuckle_type">

  <inherit name="unarmed_type" />

</type>

<type name="fist_type">

  <inherit name="unarmed_type" />

</type>

<type name="melee_type">

  <inherit name="nonprojectile_type" />

</type>

<type name="projectile_type">

  <inherit name="weapon_type" />

</type>

<type name="throwing_type">

    <inherit name="projectile_type" />

</type>

<type name="firearm_type">

  <inherit name="projectile_type" />

</type>

<type name="gun_type">

  <inherit name="firearm_type" />

</type>

<type name="handgun_type">

  <inherit name="gun_type" />

</type>

<type name="shotgun_type">

  <inherit name="gun_type" />

</type>

<type name="rifle_type">

  <inherit name="gun_type" />

</type>

<type name="assault_rifle_type">

  <inherit name="gun_type" />

</type>

<type name="machine_gun_type">

  <inherit name="gun_type" />

</type>

<type name="thrower_type">

  <inherit name="firearm_type" />

</type>

<type name="launcher_type">

  <inherit name="firearm_type" />

</type>

<type name="armor_type">

  <attr name="armor_class" type="int">0</attr>

  <attr name="normal_damage_resistance" type="int">0</attr>
  <attr name="fire_damage_resistance" type="int">0</attr>
  <attr name="laser_damage_resistance" type="int">0</attr>
  <attr name="plasma_damage_resistance" type="int">0</attr>
  <attr name="explosive_damage_resistance" type="int">0</attr>
  <attr name="electrical_damage_resistance" type="int">0</attr>

  <attr name="normal_damage_threshold" type="int">0</attr>
  <attr name="fire_damage_threshold" type="int">0</attr>
  <attr name="laser_damage_threshold" type="int">0</attr>
  <attr name="plasma_damage_threshold" type="int">0</attr>
  <attr name="explosive_damage_threshold" type="int">0</attr>
  <attr name="electrical_damage_threshold" type="int">0</attr>

  <slot_stringlist_attribute type="stringlist">

    <value>armor</value>

  </slot_stringlist_attribute>

</type>

<type name="unarmored_type">

  <inherit name="armor_type" />

</type>

<type name="robe_type">

  <inherit name="armor_type" />

</type>

<type name="leather_jacket_type">

  <inherit name="armor_type" />

</type>

<type name="leather_armor_type">

  <inherit name="armor_type" />

</type>

<type name="metal_armor_type">

  <inherit name="armor_type" />

</type>

<type name="combat_armor_type">

  <inherit name="armor_type" />

</type>

<type name="tesla_armor_type">

  <inherit name="armor_type" />

</type>

<type name="brotherhood_armor_type">

  <inherit name="armor_type" />

</type>

<type name="power_armor_type">

  <inherit name="armor_type" />

</type>

<type name="hardened_power_armor_type">

  <inherit name="armor_type" />

</type>

you can also look at my old combat code (basic design for turn based combat):

https://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread#22483

and my key/legend for all of my abbrevs (warning: I got a lot of mistakes in my code, for example, I got some of my damages of the damage types vs damage type resistances, messed up, argh --- I've learned to NEVER use abbrevs, ever again, lol):

https://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread#22486


https://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread#22485 (download link of Pertex' refactoring of my code)

If you don't want to click the download link, here's Pertex' refactoring of my code (it can be cleaned up a bit more --- as I got some mistakes -- confused up some of my damage types vs damage type resistances, and have some junk code lines still in it to remove or fix up):

    <asl version="530">
      <include ref="English.aslx" />
      <include ref="Core.aslx" />
      <game name="Test">
        <gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
        <version>1.0</version>
        <pov type="object">player</pov>
        <start type="script">
          cc
        </start>
        <turns type="int">0</turns>
        <statusattributes type="stringdictionary">turns = </statusattributes>
      </game>
      <object name="room">
        <inherit name="editor_room" />
        <object name="player">
          <inherit name="defaultplayer" />
          <inherit name="pc" />
          <cur_hp type="int">999</cur_hp>
          <max_hp type="int">999</max_hp>
          <str type="int">100</str>
          <end type="int">100</end>
          <dex type="int">100</dex>
          <agi type="int">100</agi>
          <spd type="int">100</spd>
          <hc type="int">100</hc>
          <pd type="int">100</pd>
          <pr type="int">100</pr>
        </object>
        <object name="orc1">
          <inherit name="editor_object" />
          <inherit name="npc" />
          <hostile type="boolean">true</hostile>
          <dead type="boolean">false</dead>
          <alias>orc</alias>
          <cur_hp type="int">999</cur_hp>
          <max_hp type="int">999</max_hp>
          <str type="int">25</str>
          <end type="int">25</end>
          <dex type="int">25</dex>
          <agi type="int">25</agi>
          <spd type="int">75</spd>
          <hc type="int">25</hc>
          <pd type="int">25</pd>
          <pr type="int">25</pr>
        </object>
      </object>
      <turnscript name="game_turns">
        <enabled />
        <script>
          sa
          game.turns = game.turns + 1
        </script>
      </turnscript>
      <command name="fight">
        <pattern>fight #text#</pattern>
        <script>
          battle_system (game.pov,text)
        </script>
      </command>
      <type name="char">
        <cur_hp type="int">0</cur_hp>
        <drop type="boolean">false</drop>
        <defending type="boolean">false</defending>
        <max_hp type="int">0</max_hp>
        <str type="int">0</str>
        <end type="int">0</end>
        <dex type="int">0</dex>
        <agi type="int">0</agi>
        <spd type="int">0</spd>
        <hp type="int">0</hp>
        <hc type="int">0</hc>
        <pd type="int">0</pd>
        <pr type="int">0</pr>
      </type>
      <type name="pc">
        <inherit name="char" />
        <statusattributes type="stringdictionary">hp = ;str = ;end = ;dex = ;agi = ;spd = ;hc = ;pd = ;pr = </statusattributes>
      </type>
      <type name="npc">
        <inherit name="char" />
        <dead type="boolean">false</dead>
        <hostile type="boolean">false</hostile>
        <displayverbs type="list">Look at; Talk; Fight</displayverbs>
      </type>
      <function name="cc">
        msg ("What is your name?")
        get input {
          game.pov.alias = result
          msg (" - " + game.pov.alias)
          show menu ("What is your gender?", split ("male;female" , ";"), false) {
            game.pov.gender = result
            show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
              game.pov.race = result
              show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
                game.pov.class = result
                msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
                wait {
                  ClearScreen
				  
                }
              }
            }
          }
        }
      </function>
      <function name="sa">
        game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
      </function>
      <function name="battle_system" parameters="self,text">
        enemy = GetObject (text)
        if (enemy = null) {
          foreach (obj,AllObjects()) {
            if (obj.alias=text) {
              enemy = obj
            }
          }
        }
        if (enemy = null) {
          msg ("There is no " + text + " here.")
        }
        else if (not Doesinherit (enemy,"npc")) {
          msg ("You can not battle that!")
        }
        else if (not npc_reachable (enemy)) {
          msg ("There is no " + enemy.alias + " in your vicinity.")
        }
        else if (GetBoolean (enemy,"dead") = true) {
          msg (enemy.alias + " is already dead.")
        }
        else if (GetBoolean (enemy,"hostile") = false) {
          msg (enemy.alias + " is not hostile.")
        }
        else {
			battle_sequence (self,enemy)
    	} 

      </function>
      <function name="battle_sequence" parameters="self,enemy"><![CDATA[
		if (enemy.dead = false) {
			playerfirst=false
			if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
				playerfirst=true
			} else if (GetInt (self,"spd") = GetInt (enemy,"spd") and RandomChance (50)) {
				playerfirst=true
			}   		  
			
			if (playerfirst) {
			   msg ("You get to go first for this round")
			   self_battle_turn (self,enemy) 
			   on ready {
				 if (not enemy.dead){
				   enemy_battle_turn (self,enemy) 
				 }
			   }
			} else {
			   msg (enemy.alias + " gets to go first for this round.")
				enemy_battle_turn (self,enemy) 
				msg ("It is now your turn.")
				self_battle_turn (self,enemy) 
			}
			on ready {
				msg ("The round has ended.")
				msg("")  
				battle_sequence (self,enemy)	
			}	
        } 	else { 
				msg ("The battle is over.")
        }
      ]]></function>
      <function name="self_battle_turn" parameters="self,enemy"><![CDATA[
		msg (self.alias + " has " + self.cur_hp + " HP left.")
        msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
        wait {
          show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
            switch (result) {
              case ("Attack") {
                fourth_value = false
                if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
                  msg (enemy.alias + "evaded your attack!")
                  fourth_value = true
                }
                else if (RandomChance (GetInt (enemy,"Dex") - GetInt (self,"agi")) = true) {
                  msg (enemy.alias + "parried your attack!")
                  fourth_value = true
                }
                else if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"dex")) = true) {
                  msg (enemy.alias + "blocked your attack!")
                  fourth_value = true
                }
                else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
                  msg ("Your attack missed " + enemy.alias +"!")
                  fourth_value = true
                }
                else if (RandomChance (GetInt (enemy,"pr") - GetInt (self,"hc")) = true) {
                  msg ("Your attack got resisted by " + enemy.alias +"!")
                  fourth_value = true
                }
                else if (fourth_value = false) {
                  if (self.defending = true and enemy.defending = true) {
                    enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
                    msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
                    self.defending = false
                  }
                  else if (self.defending = true and enemy.defending = false) {
                    enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
                    msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
                    self.defending = false
                  }
                  else if (self.defending = false and enemy.defending = true) {
                    enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
                    msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
                  }
                  else if (self.defending = false and enemy.defending = false) {
                    enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
                    msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
                  }
                }
              }
              case ("Defend") {
                if (self.defending = false) {
                  self.defending = true
                }
              }
              case ("Cast") {
                self.defending = false
              }
              case ("Item") {
                self.defending = false
              }
              case ("Run") {
                self.defending = false
              }
            }
            if (GetInt (enemy,"cur_hp") > 0) {
			  if ( RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd"))= true) {
                msg ("You get an extra battle turn!")
                self_battle_turn (self,enemy)
              }
              else {
                msg ("Your battle turn is over.")
              }
            }
            else if (GetInt (enemy,"cur_hp") <= 0) {
              msg (enemy.alias + " is dead.")
              msg ("You have won the battle!")
              enemy.defending = false
              enemy.dead = true
              }

          }
        }
      ]]></function>
      <function name="enemy_battle_turn" parameters="self,enemy"><![CDATA[
        msg (self.alias + " has " + self.cur_hp + " HP left.")
        msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
        result = GetRandomInt (1,3)
        switch (result) {
          case (1) {
            sixth_value = false
            if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
              msg ("You have evaded the attack!")
              sixth_value = true
            }
            else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"agi")) = true) {
              msg ("You have parried the attack!")
              sixth_value = true
            }
            else if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"dex")) = true) {
              msg ("You have blocked the attack!")
              sixth_value = true
            }
            else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
              msg (enemy.alias +"'s attack missed!")
              sixth_value = true
            }
            else if (RandomChance (GetInt (self,"pr") - GetInt (enemy,"hc")) = true) {
              msg ("You resisted the attack!")
              sixth_value = true
            }
            else if (sixth_value = false) {
              if (enemy.defending = true and self.defending = true) {
                self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
                msg (self.alias + " has " + self.cur_hp + " HP left.")
                enemy.defending = false
              }
              else if (enemy.defending = true and self.defending = false) {
                self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
                msg (self.alias + " has " + self.cur_hp + " HP left.")
                enemy.defending = false
              }
              else if (enemy.defending = false and self.defending = true) {
                self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
                msg (self.alias + " has " + self.cur_hp + " HP left.")
              }
              else if (enemy.defending = false and self.defending = false) {
                self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
                msg (self.alias + " has " + self.cur_hp + " HP left.")
              }
            }
          }
          case (2) {
            if (enemy.defending = false) {
              msg (enemy.alias + " has choosen to defend itself.")
              enemy.defending = true
            }
          }
          case (3) {
            enemy.defending = false
            msg ("Cast")
          }
        }
        if (GetInt (self,"cur_hp") > 0) {
          if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
            msg (enemy.alias + " gets an extra battle turn!")
            wait {
              enemy_battle_turn (self,enemy)
            }
          }
          else {
            msg (enemy.alias + " 's battle turn is over.")
          }
        }
        else if (GetInt (self,"cur_hp") <= 0) {
          msg (self.alias + " has died.")
          msg ("GAME OVER")
          finish
        }
      ]]></function>
      <function name="npc_reachable" parameters="object" type="boolean">
        value = false
        foreach (x,ScopeReachableNotHeld ()) {
          if (x=object) {
            value = true
          }
        }
        return (value)
      </function>
      <function name="crit_hit" parameters="object" type="int">
        if (RandomChance (GetInt (object,"luck")) = true) {
          value = 2
        }
        else {
          value = 1
        }
        return (value)
      </function>
    </asl>

@hegemonkhan

Holy cannoli. I feel that I could properly gauge the usefulness of all of this if I knew a little more about coding.

This is amazing. However, I only really want a simplistic system that doesn't involve any kind of limb or stat management other than raw HP. Most of these combat systems all have RPG mechanics in mind (like stats), and I'm not making an RPG. I'm looking to have the bare bones of a turn-based combat system.


Something like:

// players's turn
hit creature...
creature.HP=creature.HP- damage
if creature.HP<0 {
msg("It falls over dead, you win!")
}
if alive, creature hit's player
player.HP=player.HP-damage
if player dead {
msg("sorry, you died")
end game
}
else, goto player's turn

The only stat would be hit points, and damage done.


Here is what I use right now.

Simple Combat
It is from this forum but someone put it all together on deviant. Just copy the parts you want. Each script is labeled and instructions are given.


@DarkLizerd

Yes, something exactly like that. I'm a complete beginner when it comes to anything code. How would I copy and paste chunks of code? Like, I don't know or understand where to put them.

@Forgewright

Link 404'd, unfortunately. :/



This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums