problem with my code, warlock staff attached to warlock

Posted By: Lecithin

problem with my code, warlock staff attached to warlock - 04/13/10 13:09

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
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
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?
Posted By: Progger

Re: problem with my code, warlock staff attached to warlock - 04/13/10 13:18

you forgot IGNORE_PASSABLE in c_move

c_move(me, vector(distance,0,0), NULL, GLIDE | IGNORE_PASSABLE);
and here
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);
      }
}



I would do the set(my,PASSABLE); before the while loop
like this
Code:
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 laugh




Posted By: Lecithin

Re: problem with my code, warlock staff attached to warlock - 04/13/10 13:34

wow thanks!

I'm not sure why I put the set in the while, I must have moved that when I was debugging.

I wouldn't have thought of telling the wizard to ignore it, thanks for the help!
Posted By: Widi

Re: problem with my code, warlock staff attached to warlock - 04/13/10 13:50

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);
Posted By: Lecithin

Re: problem with my code, warlock staff attached to warlock - 04/13/10 14:56

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
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!
Posted By: Pappenheimer

Re: problem with my code, warlock staff attached to warlock - 04/13/10 16:33

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?
Posted By: Lecithin

Re: problem with my code, warlock staff attached to warlock - 04/13/10 17:50

I live in the United States and teach high school students. I am introducing them to Gamestudio in the advanced class so I'm currently in the process of learning it.

I was doing the exact method you described but I thought maybe I was doing something wrong.

I guess I'll just keep experimenting.
Posted By: Pappenheimer

Re: problem with my code, warlock staff attached to warlock - 04/13/10 22:51

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:
Code:
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.
Posted By: Widi

Re: problem with my code, warlock staff attached to warlock - 04/14/10 09:47

Code without the disadvantage from the code of Pappenheimer see here:
Attach Entity
Posted By: Lecithin

Re: problem with my code, warlock staff attached to warlock - 04/15/10 13:06

Thanks for all the advice. I ended up adjusting the frames a little in the MED and now it looks beautiful.

I'm starting to see some progress and independence in my learning which is a good sign. I was a little leery of this program at first but I think it's beginning to grow on me laugh
Posted By: Lecithin

Re: problem with my code, warlock staff attached to warlock - 04/15/10 13:27

figures I would get some confidence and then get another problem. This one doesn't seem to make sense to me since the coding is so simple...

I get the following error....
Error in 'MAIN' line 5: 'PATH' undeclared identifier < PATH "models"; >

What gives?!

Code:
#include <acknex.h>
#include <default.c>

PATH "models";


Posted By: Widi

Re: problem with my code, warlock staff attached to warlock - 04/15/10 17:10

Use PRAGMA_PATH instead of PATH.

Example:
#define PRAGMA_PATH "Modelle\\Animiert";
Posted By: Lecithin

Re: problem with my code, warlock staff attached to warlock - 04/15/10 19:53

works fine but did they change PATH? I've seen other projects use PATH just fine, what gives?

PRAGMA is a way for each OS/Computer to have control over certain features while still being compatible w/C-lite.... correct?
Posted By: Pappenheimer

Re: problem with my code, warlock staff attached to warlock - 04/15/10 20:24

PATH "models";

is C-Script

#define PRAGMA_PATH "Modelle\\Animiert";

is Lite-C
Posted By: Lecithin

Re: problem with my code, warlock staff attached to warlock - 04/16/10 12:07

ah ok, I really wish they would update the manual. A lot of this stuff could be averted with some updates. It's tough for new people to figure out the differences, even a simple note in the remarks would work.

I also wish they'd include all the other variables that are often missing like some of the EVENT_ s
© 2024 lite-C Forums