Solved Script to flip shots on demand

Question that is answered or resolved.

DJGameFreakTheIguana

Active member
Just want to know if there's a way to flip scripted shots so I wont have to copy it just to give it a flip header.
Code:
	delay	5
	offset	74 66
	sound	Data/CHARS/Vector/hurah.wav
	drawmethod scalex 1.3
	drawmethod scaley 1.1
	blast	59 32 38 40 30 0 0 0 20
	dropv 4.0 5.0
        @cmd    dasher 6 0 0 0
	@cmd	shooter "VZX3" 0 0 0 5 0 0
	@cmd	shooter "VZX3" -3 0 0 -2 0 0
	frame	data/chars/Vector/JA3-0.gif
	blast	58 29 38 40 30 0 0 0 20
	dropv 4.0 5.0
	frame	data/chars/Vector/JA3-1.gif
	@cmd	shooter "VZX3" 0 0 0 5 0 0
	@cmd	shooter "VZX3" -3 0 0 -2 0 0
	frame	data/chars/Vector/JA3-2.gif
	frame	data/chars/Vector/JA3-3.gif
	@cmd	shooter "VZX3" 0 0 0 5 0 0
	@cmd	shooter "VZX3" -3 0 0 -2 0 0
	frame	data/chars/Vector/JA3-4.gif
	frame	data/chars/Vector/JA3-1.gif
	@cmd	shooter "VZX3" 0 0 0 5 0 0
	@cmd	shooter "VZX3" -3 0 0 -2 0 0
	frame	data/chars/Vector/JA3-2.gif
	frame	data/chars/Vector/JA3-3.gif
	@cmd	shooter "VZX3" 0 0 0 5 0 0
	@cmd	shooter "VZX3" -3 0 0 -2 0 0
	frame	data/chars/Vector/JA3-4.gif
	frame	data/chars/Vector/JA3-1.gif
	@cmd	shooter "VZX3" 0 0 0 5 0 0
	@cmd	shooter "VZX3" -3 0 0 -2 0 0
	frame	data/chars/Vector/JA3-2.gif
	frame	data/chars/Vector/JA3-3.gif
	@cmd	shooter "VZX3" 0 0 0 5 0 0
	@cmd	shooter "VZX3" -3 0 0 -2 0 0
	frame	data/chars/Vector/JA3-4.gif
	frame	data/chars/Vector/JA3-0.gif

This is what I was trying to do.

X)
 
Solution
Alright, while facing 2 was close, I did some tests with facing 1 and -1 and for some reason, now, I'm getting the result I want.

delay 20
offset 74 84
mpcost 10
mponly 1
sound Data/CHARS/Vector/raaawugh.wav
@cmd shooter4 "shadows" 0 0 0 3 0 0 1
@cmd shooter4 "VeMSP1" 0 0 0 -3 0 0 -1
frame data/chars/Vector/FSP.gif
@cmd shooter4 "shadows" 0 0 0 3 0 0 1
@cmd shooter4 "VeMSP1" 0 0 0 -3 0 0 -1
frame data/chars/Vector/FSP.gif
@cmd shooter4 "VeMSP1" 0 0 0 3 0 0 1
@cmd shooter4 "shadows" 0 0 0 -3 0 0 -1
frame data/chars/Vector/FSP.gif
@cmd shooter4 "VeMSP1" 0 0 0 3 0 0 1
@cmd shooter4 "shadows" 0 0 0 -3 0 0 -1
frame data/chars/Vector/FSP.gif

The shots with facing 1 shoot and face in the direction I'm facing, and vice...
How exactly do I do I change this? This is the script I have.
Code:
void shooter(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Shooting projectile with speed control
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   void vShot;

   if (Direction == 0){ //Is entity facing left?                  
      dx = -dx; //Reverse X direction to match facing
   }

   vShot = projectile(Shot, x+dx, z+dz, y+dy, Direction, 1, 0, 0);
   changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
   changeentityproperty(vShot, "speed", Vx);
}
Maybe this can be modified so shots are turned around?

I found this to and ran some test with it, but I noticed no changes.
Code:
void shooter2(void Shot, float dx, float dy, float Vx, float Vy)
{ // Shooting special projectile with speed control
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   void vShot;

   if (Direction == 0){ //Is entity facing left?                  
      Vx = -Vx; //Reverse Vx direction to match facing
   }

   vShot = spawn01(Shot, dx, dy, 0);
   changeentityproperty(vShot, "velocity", Vx, 0, Vy);

   return vShot;
}


