White Dragon
New member
Here is my method to insert in a own MOD a wall splat system:
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)
Wall Splat - 1st (BACKWARD SPLAT)
Wall Splat - 2nd (FALLING)
Wall Splat - 2nd (BACKWARD FALLING)
Wall Splat - 3th (LANDING)
Wall Splat (RISE)
Wall Splat (DEATH)
Than put this script.c in th header of player like: script data/scripts/script.c
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:
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;
}