2 registered members (TedMar, AndrewAMD),
1,344
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Bullets are Scary
[Re: Creepinbox]
#177885
01/14/08 17:47
01/14/08 17:47
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
The reason that you couldn't get it in front of the player is because '+ 20' does not get affected by player rotation. Try searching for vec_for_angle in the manual and see if you can figure out . For your other problem, I can't read your script from here, so I have no clue .
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Bullets are Scary
[Re: Creepinbox]
#177888
01/14/08 18:41
01/14/08 18:41
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
vec_set(temp,vector(20,0,0)); vec_for_angle(temp,my.pan); vec_add(temp,my.x); ent_create("bullet.mdl",temp,bullet_func);
dont know if its rigth i dont have lite-c
"empty"
|
|
|
Re: Bullets are Scary
[Re: flits]
#177889
01/14/08 19:35
01/14/08 19:35
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
@flits vec_for_angle resets 'temp', so if you first use vec_set, it will be overwritten by vec_for_angle . Vec_normalize is used to stretch a vector along it's length, so it will be placed [n] quants ahead of where it is facing (in this case, vec_scale will do too).
Last edited by Joozey; 01/14/08 19:36.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Bullets are Scary
[Re: Creepinbox]
#177891
01/14/08 21:34
01/14/08 21:34
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
=_O it shouldn't be weird. So what I understood is that you want to trace from player to [distance in front of the player] and trace for a target? And IGNORE_ME does not work? Presumably you have done something wrong then . But you can do it many ways without trace, just depends what you want precisely. moving the bullet can be done through c_move or just count up the position with vector calculation. Scanning for entities can be done with c_scan and checking for blocks with c_content (this in combination with c_move). Now you really move the bullet instead of just tracing whether it will hit an object or not. While moving you scan if you hit something. Downside of this method is that it is slower than c_trace.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Bullets are Scary
[Re: Creepinbox]
#177893
01/14/08 22:59
01/14/08 22:59
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Ok, then I suggest you try c_move. This code works: Code:
... ent_create ("bullet.mdl", my.x, bullet_behaviour); ...
function bullet_behaviour() { var covered_distance = 0; vec_for_angle (my.x, you.pan); vec_scale (my.x, 10); vec_add (my.x, you.x); vec_set(my.pan, you.pan);
//we need to store the you (parent entity) because it will be emptied after the next wait(1) ENTITY* parent_ent = you; while (me) { you = parent_ent; //search back for the parent entity covered_distance = c_move (me, vector(40 * time_step, 0, 0), nullvector, IGNORE_YOU); //move 40 quants ahead and ignore the parent entity //bullet is stuck on impact, do possible damage and remove if (covered_distance <= 0) { you = c_trace (target.x, target.x, IGNORE_ME); //search for the entity hit if (you) {you.health -= 5;} //If theres an entity, remove health. or whatever you had in mind ;) ent_remove(me); //ptr_remove(me) if you have the newest version } wait(1); } }
Last edited by Joozey; 01/14/08 23:02.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
|