Gamestudio Links
Zorro Links
Newest Posts
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
2 registered members (dr_panther, AndrewAMD), 1,291 guests, and 4 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 2 1 2
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
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

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
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?

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
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

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
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





Last edited by Progger; 04/13/10 13:20.

asking is the best Way to get help laugh laugh laugh
Re: problem with my code, warlock staff attached to warlock [Re: Progger] #319234
04/13/10 13:34
04/13/10 13:34
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
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!

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 Offline
Serious User
Widi  Offline
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
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

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
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 Offline
Senior Expert
Pappenheimer  Offline
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: Pappenheimer] #319272
04/13/10 17:50
04/13/10 17:50
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
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.

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 Offline
Senior Expert
Pappenheimer  Offline
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:
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.

Re: problem with my code, warlock staff attached to warlock [Re: Pappenheimer] #319336
04/14/10 09:47
04/14/10 09:47
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Code without the disadvantage from the code of Pappenheimer see here:
Attach Entity

Re: problem with my code, warlock staff attached to warlock [Re: Widi] #319504
04/15/10 13:06
04/15/10 13:06
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
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

Page 1 of 2 1 2

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