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); } //////////////////////////////////////////////////////////////////////////////////////