1 registered members (TipmyPip),
18,449
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
OP
Junior Member
|
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 ... 
|
|
|
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
Expert
|
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: Rohiaw]
#254509
03/03/09 19:28
03/03/09 19:28
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
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
OP
Junior Member
|
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: ______________________________________________________________
/////////////////////////////////////////////////////// // 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
OP
Junior Member
|
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
Expert
|
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)... 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
OP
Junior Member
|
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
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:
///////////////////////////////////////////////////////
// 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]
#254585
03/04/09 08:52
03/04/09 08:52
|
Joined: Feb 2009
Posts: 52
Rohiaw
OP
Junior Member
|
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:
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! 
|
|
|
|