Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (7th_zorro), 1,390 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Ladder climb 4r FPS [C-SCRIPT] #286372
08/25/09 00:56
08/25/09 00:56
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I need a ladder script (I hate one from Wiki) like in "Half Life", player can walk on the ladder to the sides (left & right with "a" & "d" keys) and he climb the way he look with camera (if we look up pressing "w" then we climb up, if we look down and we press "w" then climb down), player can jump off the ladder as well... Please help me! This is the only thing I have left in my player script what I need....


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Ladder climb 4r FPS [C-SCRIPT] [Re: 3run] #292277
10/01/09 16:58
10/01/09 16:58
Joined: Jul 2005
Posts: 15
Brazil, São Paulo
R
rogodoy Offline
Newbie
rogodoy  Offline
Newbie
R

Joined: Jul 2005
Posts: 15
Brazil, São Paulo
This has been brought up in similar posts, but I could not get it to work.

I feel like I am very close to getting this right after spending many hours trying to figure it out. My game is a 3rd person isometric. I want my player unable to climb very steep hills, as a way to keep the player inside a particular path or boundary. I have used many invisible blocks, but using the terrain as a restriction would save a HUGE amount of time through the rest of the game. And invisible blocks just aren't practical for some situations.My code is heavily modified from zeldacode.The 'standard player movement' code in the manual (which slows the player speed on slopes) would be awsome but I can't get it to work . Here is what I use to move the player and my Player_ACTION:


c_move(my,nullvector, player_diff.x, IGNORE_PASSENTS | GLIDE);



