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
2 registered members (TipmyPip, 1 invisible), 18,731 guests, and 7 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
Page 1 of 2 1 2
Pls help! My scripts crash for no reason! #254498
03/03/09 19:05
03/03/09 19:05
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
Hey ppl! sometimes, (which is very often), when I Test Run my script, it crash with an error : "Crash in [..]" , where [..] is either the main function or some other function or action (error code E1513).

When I tried tracing the line that causes this, it is usually something stupid like "camera.x = my.x" or "c_move(...)".

I can't find out what is causing this. It had never done this before. I am afraid I may have touched the settings ... crazy

Re: Pls help! My scripts crash for no reason! [Re: Rohiaw] #254502
03/03/09 19:10
03/03/09 19:10
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Sounds like your actions arent closing off once MY no longer exists.
Make sure the main loop in your actions is
while(me!=NULL) and that any waits are at the very end of the loop if you can.

Without seeing your code, thats the best I can manage...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Pls help! My scripts crash for no reason! [Re: EvilSOB] #254503
03/03/09 19:13
03/03/09 19:13
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
Thanks I've never tried that one before.
But still. It is crashing whenever i try to move an entity, which I have set as a dummy (no graphic).

Re: Pls help! My scripts crash for no reason! [Re: Rohiaw] #254509
03/03/09 19:28
03/03/09 19:28
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Can you post up the c_move line please?

Or post the whole action if its not too big...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Pls help! My scripts crash for no reason! [Re: EvilSOB] #254513
03/03/09 19:44
03/03/09 19:44
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
How 'bout the entire code + explanation?

The complicated part is the turn to left and right + the camera as turning the camera left and right in an arc with an entity is pretty complicated.

What I do is use a "tcam" Entity without a model graphic that is always equal to the player co-ordinates. When ever this turns, the tcam entity moves back and i store its x,y,z co-ords and move the entity cam (which holds the camera) onto those co-ords. The diagrams below explain it:



the code is this:
______________________________________________________________

Quote:


///////////////////////////////////////////////////////
// INCLUDES
///////////////////////////////////////////////////////

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

///////////////////////////////////////////////////////
// VARIABLES
///////////////////////////////////////////////////////

VECTOR offset;

ENTITY* cam;
ENTITY* actor;
ENTITY* tcam;

var attach;

//////////////////////////////////////////////////////
// ACTIONS
//////////////////////////////////////////////////////

action camera_action(){
cam = me;
while (me!=NULL){
wait(5);
camera.x = cam.x;
camera.y = cam.y;
camera.z = cam.z;
camera.pan = cam.pan;
wait(1);
}
}

action actor_action(){
actor = me;
}


action tcam_action(){
tcam = me;
while (me!=NULL){
wait(5);
my.x = actor.x;
my.y = actor.y;
my.z = actor.z;
my.pan = actor.pan;
wait(1);
}
}


/////////////////////////////////////////////////////
// FUNCTIONS
/////////////////////////////////////////////////////


function initCamOffset(ox,oy,oz){
offset.x = ox;
offset.y = oy;
offset.z = oz;
cam.x += offset.x;
cam.y += offset.y;
cam.z += offset.z;
return vector(cam.x,cam.y,cam.z);
}


function attachCam(){
attach = true;
}

function removeCam(){
attach = false;
}


function actorForward(){
c_move(actor,vector(4 * time_step,0,0),nullvector,GLIDE);
c_move(cam,vector(4 * time_step,0,0),nullvector,GLIDE);
}

function actorBackwards(){
c_move(actor,vector(-4 * time_step,0,0),nullvector,GLIDE);
c_move(cam,vector(-4 * time_step,0,0),nullvector,GLIDE);
}


////////////////////////////////////////////////////
// MAIN
////////////////////////////////////////////////////

function main(){

// load level
level_load("game.wmb");
wait(5);

// initialise the offset
initCamOffset(30,0,15);

// tcam set up
attachCam();
ent_create(NULL,nullvector,tcam_action);

while (1){

while (key_cuu){
actorForward();
wait(1);
}

while (key_cud){
actorBackwards();
wait(1);
}

if (key_cur){
attachCam();
while (key_cur){
actor.pan -= 6 * time_step;
c_move(tcam,vector(offset.x,0,0),nullvector,IGNORE_MODELS);
cam.x = tcam.x;
cam.y = tcam.y;
cam.z = tcam.z;
wait(2);
}
removeCam();
}

wait(1);
}

}



the actor and cam entity are placed in WED.

that just about all of it.

Re: Pls help! My scripts crash for no reason! [Re: Rohiaw] #254516
03/03/09 19:55
03/03/09 19:55
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
and these are my SED settings:



the rest of the settings are irrelevant, right?
thanks again for any help posted!!

Re: Pls help! My scripts crash for no reason! [Re: Rohiaw] #254518
03/03/09 20:23
03/03/09 20:23
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Firstly, your offset vector is badly assigned. It should be
VECTOR offset = { x=0; y=0; z=0; }

Secondly, like I said, move all waits to the end of a function where possible.
Two actions need fixing, here they are fixed (with an extra safety check thrown in)...
Code:
action camera_action()
{
   cam = me;
   while (me!=NULL)
   {
      camera.x = cam.x;
      camera.y = cam.y;
      camera.z = cam.z;
      camera.pan = cam.pan;
      wait(5);
   }
}

