• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Combat State in RPGs

Status
Not open for further replies.
I'm thinking of adding a death mechanic wherein if a party member falls in battle, there are no means to revive them until the "battle" is over.

The combat state starts at the first encounter/aggro of an enemy, and will last until all the enemies in that blob is killed.

I've been playing around timers, is attacked events, and unit groups, but I still can't wrap my head around of implementing this kind of mechanic. I was thinking of just using good old fashioned resurrection stones in safe havens far from battle, but I want the deaths to be semi-permanent using the mechanic I described.

Also, if all party members are down, it's game over.

I'm hoping for ideas from anyone who's familiar with this. TIA!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,217
There are two main approaches I can think of.
  • Every time something combat related happens you restart the timer and disable reviving. Only if the timer expires do you enable reviving.
  • When the blob of enemies spawns/engages you disable reviving. Periodically you check the status of the blob including proximity to party members. If the blob of units is all dead, or if the minimum distance between them and a living part member is outside their agro range then you enable reviving.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,626
I attached a map with a working system that could help you get started. It uses Bribe's Unit Indexer to keep track of the different Battle Groups (unit groups) that enemy units belongs to. Requires latest patch to open.
  • Setup Battle System
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • -------- Setup active human players: --------
      • Set VariableSet Players = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)).)
      • -------- --------
      • -------- Setup heroes owned by these players: --------
      • Player Group - Pick every player in Players and do (Actions)
        • Loop - Actions
          • Set VariableSet TempGroup = (Units owned by (Picked player) matching (((Matching unit) is A Hero) Equal to True).)
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to PlayerHeroes
          • Custom script: call DestroyGroup (udg_TempGroup)
      • -------- --------
      • -------- Setup resurrection stones: --------
      • Set VariableSet ResStones = (Units of type Resurrection Stone)
      • Unit Group - Pick every unit in ResStones and do (Actions)
        • Loop - Actions
          • Player Group - Pick every player in Players and do (Actions)
            • Loop - Actions
              • Set VariableSet TempPoint = (Position of (Picked unit))
              • Unit - Create 1 Patron Dummy for (Picked player) at TempPoint facing Default building facing degrees
              • Custom script: call RemoveLocation (udg_TempPoint)
              • Unit - Pause (Last created unit)
      • -------- --------
      • -------- Setup enemy battle groups (blobs): --------
      • -------- --------
      • -------- Blob 0: --------
      • Custom script: set udg_BattleGroup[udg_BattleIndex] = CreateGroup()
      • Set VariableSet TempGroup = (Units in Blob0 <gen>)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Neutral Hostile
            • Then - Actions
              • Unit Group - Add (Picked unit) to BattleGroup[BattleIndex]
              • Set VariableSet CV = (Custom value of (Picked unit))
              • Set VariableSet BattleGroupIndex[CV] = BattleIndex
            • Else - Actions
      • Custom script: call DestroyGroup (udg_TempGroup)
      • Set VariableSet BattleIndex = (BattleIndex + 1)
      • -------- --------
      • -------- Blob 1: --------
      • Custom script: set udg_BattleGroup[udg_BattleIndex] = CreateGroup()
      • Set VariableSet TempGroup = (Units in Blob1 <gen>)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Neutral Hostile
            • Then - Actions
              • Unit Group - Add (Picked unit) to BattleGroup[BattleIndex]
              • Set VariableSet CV = (Custom value of (Picked unit))
              • Set VariableSet BattleGroupIndex[CV] = BattleIndex
            • Else - Actions
      • Custom script: call DestroyGroup (udg_TempGroup)
      • Set VariableSet BattleIndex = (BattleIndex + 1)
      • -------- --------
      • -------- Blob 2: --------
      • Custom script: set udg_BattleGroup[udg_BattleIndex] = CreateGroup()
      • Set VariableSet TempGroup = (Units in Blob2 <gen>)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Neutral Hostile
            • Then - Actions
              • Unit Group - Add (Picked unit) to BattleGroup[BattleIndex]
              • Set VariableSet CV = (Custom value of (Picked unit))
              • Set VariableSet BattleGroupIndex[CV] = BattleIndex
            • Else - Actions
      • Custom script: call DestroyGroup (udg_TempGroup)
      • Set VariableSet BattleIndex = (BattleIndex + 1)
      • -------- --------
      • -------- Blob 3 (etc): --------
  • Enter Battle 1
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit)).) Equal to True
      • BattleStarted Equal to False
    • Actions
      • -------- Find the Enemy unit's BattleIndex, which is the Index of their BattleGroup (the unit group they're stored in): --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Attacked unit)) Equal to Neutral Hostile
        • Then - Actions
          • Set VariableSet CV = (Custom value of (Attacked unit))
        • Else - Actions
          • Set VariableSet CV = (Custom value of (Attacking unit))
      • Set VariableSet BattleIndex = BattleGroupIndex[CV]
      • -------- --------
      • Trigger - Run Start Battle <gen> (ignoring conditions)
  • Enter Battle 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Target unit of ability being cast) belongs to an enemy of (Owner of (Casting unit)).) Equal to True
      • BattleStarted Equal to False
    • Actions
      • -------- Find the Enemy unit's BattleIndex, which is the Index of their BattleGroup (the unit group they're stored in): --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Target unit of ability being cast)) Equal to Neutral Hostile
        • Then - Actions
          • Set VariableSet CV = (Custom value of (Target unit of ability being cast))
        • Else - Actions
          • Set VariableSet CV = (Custom value of (Casting unit))
      • Set VariableSet BattleIndex = BattleGroupIndex[CV]
      • -------- --------
      • Trigger - Run Start Battle <gen> (ignoring conditions)
  • Start Battle
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) for 3.00 seconds the text: |cff00ff00Battle St...
      • -------- --------
      • Set VariableSet BattleStarted = True
      • Countdown Timer - Start BattleTimer as a Repeating timer that will expire in 0.25 seconds
      • -------- --------
      • -------- Disable resurrection stones: --------
      • Unit Group - Pick every unit in ResStones and do (Actions)
        • Loop - Actions
          • Unit - Pause (Picked unit)
  • Battle Timer
    • Events
      • Time - BattleTimer expires
    • Conditions
    • Actions
      • Game - Display to (All players) for 1.00 seconds the text: (|cff00ff00Checking battle status for Battle Index: |r + (String(BattleIndex)))
      • -------- --------
      • -------- Check on the status of the Player Heroes in the battle: --------
      • Set VariableSet AllHeroesDead = True
      • Unit Group - Pick every unit in PlayerHeroes and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Set VariableSet AllHeroesDead = False
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AllHeroesDead Equal to True
        • Then - Actions
          • Trigger - Run Battle Defeat <gen> (ignoring conditions)
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • -------- Check on the status of the Enemies in the battle: --------
      • Unit Group - Pick every unit in BattleGroup[BattleIndex] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to False
            • Then - Actions
              • Unit Group - Remove (Picked unit) from BattleGroup[BattleIndex].
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in BattleGroup[BattleIndex]) Equal to 0
        • Then - Actions
          • Trigger - Run Battle Victory <gen> (ignoring conditions)
        • Else - Actions
  • Battle Victory
    • Events
    • Conditions
    • Actions
      • -------- This runs if all of the Enemies in the Battle are killed. --------
      • -------- --------
      • Game - Display to (All players) for 3.00 seconds the text: |cff00ff00--- Battl...
      • Set VariableSet BattleStarted = False
      • Countdown Timer - Pause BattleTimer
      • -------- --------
      • -------- Enable resurrection stones: --------
      • Unit Group - Pick every unit in ResStones and do (Actions)
        • Loop - Actions
          • Unit - Unpause (Picked unit)
  • Battle Defeat
    • Events
    • Conditions
    • Actions
      • -------- This runs if all of the Player Heroes in the Battle are killed. --------
      • -------- --------
      • Game - Display to (All players) for 3.00 seconds the text: |cffff0000--- Battl...
      • Player Group - Pick every player in Players and do (Actions)
        • Loop - Actions
          • Game - Defeat (Picked player) with the message: Defeat!
Edit: Fixed a Unit Group leak, added v.2.
 

Attachments

  • Battle System 2.w3m
    27.4 KB · Views: 14
Last edited:
Status
Not open for further replies.
Top