Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (EternallyCurious, Quad, vicknick), 700 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Check my code please? #288823
09/08/09 21:44
09/08/09 21:44
Joined: Jul 2009
Posts: 39
Chile!
Renard Offline OP
Newbie
Renard  Offline OP
Newbie

Joined: Jul 2009
Posts: 39
Chile!
I`m having some issues with this, it is supposed to attach a gun to my model, it works fine but the model doesn`t move anymore, i mean, the anims are running but the character doesn`t.

The gun model is already set to PASSABLE, (and if i set the same flag on the player model it runs smoothly) i think it has something to do with the bounding box of the model, when using fat hull (the default one) it kinda moves but it get stuck after some frames. here`s the attaching code:

STRING Gatlin_mdl = "Gatlin.mdl";
function Gatlin()

{
proc_mode = PROC_LATE;
set(my,PASSABLE); // the Gatlin shouldn't slow down the player
while (player == NULL){wait (1);}//wait ītill the player is created.
while(1)
{
vec_for_vertex (my.skill1, you, 1446);
vec_for_vertex (my.skill4, you, 1447); //special vertex made for this


vec_diff (my.skill7, my.skill4, my.skill1);// compute the vector that will be used by the Gatlin
vec_to_angle (my.pan, my.skill7); // rotate the Gatlin accordingly

// put the origin of the Gatlin in the vertex that is placed at the bottom of the arm
vec_set (my.x, my.skill1);
wait (1);
}
}


and just in case, this is the whole thing:


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

///////////////////////////////
var run_speed; //
var stand_speed;
var shoot_speed;
var run_mov = 50;
var strife_mov= 50;
var brun_mov = 50;
var fps_max = 125;
ANGLE bone_angle; // a vector that holds the pan, tilt and roll angles
ANGLE bone_ang2;
BMAP* crosshair_pcx = "crosshair.pcx"; // the bitmap used for our crosshair



var jump_percentage; // animation percentage for jumping
var distance_to_ground; // the distance between player's origin and the ground
var jump_height;
var reached_height;
////////////////////////////////////////////////////////////////////////////////////

function grav()
{
vec_set(target,my.x);
target.z -= 1000;
result = c_trace(my.x,target,IGNORE_PASSABLE | IGNORE_ME | USE_BOX);
if(result + my.min_z > 0)
{
if(result + my.min_z > 10) // play with this value
{
my.z -= 15 * time_step; // play with this value
}
else
{
my.z -= result + my.min_z;
}
}
}



function CAM()
{
camera.arc = 60;
camera.x = player.x - 400 * cos(player.pan); // 200 = distance
camera.y = player.y - 400 * sin(player.pan); // same value here
camera.z = player.z + 250; // above the player
camera.pan = player.pan;
camera.tilt = -10; // look down at the player
camera.roll = 0;
}


function aim()//called when need to shoot standing
{
bone_angle.pan = (screen_size.x /2 - mouse_pos.x) / 10; // changes pan from -40 to +40 degrees
bone_angle.tilt = (screen_size.y / 2 - mouse_pos.y) / 10; // changes tilt from -30 to +30 degrees
bone_angle.roll = 0; // no need to change the roll angle for this bone
//ent_bonereset(my,"bone4"); //no need to reset the bones position here!
ent_bonerotate(my,"bone4", bone_angle); // rotate the bone ARM
}

function aim_moving()//called when need to shoot moving
{
bone_angle.pan = (screen_size.x /2 - mouse_pos.x) / 10 + 40; // changes pan from -40 to +40 degrees, and add 40° to shoulder
bone_angle.tilt = (screen_size.y / 2 - mouse_pos.y) / 10; // changes tilt from -30 to +30 degrees
bone_angle.roll = 0; // no need to change the roll angle for this bone
ent_bonereset(my,"bone4");
ent_bonerotate(my,"bone4", bone_angle); // rotate the bone SHOULDER
}

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

STRING Gatlin_mdl = "Gatlin.mdl";
function Gatlin()

