Stealth System

Lord Valdyr

Team BlackHawk Dev
Veteran
Joined
Mar 13, 2012
Messages
159
Reaction score
18
First Language
English
Primarily Uses
Idk if I'm doing this wrong but the character sprite doesn't appear to change when I duck?

I used the suffix "_duck" in the script and I made a translucent version of the evil sprite sheet.

So to be clear my normal character sprite sheet is Evil.png my translucent sprite sheet is Evil_duck.png

Edit:

Also when I use a conditional branch with "can_see?(0)"

I get This error.

"Script 'Game_Interpreter' line 450: Math::DomainError occurred

Numerical argument is out of domain - "atan2"

Do I misunderstand how to use this?
 
Last edited by a moderator:

Helladen

Deviant Designer
Veteran
Joined
Jul 13, 2012
Messages
635
Reaction score
186
First Language
English
I don't think the stealth detection in this script works, because I've increased my camouflage by 1,000 and setup a parallel process event, but it still detects me over 50 tiles away. It could be my fault, but I've spent almost thirty minutes testing this and nothing appears to get it working correctly.

I am using can_see?(0) as the conditional branch check and making sure it sets my camouflage before the parallel process event will even check it. I would look around the script and fix this, but I'm doing this for the summer contest, and would much rather just write a common event system to save time.

Let me know if you have a solution, thanks. :)
 
Last edited by a moderator:

Lord Valdyr

Team BlackHawk Dev
Veteran
Joined
Mar 13, 2012
Messages
159
Reaction score
18
First Language
English
Primarily Uses
It's can_see?(-1) to detect the player I did the same thing lol
 

Helladen

Deviant Designer
Veteran
Joined
Jul 13, 2012
Messages
635
Reaction score
186
First Language
English
It is? I thought the instructions said it was 0.

Oh wow, thanks. The way it was written appeared like it was leading up to 0, but it was actually not. No problem with the script, just a misinterpretation.
 
Last edited by a moderator:

Lord Valdyr

Team BlackHawk Dev
Veteran
Joined
Mar 13, 2012
Messages
159
Reaction score
18
First Language
English
Primarily Uses
Yea I was confused too
 

IsFutureBright

Lightning Bolt Action
Veteran
Joined
Dec 26, 2012
Messages
120
Reaction score
11
First Language
Portuguese
Primarily Uses
What's the min and max camo? I mean I've set up camo = 10 and when I'm standing 1 tile away from the guard he does not sees me. Hell I event tried camo = 0 but he will only see me if I start running around his direction for a while... Am I being dumb? lol
 

Alien51

Warper
Member
Joined
Jan 14, 2013
Messages
3
Reaction score
0
First Language
English
Primarily Uses
Um, I very new to RPG maker and was wondering how do I check if i'm detected?

EDIT: whoops it was really obvious  :)

EDIT How do I make it so that the event can detect me by hearing? I would like the ability to have to sneak up to people not be able to walk right behind them.
 
Last edited by a moderator:

ninjatone

Villager
Member
Joined
Feb 12, 2013
Messages
6
Reaction score
0
Primarily Uses
I really like the ideas in this script; seems quite nice. However, with the default settings and no other scripts installed, I keep getting two problems: first, if the player is in a direct line from the event, the player isn't caught by the "sighted?" function. I have a test event with a parallel process checking for the script condition "can_see?(-1)"; if i take even one step out of a direct line from the event, suddenly the player is spotted, but the player will remain invisible as long as he's in a direct line in front of where the event is facing. Second, if there's an impassible tile between the player and the event in a direct line, no matter what the impassible tile height is set to be, the "sighted?" function will also fail (though it will return a value).

When debugging with the RGSS console, the problem area in the "sighted" function seems  to be this part:

  tiles.each {|coords, heights|
      next if coords == [self.x, self.y]
      if heights[1] <= 0
        puts("Height fail:",heights[1])
        return false
      end
    }

In the case of the player being in a direct line of sight from the event with no obstacle, "heights[1]" is 0. If there's an impassible event in the way, no matter the height, the value is -Infinity.

Anyone else having this issue? Any ideas?
 
Last edited by a moderator:

ninjatone

Villager
Member
Joined
Feb 12, 2013
Messages
6
Reaction score
0
Primarily Uses
OK, I went back to this after a while, and got somewhat of a 'hack' fix for the above issues; it seems to work in testing (even when running XAS Ace, no less). While this fix will likely screw up plans for complex & precise height checking across varied terrain and event heights, it at least allows you to have a stealth action game where you can crouch behind waist-high obstacles in order to remain hidden, and you get seen when you stand up in the enemy's line of sight. It will also cause obstacles taller than the height of an event to block that event's line of sight.

I'm not a scripter so this may be inefficient/buggy, but this solution seems to work, provided you're OK with the above tradeoffs. (And I am. Assuming your map terrain was probably going to be mostly flat anyway, and the 'characters' in your stealth sequences have mostly the same heights, it works and makes sense. This probably also works best with Mack-sized charas, since that makes ducking look & work more naturally with the settings below.)

Basically, there are four steps to get it working. Note that you *DO* have to do some manual terrain tagging of your tilesets.

1. Find the code in my post above and replace it with this:

