[Script] Wall Splat

White Dragon

New member
Here is my method to insert in a own MOD a wall splat system:
tmntwallsplat.png


WallSplat is divided into 3 times: SPLATTING -> FALLING -> LANDING
Each of these times has its own event.
Moreover, the first two times have the animation "BACKWARD" if the entity hits the other side of self!
So all events are: SPLATTING -> FALLING -> LANDING and SPLATTING (Backward) -> FALLING (Backward) -> LANDING (Backward).

Now the codes:
Put these 7 animations (yes 7)...

Wall Splat - 1st (SPLAT)
Code:
anim	FOLLOW30 # Wall Splat - 1st (SPLAT) 
	loop 0

	@script
		void self = getlocalvar("self");

		if ( getentityproperty(self, "direction") != getentityvar(self,0) ) {  // verifichiamo che non sia urtato di spalle. se no allora giriamolo...
			if ( getentityproperty(self, "direction") == 1 ) changeentityproperty(self, "direction", 0);
			else  changeentityproperty(self, "direction", 1);
		}
	@end_script

	custknife say_mynose
        throwframe	0 40
	sound data/sounds/tdoor.wav
	delay	30
	offset  40  86
	frame	data/chars/raph/splat4.gif
	delay 1
	@cmd changeentityproperty getlocalvar("self") "animation" openborconstant("ANI_FOLLOW31")
	frame	data/chars/raph/splat4.gif
	frame	data/chars/raph/splat4.gif

Wall Splat - 1st (BACKWARD SPLAT)
Code:
anim	FOLLOW34 # Wall Splat - 1st (BACKWARD SPLAT)
	loop 0

	@script
		void self = getlocalvar("self");

		/*if ( getentityproperty(self, "direction") != getentityvar(self,0) ) {  // verifichiamo che non sia urtato di spalle. se no allora giriamolo...
			if ( getentityproperty(self, "direction") == 1 ) changeentityproperty(self, "direction", 0);
			else  changeentityproperty(self, "direction", 1);
		}*/
	@end_script

	custknife say_mynose
        throwframe	0 40
	sound data/sounds/tdoor.wav
	delay	30
	offset  62  86
	frame	data/chars/raph/splat3.gif
	delay 1
	@cmd changeentityproperty getlocalvar("self") "animation" openborconstant("ANI_FOLLOW35")
	frame	data/chars/raph/splat3.gif
	frame	data/chars/raph/splat3.gif

Wall Splat - 2nd (FALLING)

Code:
anim	FOLLOW31 # Wall Splat - 2nd (FALLING)
	loop 1
	@script
		void self = getlocalvar("self");
       		float a = getentityproperty(self, "a");

		if ( getentityproperty(self, "a") <= 0 ) {
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW32"));
			/*
			changeentityproperty(self, "antigravity", 0); // quando va a terra fa il RISE!!
			if ( getentityproperty(self, "health") <= 0 ) {
				changeentityproperty(self, "noaicontrol", 0);
				changeentityproperty(self, "animation", openborconstant("ANI_DIE10"));
			}
			*/
		} else if ( getentityproperty(self, "animpos") <= 0 ) { // mettere ELSE
       			float x = getentityproperty(self, "x");
       			float z = getentityproperty(self, "z");
       			float a = getentityproperty(self, "a");

        		//changeentityproperty(self, "position", x, z, a-1);
			changeentityproperty(self, "velocity", 0, 0, -1);
			//changeentityproperty(self, "antigravity", 0);
		} else 	if ( a == getlocalvar("a") ) {
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW32"));
		}
		setlocalvar("a", a);
	@end_script
	delay	1
	offset  40  86
	frame	data/chars/raph/splat4.gif
	frame	data/chars/raph/splat4.gif

Wall Splat - 2nd (BACKWARD FALLING)
Code:
anim	FOLLOW35 # Wall Splat - 2nd (BACKWARD FALLING)
	loop 1
	@script
		void self = getlocalvar("self");
       		float a = getentityproperty(self, "a");

		if ( getentityproperty(self, "a") <= 0 ) {
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW32"));
		} else if ( getentityproperty(self, "animpos") <= 0 ) { // mettere ELSE
       			float x = getentityproperty(self, "x");
       			float z = getentityproperty(self, "z");
       			float a = getentityproperty(self, "a");

        		changeentityproperty(self, "velocity", 0, 0, -1);
		} else 	if ( a == getlocalvar("a") ) {
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW32"));
		}
		setlocalvar("a", a);
	@end_script
	delay	1
	offset  62  86
	frame	data/chars/raph/splat3.gif
	frame	data/chars/raph/splat3.gif

