Stealth System

Weyrling

New Member
Reaction score
25
I'm creating a stealth type system, which will check a 'Detection' value, and a 'Stealth' value for every unit on the map, I'm creating this so that I can increase sight range significantly, but still retain the element of surprise. I also think it's better than the Boolean Invisible/Detected system currently in place.
Every unit with a stealth value will have permanent invisibility.
Here's the detection trigger:
Code:
Stealth Detect
    Events
        Time - Every 0.60 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Set Integer = (Integer A)
                Set TempPoint = (Position of PlayerHeros[Integer])
                Set TempGroup[0] = (Units within PlayerStealthDetect[Integer] of TempPoint matching (((Matching unit) belongs to an enemy of (Player(Integer))) Equal to True))
                Unit Group - Pick every unit in TempGroup[0] and do (Actions)
                    Loop - Actions
                        Set TempPoint2 = (Position of (Picked unit))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Picked unit) is A Hero) Equal to True
                                ((Random real number between 5.00 and 200.00) + (PlayerStealthDetect[Integer] - ((Distance between TempPoint and TempPoint2) / 3.00))) Greater than or equal to PlayerStealth[(Player number of (Owner of (Picked unit)))]
                                (TempPoint2 is visible to (Player(Integer))) Equal to True
                            Then - Actions
                                Unit - Grant shared vision of (Picked unit) to (Player(Integer))
                                Unit Group - Add (Picked unit) to PlayerDetectedGroup[Integer]
                            Else - Actions
                        Custom script:   set udg_TempPoint2 = null
                Custom script:   set udg_TempPoint = null
                Custom script:   set udg_TempGroup[0] = null
        Set TempGroup[1] = (Units of type Footman)
        Unit Group - Pick every unit in TempGroup[1] and do (Actions)
            Loop - Actions
                Set TempUnit[0] = (Picked unit)
                Set TempPoint = (Position of (Picked unit))
                Set TempGroup[2] = (Units within 500.00 of TempPoint matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
                Unit Group - Pick every unit in TempGroup[2] and do (Actions)
                    Loop - Actions
                        Set TempPoint2 = (Position of (Picked unit))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (750.00 - ((Distance between TempPoint and TempPoint2) / 3.00)) Greater than or equal to PlayerStealth[(Player number of (Owner of (Picked unit)))]
                            Then - Actions
                                Unit - Grant shared vision of (Picked unit) to (Owner of TempUnit[0])
                            Else - Actions
                        Custom script:   set udg_TempPoint2 = null
                Custom script:   set udg_TempGroup[2] = null
                Custom script:   set udg_TempPoint = null
        Custom script:   set udg_TempGroup[1] = null

Here's the 'Un'Detection trigger:
Code:
Stealth UnDetect
    Events
        Time - Every 0.60 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Unit Group - Pick every unit in PlayerDetectedGroup[Integer] and do (Actions)
                    Loop - Actions
                        Set Integer = (Integer A)
                        Set TempPoint = (Position of PlayerHeros[Integer])
                        Set TempPoint2 = (Position of (Picked unit))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Or - Any (Conditions) are true
                                    Conditions
                                        (Distance between TempPoint and TempPoint2) Greater than or equal to PlayerStealthDetect[Integer]
                                        (TempPoint2 is visible to (Player(Integer))) Equal to False
                            Then - Actions
                                Unit - Deny shared vision of (Picked unit) to (Player(Integer))
                                Unit Group - Remove (Picked unit) from PlayerDetectedGroup[Integer]
                            Else - Actions
                        Custom script:   set udg_TempPoint2 = null
                Custom script:   set udg_TempPoint = null

I can't test it right now, so I'd appreciate if somebody could look it over and tell me:
1) Will it work properly?
2) Would it lag horribly?
2a) How can I optimize it if so?
 

Ashcat

Hellooo
Reaction score
68
I don't see any leaks, and every 0.6 seconds isn't too horrible, so I don't see it causing any lag unless your map is huge and has many triggers like this running at once.

And I'm not really sure if it will work, I'm not 100% sure what its supposed to do, unless you're trying to recreate the WoW stealth system. You should test it out yourself when you are able to, or attach the map so one of us can.
 

Slapshot136

Divide et impera
Reaction score
471
i think it would work, however is there any reason as to y there are 2 different triggers?
 

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
Because it's more organized that way, at least, that's my guess.
 

Weyrling

