|
|
Bow&arrow
#148687
08/17/07 17:21
08/17/07 17:21
|
Joined: Jan 2002
Posts: 454 Germany
CD_saber
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 454
Germany
|
Hello George, I tried to use your old Bow and arrow code, and it works fine but there is one thing which doesn't work. The arrows don't stop when they hit a wall or an entity the just drift right or left till get over the entity and continue flying. I know that it's an old code, but, how can I fix it? Thank you! here is the code: Code:
function init_bowarrow(); function get_bow(); function move_arrow(); function hurt_you();
var arrow_fired = 0;
string arrow_mdl = <arrow.mdl>;
entity bow_entity { type = <bow.mdl>; layer = 10; view = camera; x = 30; y = 8; z = -10; }
action bow // attach this action to your bow & arrow model { my.enable_impact = ON; my.event = get_bow; while (my != null) // rotates as long as it hasn't been picked up { my.pan += 3 * time; wait (1); } }
function get_bow() { wait (1); ent_remove (me); bow_entity.frame = 2; // show the arrow bow_entity.visible = on; }
function init_bowarrow() { clip_size = 0; // show all the triangles for all the models while (1) { if ((mouse_left == 1 || key_ctrl == 1) && bow_entity.frame < 7) { bow_entity.frame += 2 * time; } else { if (bow_entity.frame >= 7 && arrow_fired == 0) // we have to fire { while (mouse_left == 1 || key_ctrl == 1) {wait (1);} // disable autofire vec_set (temp, player.pos); temp.z += 20; // the arrow is fired 20 quants above player's origin ent_create (arrow_mdl, temp, move_arrow); arrow_fired = 1; // a single arrow } else // the player isn't shooting { arrow_fired = 0; bow_entity.frame = 2; } } wait (1); } }
function move_arrow() { wait (1); my.enable_entity = on; my.enable_block = on; my.event = hurt_you(); my.passable = on; my.pan = camera.pan; my.tilt = camera.tilt;
my.skill12 = 50; // skill12, 13, 14 act like a var my.skill13 = 0; my.skill14 = 0; my.skill12 *= time; while (my.skill12 != 0) // moves until it hits something { if (vec_dist (my.x, player.x) < 100) {my.passable = on;} // don't collide with the player else {my.passable = off;} ent_move (my.skill12, nullvector); wait (1); } }
function hurt_you() { wait (1); if (you == event_entity) { my.skill12 = 0; // stop moving ent_remove (me); } if (you == event_block) { my.skill12 = 0; // stop the arrow my.passable = on; // the arrow won't move from now on so it shouldn't stand in our way } }
Ja, lach du nur du haariges Pelzvieh!
|
|
|
Re: Bow&arrow
[Re: George]
#148689
08/18/07 09:49
08/18/07 09:49
|
Joined: Jan 2002
Posts: 454 Germany
CD_saber
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 454
Germany
|
Thank you, but the arrow still does not stop when hitting a model or a wall. Is there a fault in the hurt_you() funkction ?
Ja, lach du nur du haariges Pelzvieh!
|
|
|
Re: Bow&arrow
[Re: CD_saber]
#148690
08/18/07 14:24
08/18/07 14:24
|
Joined: Dec 2005
Posts: 478 India
msl_manni
Senior Member
|
Senior Member
Joined: Dec 2005
Posts: 478
India
|
Instead of ent_move use the c_move, because ent_move has been deprecated in A6-A7.
My Specialities Limited.
|
|
|
Re: Bow&arrow
[Re: CD_saber]
#148692
08/19/07 09:47
08/19/07 09:47
|
Joined: Jan 2002
Posts: 454 Germany
CD_saber
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 454
Germany
|
Ok, I did replace it : Crash in arrow: c_move (my.skill12, nullvector);
Actually I got it working by using this
function hurt_you(){ wait (1); if (you == 1) { my.skill12 = 0; // stop moving ent_remove (me); } if (you == 0) { my.skill12 = 0; // stop the arrow my.passable = on; // }
instead of
function hurt_you(){ wait (1); if (you == event_entity) { my.skill12 = 0; // stop moving ent_remove (me); } if (you == event_block) { my.skill12 = 0; // stop the arrow my.passable = on; // } }
But I have another question. How can i modify the skript, so that the arrow "starts" at a special vertex of the Bow model?
Ja, lach du nur du haariges Pelzvieh!
|
|
|
Re: Bow&arrow
[Re: CD_saber]
#148693
08/19/07 11:53
08/19/07 11:53
|
Joined: Dec 2005
Posts: 478 India
msl_manni
Senior Member
|
Senior Member
Joined: Dec 2005
Posts: 478
India
|
The correct syntax for c_move is Code:
c_move(ENTITY* entity,VECTOR* reldist,VECTOR* absdist,var mode)
Quote:
if (you == 1)
Please use event_type for comparision and not you .
Code:
if(event_type == event_block)
Quote:
so that the arrow "starts" at a special vertex of the Bow model?
And see vec_for_vertex for the solution to your second question.
My Specialities Limited.
|
|
|
Re: Bow&arrow
[Re: CD_saber]
#148694
08/19/07 15:30
08/19/07 15:30
|
Joined: Jan 2002
Posts: 454 Germany
CD_saber
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 454
Germany
|
OK, thank you
@George:
Is there a way to combine the dart code from AUM27 with the bow and arrow code? What is that the arrow starts from a special vertex of the bow entity and goes to the position off a cross-panel, like in the dart code. I'd would be great if it is possible to make the cross moving on the screen (dart code) Iam no programmer, and I hope you can help me
Thank you, CD_SABER
Ja, lach du nur du haariges Pelzvieh!
|
|
|
Re: Bow&arrow
[Re: George]
#148696
08/21/07 12:09
08/21/07 12:09
|
Joined: Jan 2002
Posts: 454 Germany
CD_saber
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 454
Germany
|
Ok, thank you. I'm sorry, but i'm not a programmer. can someone please help me? I want the arrow to start at a special vertex of the view-entity and to fly to a postition of a cross on the screen. Moreover, can someone change the ent_move into c_move? Code:
function init_bowarrow(); function get_bow(); function move_arrow(); function hurt_you();
var arrow_fired = 0;
var bow_vertex = 300; var counter;
var bowpos[3]; string arrow_mdl = <arrow.mdl>;
entity bow_entity { type = <bow2.mdl>; layer = 10; view = camera; x = 23; y = -3; z = -10; }
action bow // attach this action to your bow & arrow model { my.unlit = ON; my.enable_impact = ON; my.event = get_bow; while (my != null) // rotates as long as it hasn't been picked up { my.pan += 3 * time; wait (1); } }
function get_bow() { wait (1); ent_remove (me); bow_entity.frame = 2; // show the arrow bow_entity.visible = on; }
function init_bowarrow() { clip_size = 0; // show all the triangles for all the models while (1) {
if ((mouse_left == 1 || key_ctrl == 1) && bow_entity.frame < 7) { bow_entity.frame += 0.2 * time; } else {
if (bow_entity.frame >= 7 && arrow_fired == 0) // we have to fire { while (mouse_left == 1 || key_ctrl == 1) {wait (1);} // disable autofire vec_set (temp, bow_entity.pos); temp.z += 20; ent_create (arrow_mdl,temp, move_arrow);
arrow_fired = 1; // a single arrow } else // the player isn't shooting { arrow_fired = 0; bow_entity.frame = 2; } } wait (1); } }
function move_arrow() { wait (1); my.polygon = ON; my.enable_entity = on; my.enable_block = on; my.event = hurt_you; my.passable = on; my.pan = camera.pan; my.tilt = camera.tilt;
my.skill12 = 50; // skill12, 13, 14 act like a var my.skill13 = 0; my.skill14 = 0; my.skill12 = 25 - 8*time; //// my.skill12 *= 2*time; while (my.skill12 != 0) // moves until it hits something { if (vec_dist (my.x, player.x) < 100) {my.passable = on;} // don't collide with the player else {my.passable = off;} ent_move (my.skill12, nullvector); wait (1); } }
function hurt_you() { wait (1); if (you == 1) { my.skill12 = 0; // stop moving ent_remove (me); } if (you == 0) { my.skill12 = 0; // stop the arrow my.passable = on; // the arrow won't move from now on so it shouldn't stand in our way } }
Ja, lach du nur du haariges Pelzvieh!
|
|
|
|