Wall Splat - 3th (LANDING)
Code:
anim	FOLLOW32 # Wall Splat - 3th (LANDING)
	loop 0
	@script
		void self = getlocalvar("self");

		if ( getentityproperty(self, "animpos") == 0 ) {
       			float x = getentityproperty(self, "x");
       			float z = getentityproperty(self, "z");
       			float a = getentityproperty(self, "a");

    			changeentityproperty(self, "invincible", 1);
    			changeentityproperty(self, "invinctime", openborvariant("elapsed_time") + (openborvariant("game_speed")*0.7));

			if ( getentityproperty(self, "direction") == getentityvar(self,0) ) {  // verifichiamo che non sia urtato di spalle. se no allora giriamolo...
				if ( getentityproperty(self, "direction") == 1 ) changeentityproperty(self, "direction", 0);
				else  changeentityproperty(self, "direction", 1);

			}

    			changeentityproperty(self, "invincible", 1);
    			changeentityproperty(self, "invinctime", openborvariant("elapsed_time") + (openborvariant("game_speed")*0.8)); //makes entity invincible for 1.5 seconds, change decimal number to change time length

        		//changeentityproperty(self, "position", x, z, 0.1);
			changeentityproperty(self, "animation", openborconstant("ANI_RISE10"));
		}
	@end_script
	delay 50
	offset	21 49
	frame	data/chars/raph/148.gif
	delay 1
	frame	data/chars/raph/148.gif

Wall Splat (RISE)

Code:
anim	RISE10 # Wall Splat
	loop 0

	@script
		void self = getlocalvar("self");

		if ( getentityproperty(self, "animpos") == 0 ) {
			changeentityproperty(self, "antigravity", 0);
		} else if ( getentityproperty(self, "animpos") >= 5 ) {
			changeentityproperty(self, "noaicontrol", 0);
		}

		if ( getentityproperty(self, "health") <= 0 ) {
			changeentityproperty(self, "noaicontrol", 0);
			changeentityproperty(self, "velocity", 0, 0, 0);
			changeentityproperty(self, "animation", openborconstant("ANI_DIE10"));
		}
	@end_script

	delay 50
	offset	21 49
	frame	data/chars/raph/148.gif
	delay 1
	frame	data/chars/raph/148.gif

	offset	40 80
	delay	5
	frame	data/chars/raph/rise01.gif
	frame	data/chars/raph/rise02.gif
        frame	data/chars/raph/rise03.gif
	frame	data/chars/raph/rise04.gif
	offset	40 80
        frame	data/chars/raph/rise06.gif

Wall Splat (DEATH)
Code:
anim	DEATH10 # Wall Splat
	loop 0
	bbox	0 0 0 0
	custknife say1
        throwframe	8 40

	delay	10
	offset	21 49
	frame	data/chars/raph/148.gif
	frame	data/chars/raph/148.gif
	frame	data/chars/raph/148.gif
	frame	data/chars/raph/148.gif
	frame	data/chars/raph/148.gif
	frame	data/chars/raph/148.gif
	frame	data/chars/raph/148.gif

	delay	10
	@cmd	changeentityproperty getlocalvar("self") "velocity" 0 0 0
	offset	21 49
	frame	data/chars/raph/148.gif
	delay	120
	frame	data/chars/raph/148.gif

	sound	data/sounds/death.wav
	delay	7
	offset  61  63
	bbox  0
	frame	data/chars/raph/death1.gif
	frame	data/chars/raph/death2.gif
	frame	data/chars/raph/death3.gif
	frame	data/chars/raph/death4.gif
	frame	data/chars/raph/death1.gif
	frame	data/chars/raph/death2.gif
	frame	data/chars/raph/death3.gif
	frame	data/chars/raph/death4.gif
	frame	data/chars/raph/death1.gif
	frame	data/chars/raph/death2.gif
	frame	data/chars/raph/death3.gif
	frame	data/chars/raph/death4.gif
	frame	data/chars/raph/death1.gif
	frame	data/chars/raph/death2.gif
	frame	data/chars/raph/death3.gif
	frame	data/chars/raph/death4.gif
	frame	data/chars/raph/death1.gif
	frame	data/chars/raph/death2.gif
	frame	data/chars/raph/death3.gif
	frame	data/chars/raph/death4.gif
	frame	data/chars/raph/death1.gif
	frame	data/chars/raph/death2.gif
	frame	data/chars/raph/death3.gif
	frame	data/chars/raph/death4.gif
	frame	data/chars/raph/death5.gif

