Laserbrain Studios

Games Forum Blog Contact

Author Topic: Mass combat code  (Read 2029 times)

Areetsa

  • Newbie
  • *
  • Posts: 6
    • View Profile
Mass combat code
« on: April 08, 2013, 03:35:26 PM »
So I was fiddling around trying to get multi-party combat to work, and having difficulties; f'rinstance, I'd have two characters with three of each being spawned, and they'd fight, but they'd sign a ceasefire after one guy on each side died. Monkeying about with CharacterKilled and ChangeCharacterOrderTarget tags didn't accomplish much. Eventually I decided to go with an approach that wasn't as nice to look at (instead of nice tidy uniform swarms of Retro Troopers following Retro Squadleaders into battle against Militiamen led by a Confed Officer it'd have Retro Squaddies 1 through X fighting against Militamen 1 through Y) but more likely to work, and I managed to get something going.

Since this is the sort of thing that can be useful for quests in situations like a branching storyline where a character lands on a base to find their Confed buddy and his squad fighting against his Pirate pal's merry band and has to choose which one to help, or just background stuff like, oh, bank robberies, I figured I'd post the code. It's a bit clunky and isn't too great to look at in action, but it works and that's the important thing.



Basically, how it works is that each side has three characters: A, B, and C, for the Confeds, and 1, 2, and 3, for the Retros. After a timer's given them time to bunch up, A will attack 1, B will attack 2 and so on. Once a character dies, their paired enemy will move on to the next; so, if A kills 1, he'll move on to 2. If C kills 3, he'll help A with 1.

With armour, this results in about three minutes (if you're hiding in a building and don't have to watch all the little X shoots Y in the Z dialogue boxes) of back and forth gunfire followed by about four screams in quick succession. Without, it's much the same just a lot quicker and more variable.

Who wins is a bit of a toss-up; the Retros have assault rifles, which means they do more damage, but the Confeds don't have to reload. Who shoots first plays a fair part, with blind luck coming second; they've all got default skills. With higher Precision, it'd probably be quicker. Speed wouldn't make much difference, since the real slowing element is the dialogue boxes.
If each character started in a different spot and immediately moved to attack, the deaths could probably be spaced out; I didn't want to do that, since that would require picking a specific base.

Varying equipment would also affect outcomes and, more importantly, death rates and weapon sounds. I'm not sure how many unarmoured pistol wielding pirates it'd take to bring down a Retro commando team with titanium vests and assault rifles; maybe 2:1? Wouldn't want to have to actually watch it play out, though.

As I see it, making multi-member fights interesting to watch depends in large part on spacing out the initial pairings; if everyone starts shooting at the same time, everyone'll likely start dying at the same time too.

If you were to involve a player character, which you'd probably want to, I figure they'd be worth about two normal enemies, to account for the AI's unfortunate tendency to get hung up on things or occasionally get into ineffectual gunfights at hand-to-hand range.


In general, this isn't the best showcase of NPC-NPC fights; it's more along the lines of a technology demonstrator.

Giving them specific starting points would make fights a lot more interesting to watch, as well as allowing things to happen like having a player step out of their ship to find a handful of mercenaries valiantly keeping a horde of peg-legged pirates from breaking into the exchange, or something similar.


I'm not saying the code is perfect; for example, the target switching arrangement isn't that good. It'd work a lot better with each character corresponding to a variable, to allow any character to attack any other character, but that'd make it even harder to look at.


So yeah; I figure this might give someone some ideas.
Code: [Select]

Title : Fight

Author : Aree't'sa

Fight : 0

SCENE Skirmish

   ONLOAD
      Timer : 1 : Start
   /ONLOAD

   CHARACTER
      Color : 9
      EquipmentHead : Plasteel Helmet
      EquipmentRightHand : M-39 Laser Rifle
      EquipmentTorso : Kevlar Vest
      Faction : Confed
      FirstName : A
      Movement : Global
      Order : None
      Template : 1
   /CHARACTER
   CHARACTER
      Color : 9
      EquipmentHead : Plasteel Helmet
      EquipmentRightHand : M-39 Laser Rifle
      EquipmentTorso : Kevlar Vest
      Faction : Confed
      FirstName : B
      Movement : Global
      Order : Protect
      OrderTarget : A
      Template : 2
   /CHARACTER
   CHARACTER
      Color : 9
      EquipmentHead : Plasteel Helmet
      EquipmentRightHand : M-39 Laser Rifle
      EquipmentTorso : Kevlar Vest
      Faction : Confed
      FirstName : C
      Movement : Global
      Order : Protect
      OrderTarget : A
      Template : 3
   /CHARACTER

   CHARACTER
      Color : 5
      EquipmentHead : Plasteel Helmet
      EquipmentLeftBelt : C-47 Clip
      EquipmentRightBelt : C-47 Clip
      EquipmentRightHand : C-47 Assault Rifle : 6
      EquipmentTorso : Kevlar Vest
      Faction : Retro
      FirstName : 1
      Movement : Global
      Order : None
      Template : 4
   /CHARACTER
   CHARACTER
      Color : 5
      EquipmentHead : Plasteel Helmet
      EquipmentLeftBelt : C-47 Clip
      EquipmentRightBelt : C-47 Clip
      EquipmentRightHand : C-47 Assault Rifle : 6
      EquipmentTorso : Kevlar Vest
      Faction : Retro
      FirstName : 2
      Movement : Global
      Order : Protect
      OrderTarget : 1
      Template : 5
   /CHARACTER
   CHARACTER
      Color : 5
      EquipmentHead : Plasteel Helmet
      EquipmentLeftBelt : C-47 Clip
      EquipmentRightBelt : C-47 Clip
      EquipmentRightHand : C-47 Assault Rifle : 6
      EquipmentTorso : Kevlar Vest
      Faction : Retro
      FirstName : 3
      Movement : Global
      Order : Protect
      OrderTarget : 1
      Template : 6
   /CHARACTER

   TRIGGER
      Event : Timer : 1 : 1

      Result : CreateCharacter : 1
      Result : CreateCharacter : 2
      Result : CreateCharacter : 3

      Result : Variable : Fight : 1
   /TRIGGER
   TRIGGER
      Event : Variable : Fight : 1

      Result : CreateCharacter : 4
      Result : CreateCharacter : 5
      Result : CreateCharacter : 6
   /TRIGGER


   TRIGGER
      Event : Timer : 1 : 200

      Result : ChangeCharacterOrderTarget : A : 1
      Result : ChangeCharacterOrder : A : attack

      Result : ChangeCharacterOrderTarget : B : 2
      Result : ChangeCharacterOrder : B : attack

      Result : Variable : Fight : 2
   /TRIGGER

   TRIGGER
      Event : Variable : Fight : 2

      Result : ChangeCharacterOrderTarget : C : 3
      Result : ChangeCharacterOrder :C  : attack

      Result : ChangeCharacterOrderTarget : 1 : A
      Result : ChangeCharacterOrder : 1 : attack

      Result : Variable : Fight : 3
   /TRIGGER

   TRIGGER
      Event : Variable : Fight : 3

      Result : ChangeCharacterOrderTarget : 2 : B
      Result : ChangeCharacterOrder : 2 : attack

      Result : ChangeCharacterOrderTarget : 3 : C
      Result : ChangeCharacterOrder : 3 : attack
   /TRIGGER


   TRIGGER
      Event : CharacterKilled : 1

      Result : ChangeCharacterOrderTarget : A : 2
   /TRIGGER

   TRIGGER
      Event : CharacterKilled : 2

      Result : ChangeCharacterOrderTarget : B : 3
   /TRIGGER

   TRIGGER
      Event : CharacterKilled : 3

      Result : ChangeCharacterOrderTarget : C : 1
   /TRIGGER


   TRIGGER
      Event : CharacterKilled : A

      Result : ChangeCharacterOrderTarget : 1 : B
   /TRIGGER

   TRIGGER
      Event : CharacterKilled : B

      Result : ChangeCharacterOrderTarget : 2 : C
   /TRIGGER

   TRIGGER
      Event : CharacterKilled : C

      Result : ChangeCharacterOrderTarget : 3 : A
   /TRIGGER


   TRIGGER
      Event : Timer : 2 : 300
      Result : QuestDone
   /TRIGGER
/SCENE