Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 844 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Bow and Arrow Script! #147058
08/10/07 14:05
08/10/07 14:05
Joined: Apr 2006
Posts: 58
Moerk Offline OP
Junior Member
Moerk  Offline OP
Junior Member

Joined: Apr 2006
Posts: 58
Hi there
i need help in scripting a good bow and arrow script. At the moment i´m using this!

That is for creating the arrow:

Code:
function bowarrow()
{
while (1)
{
if (mouse_left == 1 && arrowfired != 1) // Check something
{
vec_set (temp, camera.pos); // Arrow start at camera
ent_create (arrows, temp, move_arrow); // create arrow
arrowmenge += 1; // variables
arrowfired = 1; // variables
}
wait(1);
}
}



That is for moving the arrow:

Code:
action move_arrow()
{
fire_spur(); // particles
my.enable_block = on;
my.event = hurt_you;
my.pan = camera.pan;
my.tilt = camera.tilt;
my.firespeed = 80; // Defined
my.schwerkraft = 0; // Gravity
while (my.firespeed != 0) // moves until it hits something
{
if (vec_dist (my.x, player.x) < 100) // Make it passable if it collides with player
{
my.passable = on;
}
else
{
my.passable = off;
}

ent_move (vector(my.firespeed, 0, my.schwerkraft), nullvector); // move it!
my.schwerkraft -= 1*time_step; // add gravity to pull it down
wait (1);
}
}



That is for removing arrow on event:

Code:
function hurt_you()
{
if (EVENT_TYPE == EVENT_BLOCK)
{
my.firespeed = 0; // stop the arrow
sleep(3); // show the impact for 3 seconds
ent_remove(my); // remove arrow
arrowmenge -= 1;
wait(1);
}
}



That code works fine but the problem is that the arrows stop a little bit before the wall. I want that they put in the wall.

Another problem is that the tilt of the arrow is only turned to the tilt position at the beginning shoot if the gravity pulls it down to earth it looks in the air. How can i turn it while he´s flying to the ground.

Here is a pic of the arrow in wall:





Another question: Do you know other better Bow and Arrow Solutions?

And another one: How about trying with Physic Objects? And if yes how to do it?

Thank you guys!


"Die Kette die mich ewig hält möge man erst noch schmieden" Regina S.
Re: Bow and Arrow Script! [Re: Moerk] #147059
08/10/07 16:47
08/10/07 16:47
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
try my.polygon = on for the collision detection. this might help the stopping before the wall problem.

As for the tilt problem: ent_move, the way you are using it, moves the arrow in the direction that it's pointing, not absolute coordinates. So, what you should do is not apply a gravitational force at all, but simply tilt the arrow, and let ent_move do the rest of the work:

Code:

temp.x = my.firespeed;
temp.y = 0;
temp.z = 0;
ent_move(temp, nullvector);
my.tilt -= time_step; // play with this value



See if those 2 things help!

Last edited by LogantheHogan; 08/10/07 16:50.
Re: Bow and Arrow Script! [Re: LogantheHogan] #147060
08/10/07 17:13
08/10/07 17:13
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
@LogantheHogan: Never ever set the polygon flag for moving objects. It may mess up collision detection completly.

@Moerk: Set the arrow to passable when he hit the wall. Stopp the normal movement and move it X quants forwards using a c_move instruction.
That should solve your not-in-wall problem.

EDIT:
Use the new instructions (c_*) like c_move etc.

Last edited by Xarthor; 08/10/07 17:20.
Re: Bow and Arrow Script! [Re: Xarthor] #147061
08/10/07 18:09
08/10/07 18:09
Joined: Apr 2006
Posts: 58
Moerk Offline OP
Junior Member
Moerk  Offline OP
Junior Member

Joined: Apr 2006
Posts: 58
Allright i will give it a try.

Thank you!


"Die Kette die mich ewig hält möge man erst noch schmieden" Regina S.
Re: Bow and Arrow Script! [Re: Xarthor] #147062
08/10/07 18:29
08/10/07 18:29
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
Quote:

@LogantheHogan: Never ever set the polygon flag for moving objects. It may mess up collision detection completly.




Hmm. Why not? I've never heard that before - and I use it for every moving object in my game, including my player. I've never encountered problems.

Re: Bow and Arrow Script! [Re: LogantheHogan] #147063
08/10/07 18:30
08/10/07 18:30
Joined: Apr 2006
Posts: 58
Moerk Offline OP
Junior Member
Moerk  Offline OP
Junior Member

Joined: Apr 2006
Posts: 58
I tried both of your ideas and both combined work perfect. Much thanks!

Last edited by Moerk; 08/10/07 18:31.

"Die Kette die mich ewig hält möge man erst noch schmieden" Regina S.
Re: Bow and Arrow Script! [Re: Moerk] #147064
08/10/07 18:47
08/10/07 18:47
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
@LogantheHogan:
JCL himself stated it once and it is also mentioned in the manual:
Quote:


- Only one of the objects involved in a collision should have a polygonal hull. Thus do not set this flag for moving actors.
- This flag does not use animation, so don't set it for animated models.




Quoted: The manual | keyword: polygon | section: remarks

Re: Bow and Arrow Script! [Re: Xarthor] #147065
08/10/07 20:53
08/10/07 20:53
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
Ah! I see it and I'm looking at the page in the manual and you are right. How strange, though, I've never had any issues at all. I guess now I know what to change if my collision starts to act up. Thanks


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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