Than put this script.c in th header of player like: script data/scripts/script.c

Code:
void main() { 
  void self = getlocalvar("self");
  int refresh_time = openborvariant("elapsed_time")%2;

    if ( refresh_time == 0 ) setentityvar( self, 0, getwalkingdir(self) );
}

/*
 * 0 = going left
 * 1 = going right
 * 2 = stop
 * NULL = not detectable
 */
int getwalkingdir(void ent) {
    int x1 = getlocalvar("old_x");
    int x2 = getentityproperty(ent, "x");
    int p;
    int result = NULL();

    if ( x1 != NULL() && x2 != NULL() ) {
        if ( x2 > x1 ) {
            result = 1;
        } else if ( x2 < x1 ) {
            result = 0;
        } else { // se x2 == x1...
            // se corri o cammini ma urti sul muro guarda la direzione senza osservare se c'è un cambiamento fra x1 e x2 (se x1==x2 evidentemente stavi già sul muro)
            if ( checkwalls(ent,1,1) ) {
                    return getentityproperty(ent,"direction");
            } else if ( getentityproperty(ent, "animationid") == 375 || getentityproperty(ent, "animationid") == 376 || getentityproperty(ent, "animationid") == 379
                             || getentityproperty(ent, "animationid") == 380 ) result = getentityvar(ent,0); // Se avviene wall splat non consideriamo le relative animazioni... restituiamo quindi quello che c'era prima!
            else result = 2;
        }
    } else result = NULL();

    setlocalvar("old_x", x2);

    return result;
}

int checkwalls(void player, int distx, int distz) {
    int i,j;
    float x = getentityproperty(player, "x");
    float z = getentityproperty(player, "z");

/*
 * f:  1,0
 * d/f:1,1
 * d:  0,1
 * d/b:-1,1
 * b:  -1,0
 * u/b:-1,-1
 * u:0,-1
 * u/f:1,-1
 */

    for (i = -1; i < 1+1; ++i) {
        for (j = -1; j < 1+1; ++j) {
            if ( checkwall(x+(i*distx),z+(j*distz)) > 0 ) return 1;
            else continue;
        }
    }

    return 0;
}

variant entityvar(self,0) keeps track of your movement. If it is 1 then the player is going to the right, if 0 than left. NOTE: It is different from DIRECTION. A player can also look to the left and go right (moonwalk LOL).

Finally put an event "onblockwscript data/scripts/wall_splat.c" with this code:
Code:
void main() {
  void self = getlocalvar("self");

    // drawstring( 20,180,0,"MURO!!" );

    // getentityproperty(self, "invincible") == 0 && getentityproperty(self,"animationid") == FALL (IN ARIA) e anche "a" >= threshold  ||||||||||  getentityproperty(self, "running", "speed")
    // CAMBIARE LE PRIME 2!!
    if ( getentityproperty(self,"animationid") != 2333 && getentityproperty(self, "invincible") == 0  && getentityproperty(self, "a") >= 0
                    && getentityproperty(self, "aiflag", "running") == 1 && getentityproperty(self, "animationid") !=134
                    && getentityproperty(self, "animationid") !=102 && getentityproperty(self, "animationid") != 379 && getentityproperty(self, "animationid") != 375
                    && checksplattablewall(self,1,1,1001) == 1 ) {

        float x = getentityproperty(self, "x");
        float z = getentityproperty(self, "z");
        float a = getentityproperty(self, "a");

        // IMPORTANTISSIMO: noaicontrol + cambio d'animazione funziona solo se lo script viene ripetuto a ciclo ad ogni frame!!
        changeentityproperty(self, "noaicontrol", 1); // lo facciamo perchè con qualche mossa speciale altrimenti può evitare di cadere
        changeentityproperty(self, "antigravity", 1);
        changeentityproperty(self, "position", x, z, a);
        //changeentityproperty(self, "base", a);

        damageentity(self,self,30,0,openborconstant("ATK_NORMAL10"));
        //damageentity(self,self,30,0,openborconstant("ANI_ATTACK10"));

        // SUPER IMPORTANTISSIMO: Se non imposti la velocity a 0 su tutti i parametri, il player continuerà a camminare anche dopo noaicontrol impostato a vero!!
        changeentityproperty(self, "velocity", 0, 0, 0);

        if ( getentityvar(self,0) == getentityproperty(self, "direction") ) {
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW30"));
        } else {
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW34"));
        }

    }

}