New Member
Reaction score
25
What I intend for it to do, is make every player invisible unless a unit detects them, I'm making the detection range based on a random number and a 'detection' variable compared against a 'stealth' variable, so you can be better or worse at stealth or detection, instead of just a truesight-500AoE instant detect.
I wasn't basing this off any other system, and I've never played WoW. I used 2 triggers for organization, yes.
I have attached the map here.
 

Ashcat

Hellooo
Reaction score
68
It doesn't seem to work. : /

When I selected my paladin by dragging the mouse over him instead of normally clicking on him, a second unit was also selected with the sorceress icon named "sight". Also when I try to move my paladin in any direction south, the paladin gets blocked by this "sight" unit and starts stumbling back and fourth without moving, so I suggest giving your sight unit the "Locust" unit ability (so make it unselectable and with no collision), and making it modeless because I can slightly see it as a tiny dot on the ground.

Back to the matter of the stealth detection, In the very first few seconds of the game, I saw the blue paladin even though I wasnt anywhere near him, then he disappeared and no matter how close I got to him he wouldn't show up. So I guess you need to rework your system, but I dont know what you could do, it looks to complicated for me to try to understand.
 

Weyrling

New Member
Reaction score
25
My bad, Blue is on force 1 with Red, and I did an 'enemy of' condition, I'll fix that and update it.
Fixed it:
 

Attachments

  • Shinobi.w3x
    66.8 KB · Views: 101

Ashcat

Hellooo
Reaction score
68
Okay that seems to work, I was able to see and attack the other paladin, and he chased me around too until i got too far, though the "Sight" unit is still getting in the way of movement and is very easy to see with it moving around, should still fix that.
 

Weyrling

New Member
Reaction score
25
I gave it Locust and it has pathing of 0.00, I don't want to give it flying because it could see past trees and cliffs and stuff, there any other way I could fix that?
 

Ashcat

Hellooo
Reaction score
68
This will work.

Code:
Unit - Turn collision for (Last created unit) Off

Also, I dont suppose you intend for people to see it, so in the object editor, click the "Art - Model File" field, check "Custom" and type in something like "none.mdl" then it will be invisible during gameplay.
 

Sooda

Diversity enchants
Reaction score
318
> I don't see any leaks, and every 0.6 seconds isn't too horrible

Firstly global variables (with 'udg_' suffix) don' t need to be nulled. Still all local variables what you create (if not natives like integers, reals, booleans, player variables) needs to be nulled when you are finished with using them. To remove successfully point leak use custom script:
Code:
call RemoveLocation(udg_pointVariableName)
Dosn' t small interval like 0.60 seconds diminishes your complicated distance formula? It dosn' t seem to give much effect.
Don' t you want to use default True Sight instead? You could make True Sight unit ability with so many levels how strong random effect you want per level. one dummy hero ability is needed to fake hero learns ability (or levels ability).
Create True Sight (unit) with 9 levels, make first hero level be between 1 to 3 level (1 level with 500 range, 2 level with 600 range and 3 level with 700 range. Make fake hero ability to say gives detection in 500 to 700 radius. If hero learns our fake True Sight ability add to hero our unit True Sight ability and periodically pick every hero on map (You could add heroes to unit group if hero learns fake True Sight ability and when periodic timer fires just do action for each unit in unit group, it would be clever and optimized approach to problem.) and check if True Sight for picked unit is less or equal to level 3 then get random number between 1 and 3 and set on picked unit True Sight ability to that random number (If level would be less or equal to 6 it would mean hero has level 2 detection, get random number between 4 and 6 and set hero True Sight (unit) ability to that level).
It' s good because you only have to set hero ability level and all that detection is actually done very fast and additionally units will fade out automatically with Visibility if out of range.
This method expects that tooltips for True Sight (unit) are from 1 to 3 level exactly same to fake player to think there isn' t going on anything.
 

Ashcat

Hellooo
Reaction score
68
The problem with using true sight, is that he said there are both detection levels, and stealth levels. If a hero has say lvl 3 detection, and a lvl 1 stealth hero comes in range, but then another lvl 9 stealth hero comes in range at the same time, he would be able to spot the level 9 hero even though its stealth level is so much higher.
 

Weyrling

New Member
Reaction score
25
The problem with that is I want both the guy detecting, and the guy being detected to modify the chance to detect. I'm not entirely sure how to implement both variables and a leveled truesight ability. If the current method works properly, would the optimization be worth it?
 

Sooda

Diversity enchants
Reaction score
318
> If the current method works properly

Then keep it, just remove memory leaks and you have to remove/ destroy leak before you null it. For more specific memory leak definition use search. Ace explained it well.
Must say your stealth system concept is very original and good.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top