tiles.each {|coords, heights| next if coords == [self.x, self.y] sx = self.x - char.x sy = self.y - char.y if sx.abs > sy.abs direction = sx > 0 ? 4 : 6 elsif sy != 0 direction = sy > 0 ? 8 : 2 end height = $game_map.total_height(coords[0], coords[1], direction) return false if height >= self.height case direction when 2 return false if ((height >= char.height) and (char.x == coords[0]) and (char.y == coords[1] + 1)) when 8 return false if ((height >= char.height) and (char.x == coords[0]) and (char.y == coords[1] - 1)) when 4 return false if ((height >= char.height) and (char.x == coords[0]-1) and (char.y == coords[1])) when 6 return false if ((height >= char.height) and (char.x == coords[0]+1) and (char.y == coords[1])) end if heights[1] < 0 return false end }Note that "heights[1] < 0" replaces "heights[1] <= 0"--this is crucial, as it fixes the "invisible in direct line of sight" issue. I have no idea what that variable evens means, though; I haven't encountered any bugs with it, but there could be some. It just seems to work.

Also note that when the player is ducking behind an object of a height less than that of the 'enemy' event's height, the player will *only* be hidden if he is right next to the tile and on the far side of it in the enemy's line of sight. I suppose you could also change the code above to have the cutoff height be based on the player's instead of the enemy event's. Meh. As I said, I'm no coder, so I go with whatever works for me regardless of elegance/precision/efficiency.

2. Change "UNPASSABLE_HEIGHT = (1.0 / 0.0)" to just "UNPASSABLE_HEIGHT = (1.0)"--that should fix the div by zero issue causing the "-infinity" result described in my previous post.

3. Define custom terrain heights. These are the ones I used, which assume that all other settings are left as default. Descriptions included below.

TERRAIN_HEIGHTS = { 1 => 5.0, # Wall 2 => 2.0, # Two-tile-high impassable object 3 => -1.0, # Impassable object that player shouldn't be able to duck behind }4. Apply the terrain tags to your tiles.

You need to apply Terrain 1 to ALL wall & ceiling tiles--otherwise the default impassable height of 1.0 will cause enemies to have magic x-ray vision and see the player through walls (since the height of the player is 1.7 by default).

Like it says, Terrain 2 should be applied to two-tile-high impassable objects. This will allow you to hide behind the obstacle without ducking. The terrain tag should *only be applied to the base tile* of the object, though.

Terrain 3 is for tiles that are impassable but which the player shouldn't be able to hide behind by ducking--beer bottles, bones, things of that nature. The -1 offsets the default impassable terrain height of 1.

-----

OK, that about covers it. I won't be supporting this workaround b/c I really have no idea what I'm doing in the first place.

Adding in scripts for sound detection or backstabbing (via XAS) would be interesting, but I'm not up to the task. Happy stealthing.
 
Last edited by a moderator:

Obrusnine

Warper
Member
Joined
May 5, 2012
Messages
4
Reaction score
1
First Language
English
Primarily Uses
It's odd, this seems to work mostly fine, but I noticed that if you are in events direct line of sight (the direction it is facing) everything within that line of sight (the tiles straight ahead of the events facing) you are completely unable to be detected.
 

Necromedes

Artist, Composer and Eventer
Member
Joined
Jan 6, 2013
Messages
19
Reaction score
1
First Language
English
Primarily Uses
Ok, I may be missing something here but I have a few questions regarding your script.

01: I see nothing in the script that allows me to adjust an events sight range. Does it simply not have an option for that? The reason I ask is because I may want to make human events and then guard dogs with a higher sight range.

02: By region ID, do you mean the map ID? (I know, dumb question but I'm out of practice of using scripts)

03: Once I get a handle on using this script, would you permit me to make a tutorial video of it? I'm working on a youtube channel for game design like this and thought it would be handy to have a tutorial on some of the more popular scripts.

Thanks in advance!
 

gallo101

Villager
Member
Joined
Dec 14, 2015
Messages
6
Reaction score
0
First Language
Italian
Primarily Uses
i used on an event ">@Conditional branch: Script: can_see?(-1)" but it seems not to see the character. There's a big possibility that i made something wrong. Can someone please tell me to do what have i got to write?
 

Dragon Brother

Survive, Adapt, Infest.
Veteran
Joined
Dec 30, 2015
Messages
102
Reaction score
128
First Language
English
Primarily Uses
RMVXA
First of I'd like to greet and introduce Myself, as You may already know, I am Dragon Brother, secondly thank You for allowing a noob to reply and comment on this thread, lastly is this script available for commercial use? I fully understand it is Your creation and if no, I can accept.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,140
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
Jet said:
If you need commercial usage of my scripts, or would like to commission me for a script, PM me for details.
 

Guardinthena

Artist
Veteran
Joined
Nov 30, 2013
Messages
271
Reaction score
494
First Language
English
Primarily Uses
RMVXA
Whoa, whoa, whoa...wait, I was reading the directions in the script and correct me if I'm wrong but I can have two events (not the player) check to see if they see each other?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

There's another Humble Bundle available now for RPG developer assets, this time focused somewhat more towards pixel art style games.
Ive got a long lost half uncle. Thats real cool.
I forget what is bumping rule in this forum. Is anyone know? Thank you.
BCj
Ew, why does my blogpost on the rpgmaker.net site look like a garbled mess? Are html codes disabled or something?
I feel that I should cut down on my order queue so I can get some more time for my projects, its been quite a longggg while since I worked on them LOL

Forum statistics

Threads
97,900
Messages
947,725
Members
129,136
Latest member
ivanpuvko
Top