// Tra l'altro il muro sulle ordinate si vede se x == 0 e z > oppure < 0...
// Guarda a 360° (le 8 direzioni) rispetto al player se c'è un muro di altitudine definita dall'utente
int checksplattablewall(void player, int distx, int distz, float altitude) {
    int i,j;
    float x = getentityproperty(player, "x");
    float z = getentityproperty(player, "z");

/*
 * f:  1,0
 * d/f:1,1
 * d:  0,1
 * d/b:-1,1
 * b:  -1,0
 * u/b:-1,-1
 * u:0,-1
 * u/f:1,-1
 */

    for (i = -1; i < 1+1; ++i) {
        for (j = -1; j < 1+1; ++j) {
            if ( checkwall(x+(i*distx),z+(j*distz)) == altitude ) return 1;
            else continue;
        }
    }

    return 0;
}
 
Nice job, but you did WAY more work than you had to. You really don't need a separate animation and associated scripts for each portion of a splat. Judicious use of dropframe, landframe and loop {toggle} {start} {end} would work just as well. All you would need from there is the splat trigger (onblockwscript) and five animations total: Backsplat, Forwardsplat, Rise, Fall, and Death.

Actually on closer look there are a LOT of problems here.

Don't ever use antigravity to make an entity hang in the air; this has lots of side effects. Use tosstime. Not only is it more dependable and has no side effects, you can set it and forget it.

X = Time you want entity to hang in the air
tosstime = current time + X

As soon as time catches up to tosstime the entity falls again and that's it - no more code is needed.

