4 registered members (ozgur, Ayumi, VHX, monarch),
1,161
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: make an arrow stick to the hit entity
[Re: Altarius]
#447224
11/26/14 20:09
11/26/14 20:09
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
Hi. Here's an example how to place a sprite that will follow another entity ( taken from: http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=414718 )
define selected skill100
void selection_sprite(){ // fex a circle sprite
set(my,PASSABLE|TRANSLUCENT);
my.tilt += 90;
while(you){
vec_set(my.x, you.x);
if (you) if (!you.selected) break;
wait(1);
}
wait(1);
ptr_remove(me);
}
..
my.selected = 1;
ent_create("circle.tga", vector(my.x, my.y, my.z), selection_sprite);
..
wait(-1);
my.selected = 0;
Besides the following commands where made for that:
vec_for_vertex, vec_for_bone, vec_set
example ( taken from here http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=404673 )
VECTOR _p,_a;
vec_for_bone(_p, ThePlayer, "Righthand");
ang_for_bone(_a, ThePlayer, "Righthand");
vec_set(Axe.x, _p.x); //set the axe to the right hand
vec_set(Axe.pan, _a); //and rotate it with the animation of the bone
edit: If you want to stick a model to last hit position you could do it like this ( just wrote it, but didnt test )
.
..
...
c_trace (...);
if (you){ // hit entity?
you.skill1 = hit.vertex; // store vertexnr in skill1
example_arrow (you); // create arrow at hit pos
}
...
..
.
void example_arrow (ENTITY* _ent){
proc_mode |= PROC_GLOBAL;
if (!_ent) return;
ENTITY* your_mdl = ent_create ("arrow.mdl", nullvector, NULL);
if (!your_mdl) return; // creation error?
set (your_mdl, PASSABLE);
while (_ent && your_mdl){ // hit-you and arrow-mdl != NULL
vec_for_vertex (your_mdl.x, _ent, _ent.skill1); // set pos of saved vertexnr
wait (1);
}
wait (1);
ptr_remove (your_mdl);
}
Greets
Last edited by rayp; 11/26/14 21:20. Reason: corrected some things
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
|