1 registered members (Ayumi),
1,177
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Grabbing Edges -- Help Needed
[Re: bk9iq]
#332183
07/07/10 21:37
07/07/10 21:37
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
I've translated the main parts, but I need to pull all this together, to make a playable demo ![wink wink](/ubb7/images/graemlins/default_dark/wink.gif) This is first time when I handle such staff ![laugh laugh](/ubb7/images/graemlins/default_dark/laugh.gif) So, any help will be grateful.
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
VECTOR ladder_x;
VECTOR player_diff;
VECTOR temp;
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
var movement_mode = 0;
var player_feet_height = 32; //the distance from the origin to the feet of the player
var z_force = 0;
var jump_z;
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
#define animdist skill20
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
function detect_edge()
{
my.animdist = 0;
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;
result = c_trace(my.x,temp,IGNORE_ME|IGNORE_SPRITES|IGNORE_MODELS|SCAN_TEXTURE);
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
result = c_trace(my.x,temp,IGNORE_ME|IGNORE_SPRITES|IGNORE_MODELS|USE_BOX);// subtract vertical distance to ground
if (result <= 3)
{
// in the air?
if ((result < 1.3) && (result > -1.3) && (result > 0.5) && (result < -0.5))
{
//change the value 1.5 to change how high steps he can climb, make it no higher than 3
my.skill13 = 0;
}
vec_set(temp,my.x);
temp.z -= 4000; // calculate a position 4000 quants below the player
result = c_trace(my.x,temp,IGNORE_ME|IGNORE_SPRITES|IGNORE_MODELS|USE_BOX);
// subtract vertical distance to ground
z_force = -1 * result;
}
else
{
if ((result <= 3) && (my.animdist > 20))
{
if ((result < 1.3) && (result > -1.3) && (result > 0.5) && (result < -0.5))
{
//change the value 1.5 to change how high steps he can climb, make it no higher than 3
my.skill13 = 0;
}
vec_set(temp,my.x);
temp.z -= 4000; // calculate a position 4000 quants below the player
result = c_trace(my.x,temp,IGNORE_ME|IGNORE_SPRITES|IGNORE_MODELS|USE_BOX);// subtract vertical distance to ground
z_force = -1 * result;
}
}
if ((key_w == 1) || (key_s == 1) || (key_d == 1) || (key_a == 1))
{
if (key_shift == 0)
{
ent_animate(my,"run",my.animdist,ANM_CYCLE);
my.animdist += 10 * time_step;
}
else
{
ent_animate(my,"walk",my.animdist,ANM_CYCLE);
my.animdist += 9 * time_step;
}
}
else
{
ent_animate(my,"stand",my.animdist,ANM_CYCLE);
my.animdist += 3 * time_step;
}
my.skill13 = 0.5*z_force + maxv(1-0.5*0.7,0)*my.skill13; // calculate vertical speed, replace 0.3 with time to convert to the old equation
jump_z = time_step * my.skill13; // distance down
player_diff.z = jump_z;
c_move(my,player_diff, nullvector,IGNORE_PASSABLE|GLIDE);
//center_check();
//update_views();
}
if (movement_mode == 2)
{
//pulling yourself up onto a ledge
my.z += 5 * time_step;
player_diff.x = 1;
player_diff.y = 0;
player_diff.z = 0;
c_move(my,player_diff.x,nullvector,IGNORE_PASSABLE|GLIDE);
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 - player_feet_height; //set the value 32 to the distance to the models feet
if(c_trace(my.x,temp,IGNORE_ME|IGNORE_SPRITES|IGNORE_MODELS) == 0)
{
movement_mode = 3;
vec_set(ladder_x.x,my.x);
}
ent_animate(my,"walk",my.animdist,ANM_CYCLE); // edge climb animation here
my.animdist += 9 * time_step; // 9 is climbing speed
//center_check();
//update_views();
}
if (movement_mode == 3)
{
//moving a little bit forward so that player doesn't fall down
player_diff.x = 3 * time_step;
player_diff.y = 0;
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
result = c_trace(my.x,temp,IGNORE_ME|IGNORE_SPRITES|IGNORE_MODELS|USE_BOX);// subtract vertical distance to ground
player_diff.z = 0;
if (result < 4) { player_diff.z = -0.2 * result; }
if(vec_dist(my.x,ladder_x.x) > 7)
{
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
result = c_trace(my.x,temp,IGNORE_ME|IGNORE_SPRITES|IGNORE_MODELS|USE_BOX);// subtract vertical distance to ground
if (result < 4) { player_diff.z = -1 * result; }
}
else
{
player_diff.z = 0;
}
c_move(my,player_diff, nullvector, IGNORE_PASSABLE|GLIDE);
if(vec_dist(my.x,ladder_x.x) > 15)
{
movement_mode = 0;
player_diff.z = 0;
//z_force = 0;
my.skill13 = 0;
}
ent_animate(my,"walk",my.animdist,ANM_CYCLE);
my.animdist += 9 * time_step;
//center_check();
//update_views();
}
}
|
|
|
Re: Grabbing Edges -- Help Needed
[Re: bk9iq]
#332190
07/07/10 22:43
07/07/10 22:43
|
Joined: Jul 2010
Posts: 129
bk9iq
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 129
|
I don't get it at all ... I think it is better to add something like a small bar model over the edge that we want our player to be able to grab and attach it to an action that is close to that you used in your stairs level for stairs .. Isn't that possible??
Last edited by bk9iq; 07/07/10 22:44.
|
|
|
Re: Grabbing Edges -- Help Needed
[Re: bk9iq]
#332191
07/07/10 23:03
07/07/10 23:03
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Never give up! ![wink wink](/ubb7/images/graemlins/default_dark/wink.gif) Here is a simple 3rd person demo: Download link I'll add climbing to this ![wink wink](/ubb7/images/graemlins/default_dark/wink.gif) Learn this script now, it's very easy ![wink wink](/ubb7/images/graemlins/default_dark/wink.gif) PM me if any questions. Keys: WSAD - for movement; Mouse - camera movement; Mouse scroll - for zooming in and out; SPACE - jump;
|
|
|
Re: Grabbing Edges -- Help Needed
[Re: 3run]
#332192
07/07/10 23:20
07/07/10 23:20
|
Joined: Jul 2010
Posts: 129
bk9iq
OP
Member
|
OP
Member
Joined: Jul 2010
Posts: 129
|
Hehhehe Thanks ... I wrote a very simple 3rd person but it is definitely incomparable... I think urs is great coz I already read ur ladder code and it was almost 90% comprehensible for me ![laugh laugh](/ubb7/images/graemlins/default_dark/laugh.gif) Thanks again BTW :: Change (var jump_time = 1;) at the beginning of the code to (var jump_time = 0;) so that the character does not jump when u start the level
Last edited by bk9iq; 07/07/10 23:26.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|