Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 818 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
simple path following? #316992
03/28/10 14:24
03/28/10 14:24
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
I've searched the manual, tried the wiki, and looked at the forums for awhile now but I can't seem to figure this out. I've tried a few versions of code but each one gives a different problem :-/

I need a very simple script that allows an entity to follow a simple path. I know how to create the path but I can't seem to script the entity to follow it.

I used action patrol_path() in the manual but I get a "Crash in patrol_path" error... I added the var temp; part because w/out it I got another error.

Code:
action patrol_path()
 {
  result = path_scan(me,my.x,my.pan,vector(360,180,1000));     
  if (result == 0) { return; }

  var node = 1;
  path_getnode(my,node,my.skill20,NULL);

  while (1)
  {
    var temp;
    var angle[3];
    result = vec_to_angle(angle,vec_diff(temp,my.skill20,my.x));

    if (result < 25) 
    {
      node = path_nextnode(my,node,1);
      path_getnode(my,node,my.skill20,NULL);
    }

    my.pan = angle[0];
    c_move(me,vector(3*time_step,0,0),NULL,GLIDE);
    wait(1);
  }
}



What am I doing wrong? I'm sure this is very simple but I can't seem to put 2 + 2 together today. Thanks for your help!

Re: simple path following? [Re: Lecithin] #316993
03/28/10 14:34
03/28/10 14:34
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
temp is supposed to be a vector, not a variable. Try changing it to 'VECTOR temp;'.

Last edited by DJBMASTER; 03/28/10 14:34.
Re: simple path following? [Re: DJBMASTER] #316995
03/28/10 14:46
03/28/10 14:46
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
thank you very much! I've got a lot to learn laugh

Re: simple path following? [Re: Lecithin] #316998
03/28/10 15:10
03/28/10 15:10
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
No problem, at least you are doing the sensible thing and trying yourself, and then asking. The example in the manual is probably targeted for the older language C-Script as 'temp' was a built-in vector, rather than requiring the user to define it themselves.

Last edited by DJBMASTER; 03/28/10 15:10.
Re: simple path following? [Re: DJBMASTER] #316999
03/28/10 15:17
03/28/10 15:17
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
ah, I was going to ask that. I noticed it a lot in the example codes but in those same codes it wasn't defined beforehand.

I'm experimenting with getting the mage in workshop 24 to follow a path when out of range of the other mage and then changing his state and attacking when in range.

We'll see how it goes but with my current luck I might be asking more questions :-)

Last edited by Lecithin; 03/28/10 15:18.
Re: simple path following? [Re: Lecithin] #317019
03/28/10 16:49
03/28/10 16:49
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
Ok, I've gotten the character to follow the path and when the player's mage comes into c_scan range the AI mage begins attacking. All of that works flawlessly when the mage is approximately 50 pixels above the terrain but when I tried to set the mage on the terrain (using c_trace and hit.z etc) he only walks & animates until he hits the next node on the pathand then gets stuck. Once stuck he changes his pan incredibly quickly (essentially pointing one way then another) but doesn't move forward.

There's more to the code than this but the only pertinent part is (I think)...

Code:
action wizard_patrol()
{
	my.event = wizard_hit;
	my.emask |= ENABLE_IMPACT;   
	
	VECTOR vFeet;
	vec_for_min(vFeet,me);

  ENTITY* enemy = NULL; // spell target

	my.STATE = 1;
	
	result = path_scan(me,my.x,my.pan,vector(360,180,1000));     
	if (result == 0) { return; } 
	var node = 1; // start at first node
	path_getnode(my,node,my.skill20,NULL);
	
	while (1)
	{
		if(my.STATE == 1) 
		{		
		c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
		if (you) // red wizard or flying spell detected?
		    {
			my.STATE = 2; 
			enemy = your.CREATOR;
		    }
		else
		    {
		    VECTOR* temp = NULL;
		    var angle[3];
		    result = vec_to_angle(angle,vec_diff(temp,my.skill20,my.x));
		    if (result < 25) 
		        {
		        node = path_nextnode(my,node,1);
	                path_getnode(my,node,my.skill20,NULL);
		        }
		    my.pan = angle[0];
		    c_move(me,vector(3*time_step,0,0),NULL,GLIDE);
		    my.ANIMATION += 5*time_step;
		    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;
	            }
                }



So I believe the problem is w/my c_trace. I adjusted the script to use this same exact code but place the wizard 50 pixels above the terrain and it works fine there so I believe my collisions are off for some reason.

Re: simple path following? [Re: Lecithin] #317077
03/29/10 07:40
03/29/10 07:40
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Have a look at c_move in the manual it has a good example of a basic walking script with gravity and floor detection.


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: simple path following? [Re: Nidhogg] #317309
03/30/10 14:10
03/30/10 14:10
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
I've checked out the c_move example and it is a great example of movement but my player's movement already worked. I learned a lot from that example but when I applied the pertinent parts to my code I still ended up with problems.

My problem isn't the player's character movement rather it's the AI wizard that's patrolling. He gets stuck when switching to the next node on the path but only gets stuck when he's on the ground, when floating approximately 50 quants up he does just fine.

I've even drawn out my formula and can't seem to find a problem but I'm new so who knows what I'm missing.

Suggestions?

Re: simple path following? [Re: Lecithin] #317379
03/31/10 05:50
03/31/10 05:50
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Check your nodes maybe they are to close to the floor or something.


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: simple path following? [Re: Nidhogg] #317427
03/31/10 16:32
03/31/10 16:32
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
ah, I figured part of the problem out. It's not the movement that's the problem its the path! He gets stuck once he gets to the path but he finds it perfectly. He can walk over mountains and all else, but my path is broken. I'm happy that I at least know what to try to fix now laugh


At least I thought.... now nothing seems to be working properly. I'm pretty sure its the path so I'll set my mind to attempting to fixing that.

Last edited by Lecithin; 03/31/10 23:32.
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