Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Grant, dr_panther, AndrewAMD), 1,379 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
c_trace and shooting projectile help #168146
11/19/07 07:15
11/19/07 07:15
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
Code:
 function PewPew()
{
var theTarget;
vec_set(theTarget.x, vector(10000, 0, 0)); //shoots 10000 quants
vec_rotate(theTarget.x, camera.pan); //shoots in the direction of the player
c_trace(my.x, theTarget.x, ignore_me + scan_texture | ignore_passable | use_aabb ); // aabb works great here :)

if(str_cmpi(tex_name, "TESTBOSS.MDL") == 1) // if the entity hit is square.mdl
{
doDamage(1);
}
}



That's my weapon code for right now, it takes away 1 point of health everytime I shoot a TESTBOSS.MDL -- this all works fine, how can i make it fire a .mdl in the same direction as the c_trace ray?

Re: c_trace and shooting projectile help [Re: immolat3] #168147
11/20/07 06:26
11/20/07 06:26
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
any help? please?

Re: c_trace and shooting projectile help [Re: immolat3] #168148
11/20/07 15:00
11/20/07 15:00
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
make an entity and move it in the right direction. To do this, make a new function called "iKillYou()" and attach it to the entity you created. In this function, you put the entity at the start position of the c_trace. Then, using vec_to_angle and the direction between start and endpoint of the c_trace, turn the model towards the end position of the c_trace. Your bullet is now created and faces the target.

The following depends on how you want the bullet to function. Should it hit obstacles that come in the way while moving in the path of the bullet, or is it just a straight line reaching the c_trace target whatever is inbetween? The first is somewhat complicated, the latter is the quickest.

For shooting at a target where the bullet will always reach the target of c_trace:
Code:

//psuedo code
function iKillYou
while (target != reached) {
bullet.angle = vec_to_angle(dirVecToTarget) //bullet faces target of the c_trace (dirVecToTarget = direction from start to end of c_trace)
bullet.position += vec_normalize (dirVecToTarget, speed) //now move forward by adding the direction vector, multiplied by the speed of the bullet
}



EDIT:
as a side note, you can pass the direction vector and player angles to the function immediately as well of course, which spares some calculations with vec_for_angle and vec_to_angle. Probably a better way as you need less calculations and code. Hope that will help you enough to find out yourself.

Last edited by Joozey; 11/20/07 15:04.

Click and join the 3dgs irc community!
Room: #3dgs
Re: c_trace and shooting projectile help [Re: Joozey] #168149
11/20/07 18:10
11/20/07 18:10
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
Thanks ill give that a go and let you know.

i appreciate your reply

Re: c_trace and shooting projectile help [Re: immolat3] #168150
11/20/07 19:30
11/20/07 19:30
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
im having issues trying what you described...hmmm, it's just making the object and i get stuck inside it, my game is 3rd person

Re: c_trace and shooting projectile help [Re: immolat3] #168151
11/20/07 23:54
11/20/07 23:54
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
Code:
  
// Fire Gun Function
function PewPew()
{
var theTarget;
bullet = "bullet.mdl";
vec_set(theTarget.x, vector(10000, 0, 0)); // shoots 10000 quants
vec_rotate(theTarget.x, camera.pan); // shoots in the direction of the player (cameras pan, b/c 3rd person)
c_trace(my.x, theTarget.x, ignore_me + scan_texture | ignore_passable | use_aabb );

if(str_cmpi(tex_name, "TESTBOSS.MDL") == 1 && getEnergy() >= shootEnergy)
{
doDamage(shootDmg);
subtractEnergy(shootEnergy);
snd_play(laserPew, 100, 0);
}
if(getEnergy() < shootEnergy)
{
snd_play(laserEmpty, 100, 0);
subtractEnergy(0);
}
else
{
snd_play(laserNoHit, 100, 0);
subtractEnergy(shootEnergy);
}
snd_stop(laserPew);
snd_stop(laserEmpty);
snd_stop(laserNoHit);
}





Any ideas on how to make this shoot bullet.mdl?

Re: c_trace and shooting projectile help [Re: immolat3] #168152
11/21/07 11:09
11/21/07 11:09
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
I don't see where you create the bullet. When you get stuck, try set the bullet's passable flag on.

Last edited by Joozey; 11/21/07 11:10.

Click and join the 3dgs irc community!
Room: #3dgs
Re: c_trace and shooting projectile help [Re: Joozey] #168153
11/21/07 16:09
11/21/07 16:09
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
sorry i have

ENTITY* Bullet;

before all that.

ill try the passable thing now, good point.

Re: c_trace and shooting projectile help [Re: immolat3] #168154
11/21/07 16:58
11/21/07 16:58
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
Code:
 entity* bullet;

action bulletFly
{
my.passable = on;
c_move(me, nullvector, nullvector, ignore_me);
}

// Fire Gun Function
function PewPew()
{
var theTarget;
vec_set(theTarget.x, vector(10000, 0, 0)); // shoots 10000 quants
vec_rotate(theTarget.x, camera.pan); // shoots in the direction of the player (cameras pan, b/c 3rd person)
c_trace(my.x, theTarget.x, ignore_me + scan_texture | ignore_passable | use_aabb );
ent_createlocal("bullet.mdl", plBiped01_entity.x, bulletFly);


if(str_cmpi(tex_name, "TESTBOSS.MDL") == 1 && getEnergy() >= shootEnergy)
{
doDamage(shootDmg);
subtractEnergy(shootEnergy);
snd_play(laserPew, 100, 0);
}
if(getEnergy() < shootEnergy)
{
snd_play(laserEmpty, 100, 0);
subtractEnergy(0);
}
else
{
snd_play(laserNoHit, 100, 0);
subtractEnergy(shootEnergy);
}
snd_stop(laserPew);
snd_stop(laserEmpty);
snd_stop(laserNoHit);
}



right now it creates the bullet.mdl when i fire, but it just kind of stays there.

Re: c_trace and shooting projectile help [Re: immolat3] #168155
11/21/07 17:01
11/21/07 17:01
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Because it only will go through c_move once now, you need to put it in a while loop while (me) {}. When the bullet is removed, 'me' will return false and the while loop will automaticly stop to prevent empty pointer errors.

EDIT: And you need to replace the first nullvector with vector (speed, 0, 0)
EDIT2: Ánd if your game is not multiplayer, you can just use ent_create isntead of ent_createlocal

Last edited by Joozey; 11/21/07 17:03.

Click and join the 3dgs irc community!
Room: #3dgs
Page 1 of 4 1 2 3 4

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