Hi, thanks for asking. I'm trying to create a script that can detect if an entity is outside of the view where the players are currently playing for example.
I'm searching in the forum and the manual (but no luck). I've used to program with game maker and the code language was called viewport , you could make scripts like if enemy is outside of viewport destroy enemy or whatever really.
int...
My apologies, I mean the screenviewWhat do you mean "outside of view"?
DC
Hi, thanks for asking. I'm trying to create a script that can detect if an entity is outside of the view where the players are currently playing for example.@PS_VITA
do you mean something like the cop car you summon on streets of rage or the elevated camera intro of aztec level in NSlashers?
Hi, thanks for asking. I'm trying to create a script that can detect if an entity is outside of the view where the players are currently playing for example.
I'm searching in the forum and the manual (but no luck). I've used to program with game maker and the code language was called viewport , you could make scripts like if enemy is outside of viewport destroy enemy or whatever really.
int screen_size_x = 0;
int scroll_x = 0;
int edge_right = 0;
screen_size_x = openborvariant("hresolution");
scroll_x = openborvariant("xpos");
edge_right = scroll_x + screen_size_x;
Hi,Oh! That's easy. You just need the current scroll position and screen size. Scroll position is the left edge. Add the horizontal screen size to that and you get the right edge. All you need to do from there is compare them to an entity's X position. This assumes you don't have any scripted camera offset positions in play.
C:int screen_size_x = 0; int scroll_x = 0; int edge_right = 0; screen_size_x = openborvariant("hresolution"); scroll_x = openborvariant("xpos"); edge_right = scroll_x + screen_size_x;
HTH,
DC
Yes thanks, it's the reason why I made this topic is to find out how offscreenkill works. (I actually mentioned it in the very first post) I'm not particularly using this to kill any entities atm, but it's very usefull for NPCs that tend to hang out a bit to much offscreen and other useful things.@PS_VITA,
I forgot to mention that depending on the situation you may not have to use script at all. The engine automatically kills entities that reach a certain distance offscreen. You can adjust this withoffscreenkill {value}
model setting.
DC
On that front - what is your solution @PS_VITA - to entiities that are supposed to wander, but you want them to be "scared" of want them to avoid staying off screen too much -Yes thanks, it's the reason why I made this topic is to find out how offscreenkill works. (I actually mentioned it in the very first post) I'm not particularly using this to kill any entities atm, but it's very usefull for NPCs that tend to hang out a bit to much offscreen and other useful things.
On that front - what is your solution @PS_VITA - to entiities that are supposed to wander, but you want them to be "scared" of want them to avoid staying off screen too much -
basically how would you make them wanderers, but only within the confines fo the screen ?
@oldyz I always used custom chase scripts and I believe that's the reason I never got wanders to actually work and as for editing every wanderers I know it can be alot of work. There's is an option you can toggle to change all entities that go offscreen but it didn't work for me but I wonder if you ever tried it. unfortunately, I can't remember what it was called but I will search and try to get back to you.@PS_VITA - Ok if you have any chance too look into how to make "Wander" enemies scared of the edges let me know,
i did suspect that its a script to change the AI based on position, but such a solution means editing every single "wanderer' on my module....
You are absolutely right, and actually I think offscreen_noatk_factor effects all entities....@PS_VITA
no, that toggle would not work, I like the entities to launch attacks offscreen, if you use that toggle it means that an entity would not try and punch you or do antything if its beyond the visible border - in this case i would like the wanderers to be offscreen enough to be realsitic -
On that front - what is your solution @PS_VITA - to entiities that are supposed to wander, but you want them to be "scared" of want them to avoid staying off screen too much -
basically how would you make them wanderers, but only within the confines fo the screen ?