action tcam_action()
{
   tcam = me;
   while(me!=NULL)   
   {
      if(actor!=NULL)
      {
         my.x = actor.x;
         my.y = actor.y;
         my.z = actor.z;
         my.pan = actor.pan;
      }
      wait(5);
   }
}

And finally, and possibly un-necessary (but it makes things more stable),
change your c_move line to be this...
[b]if(tcam!=NULL) c_move(tcam,vector(offset.x,0,0),nullvector,IGNORE_MODELS);/b]

Anyway, time for bed. Night shift is over and Im going home.
If youve still got problems I'll be back on-line in about 12 hours.

PS. All SED setting look fine. Almost all are pretty irrelevent anyway.
And when you are posting lots of code, try to encase it between these UBB codes.
[code ]Your stuff[/code ]


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Pls help! My scripts crash for no reason! [Re: EvilSOB] #254579
03/04/09 08:32
03/04/09 08:32
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
Thanks EvilSOB. I'm kinda new on script optimisting. I guess it makes it better. But still, I am getting the same crashes.
But this time, I tried to track it down wisely;
I started commenting the lines which I think are causing this and I found it.

When I commented the line
Code:
if (tcam!=NULL)
c_move(tcam,vector(offset.x,0,0),nullvector,IGNORE_MODELS);


All worked fine without crashing. And when I uncomment it, I ge t the crash again - but only when I press the '->' button on my keyboard.

my current code is this:

Code:

///////////////////////////////////////////////////////
// 			INCLUDES
///////////////////////////////////////////////////////

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

///////////////////////////////////////////////////////
// 			VARIABLES
///////////////////////////////////////////////////////

VECTOR offset;

ENTITY* cam;
ENTITY* actor;
ENTITY* tcam;

var attach;

//////////////////////////////////////////////////////
// 			   ACTIONS
//////////////////////////////////////////////////////

action camera_action(){
	cam = me;
	while (me!=NULL){
		wait(5);
		camera.x = cam.x;
		camera.y = cam.y;
		camera.z = cam.z;
		camera.pan = cam.pan;
		wait(5);
	}
}

action actor_action(){
	actor = me;
}


action tcam_action(){
	tcam = me;
	while (me!=NULL)	
	{	   
		if (actor!=NULL)
		{
		   my.x = actor.x;
		   my.y = actor.y;
		   my.z = actor.z;
		   my.pan = actor.pan;
		}
		
		wait(5);
   }
}


/////////////////////////////////////////////////////
// 			   FUNCTIONS
/////////////////////////////////////////////////////


function initCamOffset(ox,oy,oz){
	offset.x = ox;
	offset.y = oy;
	offset.z = oz;
	cam.x += offset.x;
	cam.y += offset.y;
	cam.z += offset.z;
	return vector(cam.x,cam.y,cam.z);
	wait(5);
}


function attachCam(){
	attach = true;
	wait(5);
}

function removeCam(){
	attach = false;
	wait(5);
}


function actorForward(){
	c_move(actor,vector(4 * time_step,0,0),nullvector,GLIDE);
	c_move(cam,vector(4 * time_step,0,0),nullvector,GLIDE);
	wait(5);
}

function actorBackwards(){
	c_move(actor,vector(-4 * time_step,0,0),nullvector,GLIDE);
	c_move(cam,vector(-4 * time_step,0,0),nullvector,GLIDE);
	wait(5);
}


////////////////////////////////////////////////////
// 			MAIN
////////////////////////////////////////////////////

function main(){
	
	// load level
	level_load("game.wmb");
	wait(5);
	
	// initialise the offset
	initCamOffset(30,0,15);
	
	// tcam set up
	attachCam();
	ent_create(NULL,nullvector,tcam_action);
	
	while (1){
		
		while (key_cuu){
			actorForward();			
			wait(1);
		}
		
		while (key_cud){
			actorBackwards();
			wait(1);
		}
		
		if (key_cur){
			attachCam();
			while (key_cur){
				actor.pan -= 8 * time_step;				
				//  trouble-maker line - the cause of the crash
				if (tcam!=NULL)
				   c_move(tcam,vector(offset.x,0,0),nullvector,IGNORE_MODELS);				
				cam.x = tcam.x;
				cam.y = tcam.y;
				cam.z = tcam.z;
				cam.pan = tcam.pan;				
				wait(5);
			}
			removeCam();
		}
		
		wait(1);
	}
	
}



I just can't see what is causing the crash.
Any help much appreciated ppl.

Re: Pls help! My scripts crash for no reason! [Re: Rohiaw] #254580
03/04/09 08:33
03/04/09 08:33
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
The only thing I forgot in my previous post, was to change my Vector declaration. oops! whistle

Re: Pls help! My scripts crash for no reason! [Re: Rohiaw] #254585
03/04/09 08:52
03/04/09 08:52
Joined: Feb 2009
Posts: 52
Rohiaw Offline OP
Junior Member
Rohiaw  Offline OP
Junior Member

Joined: Feb 2009
Posts: 52
Hey Guys I changed my code, well, A LOT, and i'm not getting crashes anymore.

I've changed the way the camera turns with the player.
I was searching on some other post in other topics and I remove the tcam dummy entity and replace the while(key_cur) loop to this:

Code:
cam.x = actor.x - offset.x * cos(actor.pan);
cam.y = actor.y - offset.x * sin(actor.pan);
cam.pan = actor.pan;


Thanks for all the help anyway, especially EvilSOB! cool

Page 1 of 2 1 2

Moderated by  HeelX, rvL_eXile 

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