Diagonal Projectiles

Can you guys suggest the best method to use for these kinds of attacks? I want to shoot from the ground to the sky and reverse
 
if you don't want to use the projectile as a bomb, you can use jumpland to simulate the ground touch and followcond to simulate the hit.
 
The best way is to use script like this to shoot the projectile:

void shooter2(void vName, float fX, float fY, float fZ, float Vx, float Vy, float Vz)
{//Spawns projectile next to caller and move it with speed
//vName: Model name of entity to be spawned in
//fX: X location adjustment
//fY: Y location adjustment
//fZ: Z location adjustment
//Vx: X speed
//Vy: Y speed
//Vz: Z speed

  void self = getlocalvar("self"); //Get calling entity
  int Direction = getentityproperty(self, "direction");
  void vSpawn; //Spawn object.

  vSpawn = spawn01(vName, fX, fY, fZ); //Spawn in projectile
  if (Direction == 0){ //Is entity facing left?                 
      Vx = -Vx; //Reverse Vx direction to match facing
  }

  changeentityproperty(vSpawn, "velocity", Vx, Vz, Vy);
  return vSpawn;
}

void spawn01(void vName, float fX, float fY, float fZ)
{
//spawn01 (Generic spawner)
//Damon Vaughn Caskey
//07/06/2007
//
//Spawns entity next to caller.
//
//vName: Model name of entity to be spawned in.
//fX: X location adjustment.
//fY: Y location adjustment.
      //fZ: Z location adjustment.

void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
int  iDirection = getentityproperty(self, "direction");

clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

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

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.

vSpawn = spawn(); //Spawn in entity.

changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
   
return vSpawn; //Return spawn.
}

and make the projectile like this:

name FlameT
type none
lifespan  2
nolife 1
subject_to_hole 1
no_adjust_base  0
subject_to_gravity 0
subject_to_platform 0
offscreenkill 200
candamage player npc obstacle


anim idle
delay 6
offset 20 43
hitfx data/sounds/burnt.wav
frame data/chars/misc/magic/flameT01.png
frame data/chars/misc/magic/flameT02.png
burn 7 22 27 25 12 1
frame data/chars/misc/magic/flameT03.png
frame data/chars/misc/magic/flameT04.png
frame data/chars/misc/magic/flameT05.png
frame data/chars/misc/magic/flameT03.png
frame data/chars/misc/magic/flameT04.png
frame data/chars/misc/magic/flameT06.png
burn 5 17 30 31 12 1
frame data/chars/misc/magic/flameT07.png
frame data/chars/misc/magic/flameT08.png
frame data/chars/misc/magic/flameT07.png
attack 0
frame data/chars/misc/magic/flameT09.png
frame data/chars/misc/magic/flameT10.png
frame data/chars/misc/magic/flameT11.png
frame data/chars/misc/magic/flameT12.png
frame data/chars/misc/empty.gif

This projectile won't remove itself after it hits something. If you want it to do that, simply set follow up mechanic which changes animation to invisible animation. No need for extra function to remove the projectile cause lifespan will remove it whichever animation it is playing

Back to the shooter2 function above, the last 3 parameters define projectile's velocity allowing you to set where it's going to fly (up or down) relative to shooter's facing direction
 
BB, sorry to disagree with you, but I don't think the LIFESPAN is a good idea. Think about a very slow projectile which is shoot  while you are on the air - the projectile will just vanish on the air.

So I sugest to use BB's code, but combine with landframe and followcond to simulate the hits.
 
Ah yes, about lifespan, it depends on the nature of projectile. the example above is shot flame which naturally dies after some time, that's why it uses lifespan
If your projectile doesn't die like that, then don't set lifespan. Set script to remove it on hit or landing (as Ilu suggested) or use offscreenkill to remove it when it flies offscreen far enough :)
 
Bloodbane said:
The best way is to use script like this to shoot the projectile:

void shooter2(void vName, float fX, float fY, float fZ, float Vx, float Vy, float Vz)
{//Spawns projectile next to caller and move it with speed
//vName: Model name of entity to be spawned in
//fX: X location adjustment
//fY: Y location adjustment
//fZ: Z location adjustment
//Vx: X speed
//Vy: Y speed
//Vz: Z speed

  void self = getlocalvar("self"); //Get calling entity
  int Direction = getentityproperty(self, "direction");
  void vSpawn; //Spawn object.

  vSpawn = spawn01(vName, fX, fY, fZ); //Spawn in projectile
  if (Direction == 0){ //Is entity facing left?                 
      Vx = -Vx; //Reverse Vx direction to match facing
  }

  changeentityproperty(vSpawn, "velocity", Vx, Vz, Vy);
  return vSpawn;
}

void spawn01(void vName, float fX, float fY, float fZ)
{
//spawn01 (Generic spawner)
//Damon Vaughn Caskey
//07/06/2007
//
//Spawns entity next to caller.
//
//vName: Model name of entity to be spawned in.
//fX: X location adjustment.
//fY: Y location adjustment.
      //fZ: Z location adjustment.

void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
int  iDirection = getentityproperty(self, "direction");

clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

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

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.

vSpawn = spawn(); //Spawn in entity.

changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
   
return vSpawn; //Return spawn.
}

