Gamestudio Links
Zorro Links
Newest Posts
zorro license, IB connection
by miwok. 12/06/23 16:32
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (miwok, AndrewAMD, TipmyPip, 3run, Quad, 1 invisible), 645 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Bow&arrow #148687
08/17/07 17:21
08/17/07 17:21
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline 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: CD_saber] #148688
08/17/07 18:33
08/17/07 18:33
Joined: Aug 2003
Posts: 2,008
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,008
Bucharest, Romania
The first error I'm seeing is this:

my.event = hurt_you();

should be:

my.event = hurt_you;

Let me know if you need more help.

Re: Bow&amp;arrow [Re: George] #148689
08/18/07 09:49
08/18/07 09:49
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline 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&amp;arrow [Re: CD_saber] #148690
08/18/07 14:24
08/18/07 14:24
Joined: Dec 2005
Posts: 478
India
M
msl_manni Offline
Senior Member
msl_manni  Offline
Senior Member
M

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&amp;arrow [Re: msl_manni] #148691
08/18/07 18:28
08/18/07 18:28
Joined: Aug 2003
Posts: 2,008
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,008
Bucharest, Romania
That's good advice. Replace ent_move with c_move and let me know what has happened.

Re: Bow&amp;arrow [Re: CD_saber] #148692
08/19/07 09:47
08/19/07 09:47
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline 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&amp;arrow [Re: CD_saber] #148693
08/19/07 11:53
08/19/07 11:53
Joined: Dec 2005
Posts: 478
India
M
msl_manni Offline
Senior Member
msl_manni  Offline
Senior Member
M

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 Offline OP
Senior Member
CD_saber  Offline 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: CD_saber] #148695
08/19/07 18:56
08/19/07 18:56
Joined: Aug 2003
Posts: 2,008
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,008
Bucharest, Romania
msl_manni's advice with vec_for_vertex is the proper solution. Sure, you can combine the darts code with the bow and arrow code, but a much more simple solution is to modify the darts code a bit (add the bow as an "entity" definition).

Re: Bow&arrow [Re: George] #148696
08/21/07 12:09
08/21/07 12:09
Joined: Jan 2002
Posts: 454
Germany
CD_saber Offline OP
Senior Member
CD_saber  Offline 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!
Page 1 of 2 1 2

Moderated by  George 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1