Ditto for forcing animation switches to a death animation yourself when health is 0. The engine doesn't "know" you've done this and it will lead to bugs. Instead try applying damage of type10. You could add a HP back if necessary (thought it isn't if done right) and then the engine will handle the death animation for you.

DC
 
Sure!! It's more complex!
See my TMNT:SS, I implemented it yet.
I wrote a lib for platforms first. You can use my code if you want!
 
Question: in the source code, there is an animation for this case - ANI_HITWALL (as you can see here: http://www.chronocrash.com/forum/index.php?topic=2022.msg40826#msg40826)

Would be better to make that animation works? Right now, it does nothing.
 
O Ilusionista said:
Question: in the source code, there is an animation for this case - ANI_HITWALL (as you can see here: http://www.chronocrash.com/forum/index.php?topic=2022.msg40826#msg40826)

Would be better to make that animation works? Right now, it does nothing.

Just I see..
BTW I prefer to use onblockwscript + onblockpscript (new) to make a custom  anim for wall/platform!
 
O Ilusionista said:
Question: in the source code, there is an animation for this case - ANI_HITWALL (as you can see here: http://www.chronocrash.com/forum/index.php?topic=2022.msg40826#msg40826)

Would be better to make that animation works? Right now, it does nothing.

ANI_HITWALL: not implemented yet
 
Here is my method to insert in a own MOD a wall splat system:
tmntwallsplat.png


WallSplat is divided into 3 times: SPLATTING -> FALLING -> LANDING
Each of these times has its own event.
Moreover, the first two times have the animation "BACKWARD" if the entity hits the other side of self!
So all events are: SPLATTING -> FALLING -> LANDING and SPLATTING (Backward) -> FALLING (Backward) -> LANDING (Backward).

Now the codes:
Put these 7 animations (yes 7)...

Wall Splat - 1st (SPLAT)
Code:
anim    FOLLOW30 # Wall Splat - 1st (SPLAT)
    loop 0

    @script
        void self = getlocalvar("self");

        if ( getentityproperty(self, "direction") != getentityvar(self,0) ) {  // verifichiamo che non sia urtato di spalle. se no allora giriamolo...
            if ( getentityproperty(self, "direction") == 1 ) changeentityproperty(self, "direction", 0);
            else  changeentityproperty(self, "direction", 1);
        }
    @end_script

    custknife say_mynose
        throwframe    0 40
    sound data/sounds/tdoor.wav
    delay    30
    offset  40  86
    frame    data/chars/raph/splat4.gif
    delay 1
    @cmd changeentityproperty getlocalvar("self") "animation" openborconstant("ANI_FOLLOW31")
    frame    data/chars/raph/splat4.gif
    frame    data/chars/raph/splat4.gif

Wall Splat - 1st (BACKWARD SPLAT)
Code:
anim    FOLLOW34 # Wall Splat - 1st (BACKWARD SPLAT)
    loop 0

    @script
        void self = getlocalvar("self");

        /*if ( getentityproperty(self, "direction") != getentityvar(self,0) ) {  // verifichiamo che non sia urtato di spalle. se no allora giriamolo...
            if ( getentityproperty(self, "direction") == 1 ) changeentityproperty(self, "direction", 0);
            else  changeentityproperty(self, "direction", 1);
        }*/
    @end_script

    custknife say_mynose
        throwframe    0 40
    sound data/sounds/tdoor.wav
    delay    30
    offset  62  86
    frame    data/chars/raph/splat3.gif
    delay 1
    @cmd changeentityproperty getlocalvar("self") "animation" openborconstant("ANI_FOLLOW35")
    frame    data/chars/raph/splat3.gif
    frame    data/chars/raph/splat3.gif

Wall Splat - 2nd (FALLING)

Code:
anim    FOLLOW31 # Wall Splat - 2nd (FALLING)
    loop 1
    @script
        void self = getlocalvar("self");
               float a = getentityproperty(self, "a");

        if ( getentityproperty(self, "a") <= 0 ) {
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW32"));
            /*
            changeentityproperty(self, "antigravity", 0); // quando va a terra fa il RISE!!
            if ( getentityproperty(self, "health") <= 0 ) {
                changeentityproperty(self, "noaicontrol", 0);
                changeentityproperty(self, "animation", openborconstant("ANI_DIE10"));
            }
            */
        } else if ( getentityproperty(self, "animpos") <= 0 ) { // mettere ELSE
                   float x = getentityproperty(self, "x");
                   float z = getentityproperty(self, "z");
                   float a = getentityproperty(self, "a");

                //changeentityproperty(self, "position", x, z, a-1);
            changeentityproperty(self, "velocity", 0, 0, -1);
            //changeentityproperty(self, "antigravity", 0);
        } else     if ( a == getlocalvar("a") ) {
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW32"));
        }
        setlocalvar("a", a);
    @end_script
    delay    1
    offset  40  86
    frame    data/chars/raph/splat4.gif
    frame    data/chars/raph/splat4.gif

Wall Splat - 2nd (BACKWARD FALLING)
Code:
anim    FOLLOW35 # Wall Splat - 2nd (BACKWARD FALLING)
    loop 1
    @script
        void self = getlocalvar("self");
               float a = getentityproperty(self, "a");

        if ( getentityproperty(self, "a") <= 0 ) {
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW32"));
        } else if ( getentityproperty(self, "animpos") <= 0 ) { // mettere ELSE
                   float x = getentityproperty(self, "x");
                   float z = getentityproperty(self, "z");
                   float a = getentityproperty(self, "a");

                changeentityproperty(self, "velocity", 0, 0, -1);
        } else     if ( a == getlocalvar("a") ) {
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW32"));
        }
        setlocalvar("a", a);
    @end_script
    delay    1
    offset  62  86
    frame    data/chars/raph/splat3.gif
    frame    data/chars/raph/splat3.gif

Wall Splat - 3th (LANDING)
Code:
anim    FOLLOW32 # Wall Splat - 3th (LANDING)
    loop 0
    @script
        void self = getlocalvar("self");

        if ( getentityproperty(self, "animpos") == 0 ) {
                   float x = getentityproperty(self, "x");
                   float z = getentityproperty(self, "z");
                   float a = getentityproperty(self, "a");

                changeentityproperty(self, "invincible", 1);
                changeentityproperty(self, "invinctime", openborvariant("elapsed_time") + (openborvariant("game_speed")*0.7));

            if ( getentityproperty(self, "direction") == getentityvar(self,0) ) {  // verifichiamo che non sia urtato di spalle. se no allora giriamolo...
                if ( getentityproperty(self, "direction") == 1 ) changeentityproperty(self, "direction", 0);
                else  changeentityproperty(self, "direction", 1);

            }

                changeentityproperty(self, "invincible", 1);
                changeentityproperty(self, "invinctime", openborvariant("elapsed_time") + (openborvariant("game_speed")*0.8)); //makes entity invincible for 1.5 seconds, change decimal number to change time length

                //changeentityproperty(self, "position", x, z, 0.1);
            changeentityproperty(self, "animation", openborconstant("ANI_RISE10"));
        }
    @end_script
    delay 50
    offset    21 49
    frame    data/chars/raph/148.gif
    delay 1
    frame    data/chars/raph/148.gif

Wall Splat (RISE)

Code:
anim    RISE10 # Wall Splat
    loop 0

    @script
        void self = getlocalvar("self");

        if ( getentityproperty(self, "animpos") == 0 ) {
            changeentityproperty(self, "antigravity", 0);
        } else if ( getentityproperty(self, "animpos") >= 5 ) {
            changeentityproperty(self, "noaicontrol", 0);
        }

        if ( getentityproperty(self, "health") <= 0 ) {
            changeentityproperty(self, "noaicontrol", 0);
            changeentityproperty(self, "velocity", 0, 0, 0);
            changeentityproperty(self, "animation", openborconstant("ANI_DIE10"));
        }
    @end_script

    delay 50
    offset    21 49
    frame    data/chars/raph/148.gif
    delay 1
    frame    data/chars/raph/148.gif

    offset    40 80
    delay    5
    frame    data/chars/raph/rise01.gif
    frame    data/chars/raph/rise02.gif
        frame    data/chars/raph/rise03.gif
    frame    data/chars/raph/rise04.gif
    offset    40 80
        frame    data/chars/raph/rise06.gif

Wall Splat (DEATH)
Code:
anim    DEATH10 # Wall Splat
    loop 0
    bbox    0 0 0 0
    custknife say1
        throwframe    8 40

    delay    10
    offset    21 49
    frame    data/chars/raph/148.gif
    frame    data/chars/raph/148.gif
    frame    data/chars/raph/148.gif
    frame    data/chars/raph/148.gif
    frame    data/chars/raph/148.gif
    frame    data/chars/raph/148.gif
    frame    data/chars/raph/148.gif

    delay    10
    @cmd    changeentityproperty getlocalvar("self") "velocity" 0 0 0
    offset    21 49
    frame    data/chars/raph/148.gif
    delay    120
    frame    data/chars/raph/148.gif

    sound    data/sounds/death.wav
    delay    7
    offset  61  63
    bbox  0
    frame    data/chars/raph/death1.gif
    frame    data/chars/raph/death2.gif
    frame    data/chars/raph/death3.gif
    frame    data/chars/raph/death4.gif
    frame    data/chars/raph/death1.gif
    frame    data/chars/raph/death2.gif
    frame    data/chars/raph/death3.gif
    frame    data/chars/raph/death4.gif
    frame    data/chars/raph/death1.gif
    frame    data/chars/raph/death2.gif
    frame    data/chars/raph/death3.gif
    frame    data/chars/raph/death4.gif
    frame    data/chars/raph/death1.gif
    frame    data/chars/raph/death2.gif
    frame    data/chars/raph/death3.gif
    frame    data/chars/raph/death4.gif
    frame    data/chars/raph/death1.gif
    frame    data/chars/raph/death2.gif
    frame    data/chars/raph/death3.gif
    frame    data/chars/raph/death4.gif
    frame    data/chars/raph/death1.gif
    frame    data/chars/raph/death2.gif
    frame    data/chars/raph/death3.gif
    frame    data/chars/raph/death4.gif
    frame    data/chars/raph/death5.gif

Than put this script.c in th header of player like: script data/scripts/script.c

Code:
void main() {
  void self = getlocalvar("self");
  int refresh_time = openborvariant("elapsed_time")%2;

    if ( refresh_time == 0 ) setentityvar( self, 0, getwalkingdir(self) );
}

/*
 * 0 = going left
 * 1 = going right
 * 2 = stop
 * NULL = not detectable
 */
int getwalkingdir(void ent) {
    int x1 = getlocalvar("old_x");
    int x2 = getentityproperty(ent, "x");
    int p;
    int result = NULL();

    if ( x1 != NULL() && x2 != NULL() ) {
        if ( x2 > x1 ) {
            result = 1;
        } else if ( x2 < x1 ) {
            result = 0;
        } else { // se x2 == x1...
            // se corri o cammini ma urti sul muro guarda la direzione senza osservare se c'è un cambiamento fra x1 e x2 (se x1==x2 evidentemente stavi già sul muro)
            if ( checkwalls(ent,1,1) ) {
                    return getentityproperty(ent,"direction");
            } else if ( getentityproperty(ent, "animationid") == 375 || getentityproperty(ent, "animationid") == 376 || getentityproperty(ent, "animationid") == 379
                             || getentityproperty(ent, "animationid") == 380 ) result = getentityvar(ent,0); // Se avviene wall splat non consideriamo le relative animazioni... restituiamo quindi quello che c'era prima!
            else result = 2;
        }
    } else result = NULL();

    setlocalvar("old_x", x2);

    return result;
}

int checkwalls(void player, int distx, int distz) {
    int i,j;
    float x = getentityproperty(player, "x");
    float z = getentityproperty(player, "z");

/*
 * f:  1,0
 * d/f:1,1
 * d:  0,1
 * d/b:-1,1
 * b:  -1,0
 * u/b:-1,-1
 * u:0,-1
 * u/f:1,-1
 */

    for (i = -1; i < 1+1; ++i) {
        for (j = -1; j < 1+1; ++j) {
            if ( checkwall(x+(i*distx),z+(j*distz)) > 0 ) return 1;
            else continue;
        }
    }

    return 0;
}

variant entityvar(self,0) keeps track of your movement. If it is 1 then the player is going to the right, if 0 than left. NOTE: It is different from DIRECTION. A player can also look to the left and go right (moonwalk LOL).

Finally put an event "onblockwscript data/scripts/wall_splat.c" with this code:
Code:
void main() {
  void self = getlocalvar("self");

    // drawstring( 20,180,0,"MURO!!" );

    // getentityproperty(self, "invincible") == 0 && getentityproperty(self,"animationid") == FALL (IN ARIA) e anche "a" >= threshold  ||||||||||  getentityproperty(self, "running", "speed")
    // CAMBIARE LE PRIME 2!!
    if ( getentityproperty(self,"animationid") != 2333 && getentityproperty(self, "invincible") == 0  && getentityproperty(self, "a") >= 0
                    && getentityproperty(self, "aiflag", "running") == 1 && getentityproperty(self, "animationid") !=134
                    && getentityproperty(self, "animationid") !=102 && getentityproperty(self, "animationid") != 379 && getentityproperty(self, "animationid") != 375
                    && checksplattablewall(self,1,1,1001) == 1 ) {

        float x = getentityproperty(self, "x");
        float z = getentityproperty(self, "z");
        float a = getentityproperty(self, "a");

        // IMPORTANTISSIMO: noaicontrol + cambio d'animazione funziona solo se lo script viene ripetuto a ciclo ad ogni frame!!
        changeentityproperty(self, "noaicontrol", 1); // lo facciamo perchè con qualche mossa speciale altrimenti può evitare di cadere
        changeentityproperty(self, "antigravity", 1);
        changeentityproperty(self, "position", x, z, a);
        //changeentityproperty(self, "base", a);

        damageentity(self,self,30,0,openborconstant("ATK_NORMAL10"));
        //damageentity(self,self,30,0,openborconstant("ANI_ATTACK10"));

        // SUPER IMPORTANTISSIMO: Se non imposti la velocity a 0 su tutti i parametri, il player continuerà a camminare anche dopo noaicontrol impostato a vero!!
        changeentityproperty(self, "velocity", 0, 0, 0);

        if ( getentityvar(self,0) == getentityproperty(self, "direction") ) {
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW30"));
        } else {
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW34"));
        }

    }

}

// Tra l'altro il muro sulle ordinate si vede se x == 0 e z > oppure < 0...
// Guarda a 360° (le 8 direzioni) rispetto al player se c'è un muro di altitudine definita dall'utente
int checksplattablewall(void player, int distx, int distz, float altitude) {
    int i,j;
    float x = getentityproperty(player, "x");
    float z = getentityproperty(player, "z");

/*
 * f:  1,0
 * d/f:1,1
 * d:  0,1
 * d/b:-1,1
 * b:  -1,0
 * u/b:-1,-1
 * u:0,-1
 * u/f:1,-1
 */

    for (i = -1; i < 1+1; ++i) {
        for (j = -1; j < 1+1; ++j) {
            if ( checkwall(x+(i*distx),z+(j*distz)) == altitude ) return 1;
            else continue;
        }
    }

    return 0;
}
Thank you for sharing.
There were issues that DCurrent mentioned.
Have you had a chance to take a look at them yet?
Thank you
 
Nice job, but you did WAY more work than you had to. You really don't need a separate animation and associated scripts for each portion of a splat. Judicious use of dropframe, landframe and loop {toggle} {start} {end} would work just as well. All you would need from there is the splat trigger (onblockwscript) and five animations total: Backsplat, Forwardsplat, Rise, Fall, and Death.

Actually on closer look there are a LOT of problems here.

Don't ever use antigravity to make an entity hang in the air; this has lots of side effects. Use tosstime. Not only is it more dependable and has no side effects, you can set it and forget it.

X = Time you want entity to hang in the air
tosstime = current time + X

As soon as time catches up to tosstime the entity falls again and that's it - no more code is needed.

Ditto for forcing animation switches to a death animation yourself when health is 0. The engine doesn't "know" you've done this and it will lead to bugs. Instead try applying damage of type10. You could add a HP back if necessary (thought it isn't if done right) and then the engine will handle the death animation for you.

DC
Can I use the tosstime in the freespecial animation or it has to be script?
Can you please give me an example on this? Sorry for noob question...
I am trying to have a character stay in the air while performing certain moves.
Currently I am using jumpframe, but it is not so good.
Thank you so much
 
Can I use the tosstime in the freespecial animation or it has to be script?
Tosstime is script only.

Create an animation script function. You can use this code:

C:
void dc_temp_fly(int float_time)
{
    void acting_entity = NULL();
    int elapsed_time = 0;
    int toss_time = 0;

    /* Get entity that called function. */
    acting_entity = getlocalvar("self");

    /* Gets current time from engine. */
    elapsed_time = openborvariant("elapsed_time");

    /* Adds desired time to current time. */
    toss_time = elapsed_time + float_time;

    /* Apply total toss time to entity. */
    changeentityproperty(acting_entity, "tosstime", toss_time);
}

Now you just need to call it on the frame you want to float. This example will make the entity stay wherever it is on the Y axis for 500 centiseconds when it plays the frame with "dude_2".

Code:
frame data/chars/dude/dude_0.png
@cmd dc_temp_fly 500
frame data/chars/dude/dude_1.png
frame data/chars/dude/dude_2.png

HTH,
DC
 
Tosstime is script only.

Create an animation script function. You can use this code:

C:
void dc_temp_fly(int float_time)
{
    void acting_entity = NULL();
    int elapsed_time = 0;
    int toss_time = 0;

    /* Get entity that called function. */
    acting_entity = getlocalvar("self");

    /* Gets current time from engine. */
    elapsed_time = openborvariant("elapsed_time");

    /* Adds desired time to current time. */
    toss_time = elapsed_time + float_time;

    /* Apply total toss time to entity. */
    changeentityproperty(acting_entity, "tosstime", toss_time);
}

Now you just need to call it on the frame you want to float. This example will make the entity stay wherever it is on the Y axis for 500 centiseconds when it plays the frame with "dude_2".

Code:
frame data/chars/dude/dude_0.png
@cmd dc_temp_fly 500
frame data/chars/dude/dude_1.png
frame data/chars/dude/dude_2.png

HTH,
DC
Greatly appreciated and god bless you.
 
Back
Top Bottom