poison dart help!!!!!

Posted By: Blink

poison dart help!!!!! - 06/05/10 18:02

Hello all, I have a poison dart code, modified from a turret code that George created in an old AUM. I modified it so it will hurt the A6 plBiped template player, but my problem is, I want to be able to block it with another model, so it cant kill me. this is an education/adventure project for my students. my player has to solve a math problem and hit the right numbered trigger. i want it to trigger a shield or wall to move in front of the poison dart statue, no prevent it from "killing" the player. can anyone help? my problem here with this code is, how to stop the darts from going through the model in its way.

Code:
function destroy_turret();
function move_bullet();
function remove_bullet();

//////////////////////////////////////////////////////////////

var bullet_speed;

//////////////////////////////////////////////////////////////

sound explode_snd = "boom.wav";
sound dart_snd = <poisondart.wav>;
//////////////////////////////////////////////////////////////

string bullet_mdl = <dart.mdl>;
entity* plBiped01_entity; 
//////////////////////////////////////////////////////////////

action dartstatue
{

	if (my.skill1 == 0) {my.skill1 = 500;} // set the range with skill1, default = 1000 quants
	if (my.skill2 == 0) {my.skill2 = 180;} // default viewing angle in front of the turret = 180	
	my.enable_impact = on;
	my.event = destroy_turret;
	while (plBiped01_entity == null) {wait (1);}
	while (my != null && plBiped01_entity != null)
	{
		my.skill10 = abs(ang(plBiped01_entity.pan) - ang(my.pan)); 
		if (vec_dist (my.x, plBiped01_entity.x) < my.skill1)
		{
			if ((my.skill10 > 180 - my.skill2 / 2) && (my.skill10 < 180 + my.skill2 / 2))
			{
				vec_set (temp.x, plBiped01_entity.x);
				vec_sub (temp.x, my.x);
				vec_to_angle (my.pan, temp);					
				ent_create (bullet_mdl, my.pos, move_bullet);
				snd_play (dart_snd, 30, 0);
			}
		}
		wait (8); // fires 2 bullets a second
	}
}

function destroy_turret()
{
	wait (1);
	if (you == plBiped01_entity) {return;} // can't be destroyed by running into it
	snd_play (explode_snd, 70, 0); 
	ent_remove (me);
}

function move_bullet()
{
	wait (1);
	my.enable_entity = on;
	my.enable_block = on;
	my.event = remove_bullet;
	my.passable = on;
	my.pan = you.pan;
   my.lightred = 250;
	my.lightgreen = 150;
	my.lightrange = 200;
	bullet_speed.x = 100;
	bullet_speed.y = 0;
	bullet_speed.z = 0;
	bullet_speed *= time_step;
	while (my != null)
	{
		if (you == null) {return;}
		if (vec_dist (my.x, you.x) < 100) // don't collide with the turret 
		{
			my.passable = on;
		}
		else	
		{
			my.passable = off;
		}
		ent_move (bullet_speed, nullvector);
		wait (1);
	}
}

function remove_bullet()
{
	wait (1);
	if (you == plBiped01_entity) {
		plBiped01_entity = you;
		plBiped01_entity._armor__003 -= 2; // decrease player's health
		if(you._armor__003 < 0)
{
// flesh damage after armor damage
you._health__003 += you._armor__003;
you._armor__003 = 0;
PlBiped_Damage_Reaction(); // display damage panel
wait(-1);
}
	}	
	ent_remove (me);
}
//////////////////////////////////////////////////////////////////////////////////////


Posted By: Blink

Re: poison dart help!!!!! - 06/06/10 14:34

is there something i can add to my script that will prevent the darts from getting past the model? thats all i need to know.
Posted By: tD_Datura_v

Re: poison dart help!!!!! - 06/07/10 14:47

At a first glance...
It looks like the turret and poison dart use ent_move, not c_move, and the dart is PASSABLE when near the turret.

*try using c_move instead with POLYGON flag ON or proper bounding box settings for the obstacle wall?
*keep the obstacle wall and the player some distance from the turret?
*change the distance the poison dart is PASSABLE when fired (maybe use turret.max_x * 1.05 instead of 100)?

Posted By: Widi

Re: poison dart help!!!!! - 06/07/10 15:50

@tD-Datura: this is the WDL section and Blink use also wdl code and not lite-c. There is no c_move, so ent_move is right.
Posted By: Pappenheimer

Re: poison dart help!!!!! - 06/07/10 17:17

@Blink:
Maybe, you can use a map entity as shield, and then add something like

if(IN_SOLID){ent_remove(me);}

or

if(EVENT == EVENT_BOUNCE){ent_remove(me);}

right in the beginning of the function.
You have to look into the manual of your version of A6 for the proper terms, because I don't remember them right now.
Posted By: Blink

Re: poison dart help!!!!! - 06/07/10 21:17

@pappenheimer, so, in my move bullet function add if(EVENT == EVENT_BOUNCE){ent_remove(me);}?
Posted By: Pappenheimer

Re: poison dart help!!!!! - 06/08/10 02:10