and make the projectile like this:

name FlameT
type none
lifespan  2
nolife 1
subject_to_hole 1
no_adjust_base  0
subject_to_gravity 0
subject_to_platform 0
offscreenkill 200
candamage player npc obstacle


anim idle
delay 6
offset 20 43
hitfx data/sounds/burnt.wav
frame data/chars/misc/magic/flameT01.png
frame data/chars/misc/magic/flameT02.png
burn 7 22 27 25 12 1
frame data/chars/misc/magic/flameT03.png
frame data/chars/misc/magic/flameT04.png
frame data/chars/misc/magic/flameT05.png
frame data/chars/misc/magic/flameT03.png
frame data/chars/misc/magic/flameT04.png
frame data/chars/misc/magic/flameT06.png
burn 5 17 30 31 12 1
frame data/chars/misc/magic/flameT07.png
frame data/chars/misc/magic/flameT08.png
frame data/chars/misc/magic/flameT07.png
attack 0
frame data/chars/misc/magic/flameT09.png
frame data/chars/misc/magic/flameT10.png
frame data/chars/misc/magic/flameT11.png
frame data/chars/misc/magic/flameT12.png
frame data/chars/misc/empty.gif

This projectile won't remove itself after it hits something. If you want it to do that, simply set follow up mechanic which changes animation to invisible animation. No need for extra function to remove the projectile cause lifespan will remove it whichever animation it is playing

Back to the shooter2 function above, the last 3 parameters define projectile's velocity allowing you to set where it's going to fly (up or down) relative to shooter's facing direction

Could you please show me this exact thing filled out so I may try and learn what part does what. Thanks.
 
Bloodbane said:
The best way is to use script like this to shoot the projectile:

Bloodline, when you post code, it's a good idea to enclose it in code tags instead of quotes. Won't mess up your formatting like quotes do and will help keep it separate from regular posts. :)

Code:
here is some code

DC
 
Ok, I am using Bloodbanes Diagonal script to shoot a bunch of little missles. Do I use "killentity" inside the script to get rid of the missiles when they hit? What is the 'Hit' command?

And can I switch the missles over to aquiring targets after a delay?

Sorry guys, I know all I got is a bunch of questions. I just discovered this over last wkend. Never programmed before but this is really interesting and exciting.

I do read the manual and always have it open. But not everything is explained down to my level. Thanks again guys!
 
I do read the manual and always have it open. But not everything is explained down to my level.

I don't blame you, shooter2 function was made by me and it's not one of default functions so it's not in the manual

Anyways, back to topic:

Do I use "killentity" inside the script to get rid of the missiles when they hit? What is the 'Hit' command?

Yes you could but it's not necessary
Here's example from Ironman's plasmaD (beam he shot downwards while hovering)

Code:
name		PlasmaD
type		none
lifespan	1
candamage	enemy obstacle
subject_to_gravity 0



anim	idle
	loop	1 1 3
	delay	6
	followanim 1
	followcond 1
	landframe 4
	offset	52 35
	attack	61 33 14 14 15 1 0 0 0 0
	frame	data/chars/Ironman/r3.gif
	frame	data/chars/Ironman/r4.gif
	frame	data/chars/Ironman/r3.gif
	frame	data/chars/Ironman/r4.gif
	frame	data/chars/misc/empty.gif
		
anim	follow1
	delay	6
	offset	52 35
	frame	data/chars/misc/empty.gif

It doesn't use any script at all. This beam simply changes animation when it hits something. Then its short lifespan will remove it
You could add killentity script in FOLLOW1 but it would be redundant

And can I switch the missles over to aquiring targets after a delay?

Why would you want that?
 
And can I switch the missles over to aquiring targets after a delay?

Why would you want that?
[/quote]

To make the effect of shooting out a bunch of missiles and then them rocketing towards acquired targets. Plus if the shoot out a ways before they chase/target, they have a better chance of finding different targets.
 
Oh you mean targetted projectiles, that would require different script system. Fortunately it's not related to downward projectile at all
 
So I am using shooter2 to launch missiles in a bunch of directions, adding the follow1 animation to disappear when they hit, or after 0.25 seconds, whichever comes first.

Next, if the missile did not 'hit', at the 0.25 second mark I will us the generic 'shoot' command to relaunch the missile, at the same coordinates it disappears, with 'chase' property.

Therefore, it should look like I'm shooting a bunch of missiles, which after a short delay, acquire and zoom at targets.

I think shooting the missiles out in different directions will help prevent them from all going after the same target.

Caveats:
1. How to determine whether or not to spawn chase missile based on if original missile 'hit'?
2. Chase missiles don't chase on the Y axis, which results in them flipping back and forth under/over some enemies.
3. Any other way to prevent the missiles from all acquiring the same target if other targets are present?


What do you guys think?
 
Caveats:
4. Effective way to end or remove Missile after set amount of time, since using shooter2 command doesn't use the missiles' lifespan properties?
 
Back
Top Bottom