Here's the last test.
Code:
	@cmd	shooter2 "shadows" 10 0 10 0
	@cmd	shooter2 "shadows" 10 0 10 0
	@cmd	shooter2 "shadows" 10 0 10 0
	frame	data/chars/shadow/sp-9.gif
	@cmd	shooter2 "shadows" 10 0 -10 0
	@cmd	shooter2 "shadows" 10 0 -10 0
	@cmd	shooter2 "shadows" 10 0 -10 0
	frame	data/chars/shadow/sp-10.gif
	@cmd	shooter2 "shadows" -10 0 -10 0
	@cmd	shooter2 "shadows" -10 0 -10 0
	@cmd	shooter2 "shadows" -10 0 -10 0
	frame	data/chars/shadow/sp-11.gif

X)
 
As malik posted, shooting scripts usually matches fired shots with shooter's facing direction.

However judging from your need, you could use different function which asks fired shot's facing direction, such as this:
Code:
void shooter3(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz, int Face)
{ // Shooting projectile with speed and direction control
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "y");
   int z = getentityproperty(self, "z");
   void vShot;

   if (Direction == 0){ //Is entity facing left?                 
      dx = -dx; //Reverse X direction to match facing
   }

   vShot = projectile(Shot, x+dx, z+dz, y+dy, Face, 1, 0, 0);
   changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
   changeentityproperty(vShot, "speed", Vx);
}

Ex: @cmd shooter3 "VZX3" -3 0 0 -2 0 0 0 will shoot VZX3 to left and faces left

And this too if you're using custom shots,
Code:
void shooter4(void Shot, float dx, float dy, float Vx, float Vy, int Face)
{ // Shooting special projectile with speed and direction control
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   void vShot;

   if (Direction == 0){ //Is entity facing left?                 
      Vx = -Vx; //Reverse Vx direction to match facing
   }

   vShot = spawn01(Shot, dx, dy, 0);
   changeentityproperty(vShot, "velocity", Vx, 0, Vy);
   changeentityproperty(vShot, "direction", Face);

   return vShot;
}

Ex: shooter4 "shadows" -10 0 -10 0 0 will shoot shadows to left and faces left.
 
First of all guys, sorry I started this topic then went inactive for as long as I did. Started doing one thing after another.

I ran some tests with the script, the shots do work, but now they only shoot in the direction the script says, so the attacks I had planned for this script don't turn out right if they're facing left. Is there a way to have the script still take account of where entities are turned while still being able to flip them on command?

x)
 
I had to take some time to think before I understand what you want.
I believe this is what you want:

Code:
void shooter3(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz, int Face)
{ // Shooting projectile with speed and direction control
   void self = getlocalvar("self");
   int Dir = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "y");
   int z = getentityproperty(self, "z");
   void vShot; int SDir;

   if(Dir == 0){ //Is entity facing left?
     dx = -dx; //Reverse X direction to match facing
     if(Face == -1){ //Opposite
       SDir = 1;
     } else {
       SDir = 1;
     }
   } else {
     if(Face == -1){ //Opposite
       SDir = 0;
     } else {
       SDir = 1;
     }
   }

   vShot = projectile(Shot, x+dx, z+dz, y+dy, Face, 1, 0, 0);
   changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
   changeentityproperty(vShot, "speed", Vx);
}

void shooter4(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz, int Face)
{ // Shooting special projectile with speed and direction control
   void self = getlocalvar("self");
   int Dir = getentityproperty(self, "direction");
   void vShot; int SDir;

   if(Dir == 0){ //Is entity facing left?
     Vx = -Vx; //Reverse Vx direction to match facing
     if(Face == -1){ //Opposite
       SDir = 1;
     } else {
       SDir = 1;
     }
   } else {
     if(Face == -1){ //Opposite
       SDir = 0;
     } else {
       SDir = 1;
     }
   }

   vShot = spawn01(Shot, dx, dy, dz);
   changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
   changeentityproperty(vShot, "direction", Face);

   return vShot;
}

In this modified functions, Face parameter defines shot's facing direction relative to shooter's. Face = -1 means shot is facing opposite the shooter, other value for Face will set shot face the same as the shooter.

HTH
 
It's close after I set it up like this.
@cmd shooter4 "shadows"  1 0 0 3 0 0 1
@cmd shooter4 "shadows"  1 0 0 3 0 0 0
frame data/chars/shadow/ZXSP.gif
@cmd shooter4 "shadows"  1 0 0 3 0 0 1
@cmd shooter4 "shadows"  1 0 0 3 0 0 0
frame data/chars/shadow/ZXSP.gif
@cmd shooter4 "shadows"  1 0 0 3 0 0 1
@cmd shooter4 "shadows"  1 0 0 3 0 0 0
frame data/chars/shadow/ZXSP.gif
@cmd shooter4 "shadows"  1 0 0 3 0 0 1
@cmd shooter4 "shadows"  1 0 0 3 0 0 0
frame data/chars/shadow/ZXSP.gif

