[SOLVED] Platforms hithead

Bloodbane

Well-known member
I had to find decent mod for my experiment, finally found one project I scrapped years ago. Please ignore the character I'm using in the demo :)

Back to topic, my experiment worked and here's the result:


I'm using this onmoveascript:
Code:
void main()
{
    void self = getlocalvar("self");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "y");
    int z = getentityproperty(self, "z");
    int Vy = getentityproperty(self,"tossv");
    void vAniID = getentityproperty(self,"animationID");

    void Plat = checkplatformbelow(x, z, y+100);
    void Plat2 = checkplatformbelow(x, z, y+1);

    if(Plat && Vy > 0 && Plat!=Plat2){
      char PName = getentityproperty(Plat, "name");

      if(PName=="Slip"){
        changeentityproperty(self, "Subject_to_Platform", 0);
      }
    }
}

This script finds platform above character when jumping or moving up. If the platform is passable i.e has Slip as its alias, it will disable subject_to_platform to allow passing from below. If the platform is not, nothing is done and hithead happens
Another script in character's JUMP animation reenable subject_to_platform to allow character to land after passing through
Code:
anim jump
@script
    void self = getlocalvar("self");
    int Vy = getentityproperty(self, "tossv");

    if(Vy < 0){
      changeentityproperty(self, "Subject_to_Platform", 1);
    }
@end_script
...

The script only reenable when falling down to prevent conflict with previous script

Similar check script is declared in character's SLIDE to allow/disallow dropping off platform.
Code:
anim slide
@script
    void self = getlocalvar("self");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int z = getentityproperty(self, "z");
    void Plat = checkplatformbelow(x, z, y+2);

    if(getentityproperty(Plat,"name")=="Slip"){
      if(y > 0 && frame == 0){
        changeentityproperty(self, "Subject_to_Platform", 0);
      }
    }
@end_script
	delay	1
	offset	46 97
	bbox	31 41 32 56
	frame	data/chars/tunas/walk3.png
	delay	10
	frame	data/chars/tunas/walk3.png
	@cmd	platform 1
	frame	data/chars/tunas/walk3.png

TBH this one is crude & simple cause I don't change the animation to other animation (like I did to some characters in Castlevania Collab)

Like I posted, this script system is experimental and most likely need more stabilizers

I would like to know if there is how to create some kind of floating basemap platform, such as this ladder in the air of the image.

I'd stack some thin solid platforms to create stairs and use some script to allow walking on stairs :)

I forgot to explain a detail:

Code:
void Plat = checkplatformbelow(x, z, y+100);

100 is from character's height + platform thickness + extra pixels.
Platform thickness is thickness of passable platform, it shouldn't be calculated anymore since it's very small i.e just one pixel. Extra pixels could be any value to ensure checkplatform checks above platform.
You can use smaller value than 100 if your character is shorter
 
everytime I use the platform script
onmoveascript
Code:
void main()
{
    void self = getlocalvar("self");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "y");
    int z = getentityproperty(self, "z");
    int Vy = getentityproperty(self,"tossv");
    void vAniID = getentityproperty(self,"animationID");

    void Plat = checkplatformbelow(x, z, y+100);
    void Plat2 = checkplatformbelow(x, z, y+1);

    if(Plat && Vy > 0 && Plat!=Plat2){
      char PName = getentityproperty(Plat, "name");

      if(PName=="plat05"){
        changeentityproperty(self, "Subject_to_Platform", 0);
      }
    }
}

and put it with the double jump script



Code:
void main()
{
    int iPlIndex = getlocalvar("player"); //Get calling player
    void vSelf = getplayerproperty(iPlIndex , "entity"); //Get calling entity
    void vAniID = getentityproperty(vSelf,"animationID"); //Get current animation ID
    void vAniPos = getentityproperty(vSelf, "animpos"); //Get current animation frame
    int iDir = getentityproperty(vSelf, "direction");  //Get current facing direction

    void iUp = playerkeys(iPlIndex, 1, "moveup"); // New key status of "Up"
    void iDown = playerkeys(iPlIndex, 1, "movedown"); // New key status of "Down"
    void iLeft = playerkeys(iPlIndex, 1, "moveleft"); // New key status of "Left"
    void iRight = playerkeys(iPlIndex, 1, "moveright"); // New key status of "Right"
    void iJump = playerkeys(iPlIndex, 1, "jump"); //New key status of "Jump"
    void iSpecial = playerkeys(iPlIndex, 1, "Special"); //New key status of "Special"
    void iAttack = playerkeys(iPlIndex, 1, "attack"); //New key status of "Attack"
    void iAttack2 = playerkeys(iPlIndex, 1, "attack2"); // New key of "Attack 2"
    void iAttack3 = playerkeys(iPlIndex, 1, "attack3"); // New key of "Attack 3"
    void iAttack4 = playerkeys(iPlIndex, 1, "attack4"); // New key of "Attack 4"

    void iLeftR = playerkeys(iPlIndex, 2, "moveleft"); // Release status of "Left"
    void iRightR = playerkeys(iPlIndex, 2, "moveright"); // Release status of "Right"
    void iDownR = playerkeys(iPlIndex, 2, "movedown"); //Release status of "Down"
    void iAttackR = playerkeys(iPlIndex, 2, "attack"); //Release status of "Attack"

    void iUpH = playerkeys(iPlIndex, 0, "moveup");
    void iDownH = playerkeys(iPlIndex, 0, "movedown");
    void iLeftH = playerkeys(iPlIndex, 0, "moveleft");
    void iRightH = playerkeys(iPlIndex, 0, "moveright");

//Double jump
    if(vAniID == openborconstant("ANI_JUMP")){ //Jumping?
      if(iJump){ //Jump pressed?
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL50"));
        if(iLeftH){ //Left held?
          changeentityproperty(vSelf, "direction", 0);
          tossentity(vSelf, 3, -1.5, 0);
        } else if(iRightH){ //Right held?
          changeentityproperty(vSelf, "direction", 1);
          tossentity(vSelf, 3, 1.5, 0);
        } else { //Nothing
          tossentity(vSelf, 3, 0, 0);
        }
      }
    }
}

