offscreenkill suggestion

ABK

Well-known member
Currently offscreenkill works when model spawns so i though how about changing it and let offscreenkill count only when model is already onscreen, so it will be active only when model is visible in playable area and it wont be active during spawn so when we will go forward and leave the model behind then offscreenkill will remove it, currently offscreenkill removes even on spawns which isnt really useful, it could be used better if offscreenkill would be activated only when given entity is already visible so offscreenkill would be inactive from the moment of spawn till whole offscreen time when it still isnt in playable area.
I had some slowdowns on android because i had lots of landmines and i thought if it slowdowns that much... i could of change their offsets a bit but it would be cool if ofscreenkill wouldnt work during spawn animation and when landmines arent even visible onscreen yet.
This might be even direction left or right based, but im using direction both in stages, i suppose it would be much easier to do it in one directional stage so offscreen would be active only when entity is offscreen on left side of the screen if stage is direction "right"
 
It is very easy to script your own offscreenkill function. Example:


Code:
void osk(int value)
{
  void self = getlocalvar("self");
  int sx = openborvariant("xpos");
  int sy = openborvariant("ypos");
  int x = getentityproperty(self, "x");
  int y = getentityproperty(self, "z");
  int w = openborvariant("hResolution");
  int h = openborvariant("vResolution");

  int active = getlocalvar("oskactive");

  x -= sx;
  y -= sy;

  if(!active)
  {
      if(x>0 && x<w && y>0 && y<h)
     {
        setlocalvar("oskactive", 1);
      }
  }
  else
  {
    if( x<-value || x>w+value || y<-value || y>h+value)
    {
      killentity(self);
    }
  }
}


Code:
anim idle
    offset 96 96
    delay 50
    @cmd osk 120
    frame data/chars/mine/idle1
    frame data/chars/mine/idle2

I think animation script should be fine for most case. Update script doesn't hurt much, but the system doesn't need to be 'accurate' at all.


Similarly, you can modify the code to make osk_right, osk_left or just add another direction parameter.
 
ah thanks, youre right, i was using killself for every entity but i noticed that if i dont use it with hitflashses then game is a bit faster, killself slowed gampley a bit with lots of hitflashes and animation of blood werent that smooth comparing without killself, now im using it only when its really needed.
 
Blood might be the problem. Because they don't disappear immediately, they'll add up quickly. Especially in a shooting stage.

There's a more straight way. You can try spawnoverride command in levels.txt, for example,

spawnoverride 75

Then give a negative priority value for those blood drops, for example:

name blood
priority -100

When there are more than 75 entities, any newly spawned entity(if priority is greater or equal to -100) will replace an old blood.
 
It is very easy to script your own offscreenkill function

I cant make it work properly.
I have a next problem to solve:
When you kill an enemy, he spawns an item, but if enemy was killed offscreen item will be spawned offscreen, so i need a script that make item kill if it is (spawned) offscreen. I have tried osk script but it does not work.

anim idle
loop 1
delay 1000
offset 16 30
bbox 0 0 32 34
@cmd osk 1
frame data/chars/misc/item/apple.gif

Can you help me?
 
TRy this, im using it in death animation so enem ywalks offscreen and is killed when hes 200 pixels offscreen
Code:
			@script
                void self = getlocalvar("self");
               int  pos  = openborvariant("xpos");
                int  selfx     = getentityproperty(self, "x");
     		if ((getentityproperty(self, "direction")==1)&&(frame == 7)){
		changeentityproperty(self, "velocity", -6, 0, 0);
		}
		if ((getentityproperty(self, "direction")==0)&&(frame == 7)){
		changeentityproperty(self, "velocity", 6, 0, 0);
		}
		if (selfx > pos + 1500 ){
                  killentity(self);
		 	}
            		 if (selfx < pos - 200 ){
                  killentity(self);
		 	}
	@end_script
 
Thank you, bWWd!
hmm.. i have modify it and now it is working.

void osk()
{
  void self = getlocalvar("self");
  int  pos  = openborvariant("xpos");
  int  selfx    = getentityproperty(self, "x");

if (selfx > pos + 961 )
{
        killentity(self);
}
        if (selfx < pos - 1 )
{
        killentity(self);
}
}

anim idle
loop 1
delay 10
offset 17 30
bbox 0 0 33 35
frame data/chars/misc/item/money.gif
@cmd osk
frame data/chars/misc/item/money.gif
 
Great, -1 is quite low vaule and if sprites are big it might disappear too soon and look weird.If you have small sprites then should be fine

Offscreenkill could have 2 values, for left and right border of the screen so if you will use only "offscreenkill 500" then it will remove them at 500 from left and right but if you will use "offscreenkill 100 700" then it will remove them at 100 from left and 700 from right. That would be nice instead of hackarounds like this with script.
 
Back
Top Bottom