But I realized something after a good amount of time experimenting with this script, and while I didn't get the result I wanted, the main thing is that I'm asking for something I never really did in the first place. When I copy a shot to make it go the opposite way, I use "facing  1/2". I was able to do this with the script, using the same shot to shoot in both directions without copying it, but what I had in mind was making the script making a shot not only shoot in what direction I set, but also facing in that direction.

So to specify, ""shadows"  1 0 0 3 0 0 1" shoots and faces right no matter where I'm facing, and ""shadows"  1 0 0 3 0 0 0" vice versa. Can we make [int Face] determine facing along with direction, so ""shadows"  1 0 0 3 0 0 1" shoots and faces where I face, and the opposite if [int Face] is set to 0 because I think that will do the trick. Sorry if I'm not making this sound right.

x)
 
Alright, I've added couple lines in shooter4 function into this:
Code:
void shooter4(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz, int Face)
{ // Shooting special projectile with speed and direction control
   void self = getlocalvar("self");
   int Dir = getentityproperty(self, "direction");
   void vShot; int SDir;

   if(Dir == 0){ //Is entity facing left?
     Vx = -Vx; //Reverse Vx direction to match facing
     if(Face == -1){ //Opposite
       SDir = 1;
     } else {
       SDir = 0;
     }
   } else {
     if(Face == -1){ //Opposite
       SDir = 0;
     } else {
       SDir = 1;
     }
   }

   if(Face == -2){ //Left
     SDir = 0;
   } else if(Face == 2){ // right
     SDir = 1;
   }

   vShot = spawn01(Shot, dx, dy, dz);
   changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
   changeentityproperty(vShot, "direction", Face);

   return vShot;
}

With this modification, setting Face -2 will set spawned shot to face left and Face 2 to face right, regardless of shooter's facing direction.

HTH
 
Sorry Blood, I don't think the script is working.
delay 20
offset 74 84
mpcost 10
mponly 1
sound Data/CHARS/Vector/raaawugh.wav
@cmd shooter4 "VeMSP1" 0 0 0 3 0 0 2
frame data/chars/Vector/FSP.gif
@cmd shooter4 "VeMSP1" 0 0 0 3 0 0 2
frame data/chars/Vector/FSP.gif
@cmd shooter4 "VeMSP1" 0 0 0 3 0 0 -2
frame data/chars/Vector/FSP.gif
@cmd shooter4 "VeMSP1" 0 0 0 3 0 0 -2
frame data/chars/Vector/FSP.gif
The first two shots have facing 2 and the second two have -2, but they all face right regardless and also face right if shoot towards the left. Screenshots below.

X)
 
Oops  :-[
I noticed small typo, the function should be like this:
Code:
void shooter4(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz, int Face)
{ // Shooting special projectile with speed and direction control
   void self = getlocalvar("self");
   int Dir = getentityproperty(self, "direction");
   void vShot; int SDir;

   if(Dir == 0){ //Is entity facing left?
     Vx = -Vx; //Reverse Vx direction to match facing
     if(Face == -1){ //Opposite
       SDir = 1;
     } else {
       SDir = 0;
     }
   } else {
     if(Face == -1){ //Opposite
       SDir = 0;
     } else {
       SDir = 1;
     }
   }

   if(Face == -2){ //Left
     SDir = 0;
   } else if(Face == 2){ // right
     SDir = 1;
   }

   vShot = spawn01(Shot, dx, dy, dz);
   changeentityproperty(vShot, "velocity", Vx, Vz, Vy);
   changeentityproperty(vShot, "direction", SDir);

   return vShot;
}

Sorry about that  :)
 
Alright, while facing 2 was close, I did some tests with facing 1 and -1 and for some reason, now, I'm getting the result I want.

delay 20
offset 74 84
mpcost 10
mponly 1
sound Data/CHARS/Vector/raaawugh.wav
@cmd shooter4 "shadows" 0 0 0 3 0 0 1
@cmd shooter4 "VeMSP1" 0 0 0 -3 0 0 -1
frame data/chars/Vector/FSP.gif
@cmd shooter4 "shadows" 0 0 0 3 0 0 1
@cmd shooter4 "VeMSP1" 0 0 0 -3 0 0 -1
frame data/chars/Vector/FSP.gif
@cmd shooter4 "VeMSP1" 0 0 0 3 0 0 1
@cmd shooter4 "shadows" 0 0 0 -3 0 0 -1
frame data/chars/Vector/FSP.gif
@cmd shooter4 "VeMSP1" 0 0 0 3 0 0 1
@cmd shooter4 "shadows" 0 0 0 -3 0 0 -1
frame data/chars/Vector/FSP.gif

The shots with facing 1 shoot and face in the direction I'm facing, and vice versa with -1. This will make attacks that shot in both directions simpler in the future. Thanks again Bloodbane.

X)
 
Solution
Back
Top Bottom