{
proc_mode = PROC_LATE;
set(my,PASSABLE); // the Gatlin shouldn't slow down the player
while (player == NULL){wait (1);}//wait ītill the player is created.
while(1)
{
vec_for_vertex (my.skill1, you, 1446);
vec_for_vertex (my.skill4, you, 1447); //special vertex made for this


vec_diff (my.skill7, my.skill4, my.skill1);// compute the vector that will be used by the Gatlin
vec_to_angle (my.pan, my.skill7); // rotate the Gatlin accordingly

// put the origin of the Gatlin in the vertex that is placed at the bottom of the arm
vec_set (my.x, my.skill1);
wait (1);
}
}

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


action kuro()

{
wait(1); // wait 1 frame after creation
player = me; // I'm the player
c_setminmax(me);
ent_create ("Gatlin.mdl", my.x,Gatlin); // creates and attach the Gatlin.

while(1)// main loop
{
CAM(); //calls the camera
run_speed += 10 * time_step; // increase walk_speed, sets the ANIMATION speed
stand_speed +=3 * time_step;
shoot_speed +=9 * time_step;
grav();
///////////////////////////////////////////////////MOVEMENT CODE/////////////////////////////////////////////////////

my.pan -= 15 * mouse_force.x * time_step; //to rotate the player with the mouse


if (key_w)//run forward
{
ent_animate(my, "run", run_speed, ANM_CYCLE);
c_move (my, vector(run_mov * time_step, 0, 0), nullvector, GLIDE); //Move on the facing direction.
}
else {ent_animate(my, "stand", stand_speed, ANM_CYCLE);} // not key pressed? stand!



if (key_s)//run backward
{
ent_animate(my,"brun", run_speed, ANM_CYCLE);
c_move (my, vector(- brun_mov * time_step, 0, 0), nullvector, GLIDE); //move on negative facing direction.
aim();
}
else {}



if (mouse_left)//attack presed standing?
{
ent_animate(my, "shot", shoot_speed, ANM_CYCLE);
aim();
}
else{}



if (mouse_left && key_w)//attack pressed running?
{
ent_animate(my,"run", run_speed, ANM_CYCLE);
c_move (my, vector(0 * time_step, 0, 0), nullvector, GLIDE); //move the same as if (W)
aim_moving();
}
else{}



if (mouse_left && key_s)//run backwards and attack pressed?
{ent_animate(my,"brun", run_speed, ANM_CYCLE);
c_move (my, vector(0 * time_step, 0, 0), nullvector, GLIDE); //move the same as if (S)
aim_moving();
}
else{}

//////////////////////////////////////////avanze diagonal
if (key_q) //diagonal IZQ
{ent_animate(my,"daw", run_speed, ANM_CYCLE);
}
else{}

if (key_w && key_d) //diagonal DER
{
}

if (key_w && key_a && mouse_left) //diagonal IZQ + Shooting
{
}

if (key_w && key_d && mouse_left) //diagonal DER + Shooting
{
}



////////////////////////////////////////retroceso diagonal
if (key_s && key_d)
{
}

if (key_s && key_a)
{
}

if (key_s && key_a && mouse_left)
{
}

if (key_s && key_d && mouse_left)
{
}

///////////////////////////////////////strife

if (key_d) // strife d
{
ent_animate (my, "astrife", run_speed, ANM_CYCLE);
c_move (my, vector(0, -run_mov * time_step, 0), nullvector, GLIDE); //Move on the facing direction.
}
else{}



if (key_a) // strife a
{
ent_animate (my, "dstrife", run_speed, ANM_CYCLE);
c_move (my, vector(0 ,run_mov * time_step, 0), nullvector, GLIDE); //Move on the facing direction.
}
else{}


if (key_d && mouse_left) // strife d + shot
{
ent_animate (my, "astrife", run_speed, ANM_CYCLE);
aim_moving();
c_move (my, vector(0, 0 * time_step, 0), nullvector, GLIDE); //Move on the facing direction.
}
else{}


if (key_a && mouse_left) // strife a + shot
{
ent_animate (my, "dstrife", run_speed, ANM_CYCLE);
aim_moving();
c_move (my, vector(0 ,0 * time_step, 0), nullvector, GLIDE); //Move on the facing direction.
}
else{}

////////////////////////////////////////SALTOS


if (key_space)// jump
{ent_animate(my, "jump", run_speed, ANM_CYCLE);
}
else{}



if (key_space && mouse_left)//jump in place + attack
{ent_animate(my, "jump", stand_speed, ANM_CYCLE);
aim_moving();
}
else{}


if (key_space && key_w) //jump forward
{ent_animate(my, "wjump", run_speed, ANM_CYCLE);
}
else{}


if (key_space && key_s) //jump backwards
{}
else{}



if (key_space && key_a) //jump side left
{}
else{}


if (key_space && key_d) //jump side right
{}
else{}


//////////////////////////////Moves the head to follow the cursor, always needed so itīs "free" in the playerīs action.
bone_angle.pan = (screen_size.x /2 - mouse_pos.x) / 10; // changes pan from -40 to +40 degrees
bone_angle.tilt = (screen_size.y / 2 - mouse_pos.y) / 10; // changes tilt from -30 to +30 degrees
bone_angle.roll = 0; // no need to change the roll angle for this bone
ent_bonereset(my,"bone33");
ent_bonerotate(my,"bone33", bone_angle); // rotate the bone HEAD
/////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////END MOVEMENT CODE///////////////////////////////////////////////////////
wait(1);//for main loop
}

}

