Coding Stealth

Discussion in 'Custom Content' started by Lancelot1106, Feb 23, 2019.

  1. Lancelot1106

    Lancelot1106 Orbital Explorer

    Hi everyone,
    I'm creating a big level starting with a stealth(ish) part in fog of war, but since I'm not good enough yet with the event editor, I might need some help....

    So I was thinking to start things of with the next event:

    Properties:
    - Trigger Name: Commander is 'seen'
    - Recurrent: Repeat

    Players:
    - 'Commander from trigger name'

    Conditions:
    - Unit: Visible (When Commander from player 1 at any location can see unit from player 2)

    Actions:
    - Unit: Modify Health (Set Commander hp to 10%)


    The 10% is to add a little bit of a scare and also a little bit of comeback possibility even after being spotted. The problem, though, is the Commander's health dropping to 10% at the start of the game when there's not even a unit from player 2 on the field.....

    The second problem I faced is the reset for health.
    My goal is to make the player go out of vision again and gaining its health restored to 100%

    I thought something like this:

    Properties:
    - Trigger Name: Commander is 'unseen'
    - Recurrent: Repeat

    Players:
    - 'Commander from trigger name'

    Conditions:
    - When: End of Unit Turn
    - (this is where the second problem is, creating a way to inverse the 'Unit: Visible')

    Actions:
    - Unit: Modify Health (Set Commander hp to 100%)

    I hope anyone can help me with these problems.
     
    • Hezablak

      Hezablak Tentacle Wrangler

      I understand this is an old post. But I have some algorithms I am currently trying to code for your problem. If you could provide more details, I think I can better code stealth. For example. Is the commander trying to stealth through the stage? From what I understand the commander is stealthing, yet when he sees a unit, the commander loses health. I was wondering if it should be the other way around? When he enters an enemies field of vision. He goes down to 10? Either way. More details would help.
       
      • Lancelot1106

        Lancelot1106 Orbital Explorer

        Since the field of vision of most unit's is 4 (including the commander's) I thought it would be easiest to trigger everything only when the commander sees an enemy unit, since the vision is the same and the enemy will see the commander too.

        The reason the commander loses health is for 2 reasons. First of all, it acts as a warning to tell people: 'hey, you're about to be spotted!'. Second, it gets rid of the commander being able to kill the unit (so it acts as anti-cheese).

        As a side note, I worked out the kill mechanism with a counter set to 2. When in vision, the counter drops with 1 per turn and at 0 it kills the commander.

        Also, I have been messing around and actually found a kind of solution. Creating zones with the exact vision range helped me out a lot. When the commander enters a zone, his/her health drops. When the commander is in the zone for too long, he/she will be 'spotted' and die. When the commander goes out of vision again, the health restores. This can be particularly useful since you can move the units, followed by moving the zone onto the unit. Only problem is that with 20 units, you'll have to make 20 zones. Hopefully you can do something with these ideas.
         
        • Hezablak

          Hezablak Tentacle Wrangler

          Here is a stealth algorithm that I broke down into 4 events.

          Process. Player 1 is trying to get 1 commander through an area without being seen. If spotted by an enemy unit the commander will be told he is seen and hp set to 10% at the end of turn. On Player 2's turn, if the commander is still visible by the end of turn, the commander will be marked as seen. On Player 1's turn, if the commander is marked as seen and is still visible by the end of the turn, they lose.

          If on their turn they are able to get rid of vision they will soon be able to be healed and return to an unseen marking.

          Flag: Seen default false

          Events
          Properties:
          - Trigger Name: Commander "spotted"
          - Recurrent: Repeat

          Players:
          - Player 1
          Conditions:
          - Is map flag Spotted false?
          - Unit: Visible: Commander owned by Player 1 at Any Location can be seen by Player 2.
          - Is it the end of the turn?

          Actions:
          - Unit: Modify Health of Commander at Any Location for Player 1: set to 10%.
          - UI: Dialogue: Commander says "I've been spotted."

          Properties:
          - Trigger Name: Commander "seen"
          - Recurrent: Repeat

          Players:
          - Player 2 You only want 1 copy of most of these events. and it doesn't matter who current player is.

          Conditions:
          - At the end of the turn.
          - Is it Player 2's turn?
          -Unit Visible: Commander owned by Player 1 at Any Location can be seen by Player 2.

          Actions:
          - Set Map Flag Spotted to true.
          - UI: Dialogue: P2 Commander says "I SMELL YOU!!!"

          Properties:
          - Trigger Name: Commander "caught"

          Players:
          - Player 1

          Conditions:
          - At the end of the turn.
          - Is it Player 1's turn?
          -Unit Visible: Commander owned by Player 1 at Any Location can be seen by Player 2.
          - Is map flag Spotted true?

          Actions:
          - Eliminate Player 1.
          UI: Dialogue: P2 Commander says "GOTCHA!

          Properties:
          - Trigger Name: Commander "hidden"
          - Recurrent: Repeat

          Players:
          - Player 1

          Conditions:
          - Does Player 1 have exactly 1 of Commander at Any Location with more than 20% health?
          OR
          - Does Player 1 have exactly 1 of Commander at Any Location with more than 10% health?

          Actions:
          - Modify health of Commander at Any Location for Player 1: set to 100%
          - Set Map Flag Spotted to false.

          Side note: The tough part of coding this was the unchecking of the spotted flag. But since Commander's auto heal for percentage I took advantage of that. You can use it to be as strict or loose as possible in getting caught. if you set it for more than 10%, the commander has to stay out of vision for 1 turn. If more than 20% probably 2 turns... etc. Either way this means just because I leave vision, I am not immediately safe. Also, you can change enemy AI to aggresive or turtle depending on the state of the flag of seen or not. This means they will chase if spotted, and they will do something else if not spotted.
           

          Share This Page