Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
0 registered members (), 631 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Motion problems #144133
07/28/07 20:04
07/28/07 20:04
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
SO I finally got a bit of code working smoothly with Lite-C, but now I'm kinda stuck. I can't seem to get the balllight_mdl to move. When I press LMB it creates it at the player.x position, but doesnt move. Any suggestions?

It seems that everything is fine, until shoot_balllight and fire_balllight

Code:
#include <acknex.h>
#include <default.c>
#include "ingame_ui.c"
BMAP* ptrail_map = "plasmaglow_blue.tga";
STRING* balllight_mdl = "gem.MDL";
BMAP* sun_farbe3 = "sun_blue.tga";
var balllightparts = 30; //number of particles used for this effect
var player_speed;
function fire_balllight();
function shoot_balllight();
function remove_balllight();
function enemy_event();
function particle_trail();
function fade_trail();
function balllightcool();


//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////


function main()

{
video_set (1360,768,32,1);
freeze_mode = 0;
warn_level = 2; // announce bad texture sizes and bad wdl code
mouse_mode = 0;
wait(3);
// now load the level
level_load("spelltesting.wmb");
/////////////////////////////////////////////////////////////////////////////////////////
wait(5);
}

action player_moves ()
{
player = my;
set(my,INVISIBLE | IGNORE_MODELS); // no need to see the player because we are in 1st person mode
while (1)
{
c_move (my, vector(20 * (key_cuu - key_cud) * time_step, 10 * (key_cul - key_cur) * time_step, 0), nullvector, IGNORE_PASSABLE | GLIDE);
vec_set (camera.x, player.x); // use player's x and y for the camera as well
camera.z += 30; // place the camera 30 quants above the player on the z axis (approximate eye level)
camera.pan -= 10 * mouse_force.x * time_step; // rotate the camera around by moving the mouse
camera.tilt += 10 * mouse_force.y * time_step; // on its x and y axis
player.pan = camera.pan; // the camera and the player have the same pan angle
if (mouse_left == 1)
{
fire_balllight();
}
wait (1);
}
}


function fire_balllight()
{
proc_kill(4); // only one instance of this function is running
while (mouse_left == 1) {wait (1);}
ent_create (balllight_mdl, player.x, shoot_balllight);

}

function shoot_balllight()
{
wait(1);
set (my, ENABLE_BLOCK | ENABLE_ENTITY);
my.event = remove_balllight;
my.pan = camera.pan;
my.tilt = camera.tilt;
while (1)
{
c_move(me, nullvector, vector(15 * time_step, 0, 4 * time_step), GLIDE);
wait (1);
}
remove_balllight();
}

function remove_balllight()
{
wait (1);
ent_remove(me); // now remove it
}

action enemy()
{
my.emask |= ENABLE_SCAN; // sensible for scans
}




you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe. __________________________________ yours truly
Re: Motion problems [Re: oldschoolj] #144134
07/29/07 00:50
07/29/07 00:50
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Code:

set(my,INVISIBLE | IGNORE_MODELS); // no need to see the player because we are in 1st person mode


the IGNORE_MODELS bit isn't doing anything because it's a collision flag, and (if you have a look at atypes.h in the include file) you'll see that it corresponds with the entity flag "FLAG4", which doesn't do anything and is there for whatever purposes the programmer chooses.

this may also be an issue with "set(my, ENABLE_BLOCK | ENABLE_ENTITY);", because you need to set emask flags (my.emask |= ENABLE_BLOCK | ENABLE_ENTITY;).

this also means that the balllight is not reacting to collisions, so when it hits the player and can't move (because it's inside another entity) its event isn't making it remove itself so it appears that c_move isn't working, when it probably is.

usually intersecting entities can still move a bit so this might not be your problem.

i would personally make shoot_balllight an action, just because it is only ever assigned to entities, but i don't think that makes a difference. i don't know if the difference between a function and an action affects an entity's ability to perform certain functions correctly.

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: Motion problems [Re: JibbSmart] #144135
07/29/07 01:01
07/29/07 01:01
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
when I look closely, and try setting the mdl creat to the camera, instead player i do notice that the ball is movingvery fast, but in one place, jiggling like its stuck, maybe there is a work around for my code that makes the ball move. Such as making it not be effected by the player? or creating it at a different spot. Eventually I want to make this ball able to be luanched directly from a player model in 3rd person, so i will definately need to figure out this problem. I know it's a problem with the cmove (...) because if I change ot to my.x and my.y with += .... time_step, it works perfectly.