In:
function remove_bullet()
{
if(EVENT == EVENT_BLOCK){ent_remove(me);}Take EVENT_BLOCK instead of EVENT_BOUNCE (not sure if EVENT_BOUNCE even exists, sorry)
...

Or in the while loop of function move_bullet():

if(IN_SOLID){ent_remove(me);}

Sorry, my former answer was a bit unspecific.
Posted By: Blink

Re: poison dart help!!!!! - 06/08/10 02:27

Thanks, i will give it a try tommorow. off to bed.
Posted By: Blink

Re: poison dart help!!!!! - 06/08/10 22:19

well, it didnt work, the darts still penetrate the shield and kills the player. any other ideas?
Posted By: badapple

Re: poison dart help!!!!! - 06/09/10 04:08

you could always create a global variable , we'll call it "blocked" and set it to zero

inside its event function it could check whether blocked is true or not when it hits , if blocked is true , dont cause poison damage and remove , maybe play a deflecting sound or something

else damage normally , know what i mean
Posted By: Blink

Re: poison dart help!!!!! - 06/09/10 09:49

greetings Bad, i like that idea, but as usual, i have no idea how to implement that. an example will be helpful if you dont mind. i was going to change the temp in vec to angle to bounce, but i didnt think that would work.
Posted By: tD_Datura_v

Re: poison dart help!!!!! - 06/09/10 10:59

The following is a mutilated derivative of the code posted at the beginning of this thread.
It is an incomplete example which MAY be used to help determine what, or what not to do.
The snippet was tested and seemingly working with A6.60 + A6Templates.
*Turret / statue shoots and damages A6T biped player -> CHECK
*Model blocks shots from turret to A6T biped player -> CHECK
*Some non-essential improvements attempted -> CHECK
*Some flaws (re)introduced -> CHECK
Code:
/****************
	snippet from _helpy.wdl
	(c)opyright dummy collective
	may only be used without permission
****************/
DEFINE _range, skill1;
DEFINE _sightangle, skill2;
DEFINE _hitEntity, skill99;
ENTITY* eHit;

function destroy_turret();
function move_bullet();
function remove_bullet();

var bullet_speed[3];

sound explode_snd = "boom.wav";
sound dart_snd = <poisondart.wav>;

string bullet_mdl = <dart.mdl>;
entity* plBiped01_entity; 

action dartwall {
	wait(1);
	c_setminmax(me);
}

action dartstatue {
	wait(1);
	c_setminmax(me);

	if (my._range == 0) { my._range = 1000; } // set the range with skill1, default = 1000 quants
	if (my._sightangle == 0) {my._sightangle = 180;} // default viewing angle in front of the turret = 180	
	my.enable_impact = on;
	my.event = destroy_turret;
	while (plBiped01_entity == null) {wait (1);}
	while (my != null && plBiped01_entity != null) {
	
		if (vec_dist (my.x, plBiped01_entity.x) < my._range) {
			vec_diff(temp, plBiped01_entity.x, my.x);
			vec_to_angle(temp, temp);
			if (abs(ang(temp.pan - my.pan)) <= abs(my._sightangle) / 2) {
				// turn the turret toward the player
				vec_set(my.pan, temp);
				// try to create the dart outside of the turret bounding box
				temp.x = my.max_x * 1.25;		// <- IMPORTANTE
				temp.y = 0;
				temp.z = 0;
				vec_rotate(temp, my.pan);
				vec_add(temp, my.x);
				ent_create (bullet_mdl, temp, move_bullet);
				snd_play (dart_snd, 30, 0);
			}
		}
		wait(-0.5); // 1 bullet every 0.5 seconds
	}
}

function destroy_turret() {
	wait (1);
	if (you == plBiped01_entity) {return;} // can't be destroyed by running into it
	snd_play (explode_snd, 70, 0); 
	ent_remove (me);
}

function move_bullet() {
	wait (1);
	c_setminmax(me);
	my.enable_entity = on;
	my.enable_block = on;
	my.event = remove_bullet;
	my.pan = you.pan;
   my.lightred = 250;
	my.lightgreen = 150;
	my.lightrange = 200;
	bullet_speed.x = 100;
	bullet_speed.y = 0;
	bullet_speed.z = 0;
	while (me != null) {
		//if (you == null) { break; }	// you is the turret
		if (my._hitEntity != 0) { break; }
		c_move (me, vector(bullet_speed.x * time_step, 0, 0), nullvector, IGNORE_PASSABLE);
		wait (1);
	}
	if (my._hitEntity != -1) {
		eHit = ptr_for_handle(my._hitEntity);
		if (eHit == plBiped01_entity) {
			eHit._armor__003 -= 2; // decrease player's health
			if(eHit._armor__003 < 0) {
				// flesh damage after armor damage
				eHit._health__003 += eHit._armor__003;
				eHit._armor__003 = 0;
				PlBiped_Damage_Reaction(); // display damage panel
			}
		}
	}
	if (me != NULL) {
		ent_remove(me);
	}
}

function remove_bullet() {
	my._hitEntity = -1;	// hit block
	if (you != NULL) {
		my._hitEntity = handle(you);
	}
	my.event = NULL;
}



Posted By: Blink

Re: poison dart help!!!!! - 06/09/10 22:16

thanks tD, i will give it a try. i think it might be possible to make to wall move by way of a trigger to block the darts from hitting the player, keeping him alive.

update...it works perfectly!!! thanks t_d.
© 2024 lite-C Forums