Solved Can entities create a hole in the ground (?)

Question that is answered or resolved.

Crimsondeath

Active member
Can entities create holes in the ground? or a way to do it by script? For example:

gXOIwGQ.gif

I have this enemy who spawns from sewer and throws the cover leaving a hole (that can make you lose a live of course xd).

The problem is that I have to create the hole before to make this work properly:
5c2um8o.gif


Other wise the hole never works even if the sewer cover is already taken :( .

I already tried making a platform in sewer cover but the entities keep falling x.x.
 
Solution
You need to change the platform base to base -9999 in script.

It works great :D, thank you.
Can entities create holes in the ground? or a way to do it by script? For example:

gXOIwGQ.gif

I have this enemy who spawns from sewer and throws the cover leaving a hole (that can make you lose a live of course xd).

The problem is that I have to create the hole before to make this work properly:
5c2um8o.gif


Other wise the hole never works even if the sewer cover is already taken :( .

I already tried making a platform in sewer cover but the entities keep falling x.x.
@Crimsondeath

Hi friend. Please can you post the hole and the platform sewer cover adjustments? It seems that the cover's size is not enough to protect from the hole, in addition you must add a minimum height for the platform's cover otherwise it will not work properly.

You can download and unpack my SOR2X game to see how it works, in the video below you can see it in action from 20:45.

Here's an example of the hole's size.
1705363079602.png

Once you put a height in the cover's platform, the entities will be blocked. To make them passthrough I recommend to use a script inside the onblockpscript event inside every character (or only for players). You can get it below, you must change the name "St1_Manhole" with your entity cover's name:

C:
void platform()
{//Up or move to not stuck into platforms or non breakable obstacles (ALL STAGES)
    void self    = getlocalvar("self");
    void plat    = getlocalvar("platform");
    void pName    = getentityproperty(plat, "defaultname");
    int xDir    = getentityproperty(self, "xdir");
    int zDir    = getentityproperty(self, "zdir");
    
    if(pName == "St1_Manhole"){
        tossentity(self, 0.001, xDir, zDir);
    }
}
 
Can entities create holes in the ground? or a way to do it by script? For example:
As far as I know, they can't "create" holes, but they can manipulate them using changelevelproperty.
So you would need to have a hole on your stage somewhere - like offscreen or out of boundaries and change it on the fly. Works for walls and basemap too.

Funny enough, you actually can create basemaps by script, from scratch, using the generatebasemap() function.
 
I recommend to use a script inside the onblockpscript
hum this sounds good. I have a script to spawn my enemies on random places and, sometimes, they spawn inside objects.
So I could adapt this code to bypass this, right? I was considering making an invisble entity which would destroy any obstacle on the entity spawn.
 
So I could adapt this code to bypass this, right?
Yes, you could maybe put a movement in any axis or position adjustment, as soon as they are blocked the script will act.
In addition, you could apply an action to force them to break the obstacles, simulating some kind of "natural" reaction like if they act as players. I'm using this in the SORX.

C:
    //USED FOR ENEMIES AND CPU PARTNERS ONLY, BREAK OBSTACLES TO UNSTUCK
    if(vType == openborconstant("TYPE_ENEMY") || vType == openborconstant("TYPE_NPC")){
        if(pType == openborconstant("TYPE_OBSTACLE")){
            if(anim == openborconstant("ANI_WALK") || anim == openborconstant("ANI_RUN")){
                if(y == b && xDir == 0 && (x < xPos+hRes || x > xPos)){
                    int dir;

                    if(x > Tx){dir = 0;}
                    if(x < Tx){dir = 1;}

                    if(vType == openborconstant("TYPE_NPC")){
                        float iR = rand()%50+50;

                        //RANDOMIZE BETWEEN TWO DIFFERENT ATTACKS
                        if(iR >= 0 && iR < 50){
                            anim = openborconstant("ANI_ATTACK1");
                        }
                        else
                        if(iR >= 50 && iR <= 100){
                            anim = openborconstant("ANI_FREESPECIAL3");
                        }
                    }

                    if(vType == openborconstant("TYPE_ENEMY")){
                        anim = openborconstant("ANI_ATTACK1");
                    }

                    setidle(self, openborconstant("ANI_IDLE"));
                    changeentityproperty(self, "velocity", 0, 0, 0);
                    changeentityproperty(self, "direction", dir);
                    performattack(self, anim, 1);
                }
            }
        }
    }
}
 
@Crimsondeath

Hi friend. Please can you post the hole and the platform sewer cover adjustments? It seems that the cover's size is not enough to protect from the hole, in addition you must add a minimum height for the platform's cover otherwise it will not work properly.

You can download and unpack my SOR2X game to see how it works, in the video below you can see it in action from 20:45.

Here's an example of the hole's size.
View attachment 6733

Once you put a height in the cover's platform, the entities will be blocked. To make them passthrough I recommend to use a script inside the onblockpscript event inside every character (or only for players). You can get it below, you must change the name "St1_Manhole" with your entity cover's name:

C:
void platform()
{//Up or move to not stuck into platforms or non breakable obstacles (ALL STAGES)
    void self    = getlocalvar("self");
    void plat    = getlocalvar("platform");
    void pName    = getentityproperty(plat, "defaultname");
    int xDir    = getentityproperty(self, "xdir");
    int zDir    = getentityproperty(self, "zdir");
  
    if(pName == "St1_Manhole"){
        tossentity(self, 0.001, xDir, zDir);
    }
}

Hi @Kratus , I already tried platforms with 1px height, but force player to jump for walking over the cover:

65Rrpnf.gif


Here are the codes, how is the cover at the Stage:

Code:
...
order    ab

type    0 0 0
noreset    0
rock    0
mirror    0
blocked    0
endhole    0
maxfallspeed    -60
maxtossspeed    1000
noslow    0
setweap    0
direction    both
cameraoffset    0 -100

spawn1    430 50 250
spawn2    390 95 250

hole 1250 260 10 0 55 65 22 0 #<--- The sewer hole

...

spawn    Biosoldado_F
coords    360 260 0
map    1
at    841


spawn    Tapadesague #<--- this is the cover.
coords    360 245 0
at    925


Wait
at    1090
blockade    1090
at    1090
Group    0 4
at    1090


spawn    El_Chino
coords    360 225 0
at    1090

...

Code of the sewer cover:

Code:
name    Tapadesague
speed    10
type    none
offscreenkill    9999
height          1
subject_to_hole 0
subject_to_gravity 0

palette    data/chars/panels/stage4/tapadesague1a.gif

animationscript data/scripts/fscript.c

...

anim    idle
    loop    1
    offset    39 15
    delay    1
    platform    -16 41 -26 -26 114 114 57 1 #<-- The Platform Height
@script
if(frame == 0){
        void vEntity;
    int  iEntity;
    int iMax = openborvariant("count_enemies");
    void self = getlocalvar("self");
    for(iEntity=0; iEntity<iMax; iEntity++){
        if (iMax == 1) {
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1")); #<--- Ani_Follow1 is where the enemy is spawn.
        }
    }
}
    @end_script
    frame    data/chars/panels/stage4/tapadesague1a.gif
    frame    data/chars/panels/stage4/tapadesague1a.gif

The onblockscript on the player:

Code:
void platform()
{
    void self    = getlocalvar("self");
    void plat    = getlocalvar("platform");
    void pName    = getentityproperty(plat, "defaultname");
    int xDir    = getentityproperty(self, "xdir");
    int zDir    = getentityproperty(self, "zdir");
   
    if(pName == "Tapadesague"){
        tossentity(self, 0.001, xDir, zDir);
    }
}

Please tell me if I'm missing something.

@O Ilusionista : Thanks, I'll look the funtion in the OpenBOR manual later (I think now has some technical difficulties o.o)
 
You need to change the platform base to base -9999 in script.

 
You need to change the platform base to base -9999 in script.

It works great :D, thank you.
 
Solution
@maxman & @Crimsondeath,

Just FYI, you don't need to go insane with the numbers. Pit depth is is a constant of -250. The engine checks Y position on every update, and if Y < PIT_DEPTH, then the pit death routines fire. This applies Pit type damage to KO the entity so you see its life drain and death sound.

Once the entity reaches twice the pit depth, then the kill (kill as in the computer term, not kill as in killing something in game) routine fires, removing the entity from play.

In other words, a depth of -500 will do the job fine. The default depth for pits is -1000, and that's what we recommend. There's no need and no reason to use huge numbers like -9999.

DC
 
Pit depth is is a constant of -250. The engine checks Y position on every update, and if Y < PIT_DEPTH, then the pit death routines fire. This applies Pit type damage to KO the entity so you see its life drain and death sound.
I thought it was 1000. But now I remember than when you watch an entity faling into a pit, you won't see their base decreasing until it reaches -1000: after a certain value (probably, 250 you mentioned), the base is automatically changed to -1000
 
@maxman & @Crimsondeath,

Just FYI, you don't need to go insane with the numbers. Pit depth is is a constant of -250. The engine checks Y position on every update, and if Y < PIT_DEPTH, then the pit death routines fire. This applies Pit type damage to KO the entity so you see its life drain and death sound.

Once the entity reaches twice the pit depth, then the kill (kill as in the computer term, not kill as in killing something in game) routine fires, removing the entity from play.

In other words, a depth of -500 will do the job fine. The default depth for pits is -1000, and that's what we recommend. There's no need and no reason to use huge numbers like -9999.

DC
I didn't know that -250 is a good depth value, even -500, but I always felt that -9999 or lower is WAY too much for being a very low depth. It's like testing with setlayer values of sprites for covering the default lifebars. I forgot about that. (It's been years since I had it solved.)
 
I was testing the "-9999 base" trick to understand the logic, I never used it before. I don't know if there's some differences in this aspect but in the v4 it works by using -1 for both base and level height for the platform entity, and adjusting the platform's height to 1 (one will compensate another, there's no changes in the no_adjust_base and subject_to_gravity).

Level file
C:
spawn St1_Manhole
flip 0
coords 548 468 -1
at 1100

Platform entity
C:
name St1_Manhole
type none
setlayer -3

anim spawn
@script changeentityproperty(getlocalvar("self"), "base", -1); @end_script
    loop    0
    delay    4
    offset    32 24
    frame    data/bgs/sor2/st1a/manhole00.png

anim idle
    loop    1
    delay    4
    offset    32 24
    platform 0 39 -10 -10 74 74 29 1
    frame    data/bgs/sor2/st1a/manhole00.png
    @cmd aniXpos 100 0 openborconstant("ANI_FOLLOW1")
    frame    data/bgs/sor2/st1a/manhole00.png

 
Back
Top Bottom