Thanks for the help


you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe. __________________________________ yours truly
Re: Motion problems [Re: oldschoolj] #144136
07/29/07 01:09
07/29/07 01:09
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
it works then because it stops it from performing collision detection. it cannot c_move and actually get somewhere whilst inside another solid entity. put IGNORE_YOU in its c_move so that it ignores collisions with the entity that created it. when it does eventually hit something, the "you" pointer will point to that entity but that's not a problem because it will be immediately removed anyway.

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: Motion problems [Re: oldschoolj] #144137
07/29/07 03:19
07/29/07 03:19
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
well, I seem to have it pretty much smoothed out, but I'm constanly getting crashes in the action player_moves, and I know it has to do with the vec_set line, the original code had camera.pos, my,pos. But that Lite-C isnt liking that? not sure if I can even use pos. I though maybe I should set up a VECTOR*, but I'm not sure how. When I try to say camera.x, my.x it just says "crash in player_moves" then loads the level, and I bounce around lol.

Here's the new code:

Code:
#include <acknex.h>
#include <default.c>
#include "ingame_ui.c"
BMAP* ptrail_map = "plasmaglow_blue.tga";
BMAP* mousepnt01_pcx = "mousepnt01.pcx";
BMAP* sun_farbe3 = "sun_blue.tga";
STRING* balllight_mdl = "gem.mdl";
var balllightparts = 30; //number of particles used for this effect
var player_speed;
function shoot_balllight();
function remove_balllight();
function enemy_event();
function particle_trail();
function fire_balllight();
function fade_trail();
var mouse_wheel = 0;
VECTOR* player_speed;
VECTOR* temp;
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////


function check_mouse()
{
mouse_wheel = sys_metrics(75); // see if the mouse has a scrolling wheel or not
while (1)
{
if (mouse_wheel != 0) // wheel present?
{
// then use the wheel to zoom in and out
camera.arc -= 0.1 * mickey.z * time_step;
}
else // wheel not detected
{
// use the "Y" and "H" keys to zoom in and out
camera.arc -= (key_y - key_h) * time_step;
}
wait (1);
}
}





function main()
{
video_set (1360,768,32,1);
freeze_mode = 0;
warn_level = 2; // announce bad texture sizes and bad wdl code
mouse_mode = 2;
wait(3);
// now load the level
var MAX_PARTICLES = 10000;
level_load("spelltesting.wmb");
mouse_map = mousepnt01_pcx; //The image we use for our pointer
while (1)
{
mouse_mode = 1;
vec_set(mouse_pos,mouse_cursor);

wait (1);
}
/////////////////////////////////////////////////////////////////////////////////////////
wait(5);
}


action player_moves ()
{
player = me;
camera.pan = player.pan;
set (my, INVISIBLE);
while (1)
{
vec_set (camera.pos, my.pos);
camera.tilt += 20 * mouse_force.y * time_step;
camera.pan -= 20 * mouse_force.x * time_step;
my.pan = camera.pan;
my.tilt = camera.tilt;
player_speed.x = 15 * (key_w - key_s) * time_step;
player_speed.y = 10 * (key_a - key_d) * time_step;
vec_set (temp, my.x);
temp.z -= 1000;
trace_mode = IGNORE_ME + USE_AABB;
player_speed.z = -trace (my.x, temp);
move_mode = IGNORE_YOU + IGNORE_PASSABLE;
ent_move(player_speed, nullvector);
if (mouse_left == 1)
{
fire_balllight();
}
wait (1);
}
}




var balllightparts = 30; //number of particles used for this effect


function balllight_spec_fun(PARTICLE *p)
{
my.alpha -= 30 *time_step;
if(p.alpha < 0) { p.alpha = 0; p.lifespan = 0 ;}
}

function balllightcool(PARTICLE *p)
{
p.blue = 232.805 ;
p.green = 77.602 ;
p.red = 181.070 ;
p.bmap = sun_farbe3; //the effect bitmap
p.vel_x = random( 0.3 ) - 0.100 ;
p.vel_y = random( 0.3 ) - 0.100 ;
p.vel_z = random( 0.3 ) - 0.100 ;
p.size = 20 ;
p.alpha = 30 ;
p.gravity = 0 ;
set(p, BRIGHT);
set(p, MOVE);
set(p, TRANSLUCENT);
p.lifespan = 1;
p.event = balllight_spec_fun;
}


