Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Lite-C: Object following a path #236173
11/12/08 15:02
11/12/08 15:02
Joined: Sep 2008
Posts: 9
S
Staakman Offline OP
Newbie
Staakman  Offline OP
Newbie
S

Joined: Sep 2008
Posts: 9
Hi,

I'm trying to let an object following a path with an action.
I tryed using the patrol_path() action example.
Problem I'm having is it dosn't recognize _FORCE and _MOVEMODE.
What is the best solution for this when I'm programming in a .c file?
Should I include some header?

Thanks in advance,

Staakman

/////////////////////////////////Start Code/////////////////////////////////////
// move along a path loop
// uses _FORCE, _MOVEMODE
action patrol_path()
{
// attach entity to nearest path
result = path_scan(me,my.x,my.pan,vector(360,180,1000));
if (result == 0) { return; } // no path found

// find first waypoint
var node = 1; // start at first node
path_nodepos(my,node,my._TARGET_X);

while (my._MOVEMODE)
{
// find direction
result = vec_to_angle(angle,vec_diff(temp,my._TARGET_X,my.x));

// near target? Find next waypoint of the path
if (result < 25) {
node = path_nextnode(my,node,1);
path_nodepos(my,node,my._TARGET_X);
}

// turn and walk towards target
actor_turnto(angle.PAN);
actor_moveahead(MY._FORCE);
wait(1);
}
}
/////////////////////////////////End Code/////////////////////////////////////

Last edited by Staakman; 11/12/08 15:03.
Re: Lite-C: Object following a path [Re: Staakman] #236175
11/12/08 15:20
11/12/08 15:20
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
#define skill20 _FORCE
#define skill21 _MOVEMODE


3333333333
Re: Lite-C: Object following a path [Re: Quad] #236228
11/12/08 21:57
11/12/08 21:57
Joined: Sep 2008
Posts: 9
S
Staakman Offline OP
Newbie
Staakman  Offline OP
Newbie
S

Joined: Sep 2008
Posts: 9
Thanks.... that fixed several bugs smile

next bugs are a bit harder:

Code:
//path_nodepos(my,node,my._TARGET_X);                 // Changed to following code: 
path_scannode(my, node);                                  // Assume this is correct?

// and there is a bug with the following code

result = vec_to_angle(ANGLE * ang,vec_diff(temp,my._TARGET_X,my.x));



Last edited by Staakman; 11/12/08 22:00.
Re: Lite-C: Object following a path [Re: Staakman] #236243
11/13/08 00:16
11/13/08 00:16
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
#define skill22 _TARGET_X

vec_to_angle(ang,vec_diff(temp,my._TARGET_X,my.x));


3333333333
Re: Lite-C: Object following a path [Re: Quad] #236251
11/13/08 01:36
11/13/08 01:36
Joined: Oct 2008
Posts: 67
pewpew Offline
Junior Member
pewpew  Offline
Junior Member

Joined: Oct 2008
Posts: 67
i don't understand.
why do you need to #define the skill20-22 things?


HURRR DERP DERP DEERRPP HURR
Re: Lite-C: Object following a path [Re: pewpew] #236252
11/13/08 02:36
11/13/08 02:36
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
it's just for giving names to skills, makes the code easire to read/write.

and
comments like
//uses:

makes skills show up in the behaviour panel of wed.


3333333333
Re: Lite-C: Object following a path [Re: Quad] #237131
11/18/08 14:33
11/18/08 14:33
Joined: Sep 2008
Posts: 9
S
Staakman Offline OP
Newbie
Staakman  Offline OP
Newbie
S

Joined: Sep 2008
Posts: 9
////////////////////////////////////////// Current Code:
#define _FORCE skill18 // value = 1
#define _MOVEMODE skill19 // value = 1
#define _TARGET_X skill20 // value = 1

action patrol_path()
{
// attach entity to nearest path
result = path_scan(me,me.x,me.pan,vector(360,180,1000));
if (result == 0) { return; } // no path found

// find first waypoint
var node = 1; // start at first node
//path_nodepos(my,node,my._TARGET_X);
path_scannode(my, node);


while (my._MOVEMODE)
{
// find direction
//result = vec_to_angle(ANGLE * ang,vec_diff(temp,my._TARGET_X,my.x));
result = vec_to_angle(ang,vec_diff(vector,my._TARGET_X,my.x));
// near target? Find next waypoint of the path

if (result < 25)
{
node = path_nextnode(my,node,1);
//path_nodepos(my,node,my._TARGET_X);
path_scannode(my, node);
}

// turn and walk towards target
//actor_turnto(angle.PAN);
//actor_moveahead(MY._FORCE);
wait(1);
}
}
////////////////////////////////////////// End of Code

The code does run but as soon as the game starts he says: Error (E1513) crash in patrol_path().

The code is pretty basic and I can't find anything wrong with.
Anyone able to help me?
Thanks in advance!



Last edited by Staakman; 11/18/08 14:36.

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