1 registered members (AndrewAMD),
1,306
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
problem with my code, warlock staff attached to warlock
#319229
04/13/10 13:09
04/13/10 13:09
|
Joined: Oct 2009
Posts: 49
Lecithin
OP
Newbie
|
OP
Newbie
Joined: Oct 2009
Posts: 49
|
I got the staff to attach properly but now there seems to be some collision problems w/the staff and the warlock...? I set the staff to PASSABLE but I'm not sure what else is wrong. The staff isn't dragging on the ground, its not colliding with the warlock (which shouldn't matter anyway since I set it to passable) but the warlock doesn't walk correctly with the staff in hand whereas he moved flawlessly before. Here is the staff's code
function staff()
{
VECTOR wpos;
while(1)
{
set(my,PASSABLE);
vec_for_vertex(wpos, player, 23);
my.x = wpos.x;
my.y= wpos.y;
my.z = wpos.z;
my.pan = player.pan;
wait(1);
}
}
And here is the wizard's walking code
while (1)
{
if (my.STATE == 1)
{
my.pan += (key_cul-key_cur)*5*time_step;
var distance = (key_cuu-key_cud)*5*time_step;
c_move(me, vector(distance,0,0), NULL, GLIDE);
my.ANIMATION += 2*distance;
ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z;
if (key_space)
{
my.ANIMATION = 0;
my.STATE = 2;
}
It seems to me like the staff shouldn't effect the Warlock at all since the staff is set to PASSABLE but that means something else is wrong and I can't figure it out for the life of me.... any suggestions? Edit* When I place the staff 50 quants into the air everything works flawlessly which again leads me to believe it's a collision problem, did I set PASSABLE incorrectly?
Last edited by Lecithin; 04/13/10 13:11.
|
|
|
Re: problem with my code, warlock staff attached to warlock
[Re: Lecithin]
#319230
04/13/10 13:18
04/13/10 13:18
|
Joined: Sep 2009
Posts: 496
Progger
Senior Member
|
Senior Member
Joined: Sep 2009
Posts: 496
|
you forgot IGNORE_PASSABLE in c_move c_move(me, vector(distance,0,0), NULL, GLIDE | IGNORE_PASSABLE); and here
function staff()
{
VECTOR wpos;
while(1)
{
set(my,PASSABLE);
vec_for_vertex(wpos, player, 23);
my.x = wpos.x;
my.y= wpos.y;
my.z = wpos.z;
my.pan = player.pan;
wait(1);
}
}
I would do the set(my,PASSABLE); before the while loop like this
function staff()
{
VECTOR wpos;
set(my,PASSABLE);
while(1)
{
vec_for_vertex(wpos, player, 23);
my.x = wpos.x;
my.y= wpos.y;
my.z = wpos.z;
my.pan = player.pan;
wait(1);
}
}
WFG Progger
Last edited by Progger; 04/13/10 13:20.
|
|
|
Re: problem with my code, warlock staff attached to warlock
[Re: Lecithin]
#319237
04/13/10 13:50
04/13/10 13:50
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
You also can change this (if you don`t need wpos):
vec_for_vertex(wpos, player, 23); my.x = wpos.x; my.y= wpos.y; my.z = wpos.z;
to:
vec_for_vertex(my.x, player, 23); ----------------------------- also:
my.x = wpos.x; my.y= wpos.y; my.z = wpos.z;
to:
vec_set (my.x,wpos);
Last edited by Widi; 04/13/10 13:52.
|
|
|
Re: problem with my code, warlock staff attached to warlock
[Re: Widi]
#319247
04/13/10 14:56
04/13/10 14:56
|
Joined: Oct 2009
Posts: 49
Lecithin
OP
Newbie
|
OP
Newbie
Joined: Oct 2009
Posts: 49
|
I did eventually change it to vec_set but when messing around I used the longer way. Just a question, has anyone had any luck syncing up the warlock staff's "attack" scene to the warlock's attack scene? I can't seem to get the z of each to line up very well. I managed to get the walk and death to work very nicely but attack seems off. The problem is when my.STATE = 2 the staff hovers above the player, when I adjust the z using wpos.z-45 (or whatever) I can get the height right but the staff doesn't stay in his hand, it seems to slide a bit (because of the vertex locking I believe). Has anyone played around with these two (the warlock and his staff) and gotten it to work correctly? I noticed the staff is offset in the MED, perhaps they simply match the x, y, and z of the model and don't lock to a vertex? I want to lock the vertex because I want to show my students how to use vec_to_vertex but I can't very well show them using this method when the staff doesn't look correct w/my coding. here's my code
function staff()
{
VECTOR wpos;
set(my,PASSABLE);
while(1)
{
vec_for_vertex(wpos, player, 23);
my.pan = player.pan;
my.STATE = player.STATE;
my.ANIMATION = player.ANIMATION;
if (my.STATE == 1)
{
ent_animate(me, "walk", my.ANIMATION, ANM_CYCLE);
vec_set(my.x, wpos);
}
if (my.STATE == 2)
{
vec_set(my.x, vector(wpos.x, wpos.y, wpos.z-40));
ent_animate(me, "attack", my.ANIMATION, NULL);
}
if (my.STATE == 3)
{
ent_animate(me, "walk", my.ANIMATION, NULL);
vec_set(my.x, wpos);
}
if (my.STATE == 4)
{
ent_animate(me, "death", my.ANIMATION, NULL);
vec_set(my.x, wpos);
}
wait(1);
}
}
Thank you for your time, it has been very helpful!
|
|
|
Re: problem with my code, warlock staff attached to warlock
[Re: Lecithin]
#319268
04/13/10 16:33
04/13/10 16:33
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
When the staff is animated with the warlock to stay in place when set to its xyz and pan etc., you can't do anything about it in the script, but have to move the staff in MED in each frame to the origin. Then it should stay with the vertex of the warlock's hand. It is kind of a mixture then, keeping the position by vec_for_vertex, but keeping the angles simple by synchronized animations.
Just out of interest, because I give lessons, too: Where do you come from? What is the age of your students?
|
|
|
Re: problem with my code, warlock staff attached to warlock
[Re: Lecithin]
#319306
04/13/10 22:51
04/13/10 22:51
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
If you want to adapt the moves of the staff to the hand of the warlock without animations, you can use a second vec_for_vertex instruction to turn the staff depending the hand without animations:
function staff()
{
VECTOR wpos;
VECTOR temp;
while(1)
{
set(my,PASSABLE);
vec_for_vertex(wpos, player, 23);
my.x = wpos.x;
my.y= wpos.y;
my.z = wpos.z;
vec_for_vertex(temp, player, 24);//the vertex to look at
vec_diff(temp, temp, my.x);//results in a vector that points from my.x to temp
vec_to_angle(my.pan, temp);
wait(1);
}
}
Disadvantage of this way is that the staff can flip under certain circumstances. But that's another thing.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|