/////PLAYER_ACTION////////////////////////////
action player_action
{
player = me;
//c_setminmax(me);
player.healthpoints = 100; // and I have 100 health points
vec_set(temp,player.x);
my.fat = off;
my.narrow = on;
my.animdist = 0;


vec_set(temp,my.x);
temp.z -= 4000; // calculate a position 4000 quants below the player
trace_mode = ignore_me+ignore_sprites+ignore_passable+ignore_models+use_box;
result = trace(my.x,temp);// subtract vertical distance to ground
my.z -= result;

my.skill24 = 0;

while (player.healthpoints > 0) // Is player alive?

IF (movement_mode == 0) {


vec_set(temp,my.x); //scan in front of player to see if there is a climbable wall
temp.x += 30 * cos(my.pan);
temp.y += 30 * sin(my.pan);
temp.z = my.z;
trace_mode = ignore_me+ignore_sprites+ignore_models+scan_texture;
result = trace(my.x,temp); //changed from trace(my.x,temp);


vec_set(temp,my.x);
temp.z -= 4000; // calculate a position 4000 quants below the player

// set a trace mode for using the player's hull, and detecting map entities and level surfaces only
trace_mode = ignore_me+ignore_sprites+ignore_models+use_box;
result = trace(my.x,temp);// subtract vertical distance to ground
IF (key_space == 1) {
IF (jumping_mode == 0) { //if we are not already jumping
jumping_mode = 1;
z_force = jump_force;
my.animdist = 0;
IF (mouse_right == 1) || (key_x == 1) { store_strafe_mode = 1; } ELSE { store_strafe_mode = 0; }
}
}


IF (result <= 3) && (jumping_mode == 0) { // in the air? WADE CAHANGED - 3 originally
IF (result < 1.3) && (result > -1.3) && (result > 0.5) && (result < -0.5) { my.skill13 = 0;beep; beep; } //change the value 1.5 to change how high steps he can climb, make it no higher than 3
vec_set(temp,my.x);
temp.z -= 4000; // calculate a position 4000 quants below the player
trace_mode = ignore_me+ignore_sprites+ignore_passable+ignore_models+use_box;
result = trace(my.x,temp);// subtract vertical distance to ground
z_force = -1 * result;

IF (mouse_right == 1) || (key_x == 1) { store_strafe_mode = 1; } ELSE { store_strafe_mode = 0; }
} ELSE {
IF (result <= 3) && (my.animdist > 20) {
IF (jumping_mode == 2) {
player_diff.x = 0;
player_diff.y = 0;
IF (my.animdist <= 20) { jumping_mode = 0; } ////originally 20
IF (my.animdist < 100) {
// ent_frame("jump",my.animdist);
// my.animdist += 7 * time;
} ELSE {
jumping_mode = 0;
}
}
IF (jumping_mode == 1) { my.skill13 = 0; jumping_mode = 0; }
IF (result < 1.3) && (result > -1.3) && (result > 0.5) && (result < -0.5) { my.skill13 = 0; } //change the value 1.5 to change how high steps he can climb, make it no higher than 3
vec_set(temp,my.x);
temp.z -= 4000; // calculate a position 4000 quants below the player
trace_mode = ignore_me+ignore_sprites+ignore_passable+ignore_models+use_box;
result = trace(my.x,temp);// subtract vertical distance to ground
z_force = -1 * result;
IF (mouse_right == 1) || (key_x == 1) { store_strafe_mode = 1; } ELSE { store_strafe_mode = 0; }
}
IF (jumping_mode == 1) {
IF (result > 30) { jumping_mode = 2; }
IF (my.animdist < 40) {
ent_frame("jump",my.animdist);
my.animdist += 5 * time;
} ELSE {
my.animdist = 40;
ent_frame("jump",my.animdist);
jumping_mode = 2;
}
//IF (z_force > -20) { z_force -= 3 * time; } ELSE { z_force = -20; }
IF (jumping_mode == 0) {
IF (z_force > -20) { z_force -= 3 * time; } ELSE { z_force = -20; }
}
} ELSE {
IF (result < 30) {
IF (my.animdist < 80) {
ent_frame("jump",my.animdist);
my.animdist += 12 * time;
} ELSE {
ent_frame("jump",my.animdist);
my.animdist += 4 * time;
}
} ELSE {
IF (my.animdist < 300) { ///ORIGINALLY 40
ent_frame("jump",my.animdist);
my.animdist += 10 * time;
} ELSE {
my.animdist = 40;
ent_frame("jump",my.animdist);
jumping_mode = 2;
}
}
IF (z_force > -15) { z_force -= 8 * time; } ELSE { z_force = -50; } ///// CHANGED FROM 3 * time AND z_force =-20//////////////
}
}

IF (jumping_mode == 0) {
IF (key_x == 0) && (mouse_right == 0) {
rotate_player();
movement();
} ELSE {
strafe_movement();
}
move_mode = ignore_passable + glide;
player_diff.x /= 3;
player_diff.y /= 3;
IF (key_w == 1) && (key_d == 1) {
player_diff.x /= 1.5;
player_diff.y /= 1.5;
}
IF (key_w == 1) && (key_a == 1) {
player_diff.x /= 1.5;
player_diff.y /= 1.5;
}
IF (key_s == 1) && (key_d == 1) {
player_diff.x /= 1.5;
player_diff.y /= 1.5;
}
IF (key_s == 1) && (key_a == 1) {
player_diff.x /= 1.5;
player_diff.y /= 1.5;
}

IF (key_shift == 1) {
player_diff.x /= walk_speed;
player_diff.y /= walk_speed;
}

IF (key_w == 1) || (key_s == 1) || (key_d == 1) || (key_a == 1) {
IF (key_shift == 0) {
ent_cycle("walk",my.animdist);
my.animdist += 10 * time;
} ELSE {
ent_cycle("walk",my.animdist);
my.animdist += 9 * time;
}
} ELSE {
ent_cycle("stand",my.animdist);
my.animdist += 3 * time;
}
IF (my.animdist > 100) { my.animdist -= 100; }
} ELSE {
IF (locked_on != 1) && (locked_on != 1.5) {
rotate_player();
}
} //so player rotates towards moving direction in air, if they are not locked on

my.SKILL13 = 1.5*z_force + max(1-0.5*0.7,0)*my.SKILL13; // original code veritcal speed
jump_z = TIME * my.SKILL13; // distance down
player_diff.z = jump_z;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This is alot of code I've been experimenting, with no luck
//
//move_min_z *=.5;
//my.enable_block = on;
//move_friction = 0.5;
//disable_z_glide=1;
//
//
//player_distance.x = 5 *((key_w-key_s) || (key_a - key_d))*time_step;
//player_distance.x = sign(player_distance.x)*(abs(player_distance.x) + .1*player_feet_height); // adapt the speed on slopes
//
//
//vec_set(temp, player_moveto);//store my angle in temp
//vec_to_angle(temp, temp); //if (temp//transform it into a position/direction
//vec_scale(temp, 50);//scale it to get a position 50 quants in front of me
//result = c_trace(temp, vector(temp.x,temp.y, temp.z), ignore_me);
//if(result == 1)// if there is a ground within this distance, move
//if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0){
// dist_down = my.z + player_feet_height - target.z; }else {dist_down = 0;}// get distance between player's feet and the ground
//
//if (dist_down > 0) {dist_down = clamp(dist_down,0,accelerate(speed_down,5,0.1));}else{speed_down=0;}
//var dist_ahead;dist_ahead = 5*(key_w-key_s)*time_step;
//dist_ahead = sign(dist_ahead)*(abs(dist_ahead) + 0.5*dist_down); // adapt the speed on slopes
//c_move(me,player_moveto.x,vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE);



//var dist_ahead;dist_ahead = 5*(key_w-key_saa)*time_step;
//dist_ahead = sign(dist_ahead)*(abs(dist_ahead) + 0.5*player_diff.z); // adapt the speed on slopes
//c_move(me,vector(,0,0),vector(0,0,0),IGNORE_PASSABLE | GLIDE); // move the player



//vec_set(temp,my.x);
//temp.z -= 4000; // calculate a position 4000 quants below the player
//trace_mode = ignore_me+ignore_sprites+ignore_passable+ignore_models+use_box;
//result = trace(my.x,temp);// subtract vertical distance to ground
//my.z -= result;
////////////////////////////////////////////////////////////////////////////////////////////


c_move(my,nullvector, player_diff.x, IGNORE_PASSENTS | GLIDE); /// Move my Player///
center_check();
update_views();




IF (key_ctrl == 1) { //you can set various keys here to for various combos, then set different movement_modes for the different animations and actions
vec_set(temp,my.x);
temp.z -= 400;
trace_mode = ignore_me+ignore_sprites+ignore_passable+ignore_models+use_box;
result = trace(my.x,temp);
IF (result < 3) { //if we are on ground, not in the air
movement_mode = 100; //attacking
my.animdist = 0;
attack_state = 0;
}
}
}
IF (movement_mode == 100) {
player_attack();
}
wait(1);
}
while (my.skill23 <= 0) // the player is dead
{
ent_cycle("death",25); // play death frames animation
my.skill23 += .5 * time; // "death" animation speed
wait (1 );
}
}

Re: Ladder climb 4r FPS [C-SCRIPT] [Re: rogodoy] #292293
10/01/09 19:10
10/01/09 19:10
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
I'd use different movemodes;
Define a skill or variable, movemode or something, then, in the players code:

if(movemode == 0) // no ladder climbing
{
///// do normal movement....
}
else // ladder climbing
{

/////////////////////////////////////////////////////7
//// limit code to z axis, depending on camera angle
}


Set the movemode in an event or something...
That's the basics, have no time to write it all now, if you need more detailed code, PM me....


Moderated by  adoado, checkbutton, mk_1, Perro 

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