• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Knights and Merchants battle system.

Status
Not open for further replies.
Level 13
Joined
Oct 28, 2019
Messages
523
Any of you played KaM ? I´m trying make a map with Kam´s battle system. It happens like this: When a melee unit starts combat, the player loses control of that unit, it's simple, just change the player from the attacked unit to another pc player. But how do I get the unit back under control after the fight?
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
not familiar with KAM and so I'm not sure I understand exactly what you want to do. You are trying to detect when your unit has killed the unit he was fighting? if so you could do:

  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Killing unit) Equal to (Merchanty Knight unit)
    • Actions
 
Level 13
Joined
Oct 28, 2019
Messages
523
  • Untitled Trigger 001
    • Events
      • Unit - A unit owned by Player 1 (Red) Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to Militia
    • Actions
      • Set VariableSet UnidadesTEAL = (Attacked unit)
      • Unit - Change ownership of (Attacked unit) to Player 3 (Teal) and Retain color
  • Untitled Trigger 002
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Change ownership of UnidadesTEAL to Player 1 (Red) and Retain color
      • Wait 1.00 seconds
      • Unit - Change ownership of UnidadesTEAL to Player 1 (Red) and Retain color
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
what you did will only work with one unit bc as soon as the second unit is set as UnidadesTEAL you no longer have access to the first unit. also bc you made the trigger periodic it will keep giving you back the unit in the middle of the fight, which is not really a problem but it might behave funny.
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
this works:

  • Start Fight
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Owner of (Attacking unit)) Equal to Player 1 (Red)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (UnitGroup is empty) Equal to True
        • Then - Actions
          • Trigger - Turn on End fight loop <gen>
        • Else - Actions
      • Unit Group - Add (Attacking unit) to UnitGroup
      • Unit - Change ownership of (Attacking unit) to Player 3 (Teal) and Retain color
  • End fight loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • Set Point = (Position of (Picked unit))
          • Set UnitsInRangeGroup = (Units within 700.00 of Point matching (((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to True))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (UnitsInRangeGroup is empty) Equal to True
                  • (All units of UnitsInRangeGroup are dead) Equal to True
            • Then - Actions
              • Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color
              • Unit Group - Remove (Picked unit) from UnitGroup
            • Else - Actions
          • -------- destroy the unit group and point here to avoid leaks --------
          • Custom script: call DestroyGroup(udg_UnitsInRangeGroup)
          • Custom script: call RemoveLocation(udg_Point)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (UnitGroup is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
make sure you have teal set as an ally with shared vision in scenario settings. Also the second trigger should be set to - enabled but initially off. And I set the range to 700 bc most ranged units have 600 (I think), but if you are using any units with artillery range, you should change that part of the trigger accordingly...

I hope this answers your question:cool:2.
 

Attachments

  • KaM Auto battle.w3x
    18.6 KB · Views: 21
Last edited:
Level 25
Joined
Mar 29, 2020
Messages
1,466
Remember, you can also check if a unit is "idle" by checking if it's current order is equal to "stand down".

Looping through the UnitGroup, you can check this order for each Picked Unit.

I tried that first and I couldn't get it to work well. somehow the computer kept issuing that order between attack orders and the units kept switching ownership and were totally bugging out and not attacking.
 
Level 13
Joined
Oct 28, 2019
Messages
523
How I do upgrades? Like Iron Swords. Cause when the unit goes to player 3 controler, the upgrade dont appear.

  • ResearchsSword Copy
    • Events
      • Unit - A unit owned by Player 1 (Red) Finishes research
    • Conditions
      • (Current research level of Blindagem de Ferro for Player 1 (Red)) Equal to 1
    • Actions
      • Wait 2.00 seconds
      • Player - Set the current research level of Blindagem de Ferro to 1 for Player 3 (Teal)
done
 
Last edited:
Status
Not open for further replies.
Top