Solved script entity death after attack and at 0 altitude

Question that is answered or resolved.

Glitch

Member
Hey guys, I need some assistance with scripting please.. I'm still a long way to go with my mod 'Resident Evil - Operation Metro City'..scripting is a hurdle I'v finally come to face. I don't know much about it and this my first time trying.

I have a bullet entity its type is 'obstacle' that travels in diagonal direction towards the ground..I need to kill that entity automatically with script at the moment after it has attacked/hits the following:

1. Enemy, obstacle, player, npc ( for these I will use a follow anim, if bullet hits something it will follow to an anim with a script to kill/remove it...I need that kill script)

2. Floor.. (I'm thinking the variable in question would be entity's 'a'/altitude..script to check when its altitude is equal to the floor..then play another animation and then finaly kill/remove it)

How would I go about making these scripts, I don't know how to even start..I went through the scripting manual and looked at other examples in other modules but damn that stuff is greek..

Any assistance would be most welcome

 
------------------
name BULLETPD
health  0
type OBSTACLE

candamage  player enemy obstacle npc

REMOVE 1


anim spawn
loop0
delay1
offset114 137
hitfx  data/sounds/beat1.wav
hitflash Flashn
ATTACKONE  1

attack3  110 133 6 2 26 0 0 0 13 5
framedata/chars/spari/BULLETPD.gif



anim IDLE
loop0
delay90
offset114 137
hitfx  data/sounds/beat1.wav
hitflash Flashn
ATTACKONE  1
fastattack

DIVE 2 4
attack3  110 133 6 2 26 0 0 0 13 13
framedata/chars/spari/BULLETPD.gif
ATTACK3 0 0 0 0 0 0 0 0 0 0 0
framedata/chars/spari/BLANK.gif

#LANDFRAME data/chars/MISC/DUST2.gif

ANIM LAND
loop0
delay3
offset114 136


framedata/chars/MISC/DUST2.gif



ANIM FALL
loop1
delay1
offset114 136


framedata/chars/spari/blank.gif
----------------
 
I prefer to use script to shoot downwards and upwards and use type none for projectiles
And as Ilu suggested, the projectile use landframe to change frame to play certain animation

Here's an example:
name FlameBall
type none
subject_to_gravity 0
subject_to_wall 1
subject_to_platform 1
subject_to_hole 1
no_adjust_base  0
shadow 2
animationscript data/scripts/lescript.c
load RXplos


anim idle
loop 1 0 4
delay 4
offset 20 30
landframe 5
frame data/chars/misc/magic/flBall1.png
frame data/chars/misc/magic/flBall2.png
frame data/chars/misc/magic/flBall3.png
frame data/chars/misc/magic/flBall1.png
frame data/chars/misc/magic/flBall2.png
delay 7
frame data/chars/misc/empty.gif
delay 10
@cmd spawn01 "RXplos" 0 0 0
frame data/chars/misc/empty.gif
@cmd suicide
frame data/chars/misc/empty.gif

In this example, FlameBall animates when it hasn't touched the ground yet. When it does touch the ground or land, it jumps to 6th frame and spawns explosion before it removes itself on next frame

No dive or anything to move it downward, you ask?
That's because it is fired with shooter2 function below:

Code:
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.
}

An example is: @cmd shooter2 "FlameBall" 20 20 1 1 -2 0 which shoots FlameBall diagonal forward down

Now for your purpose of killing entity after it lands or hits anything, you can use suicide function below:

Code:
void suicide()
{ // Suicide!!
    void self = getlocalvar("self");

    killentity(self); //Suicide!
}

OR just use blank image in FOLLOW animation or landing frames and have lifespan kill the projectile ;)
 
Thanks Bloodbane and O' :), that's just what I needed and more. I tried so long to get entity to travel diagonally and stop at floor..gonna insert your script and complete the bullet entity later..will let you know the result (if I don't mess it up that is lol)
 
I managed to code the bullet without any script, the problem was the landframe guys..I used a non numerical value in error..(Feel like smacking myself now lol)
Its working perfect, dives and hits anything in its path no matter what height its spawned at and then removed, if path is clear it continues dive until hitting the floor and plays a ricochet/dust effect I made.
 
You should try to avoid using caps in your code.  I noticed openbor not recognize some things when in caps.  Scripts can also be case sensitive.

 
O Ilusionista said:
Scripts can also be case sensitive.
AFAIK, there can't be case sensitive, they ARE case sensitive. Because they use C-like coding, and C is case sensitive.

+1. That doesn't mean you CAN'T use caps, just that it's a bad idea unless you have a good handle on how/when to do it. A common use for caps is for CONSTANTS to make them stand out. Some people also like CamelCase for their variable names. I'm not a fan of the latter, but it's a matter of taste. Generally speaking the common convention is to avoid caps pretty much everywhere else.

DC
 
Thanks for the advice guys, yeah I been meaning to stop using caps..thought I'l tidy up the text files when I complete the mod, but it would be best to do so as I go along.
 
Back
Top Bottom