Crimsondeath
Active member
Hi again x.x
I got this script from the Castlevania Collaborative Demo, which I used in Silver Night's Crusaders.
Is just what I need!
It throws the Bomb in the proper X and Y Axis, but how can I add the Z axis for use it in a Beat'em up?
I already tried to add the Z axis like this and the game "crashes" or I'm missing something?:
The Entity code:
OpenBoR v3.0 Build 6391, log attached.
I got this script from the Castlevania Collaborative Demo, which I used in Silver Night's Crusaders.
Code:
void target0T(float Time, float Tx, float Ty, float dx, float dy, void Vel, int Flip)
{// Basic Targetting certain coordinate before dashing
// Produced velocity will be required speed to get to target within specified time
// Time = specified time
// Tx = target x coordinate
// Ty = target y coordinate
// dx = x added distance
// dy = y added distance
// Vel = Desired output
void self = getlocalvar("self");
int dir = getentityproperty(self, "direction");
float x = getentityproperty(self, "x");
float y = getentityproperty(self, "a");
float Vx;
float Vy;
if(Flip == 1){
if(Tx < x){
changeentityproperty(self, "direction", 0);
} else {
changeentityproperty(self, "direction", 1);
}
}
x = x+dx;
y = y+dy;
// Calculate velocity for targetting
Vx = (Tx-x)/Time;
Vy = (Ty-y)/Time;
if(Vel == "x"){
return Vx;
}
if(Vel == "y"){
return Vy;
}
}
void targetB(float Time, float dx, float dy, int Flip)
{// Targetting opponent before tossing bomb
// Time = specified time
// dx = x added distance
// dy = y added distance
// Flip = flip flag
void self = getlocalvar("self");
int dir = getentityproperty(self, "direction");
float x = getentityproperty(self, "x");
float y = getentityproperty(self, "a");
float Vx;
setlocalvar("T"+self, findtarget(self)); //Get nearest target
void Target = getlocalvar("T"+self);
if( Target != NULL()){
float Tx = getentityproperty(Target, "x");
float Ty = getentityproperty(Target, "a");
float C;
float Sy = y + dy - Ty;
if (Sy < 0){ //Negative?
Sy = -Sy; //Invert to positive
}
C = 0.5*(x-Tx)*(y+dy-Ty)/(Time+Sy);
if (dir == 0){ //Is entity facing left?
dx = -dx; //Reverse X direction to match facing
}
Vx = target0T(Time, Tx, Ty, dx-C, 0, "x", Flip);
} else {
Vx = 0;
}
setlocalvar("x"+self, Vx );
setlocalvar("T"+self, NULL()); //Clears variable
}
void tosser2(void Bomb, float dx, float dy, float Vx, float Vy)
{ // Tossing special bomb with desired speed
void self = getlocalvar("self");
void candamage = getentityproperty(self, "candamage");
int Direction = getentityproperty(self, "direction");
void Shot;
if (Direction == 0){ //Is entity facing left?
Vx = -Vx; //Reverse Vx direction to match facing
}
Shot = spawn01(Bomb, dx, dy, 0);
tossentity(Shot, Vy, Vx);
changeentityproperty(Shot, "owner", self);
changeentityproperty(Shot, "candamage", candamage);
return Shot;
}
void toss2(void Shot, float dx, float dy, float Vy)
{ // Tossing targetted bombs
void self = getlocalvar("self");
float Vx = getlocalvar("x"+self);
int Direction = getentityproperty(self, "direction");
if (Direction == 0){ //Is entity facing left?
Vx = -Vx; //Reverse Vx direction to match facing
}
if( Vx!=NULL() && Vy!=NULL() ){
tosser2(Shot, dx, dy, Vx, Vy);
}
}
Is just what I need!
It throws the Bomb in the proper X and Y Axis, but how can I add the Z axis for use it in a Beat'em up?
I already tried to add the Z axis like this and the game "crashes" or I'm missing something?:
Code:
void target0T(float Time, float Tx, float Ty, float dx, float dy, float dz, void Vel, int Flip)
{// Basic Targetting certain coordinate before dashing
// Produced velocity will be required speed to get to target within specified time
// Time = specified time
// Tx = target x coordinate
// Ty = target y coordinate
// dx = x added distance
// dy = y added distance
// Vel = Desired output
void self = getlocalvar("self");
int dir = getentityproperty(self, "direction");
float x = getentityproperty(self, "x");
float y = getentityproperty(self, "a");
float z = getentityproperty(self, "z");
float Vx;
float Vy;
float Vz;
if(Flip == 1){
if(Tx < x){
changeentityproperty(self, "direction", 0);
} else {
changeentityproperty(self, "direction", 1);
}
}
x = x+dx;
y = y+dy;
z = y+dz;
// Calculate velocity for targetting
Vx = (Tx-x)/Time;
Vy = (Ty-y)/Time;
Vz = (Tz-z)/Time;
if(Vel == "x"){
return Vx;
}
if(Vel == "y"){
return Vy;
}
if(Vel == "z"){
return Vz;
}
}
void targetB(float Time, float dx, float dy, float dz, int Flip)
{// Targetting opponent before tossing bomb
// Time = specified time
// dx = x added distance
// dy = y added distance
// Flip = flip flag
void self = getlocalvar("self");
int dir = getentityproperty(self, "direction");
float x = getentityproperty(self, "x");
float y = getentityproperty(self, "a");
float z = getentityproperty(self, "z");
float Vx;
setlocalvar("T"+self, findtarget(self)); //Get nearest target
void Target = getlocalvar("T"+self);
if( Target != NULL()){
float Tx = getentityproperty(Target, "x");
float Ty = getentityproperty(Target, "a");
float Tz = getentityproperty(Target, "z");
float C;
float Sy = y + dy - Ty;
if (Sy < 0){ //Negative?
Sy = -Sy; //Invert to positive
}
C = 0.5*(x-Tx)*(y+dy-Ty)/(Time+Sy);
if (dir == 0){ //Is entity facing left?
dx = -dx; //Reverse X direction to match facing
}
Vx = target0T(Time, Tx, Ty, Tz, dx-C, 0, dz, "x", Flip);
} else {
Vx = 0;
}
setlocalvar("x"+self, Vx );
setlocalvar("T"+self, NULL()); //Clears variable
}
void tosser2(void Bomb, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Tossing special bomb with desired speed
void self = getlocalvar("self");
void candamage = getentityproperty(self, "candamage");
int Direction = getentityproperty(self, "direction");
void Shot;
if (Direction == 0){ //Is entity facing left?
Vx = -Vx; //Reverse Vx direction to match facing
}
Shot = spawn01(Bomb, dx, dy, dz);
tossentity(Shot, Vy, Vx, Vz);
changeentityproperty(Shot, "owner", self);
changeentityproperty(Shot, "candamage", candamage);
return Shot;
}
void toss2(void Shot, float dx, float dy, float dz, float Vy)
{ // Tossing targetted bombs
void self = getlocalvar("self");
float Vx = getlocalvar("x"+self);
float Vz = getlocalvar("z"+self);
int Direction = getentityproperty(self, "direction");
if (Direction == 0){ //Is entity facing left?
Vx = -Vx; //Reverse Vx direction to match facing
}
if( Vx!=NULL() && Vy!=NULL() && Vz!=NULL() ){
tosser2(Shot, dx, dy, dz, Vx, Vy, Vz);
}
}
The Entity code:
Code:
anim freespecial2
offset 19 104
energycost 0
mponly 1
delay 4
range 50 320
rangez -100 100
bbox 9 5 22 100
frame data/chars/iga/idle.gif
offset 30 105
bbox 20 5 22 100
@cmd targetB 120 0 0 0
frame data/chars/iga/special1a.gif
frame data/chars/iga/special1b.gif
frame data/chars/iga/special1c.gif
offset 25 88
bbox 18 5 25 75
@cmd toss2 "NinjaBomb_b" 32 84 2
frame data/chars/iga/block.gif
offset 30 105
bbox 18 10 22 95
frame data/chars/iga/special1d.gif
sound data/sounds/puncha.wav
frame data/chars/iga/special1e.gif
delay 15
frame data/chars/iga/special1f.gif
OpenBoR v3.0 Build 6391, log attached.