I always pass into the platform and fall to the ground


ani jump


// @cmd targetCam 1000 50 50
@script
    void self = getlocalvar("self");
    int Vy = getentityproperty(self, "tossv");

    if(Vy < 0){
      changeentityproperty(self, "Subject_to_Platform", 1);
    }
@end_script
delay 5
offset 44 55
bbox 43 23 13 35
cancel 6 13 0 j freespecial23
frame data/chars/alucard/j01.gif
frame data/chars/alucard/j02.gif
offset 51 65
bbox 43 23 13 35

frame data/chars/alucard/jc03.gif
frame data/chars/alucard/jc04.gif
frame data/chars/alucard/jc05.gif
frame data/chars/alucard/jc05.gif

frame data/chars/alucard/jc05.gif
frame data/chars/alucard/jc05.gif
frame data/chars/alucard/jc05.gif
frame data/chars/alucard/jc06.gif
delay 10
frame data/chars/alucard/jc07.gif
frame data/chars/alucard/jc08.gif
frame data/chars/alucard/jc09.gif



anim freespecial50
          @script
if(!frame){
void self=getlocalvar("self");
void xdir=getlocalvar("xdir");
tossentity(self, 3, xdir, 1);
}
@end_script





offset 36 49
frame data/chars/alucard/q1.gif
offset 25 50
frame data/chars/alucard/q2.gif
offset 37 98
frame data/chars/alucard/q3.gif
offset 38 98
frame data/chars/alucard/q4.gif
offset 38 98
frame data/chars/alucard/q5.gif
offset 36 98

frame data/chars/alucard/q6.gif

 
ahhhhh, you have a double jump animation.

You need to copy those lines to the freespecial50

Code:
    int Vy = getentityproperty(self, "tossv");
    if(Vy < 0){
      changeentityproperty(self, "Subject_to_Platform", 1);
    }
 
About the double jump, I did what you said, but it's still wrong. If I jump to the platform That the script is configured on (the smaller),  it doesn't stabilize and And I go inside. If I'm on another platform and the configured one is on the top and I double jump, during the fall I end up going through all of them


https://youtu.be/Xq72Gve925E
 
Mario, after reading the BB code (and a deleted reply from a banned user which insists in creating fake accounts...), looks like he forgot to paste another code here

anim slide
@script
    void self = getlocalvar("self");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int z = getentityproperty(self, "z");
    void Plat = checkplatformbelow(x, z, y+2);

    if(getentityproperty(Plat,"name")=="Slip"){
      if(y > 0 && frame == 0){
        changeentityproperty(self, "Subject_to_Platform", 0);
      }
    }
@end_script
delay 1
offset 46 97
bbox 31 41 32 56
frame data/chars/tunas/walk3.png
delay 10
frame data/chars/tunas/walk3.png
@cmd platform 1
frame data/chars/tunas/walk3.png

Probably, this "platform 1"  turns the subject_to_platform again.

Code:
void platform(int plat)
{// Set's subject to platform
    void self = getlocalvar("self");
    changeentityproperty(self, "subject_to_platform", plat);
}

Or you can even write it with just one line
@cmd changeentityproperty getlocalvar("self") "subject_to_platform" 1

To tel the truth, this code should be on a takedamagescript.
Send me your mod, let me take a look.
 
Bloodbane said:
Hmmm... I'm not sure what happens when Alucard landed on platform in the video.
I might need to see the mod to see what's wrong

He was missing the function to reenable the subject_to_platform. We had talked about it in facebook and had fixed it.

Also, I've suggested him to add this as a takedamagescriot

Code:
void main()
{    void self = getlocalvar("self");
    changeentityproperty(self, "subject_to_platform", 1);
}

So it will work if you get hit while jumping, as I commented on the original topic.
 
Back
Top Bottom