function balllight()
{
while(1)
{
balllightparts = 30;
effect(balllightcool,maxv(1,balllightparts*time_step),my.x,nullvector);
wait(1);
}
}

function fire_balllight()
{
proc_kill(4); // only one instance of this function is running
while (mouse_left == 1) {wait (1);}
ent_create (balllight_mdl, player.x, shoot_balllight);
}

function shoot_balllight()
{
set (my, INVISIBLE | PASSABLE | ENABLE_ENTITY | ENABLE_BLOCK);

wait (1);

my.event = remove_balllight;
my.pan = camera.pan;
my.tilt = camera.tilt;
my.skill20 = 0;
my.skill1 = 25;
my.skill2 = 0;
my.skill3 = 0;
my.skill1 *= time_step;
my.skill10 = 0;
while (my.skill20 < 500)
{
balllightparts = 30;
effect(balllightcool,maxv(1,balllightparts*time_step),my.x,nullvector);
if (my == NULL) {return;}
temp.x = 40; // horizontal scanning angle
temp.y = 60; // vertical scanning angle
temp.z = 500; // scanning range
if ((my.skill10 == 0) && (vec_dist (my.x, player.x) > 100))
{
c_scan (my.x, my.pan, nullvector, temp);
}
my.skill20 += 1 * time_step;
ent_move (my.skill1, nullvector);
temp.x = my.x - 3 * cos(my.pan);
temp.y = my.y - 3 * sin(my.pan);
temp.z = my.z;
effect (particle_trail, 10, temp, normal);
wait (1);
}
remove_balllight();
}

function remove_balllight()
{
wait (1);
ent_remove(me); // now remove it
}


action enemy ()
{
my.emask |= ENABLE_SCAN;
my.event = enemy_event;
}

function enemy_event()
{
if (event_type == EVENT_SCAN)
{
you.skill10 = 1; // stop scanning
while (you != NULL) // as long as the rocket exists
{
vec_set (temp.x, my.x);
vec_sub (temp.x, you.x);
vec_to_angle (you.pan, temp.x); // rotate it towards the target
wait (1);
}
}
}

function particle_trail(PARTICLE *p)
{
p.blue = 38 ;
p.green = 27 ;
p.red = 122 ;
p.vel_x = random( 0.199 ) - 0.100 ;
p.vel_y = random( 0.199 ) - 0.100 ;
p.vel_z = random( 0.199 ) - 0.100 ;
temp.x = random(.2) - .1;
temp.y = random(.2) - .1;
temp.z = random(.2) - .1;
vec_rotate (temp, my.pan);
vec_normalize (temp, .2);
vec_add (p.vel_x, temp);
p.alpha = 36.230;
p.bmap = ptrail_map;
p.size = 5 ;
p.gravity = 0 ;
set(p, BRIGHT);
set(p, MOVE);
set(p, TRANSLUCENT);
p.event = fade_trail;
}


function fade_trail(PARTICLE *p)
{
p.alpha -= 18 *time_step;
if(p.alpha < 0) { p.alpha = 0; p.lifespan = 0; }
}




Last edited by oldschoolj; 07/29/07 05:13.
Re: Motion problems [Re: oldschoolj] #144138
07/29/07 19:26
07/29/07 19:26
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
Well I figured out how to solve my vector problems, and since then I've been converting old code like mad!, lol

Apparently, this works:

VECTOR blahblah;

vec_zero (blahblah);

and now setting blahblah.x ... y... z... doesnt make things crash anymore!

im still not sure why VECTOR* blahblah doesnt work, but for now I'm just happy that the other solution does the job


you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe. __________________________________ yours truly
Re: Motion problems [Re: oldschoolj] #144139
07/30/07 07:01
07/30/07 07:01
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
VECTOR* blahblah is a pointer, so it can only be used if it points to something. if you set its components (x...y...z) directly, it affects the VECTOR that blahblah is pointing to. if blahblah doesn't point to anything when you change its components, then there's trouble.

good to see you solved it mate

julz


Formerly known as JulzMighty.
I made KarBOOM!
Re: Motion problems [Re: JibbSmart] #144140
07/30/07 17:37
07/30/07 17:37
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
thanks julz, you know it's all starting to make sense now. Neat feeling


you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe. __________________________________ yours truly

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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