function main()
{
video_mode = 6; // set the screen resolution to 800 x 600 pixels
level_load ("test.wmb"); // load a level
wait(2); // wait until the level is loaded
//ent_create("kuro_missile.mdl", vector(400, 0, -50), kuro); // and then create the model
mouse_map = crosshair_pcx; // set the bitmap that is going to be used by the mouse pointer
mouse_mode = 1; // now show the pointer
while (1)
{ vec_set(mouse_pos, mouse_cursor); // update the mouse pointer position at all times
wait (1);
}

}


AND if you can tellme a thing or two about the code, would be nice. (i think the movment part is odd.)


WRYYYYYYYYYYYYYYYYYY!!!1!!ONE!!11
Re: Check my code please? [Re: Renard] #288831
09/09/09 00:07
09/09/09 00:07
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
try to activate fat hund AND narrow hull at the same time.
This might help with the collision.

p.s.; try to use different values for camera.arc,
60 is too low for an FPS.

Re: Check my code please? [Re: Damocles_] #288958
09/09/09 14:55
09/09/09 14:55
Joined: Jul 2009
Posts: 39
Chile!
Renard Offline OP
Newbie
Renard  Offline OP
Newbie

Joined: Jul 2009
Posts: 39
Chile!
I`ll give it a try!

the arc was low `cause i wanted to see the whole bounding box, 90 is the "normal" value, (it`s a 3th person shooter).

nothing to say about the movement code?
is it effective setting it as a lot of "IF" clauses?
is there another method, faster or something?

Thanxs very much!

Last edited by Renard; 09/09/09 14:56.

WRYYYYYYYYYYYYYYYYYY!!!1!!ONE!!11
Re: Check my code please? [Re: Renard] #288961
09/09/09 14:58
09/09/09 14:58
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
You have to set the IGNORE_PASSABLE flag as a parameter in the c_move function.

Re: Check my code please? [Re: Renard] #288962
09/09/09 14:59
09/09/09 14:59
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
Your jump donīt work, right? You need to hold space to play the animation, right?

Re: Check my code please? [Re: Rasch] #288967
09/09/09 15:22
09/09/09 15:22
Joined: Jul 2009
Posts: 39
Chile!
Renard Offline OP
Newbie
Renard  Offline OP
Newbie

Joined: Jul 2009
Posts: 39
Chile!
IGNORE_PASSABLE, WOW, so THAT`S what happened!! i didn`t realize!

and yup, my jump code is not working, i`m alone on this project, and being a complete noob I`m trying to solve one problem at a time.

Sooo... do you have any idea on jumping code? I took this one from a very old AUM, but you see, it isn`t working.


And again, THAAANKS


WRYYYYYYYYYYYYYYYYYY!!!1!!ONE!!11
Re: Check my code please? [Re: Renard] #288968
09/09/09 15:25
09/09/09 15:25
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
There are several ways of jumping. itīs a typical problem grin

Just use the search. Type in "jump" with the "" signs

I would maybe do something like:

on_space = jump;

and call the jump function extern. not in the players action.


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