*UPDATED* Zelda code, ladder, ledge & basic combat

Posted By: DavidLancaster

*UPDATED* Zelda code, ladder, ledge & basic combat - 12/18/04 10:56

Below is updated Zelda code including:

- ladder climbing
- ledge grabbing
- very very basic combat
- FSW camera

---------------
Ladder climbing
---------------

If the player approaches a surface with flag 1 set to "on" the player will climb the wall like a ladder. The idea is to make a really thin tall block with

one of the surfaces flag 1 set to "on", then to make the block invisible and place a ladder model or sprite there. This doesn't work though as the trace

instruction which looks for a surface with flag 1 as "on" misses invisible blocks. The trace instruction wont detect invisible blocks.

---------------
Ledge grabbing
---------------

When falling, the player will grab onto a ledge, whilst on the ledge you can move left and right, drop down or climb up. The player will grab onto all

ledges even if they have a tilted surface. To stop the player grabbing onto tilted surfaces I suggest programming code to only grab onto walls with a

particular texture or flag set.

---------------
Combat
---------------

Place one or several entities into your level and give them the action lock_on_object. When you press and hold right click or x and are in range of one of

these entites you will lock on. Press ctrl or left click to do a basic attack. To get the attack working, merge a weapon in MED to the guard, get the

verticy numbers of the tip of the sword and the bottom of the sword. Change the values in the function basic_attack().

The combat code has not been improved from this because of my lack of animation skills (plus the amount of work it would take to get it working good).

--------------
Improved camera
--------------

The camera uses a basic FSW system. It doesn't stop clipping, but avoids it and makes the camera move better. The camera code can be tweaked to stop alot

of the clipping, but all the camera will do is stay soo close to the player that it has no chance of clipping.

--------------
Other
--------------

Holding shift will allow the player to walk, holding shift and jumping will cause the player to do a shorter jump.

Whilst holding right click or x use the mouse to pan the player (as long as you haven't locked on).

Copy the jump 2 animation of the guard and paste it into jump 3 (this will allow better looking jumps).

Press space to jump. I have changed the code to jump on space instead of approaching an edge, it seems a better way to play.

Please post any problems or suggestions.

Enjoy!



-------------------------------------------------------------------------------
DEFINE animdist,skill20;

var dist_planar = 200;
var dist_total = 200;
var dist_traced = 0;
var cam_xyangle = player_pan;
var cam_zangle = -15;
var zoffset = 7;
var panoffset = 0;
var viewvec[3];
var slowdown;
var cter = 0;
var player_diff[3];
var player_moveto[3];
var centerstop = 0;
var cam_radius = 400;
var cam_height = 270;
var cam_rotate_speed = 5; //rotation speed of camera when moving
var enable_mouse_move = 0;

var player_head_height = 42; //the distance from the origin to the head of the player
var player_feet_height = 32; //the distance from the origin to the feet of the player
var locked_on = 0;
var lockon_max = 400; //this is how far the player needs to be from the lock on, while locked on, in order to break the lock
var lockon_min = 300; //this is how close the player needs to be to a lock on target in order to iniate lock on when pressing right click
var locked_target[3];

var rotate_speed = 0;
var rotate_to = 0;
var are_we_strafing = 0;
var store_strafe_mode = 0;

var attack_state = 0;
var movement_mode = 0; //for various stages of moving
var temp2[6];
var ledge_climb_z; //this is set to 1 once the player is at a high enough point from climbing a ledge it is hanging onto, used to fix bug when player falls and grabs onto a thin ledge

var jump_z; //temporary variable, is copied into player_diff.z before the move instruction
var jump_force = 18; //change this variable to affect how high the player jumps
var jumping_mode = 0; //0 for not jumping, 1 if jumping
var z_force = 0;
var center[3];
var result = 0;

var global_cam_effect = 0; //the global radius change in rays hitting walls
var walk_speed = 1.5; //the number which running speed is divided by to get walking speed
var ledge_grab_test;

/////////////////////////////////////
entity* player;

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

var camera_move_to = 200;
var cradius_speed = 20;

FUNCTION pan_back(){
/* dist_planar = dist_total; //old jump code

temp.x = player.x - dist_total * cos(cam_xyangle);
temp.y = player.y - dist_total * sin(cam_xyangle);
temp.z = player.z - sin(cam_zangle) * 200;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
dist_traced = vec_dist(target.x,player.x);
IF (dist_traced < dist_total) {
dist_traced -= 10; // Move it out of the wall
dist_planar = dist_traced;
} ELSE {
dist_planar = dist_total;
}
cam_xyangle = cter;
viewvec.x = player.x - dist_planar * cos(cam_xyangle);
viewvec.y = player.y - dist_planar * sin(cam_xyangle);
viewvec.z = player.z - sin(cam_zangle) * cam_height; */

temp.y = player.y - dist_total * sin(cam_xyangle);
temp.x = player.x - dist_total * cos(cam_xyangle);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
dist_traced = vec_dist(target.x,player.x);
IF (dist_traced < dist_total) {
dist_traced -= 15; // Move it out of the wall
camera_move_to = dist_traced;
} ELSE {
camera_move_to = dist_total;
}


temp.x = player.x - dist_total * cos(cam_xyangle + 5);
temp.y = player.y - dist_total * sin(cam_xyangle + 5);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
dist_traced = vec_dist(target.x,player.x);
IF (dist_traced < dist_total) {
camera_move_to -= (dist_total - dist_traced) / 1.3;
}


temp.x = player.x - dist_total * cos(cam_xyangle - 5);
temp.y = player.y - dist_total * sin(cam_xyangle - 5);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
result = vec_dist(target.x,player.x);
IF (result < dist_traced) {
dist_traced = result;
IF (dist_traced < dist_total) {
camera_move_to -= (dist_total - dist_traced) / 1.3;
}
}


temp.x = player.x - dist_total * cos(cam_xyangle + 10);
temp.y = player.y - dist_total * sin(cam_xyangle + 10);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
dist_traced = vec_dist(target.x,player.x);
IF (dist_traced < dist_total) {
camera_move_to -= (dist_total - dist_traced) / 3;
}


temp.x = player.x - dist_total * cos(cam_xyangle - 10);
temp.y = player.y - dist_total * sin(cam_xyangle - 10);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
result = vec_dist(target.x,player.x);
IF (result < dist_traced) {
dist_traced = result;
IF (dist_traced < dist_total) {
camera_move_to -= (dist_total - dist_traced) / 3;
}
}

temp.x = player.x - dist_total * cos(cam_xyangle + 22.5);
temp.y = player.y - dist_total * sin(cam_xyangle + 22.5);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
dist_traced = vec_dist(target.x,player.x);
IF (dist_traced < dist_total) {
camera_move_to -= (dist_total - dist_traced) / 5;
}


temp.x = player.x - dist_total * cos(cam_xyangle - 22.5);
temp.y = player.y - dist_total * sin(cam_xyangle - 22.5);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
result = vec_dist(target.x,player.x);
IF (result < dist_traced) {
dist_traced = result;
IF (dist_traced < dist_total) {
camera_move_to -= (dist_total - dist_traced) / 5;
}
}



temp.x = player.x - dist_total * cos(cam_xyangle + 35);
temp.y = player.y - dist_total * sin(cam_xyangle + 35);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
dist_traced = vec_dist(target.x,player.x);
IF (dist_traced < dist_total) {
camera_move_to -= (dist_total - dist_traced) / 10;
}

temp.x = player.x - dist_total * cos(cam_xyangle - 35);
temp.y = player.y - dist_total * sin(cam_xyangle - 35);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
result = vec_dist(target.x,player.x);
IF (result < dist_traced) {
dist_traced = result;
camera_move_to -= (dist_total - dist_traced) / 10;
}




temp.x = player.x - dist_total * cos(cam_xyangle + 50);
temp.y = player.y - dist_total * sin(cam_xyangle + 50);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
dist_traced = vec_dist(target.x,player.x);
IF (dist_traced < dist_total) {
camera_move_to -= (dist_total - dist_traced) / 15;
}

temp.x = player.x - dist_total * cos(cam_xyangle - 50);
temp.y = player.y - dist_total * sin(cam_xyangle - 50);
temp.z = camera.z;

trace_mode = ignore_me + ignore_passable + ignore_models;
trace (player.x, temp.x);
result = vec_dist(target.x,player.x);
IF (result < dist_traced) {
dist_traced = result;
camera_move_to -= (dist_total - dist_traced) / 15;
}

IF (camera_move_to < 15) { camera_move_to = 15; }
IF(abs(dist_planar - camera_move_to) < 20) {
cradius_speed = -0.25 * (dist_planar - camera_move_to);
} ELSE {
IF (dist_planar > camera_move_to) { cradius_speed = -25; }
IF (dist_planar < camera_move_to) { cradius_speed = 25; }
}
IF(abs(dist_planar - camera_move_to) < 50) { //deaccelerate camera before it reaches player
cradius_speed /= 1.3;
}
IF(abs(dist_planar - camera_move_to) < 40) { //deaccelerate camera before it reaches player
cradius_speed /= 1.3;
}
IF(abs(dist_planar - camera_move_to) < 30) {
cradius_speed /= 1.3;
}

var temp2[3];
vec_set(temp2,camera.x);

vec_set(temp,my.x);
vec_sub(temp,temp2.x);
vec_to_angle(temp.pan,temp);
camera.tilt = temp.tilt + zoffset; //this causes the camera to tile towards the player


MY.skill15 += (TIME * cradius_speed) - (min(TIME*0.7,1) * my.skill15);
dist_planar += MY.skill15 * TIME;

cam_xyangle = cter;
viewvec.x = player.x - dist_planar * cos(cam_xyangle);
viewvec.y = player.y - dist_planar * sin(cam_xyangle);
viewvec.z = player.z - sin(cam_zangle) * cam_height;


}


FUNCTION update_views(){
pan_back();
vec_set(camera.x, viewvec.x);
camera.pan = cam_xyangle - panoffset;
// camera.tilt = cam_zangle + zoffset;
camera.roll = 0;
}

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


FUNCTION init_cameras() {
beep;
camera.size_x = screen_size.x;
camera.size_y = screen_size.y;
camera.visible = on;
}


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

FUNCTION rotate_player(){
IF (jumping_mode == 0) { //so that player cannot control rotation in air
if(key_a == 1) {
rotate_to = cter + 90;
}
if(key_d == 1) {
rotate_to = cter + 270;
}
if(key_w == 1){
rotate_to = cter;
}
if(key_s == 1){
rotate_to = cter + 180;
}

if(key_w == 1 && key_d == 1){
rotate_to = cter + 315;
}

if(key_s == 1 && key_d){
rotate_to = cter + 225;
}

if(key_s == 1 && key_a == 1){
rotate_to = cter + 135;
}

if(key_w == 1 && key_a == 1){
rotate_to = cter + 45;
}

if((key_d == 1 && key_a == 1) || (key_w== 1 && key_s == 1)){
my.pan = my.pan;
rotate_to = my.pan;
}
}

IF (key_d == 1 || key_a == 1 || key_s == 1 || key_w == 1 || jumping_mode != 0) && (store_strafe_mode == 0) {
temp = ang(rotate_to - MY.PAN);
IF(temp > 5) {
rotate_speed = 20;
} ELSE {
IF (temp < -5) {
rotate_speed = -20;
} ELSE {
if(temp > -2) && (temp < 2) { my.skill14 = 0; }
rotate_speed = 3 * ang(rotate_to - MY.PAN);
}
}

MY.skill14 += (TIME * rotate_speed) - (min(TIME*0.7,1) * my.skill14);
MY.PAN += MY.skill14 * TIME;
}

if(cter > 359){ cter -= 360; }
}

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

FUNCTION movement(){
IF (key_a == 1) {
IF (key_shift == 0) {
cter += cam_rotate_speed * time;
} ELSE {
cter += cam_rotate_speed * time * 0.8;
}
player_moveto.x = (center.x + (cam_radius * cos(cter)));
player_moveto.y = (center.y + (cam_radius * sin(cter)));
player_moveto.z = player.z;
vec_diff(player_diff, player_moveto, player.x);
}
IF (key_d == 1) {
IF (key_shift == 0) {
cter -= cam_rotate_speed * time;
} ELSE {
cter -= cam_rotate_speed * time * 0.8;
}
player_moveto.x = (center.x + (cam_radius * cos(cter)));
player_moveto.y = (center.y + (cam_radius * sin(cter)));
vec_diff(player_diff, player_moveto, player.x);
player_moveto.z = player.z;
}

IF (cter > 359){ cter -= 360; }
IF (cter < 0){ cter += 360; }

IF (key_w == 1){
center.x += 10 * cos(cter);
center.y += 10 * sin(cter);
player_moveto.x = (center.x + cam_radius * cos(cter));
player_moveto.y = (center.y + cam_radius * sin(cter));
vec_diff(player_diff, player_moveto, player.x);
player_moveto.z = player.z;
}
IF (key_s == 1){
center.x -= 10 * cos(cter);
center.y -= 10 * sin(cter);
player_moveto.x = (center.x + cam_radius * cos(cter));
player_moveto.y = (center.y + cam_radius * sin(cter));
vec_diff(player_diff, player_moveto, player.x);
player_moveto.z = player.z;
}
IF(key_w == 0) && (key_s == 0) && (key_a == 0) && (key_d == 0) {
vec_set(player_diff, nullvector);
player_moveto.z = player.z;
}
}

FUNCTION strafe_movement(){

IF (key_a == 1) {
player_diff.y = 45 * time;
}
IF (key_d == 1) {
player_diff.y = -45 * time;
}
IF (key_w == 1) {
player_diff.x = 45 * time;
}
IF (key_s == 1) {
player_diff.x = -45 * time;
}
IF(key_w == 0) && (key_s == 0) && (key_a == 0) && (key_d == 0) {
vec_set(player_diff, nullvector);
}
}

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

FUNCTION center_check(){
IF (player.x != (center.x + cam_radius * cos(cter))){
center.x = (player.x - cam_radius * cos(cter));
}
IF (player.y != (center.y + cam_radius * sin(cter))){
center.y = (player.y - cam_radius * sin(cter));
}
}

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

var ladder_x[3];

ACTION player_action{
player = me;
vec_set(temp,player.x);
// create(<dummy.mdl>,temp,range200_action);
my.fat = off;
my.narrow = on;
my.animdist = 0;

my.enable_detect = on;
my.event = scan_event;

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;

ledge_grab_test = 0;

locked_on = 0;
my.skill24 = 0;
are_we_strafing = 0;

WHILE (1){

IF (movement_mode == 0) {
IF (z_force < -2) { //are we falling?
vec_set(temp,my.x); //scan in front of player to see if he has hit a wall
temp.x += 30 * cos(my.pan);
temp.y += 30 * sin(my.pan);
temp.z = my.z + player_head_height; //scan at head height
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(my.x,temp);
IF(result == 0) {
ledge_grab_test = 0;
} ELSE {
IF (result > 0) && (ledge_grab_test == 0) {
vec_to_angle(temp,normal.x);
IF (abs(ang(my.pan - (temp.pan - 180))) < 30) {
temp2.pan = (temp.pan - 180); //make player face towards ladder
vec_set(temp,target.x); //scan to see if there is space up above player for it to grab onto ledge
temp.x += 10 * cos(temp2.pan);
temp.y += 10 * sin(temp2.pan);
temp.z += player_head_height - 2; //scan at head height
target.z += 10;
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(temp.x,target.x);
// vec_to_angle(temp,target.x);
IF (result > 0) { //if we have a wall in the way, and the surface above is less than a 10 degree slant
vec_set(temp,my.x); //scan to see if there is space up above player for it to grab onto ledge
temp.z += player_head_height - 2; //scan at head height
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(temp.x,target.x);
IF (result == 0) { //scan above head to make sure we didn't hit a roof
ledge_grab_test = 1;
movement_mode = 10;
my.pan = temp2.pan; //make player face towards ladder
}
}
}
}
}
}
}


IF (movement_mode == 1) { //ladder climbing
IF(key_w == 1) && (key_s == 0) {
temp.x = 0;
temp.y = 0;
temp.z = 5 * time;
ent_move(temp.x,nullvector);
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 - 10;
trace_mode = ignore_me+ignore_sprites+ignore_models;
IF(trace(my.x,temp) == 0) {
movement_mode = 2;
}
ent_cycle("walk",my.animdist);
my.animdist += 9 * time;
}
IF(key_s == 1) && (key_w == 0) {
temp.x = 0;
temp.y = 0;
temp.z = -5 * time;
ent_move(temp.x,nullvector);
vec_set(temp,my.x);
temp.z -= 4000;
trace_mode = ignore_me+ignore_sprites+ignore_models+use_box;
result = trace(my.x,temp);
IF (result < 10) && (key_s == 1) { movement_mode = 0; }
ent_cycle("walk",my.animdist);
my.animdist += 9 * time;
}
IF (my.animdist > 100) { my.animdist -= 100; }
IF (ang(cter) < ang(player.pan)) {
IF (ang(player.pan) - ang(cter) <= 180) {
IF (ang(player.pan) - ang(cter) <= 5) {
cter += 0.25 * (ang(player.pan) - ang(cter));
} ELSE {
cter += cam_rotate_speed * 2 * time;
}
} ELSE {
cter -= cam_rotate_speed * 2 * time;
}
}
IF (ang(cter) > ang(player.pan)) {
IF (ang(cter) - ang(player.pan) <= 180) {
IF (ang(cter) - ang(player.pan) <= 5) {
cter += 0.25 * (ang(player.pan) - ang(cter));
} ELSE {
cter -= cam_rotate_speed * 2 * time;
}
} ELSE {
cter += cam_rotate_speed * 2 * time;
}
}
IF (cter > 359) { cter -= 360; }
IF (cter < 0) { cter += 360; }
// camera.z = player.z - sin(cam_zangle) * cam_height;
center_check();
update_views();
}

IF (movement_mode == 2) { //pulling yourself up onto a ledge
my.z += 5 * time;
player_diff.x = 1;
player_diff.y = 0;
player_diff.z = 0;
ent_move(player_diff.x,nullvector);
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
trace_mode = ignore_me+ignore_sprites+ignore_models;
IF(trace(my.x,temp) == 0) {
movement_mode = 3;
vec_set(ladder_x.x,my.x);
}
// camera.z = player.z - sin(cam_zangle) * cam_height;
ent_cycle("walk",my.animdist);
my.animdist += 9 * time;
IF (my.animdist > 100) { my.animdist -= 100; }
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;
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
trace_mode = ignore_me+ignore_sprites+ignore_models+use_box;
result = trace(my.x,temp);// 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
trace_mode = ignore_me+ignore_sprites+ignore_models+use_box;
result = trace(my.x,temp);// subtract vertical distance to ground
IF (result < 4) { player_diff.z = -1 * result; }
} ELSE {
player_diff.z = 0;
}
ent_move(player_diff, nullvector);

IF(vec_dist(my.x,ladder_x.x) > 15) {
movement_mode = 0;
player_diff.z = 0;
z_force = 0;
jumping_mode = 0;
my.skill13 = 0;
}
ent_cycle("walk",my.animdist);
my.animdist += 9 * time;
IF (my.animdist > 100) { my.animdist -= 100; }
center_check();
update_views();
}

IF (movement_mode == 10) {
IF (ang(cter) < ang(player.pan)) {
IF (ang(player.pan) - ang(cter) <= 180) {
IF (ang(player.pan) - ang(cter) <= 5) {
cter += 0.25 * (ang(player.pan) - ang(cter));
} ELSE {
cter += cam_rotate_speed * 1 * time;
}
} ELSE {
cter -= cam_rotate_speed * 1 * time;
}
}
IF (ang(cter) > ang(player.pan)) {
IF (ang(cter) - ang(player.pan) <= 180) {
IF (ang(cter) - ang(player.pan) <= 5) {
cter += 0.25 * (ang(player.pan) - ang(cter));
} ELSE {
cter -= cam_rotate_speed * 1 * time;
}
} ELSE {
cter += cam_rotate_speed * 1 * time;
}
}
IF (cter > 359) { cter -= 360; }
IF (cter < 0) { cter += 360; }


jumping_mode = 0;
player_diff.x = 0;
player_diff.z = 0;
z_force = 0;
IF (key_a != 0) && (key_d == 0) && (key_s == 0) && (key_w == 0) {
player_diff.y = 5 * time;
ent_cycle("walk",my.animdist);
my.animdist += 9 * time;
} ELSE {
player_diff.y = 0;
}
IF (key_d != 0) && (key_a == 0) && (key_s == 0) && (key_w == 0) {
player_diff.y = -5 * time;
ent_cycle("walk",my.animdist);
my.animdist += 9 * time;
} ELSE {
IF (key_a == 0) {
player_diff.y = 0;
}
}
IF (key_w == 1) && (key_s == 0) && (key_a == 0) && (key_d == 0) {
movement_mode = 11;
ledge_climb_z = my.z + player_head_height - 2; //this needs to be set to the height of the players head, ie my.z + # = players head
}
IF (key_s == 1) && (key_w == 0) && (key_a == 0) && (key_d == 0) {
movement_mode = 0;
jumping_mode = 0;
}
ent_move(player_diff, nullvector);
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 + 40; //scan at head height
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(my.x,temp);
IF(result == 0) {
ledge_grab_test = 0;
movement_mode = 0;
jumping_mode = 0;
}

vec_set(temp,my.x); //scan a little above head height, we don't want a wall to be this high
temp.x += 30 * cos(my.pan);
temp.y += 30 * sin(my.pan);
temp.z += 45;
vec_set(temp2,my.x);
temp.z += 45;
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(temp2,temp);
IF(result > 0) {
ledge_grab_test = 0;
movement_mode = 0;
jumping_mode = 0;
}

center_check();
update_views();
IF (my.animdist > 100) { my.animdist -= 100; }
}


IF (movement_mode == 11) { //pulling yourself up onto a ledge
IF (my.z < ledge_climb_z) {
my.z += 5 * time;
} ELSE {
movement_mode = 12;
}
ent_cycle("walk",my.animdist);
my.animdist += 9 * time;
IF (my.animdist > 100) { my.animdist -= 100; }
center_check();
update_views();
}

IF (movement_mode == 12) { //pulling yourself up onto a ledge
my.z += 5 * time;
player_diff.x = 1;
player_diff.y = 0;
player_diff.z = 0;
ent_move(player_diff.x,nullvector);
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 player_feet_height to the distance to the models feet
trace_mode = ignore_me+ignore_sprites+ignore_models;
IF(trace(my.x,temp) == 0) {
movement_mode = 3;
vec_set(ladder_x.x,my.x);
}
// camera.z = player.z - sin(cam_zangle) * cam_height;
ent_cycle("walk",my.animdist);
my.animdist += 9 * time;
IF (my.animdist > 100) { my.animdist -= 100; }
center_check();
update_views();
}



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);
// IF(str_cmpi(tex_name,"glas1") == 1) && (movement_mode == 0) { //change the texture here of the texture required to be tracing in order to climb wall
IF (tex_flag1 == on) && (movement_mode == 0) {
vec_to_angle(temp,normal.x);
IF (abs(ang(my.pan - (temp.pan - 180))) < 20) { movement_mode = 1; jumping_mode = 0; }
// my.pan = normal.pan - 180; //make player face towards ladder
}

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?
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; }
} ELSE {
IF (result <= 3) && (my.animdist > 20) {
IF (jumping_mode == 2) {
player_diff.x = 0;
player_diff.y = 0;
IF (my.animdist <= 40) { jumping_mode = 0; }
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 < 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 (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("run",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 = 0.5*z_force + max(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 * my.SKILL13; // distance down
player_diff.z = jump_z;

IF (jumping_mode != 0) { //stops changing of movement modes while jumping
key_x = 0;
mouse_right = store_strafe_mode;
}

IF (key_x == 0) && (mouse_right == 0) {
ent_move(nullvector, player_diff);
} ELSE {
ent_move(player_diff, nullvector);
}
center_check();
update_views();

//the following code moves the camera directly behind the player when holding the x key

IF (jumping_mode != 0) && (locked_on == 1.5) { //allow player to rotate around target while jumping
vec_set(temp.x,locked_target.x);
vec_sub(temp.x,my.x);
vec_to_angle(rotate_to,temp.x); // now MY looks at locked_target
IF (ang(rotate_to - my.pan) < -2) {
my.pan -= 12 * time;
}
IF (ang(rotate_to - my.pan) > 2) {
my.pan += 12 * time;
}
IF (abs(ang(rotate_to - my.pan)) > 5) { locked_on = 1; }
cter = my.pan;
}
IF (jumping_mode != 0) && (locked_on == 1) { //allow player to rotate around target while jumping
vec_set(temp.x,locked_target.x);
vec_sub(temp.x,my.x);
vec_to_angle(my.pan,temp.x); // now MY looks at locked_target
my.tilt = 0;
my.roll = 0;
cter = my.pan;
IF (vec_dist(my.x,locked_target.x) > lockon_max) { locked_on = 0; my.skill24 = 0; } //release lock if distance is greater than 320 & jumping
}

IF (jumping_mode == 0) {
IF (vec_dist(my.x,locked_target.x) > lockon_max) && (locked_on > 0) && (locked_on < 2) { locked_on = 0; my.skill24 = 0; } //release lock if distance is greater than 320 & walking
IF (key_x == 1 || mouse_right == 1) && (are_we_strafing != 2) {
are_we_strafing = 1;
IF (locked_on == 0) {
temp.pan = 360;
temp.tilt = 50;
temp.z = lockon_min;
scan_entity (my.x, temp);
locked_on = 2;
IF (my.skill24 == 1) { //if we scanned a lock on target
locked_on = 1.5;
} ELSE {
locked_on = 2;
}
}
IF (locked_on == 1.5) { //program smooth turning here
vec_set(temp.x,locked_target.x);
vec_sub(temp.x,my.x);
vec_to_angle(rotate_to,temp.x); // now MY looks at locked_target
IF (ang(rotate_to - my.pan) < -2) {
my.pan -= 12 * time;
}
IF (ang(rotate_to - my.pan) > 2) {
my.pan += 12 * time;
}
IF (abs(ang(rotate_to - my.pan)) < 5) { locked_on = 1; }
// cter = my.pan;
IF (ang(cter) < ang(player.pan)) {
IF (ang(player.pan) - ang(cter) <= 180) {
IF (ang(player.pan) - ang(cter) <= 5) {
cter += 0.25 * (ang(player.pan) - ang(cter));
cter = player.pan;
} ELSE {
cter += cam_rotate_speed * 5 * time;
}
} ELSE {
cter -= cam_rotate_speed * 5 * time;
}
}
IF (ang(cter) > ang(player.pan)) {
IF (ang(cter) - ang(player.pan) <= 180) {
IF (ang(cter) - ang(player.pan) <= 5) {
cter += 0.25 * (ang(player.pan) - ang(cter));
cter = player.pan;
} ELSE {
cter -= cam_rotate_speed * 5 * time;
}
} ELSE {
cter += cam_rotate_speed * 5 * time;
}
}
IF (cter > 359) { cter -= 360; }
IF (cter < 0) { cter += 360; }
}

IF (locked_on == 1) { //program smooth turning here
vec_set(temp.x,locked_target.x);
vec_sub(temp.x,my.x);
vec_to_angle(my.pan,temp.x); // now MY looks at locked_target
my.tilt = 0;
my.roll = 0;
cter = my.pan;
}
IF (locked_on == 2) {
IF (mouse_force.x > 0) { my.pan -= 20 * mouse_force.x * time; cter = my.pan; }
IF (mouse_force.x < 0) { my.pan -= 20 * mouse_force.x * time; cter = my.pan; }
IF (ang(cter) < ang(player.pan)) {
IF (ang(player.pan) - ang(cter) <= 180) {
IF (ang(player.pan) - ang(cter) <= 5) {
cter += 0.25 * (ang(player.pan) - ang(cter));
} ELSE {
cter += cam_rotate_speed * 5 * time;
}
} ELSE {
cter -= cam_rotate_speed * 5 * time;
}
}
IF (ang(cter) > ang(player.pan)) {
IF (ang(cter) - ang(player.pan) <= 180) {
IF (ang(cter) - ang(player.pan) <= 5) {
cter += 0.25 * (ang(player.pan) - ang(cter));
} ELSE {
cter -= cam_rotate_speed * 5 * time;
}
} ELSE {
cter += cam_rotate_speed * 5 * time;
}
}
IF (cter > 359) { cter -= 360; }
IF (cter < 0) { cter += 360; }
}
}

IF (are_we_strafing == 1) && (mouse_right == 0) && (key_x == 0) { are_we_strafing = 2; locked_on = 0; my.skill24 = 0; } //2; }
IF (are_we_strafing == 2) {
IF (panoffset < 0) { panoffset += 3 * time; }
IF (panoffset > 0) { panoffset -= 3 * time; }
IF (zoffset < 6) { zoffset += 2 * time; }
IF (zoffset > 8) { zoffset -= 2 * time; }
IF (panoffset < 1 && panoffset > -1 && zoffset < 8 && zoffset > 6) { panoffset = 0; zoffset = 7; are_we_strafing = 0; }
}
}

//allows movement of camera with mouse when player is stationary
IF (mouse_force.x != 0) && (are_we_strafing == 0) {
IF (mouse_force.x > 0) && (panoffset < 23) { panoffset += abs(mouse_force.x * 10 * time); }
IF (mouse_force.x < 0) && (panoffset > -23) { panoffset -= abs(mouse_force.x * 10 * time); }
IF (panoffset > 23) { panoffset = 23; }
IF (panoffset < -23) { panoffset = -23; }
}
IF (mouse_force.y != 0) {
IF (mouse_force.y > 0) && (zoffset > -8) { zoffset -= mouse_force.y * 10 * time; }
IF (mouse_force.y < 0) && (zoffset < 17) { zoffset -= mouse_force.y * 10 * time; }
IF (zoffset < -8) { zoffset = -8; }
IF (zoffset > 17) { zoffset = 17; }
}
IF (mouse_left == 1) || (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 = 100;
attack_state = 0;
}
}
}
IF (movement_mode == 100) {
basic_attack();
}
wait(1);
}
}

FUNCTION basic_attack() {
IF (my.animdist > 0) && (attack_state == 0) {
my.animdist -= 20 * time;
IF (my.animdist < 30) { //if we are far enough into attack animation
ent_vertex(temp,630); //sword tip
ent_vertex(temp2,601); //sword base
trace_mode = ignore_me + ignore_passable;
result = trace(temp2,temp);
IF (result != 0) {
IF (you != null) { //make sure we hit an entity and not a wall
beep;
//put affecting variables in here, ie take damage off enemy, change enemy skill number so that enemy plays taking damage animation
} ELSE { //if we hit a wall, rebound sword early
attack_state = 1;
}
}
}
IF (my.animdist <= 0) { my.animdist = 0; attack_state = 1; }
ent_frame("attack",my.animdist);
ground_player_elasticity();
}
IF (my.animdist < 100) && (attack_state == 1) {
my.animdist += 20 * time;
IF (my.animdist >= 100) { my.animdist = 100; attack_state = 0; movement_mode = 0; }
ent_frame("attack",my.animdist);
ground_player_elasticity();
}
}

FUNCTION ground_player_elasticity() {
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;
my.SKILL13 = 0.5*z_force + max(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 * my.SKILL13; // distance down
player_diff.z = jump_z;
player_diff.x = 0;
player_diff.y = 0;

ent_move(player_diff, nullvector);
center_check();
update_views();
}

ACTION lock_on_object() {
my.skill25 = 1; //1 for lock on objects
my.shadow = on;
my.enable_scan = on;
my.skill26 = 0;
WHILE(1) {
IF (my.skill26 == 1) { //this allows the locked_target vector to change whilst the enemy is moving
vec_set(locked_target.x,my.x);
}
//put ai code here
wait(1);
}
}

FUNCTION scan_event {
IF (event_type == event_detect) {
you.skill26 = 0;
IF (you.skill25 == 1) {
IF (my.skill24 == 1) {
IF (vec_dist(my.x,you.x) <= vec_dist(my.x,locked_target.x)) { //if the next target is closer than previous
vec_set(locked_target.x,you.x);
you.skill26 = 1;
my.skill24 = 1;
}
}
IF (my.skill24 == 0) {
vec_set(locked_target.x,you.x);
you.skill26 = 1;
my.skill24 = 1;
}
}
}
}

Posted By: Braxton

Re: Slightly improved Zelda code - 12/18/04 11:04

This script is now proffesional because ithas fighting!!!
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/19/04 14:51

[edited, see code above]
Posted By: Braxton

Re: Slightly improved Zelda code - 12/19/04 14:57

Cool can't wait for the combat!!!
Posted By: Orange Brat

Re: Slightly improved Zelda code - 12/19/04 15:12

[removed for clarity]
Posted By: Orange Brat

Re: Slightly improved Zelda code - 12/19/04 16:10

Finally found some time to test this out. Nice work. Everyone's after a demo...here the script applied in my old new templates tester level:

http://www.geocities.com/hainesrs/tester2.zip
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/19/04 19:19

Cool demo thanks for posting it. I managed to get ladder climbing working. I have also better animated the guard model ie when he hits the floor from a jump he kneels and gets up.

For some reason with your demo though, the guard model looked more blurier and smoother than the one I'm using

I will post the code once I further progress things, combat and ledge grabbing etc.

Also, how do you put downloads onto your website ie what is the HTML code, i've never been able to figure out how to put a download link on a web page to download a file. Thanks.
Posted By: Orange Brat

Re: Slightly improved Zelda code - 12/19/04 19:44

Maybe I messed with his skin or something somewhere along the line. I also chopped off his feather, although I wouldn't think that would have much to do with it.

In the particular example above, I used SmartFTP to upload to my account. Then, I typed the URL in the post and that's all there was to it.

You might want to animate a walk to run, run to walk transition for your test model. You'd have to add some more code to use it, but that always looks better. Another animation state would be for turning. When Guard Link turns in place, that would look better than just panning him without movement. You could also have him crawl, duck, and roll like in Zelda. Another one would be an idle animation that triggered after being inactive for awhile.

One weak spot in this setup is that the camera will clip into the wall when it first hits it. This is pretty much the norm with all the scripts around here. Although with this kind of camera it is more rare to get right up on the wall, it's still a problem. Here's a link with info that explains one way to get eliminate it. I've never been able to implement it, but maybe you or someone else can someday:

http://www.gamasutra.com/gdc2004/features/20040325/giors_02.shtml
Posted By: Josh666

Re: Slightly improved Zelda code - 12/20/04 08:48

if you end up getting the combat and climbing scripts working; you will be the hero of gamestudio.
Posted By: Iglarion

Re: Slightly improved Zelda code - 12/20/04 09:32

Yes I agree with you Josh666.

btw: Nice code for jumping.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/20/04 12:07

I am a horrible animator/modeller and will not be animating the guard model for climbing, moving between stand, walk and run positions etc, but it is a good idea.

The camera collision idea looks good, but I am not planning to work on the camera further in this script.

I don't plan to do very much with combat, just the basics, as follows:

1. Allow the player to lock on to stationary objects (which you would
need to program as enemies and give them ai)
2. Have the only attack as the Guard's default attack animation, with
weapon and allow the weapon to interact with objects (ie it rebounds
off of walls). I'm not planning to put in combos and rolls and jumps
because I am a bad animator and I don't plan to go that far with this
script.

Thanks for ideas.
Posted By: Josh666

Re: Slightly improved Zelda code - 12/20/04 18:27

cool beans!
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/21/04 19:07

I took another look at that idea for improved camera movement and I understand it now. I implemented it and it's worked so far, i'm gonna continue working on it. So the camera will actually move to the position it needs to be in (to avoid walls) instead of just appearing there and clipping into walls.
Posted By: Orange Brat

Re: Slightly improved Zelda code - 12/21/04 19:29

Do you mean from the Gamasutra article? From my understanding of it, you'd have to code an "arc" of traces from the player to the camera. One trace would go right at the camera and the others on either side of it and starting at the initial trace and spreading out from there and stopping at about the 45 degree mark(give or take 5 or 10 degrees). Each of the traces has a "weight" associated with it and the farther away the trace is from the player, the less influence it will have on the camera's forward movement. The way Doug's new template 3rd person camera handles wall collision is somewhat similar(minus the weighting), but he still hasn't been able to completely eliminate the clipping. He's come the closest, though.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/22/04 11:53

That's exactly what I did!! It doesn't eliminate clipping but reduces it and makes the camera look and work so much better. It really only clips if you turn too fast and move the camera into a wall, though if you change the speed at which the camera moves back and forth along the raduis line, you can make it fast enough so clipping stops but the camera looks dodgy because it moves too fast.

I used six traces, two at +-10 degrees, two at +-25 and two at +-50. I haven't used a central trace and it seems to work ok as long as you give the 10 degree trace 100% weight control. If you've done this type of camera before orange bat can you recommend how many traces I need, the degrees they are apart and the weight they should have (if you've done it before). Otherwise I'll try trial and error of various traces to see which layout works best. Thanks for the idea!! It makes this script rock!!
Posted By: Orange Brat

Re: Slightly improved Zelda code - 12/22/04 14:45

I've never successfully implemented it, but I understand the theory behind it. The elimination of the wall clipping is my Holy Grail and it looks like you may have finally licked it or are on the verge of it. You'll have to play with the weights until you get the right magic numbers. Also make sure that the clipping is eliminated when the camera is tilted up or down as well. The ultimate test would be successfully ridding the clipping with a more traditional 3rd person chase cam like a Max Payne or new template 3rd person style. Good luck.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/22/04 17:57

I've tried with the magic numbers but can't get rid of clipping. It seems that when I play with the numbers I am faced with two options, have no clipping but have the camera move too fast and too close to the player when it approaches the wall. Have some clipping but have the camera move at a nice speed and stays at a nice distance from the player. It's keeping a balance. I've tried making the camera move out from a wall when it is next to it but it is hard to do with this sciprt and type of movement.

What do you mean by that I should try and eliminate clipping when the camera tilts? Do you mean that if the camera height changes during gameplay to stop the camera passing through a roof etc?

Here's the code I used to calculate the radius at which it needs to move to from the player, in case you ever plan to implement it

"cam_xyangle" is the camera's pan
"dist_total" is the maximum distance the camera can move from the player
"dist_traced" is a temporary variable used to calculate
"camera_move_to" is the radius at which the camera needs to move to from it's current distance from the player

The code will give you the variable "camera_move_to", which is the distance/radius the camera needs to be from the player in order to avoid collision.

[see first post above]
Posted By: Orange Brat

Re: Slightly improved Zelda code - 12/22/04 20:41

I'll try to crack this code today or over the next couple. I'm in the middle of learning Wintermute Engine and reorganizing my own game, so my time has been stolen from me at knife point.

Quote:

What do you mean by that I should try and eliminate clipping when the camera tilts? Do you mean that if the camera height changes during gameplay to stop the camera passing through a roof etc?





Well, whenever I was playing around with Doug's new template chase cam, it would work out pretty well, but then when I tilted the camera up or down(looking up/down...mouse_force.y != 0) the thing would always clip like crazy. It's esp. bad when you're looking up into the sky. If you hit the wall when the camera is around eye level it's pretty darn good, however that only occurs when the "smoothing" variable is set to default or right around there. You can still break it but it's good most of the time(which of course is unacceptable ). If you set the smoothing to 0(which I prefer) it'll kind of snap to the trace target(or perhaps this is the vec_normalize part) and then clip(but just barely and at eye level..also clips bad when looking up).

Here's my new template test level. If your "template_6" folder is in the default folder(C:\\Program Files\\GStudio6\\template_6), it shouldn't give you any trouble. I think the ones provided are the newest, but I'm not 100% sure.

http://www.geocities.com/hainesrs/tester.zip

Stand next to a wall and try different camera heights. You'll notice tilting up is worse than eye level or looking down.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/24/04 11:35

Got ledge climbing and ladder climbing working quite good (not animated though). If you jump or fall and you are near a ledge you will grab onto it. You can move side to side, climb up or fall down. You can also program the scipt to only grab onto ledges with certain textures. The ladder climbing is only up and down (not side to side). Once I've finished combat I will post code.
Posted By: Firestorm

Re: Slightly improved Zelda code - 12/24/04 13:36

"Did you ever know that you're my hero?"
Posted By: Josh666

Re: Slightly improved Zelda code - 12/24/04 14:16

Well, he sure is everything i'd like to be...
Posted By: Iglarion

Re: Slightly improved Zelda code - 12/24/04 20:51

This sound great! I can't wait.
Posted By: old_bill

Re: Slightly improved Zelda code - 12/25/04 09:17

Very nice contribution!
5 stars are yours!

And if you need some webspace to put the file up, contact me, thats no problem!

old_bill
Posted By: Josh666

Re: Slightly improved Zelda code - 12/25/04 20:28

I got some serious errors happening when i tryed to use this
Posted By: old_bill

Re: Slightly improved Zelda code - 12/26/04 00:16

Which one?
I just had to move function scan_event{} over the action player_action{] and now it works!

old_bill
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/26/04 08:34

Just put this at the top of your code:

function scan_event;
Posted By: Josh666

Re: Slightly improved Zelda code - 12/26/04 11:12

I've got no freaking idea what i'm doing when it comes to scripting...
and... i think i've just butchered the script trying to get it to work...

Is it possable for someone to post the script that has already had the above function moved...
I've tryed a few times already, and i'm still getting errors...
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/26/04 12:35

Copy the original script. Put this "function scan_event;" at the top.

Also, post the errors you are getting. I have no idea how to begin to fix your problems unless you post the errors.
Posted By: Josh666

Re: Slightly improved Zelda code - 12/26/04 13:10

AH, ok..

heh.. my bad.... bad cut/paste job... thanks for tolerating my dumbness..
and for the script..
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/26/04 16:13

A problem you might find with the lock on code is that if there is more than one lock on object in range, if you press right click you might not lock on to the closest object.

To rectify this, find this code:

temp.pan = 360;
temp.tilt = 50;
temp.z = lockon_min;
scan_entity (my.x, temp);

and place it before "IF (locked_on == 0) {" instead of after.
Posted By: CD_saber

Re: Slightly improved Zelda code - 12/26/04 23:54

Hello AccessPhenomenon

i've sent you a private message... !
Posted By: Rauschmittel

Re: Slightly improved Zelda code - 11/06/05 11:22

Hi
First - Sorry for my bad english, but I stil working on it!

I work on a Zelda like Adventure and tried to download tester.zip and tester2.zip, but the File is down for month! It would be nice if someone could give me the files.

Thanks a lot
Timo
Posted By: JetpackMonkey

Re: Slightly improved Zelda code - 11/06/05 15:44

Here here

Any chance it can be posted again? Sounds great!

I was looking thru Grimber's mega packs to see if it had been added there, but no dice!
Posted By: Towelie

Re: Slightly improved Zelda code - 11/07/05 02:29

How do I implement this into a game? Say, I want to make a small test, and I download this, make my models with all the required animations, then what do I do?Use templates or what?

Sorry, heads still in a gutter.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 11/08/05 08:25

Dang I don't even have the demo for it. If you follow the instructions I posted at the top, it should be as simple as adding the actions and functions to code, then assigning the action to the guard model, it'd work with any model I suppose, but I made it to work with the guard models animations. Perhaps PM Orange and see what's happening.

I actually used this code for Access Phenomenon title, I've built on it dramatically since this post and fixed lots of bugs. You could always look at the Access Phenomenon code, try and learn from it or reference from it, but it's 1000s of lines of code like just for the player movement, it's pretty messy and complex, if you're a good enough programmer to understand my code then you could probably code it all yourself anyway :P
Posted By: JetpackMonkey

Re: Slightly improved Zelda code - 11/15/05 19:47

This code rocks! Thanks for sharing it! This is by far my favorite movement code for 3DGS now. Exactly what I was looking for!

I have a problem though, when I press A or D, the character runs right or left properly. BUT when I press W or S, the character runs way too slow, as if the force were 1/20th of that for A or D.

Any ideas?

Best wishes
Posted By: DCorwin

Re: Slightly improved Zelda code - 11/15/05 20:46

Are there certain template scripts that have to be included to get this to run? I'm having lots of errors implementing. Two things kind of helped, moving scan_even to top of script and putting the DEFINE animdist above the player action. But I still get errors after that, mainly dist_planar is unknown.

Thanks
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 11/15/05 23:21

Quote:

Are there certain template scripts that have to be included to get this to run? I'm having lots of errors implementing. Two things kind of helped, moving scan_even to top of script and putting the DEFINE animdist above the player action. But I still get errors after that, mainly dist_planar is unknown.

Thanks



Dang. You might have already checked this but is dist_planar defined as a variable at the top of your code, and is it spelt correctly? that's the only reason I'd know to get that error :S
Posted By: DCorwin

Re: Slightly improved Zelda code - 11/15/05 23:42

I'm afraid it's there, so that's not the problem. I'm sure it's something really simple and I'm just missing a key requirement. Here's what I'm doing:
Make a super simple room
Load a model
Start a basic script that loads the level
Attach the zelda script Player_action to one model
Posted By: JetpackMonkey

Re: Slightly improved Zelda code - 11/16/05 04:10

Great! Fixed the slow forward / backwards velocity problem by substituting
150 for the 10 here in these lines

IF (key_w == 1){
center.x += 10 * cos(cter);
center.y += 10 * sin(cter);
......
IF (key_s == 1){
center.x -= 10 * cos(cter);
center.y -= 10 * sin(cter);

I can't wait to try the ledge and ladder code. Only other problem (and it's CONITEC'S problem) is now my character goes thru the terrain. I think I can set it by tweaking the hull collision stuff but *man* I wish Conitec would fix terrain collision! arrrgh. I hope this will be in the next A6 rev.

Now I need to figure out how to increase the 'gravity' in this code, so when my charcter jumps, she falls at a good speed. I'm definitely going to use this as my primary movement code in my sleepy sushi service game.

Best wishes
Bonanza
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 11/16/05 06:37

(@ Bonanza) Walking on Terrain should work, if not then it has something to do with my trace instruction for gravity, the camera should also collide with terrain, if it doesn't then something needs changing in the trace that is hitting the terrain, usually a trace_mode issue.

If you wish to implement the ledge and ladder code, it works in this code, but it's not refined, kinda buggy, it's moreso a base idea to build something upon. I highly suggest looking through the code of the Access Phenomenon Demo, and using that as reference to refining it. As the player movement code in that game is built upon this code.

(@ DCorwin) That's really really weird, so you're just adding my code above, copying it directly into some script, making sure the scan_event function is moved or defined at the top, then just adding the action to an entity? Can you post word for word how the error appears when you try and run your level? Does it display the line number the error is on? Something else you probably know, but is the variable defined before the action "player_action" (ie above the action in the code)?

300th post! I am a Man now
Posted By: DCorwin

Re: Slightly improved Zelda code - 11/16/05 06:46

Yup, I've done all of the above. The error is:
zelda_code.wdl 2:0 Error(29) Keyword unknown

<(abs(dist_planar-camera_move_to)<20)>
243:0 error 63, Parameter unknown dist_planar
<cradius_speed=-0.25....
244:0 error 63, Parameter unknown dist_planar

<ELSE {>
245:0 Error 19, Parameter unknown ELSE bad keyword in {}
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 11/16/05 10:00

Ahh okay, the error has to do with the first line I think, what tends to happen, if one line has an issue, lines below it will appear as errors even if they are okay. Somewhere in your code is the line "zelda_code.wdl" and I'm assuming the engine doesn't like it, syntax error or whatever.
Posted By: DCorwin

Re: Slightly improved Zelda code - 11/16/05 20:51

Hah! It was the ----------------------------------- I copied from your code!
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 11/16/05 23:51

LOL, only if at the time I was aware of the Code:
 tags I could have used :P
Posted By: JetpackMonkey

Re: Slightly improved Zelda code - 11/24/05 10:46

Hello!

AP, the code is excellent.

I have only one problem. Maybe someone can help me out?

When my player lands, after a jump, she sinks thru the terrain just down to her ankles. An eighth of a second later, A6 pushes her up so her feet touch the ground.

I've also seen the same phenomenon using the old A5 player_move code (which used to drive me bonkers)

Any ideas?

Thanks again for sharing your awesome code!
Bonanza
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 11/24/05 22:41

Oh yeah, the good ol bobbing in the ground.

Try this ides, just say the player is falling, the trace is returning a value > 0, do an if statement that says, while the player is falling, check to see if result > 0, the moment that result < 0, make player.z = result; (check and do this before the next wait instruction), so that the player's z does not drop below the result value. The other thing I did, if I were moving the player's z based on a force and velocity vector, then the moment result is say < 2, I set the falling velocity to 0, to dramatically decrease the bobbing. I think that's what I did anyway :P
Posted By: Nadester

Re: Slightly improved Zelda code - 11/25/05 01:00

Quote:

When my player lands, after a jump, she sinks thru the terrain just down to her ankles. An eighth of a second later, A6 pushes her up so her feet touch the ground.



The same problem is in the Access Phenomenon demo.
Posted By: testDummy

Re: Slightly improved Zelda code - 11/25/05 07:54

Quote:

LOL, only if at the time I was aware of the Code:
 tags I could have used :P 





While, certainly such programs are already available elsewhere, for fun, after noting the great length of + the lack of indentation in the source code at the beginning of this thread, I quickly wrote a simple, small "Tabinator" program that puts the tabs/indentation back in, or corrects the tabs/identation in, source code. In other words, because I automated a code indentation process, I have the source code from the beginning of the thread with proper indentation. I would post the indented version here, but, because of the large size of the "code" font, it would cause other text in the thread to "run off the page", and I doubt that there is actually any real desire for the properly indented version. If I am wrong, and there is some demand for the version with proper indentation, if enough request it, I may post it in an alternate thread.
Posted By: koen

Re: Slightly improved Zelda code - 11/26/05 17:27

Sorry AccessPhenomenon, i cannot test ur code for this error:

var temp2[6];
103:5 Error(): Twice defined temp2

my.animdist=0
498:0 Error(50): Parameter unknown animdist Parameter

ent_cycle(@2,myanimdist)
572:0 Error(50): Parameter unknown animdist Parameter

my.animdist+9*time
573:0 Error(50): Parameter unknown animdist Parameter

i'm not a writer and i cannot resolve the problem....
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 11/27/05 00:57

Quote:

Sorry AccessPhenomenon, i cannot test ur code for this error:

var temp2[6];
103:5 Error(): Twice defined temp2

my.animdist=0
498:0 Error(50): Parameter unknown animdist Parameter

ent_cycle(@2,myanimdist)
572:0 Error(50): Parameter unknown animdist Parameter

my.animdist+9*time
573:0 Error(50): Parameter unknown animdist Parameter

i'm not a writer and i cannot resolve the problem....




Do you have the following line at the top of the code:

DEFINE animdist,skill20;

Is the variable temp2 being defined more than once?
Posted By: koen

Re: Slightly improved Zelda code - 11/27/05 02:12

yes i have DEFINE animdist,skill20; at the top

i have find in line 104 var temp2[6]; and line 309 var temp2[3];
if i write // in line 104 i dont have this 103:5 Error(): Twice defined temp2

but there is animdist error
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/01/05 06:11

Quote:

Quote:

When my player lands, after a jump, she sinks thru the terrain just down to her ankles. An eighth of a second later, A6 pushes her up so her feet touch the ground.



The same problem is in the Access Phenomenon demo.



Hooah! I just fixed this now, stopped the player from bobbing. After the move instruction, I did another trace to the ground and simply added this instruction:

IF (result < 0) { my.z -= result; my.skill13 = 0; z_force = 0; jump_z = 0; }

skill13, z_force, and jump_z all being the velocity/force vectors that just needed stopping
Posted By: IDontLikeSoccer

Re: Slightly improved Zelda code - 12/01/05 14:03

Wooah! Cool, master Axys! I will testing this now - thank you very much!
Posted By: gedimaster

Re: Slightly improved Zelda code - 12/05/05 09:54

hi,

can someone send me the .zip file? the link is dead and i'd really like to test out the camera script. i'm using a6 pro.

thanks a lot!
Posted By: darkstein

Re: Slightly improved Zelda code - 12/05/05 15:28

does someone have te complete working code for download
Posted By: SusanJ

Re: Slightly improved Zelda code - 12/05/05 17:08

I'm sure this code is really awsome from what people have been saying but I have only 1 problem. When I run the script all I get is a black screen. I dont get any errors just a black screen with nothing on it. I made a big box and placed a character inside it then gave it the player_move action, saved it and built it but all i get is a black screen.

Am i missing something? :S
Posted By: darkstein

Re: Slightly improved Zelda code - 12/05/05 18:44

did you make the block hollow
Posted By: SusanJ

Re: Slightly improved Zelda code - 12/05/05 20:45

yes the block was hollow, it worked fine with the template scripts but i just get a black screen when i use this script for some reason.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/06/05 01:41

Here's the download:

www.accessphenomenon.com/zelda.zip

If you read this, this demo has a better camera than the code I've actually posted in this thread. The camera in this demo is the same as the Axys camera, it will not clip! Download this file and enjoy the camera
Posted By: SusanJ

Re: Slightly improved Zelda code - 12/06/05 18:37

Excellent!

This code is fantastic. An excellent start for someone who wants to make a 3D platform game or of sorts. I'm all excited now .

AxysPhenomenon your phenominal. Thanks for the demo, i couldnt have seen this in action without it. Thanks xx.
Posted By: koen

Re: Slightly improved Zelda code - 12/08/05 16:52

very thx AxysPhenomenon! now it's work very fine
Posted By: darkstein

Re: Slightly improved Zelda code - 12/11/05 16:18

i can compile the script it give a error: parameters unknown shadow stencil
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/12/05 03:35

Quote:

i can compile the script it give a error: parameters unknown shadow stencil



You using A5? Just comment out the line regarding shadow_stencil in the main function, it's not needed there anyway :P
Posted By: JetpackMonkey

Re: Slightly improved Zelda code - 12/13/05 18:03

wow this just gets better and better, Axys!

Thanks a ton, I really like this version, it seems to be improved from the code you pasted earlier (or is that my imagination?)

Is there any way to put a slight padding/gentle delay on the camera to make it a little more flowy?

Thanks a ton for this code, it's sorely needed. If Conitec claims to have 'click together' games, it's silly that they have never provided platformer type code like this...

best wishes
bonanza
Posted By: darkstein

Re: Slightly improved Zelda code - 12/13/05 18:39

no i use a6 and it stil gives the error
Posted By: mo1e

Re: Slightly improved Zelda code - 12/16/05 21:57

i have tried to use this code in my game and all i get is a black screen when i run my level anyone know why?
Posted By: Pappenheimer

Re: Slightly improved Zelda code - 12/16/05 22:24

Quote:

i can compile the script it give a error: parameters unknown shadow stencil




Uncomment or delete this line:

shadow_stencil = 0; //stops shadow stencil effect, it seriously eats at FPS

Probably your version is lower than commercial, than it doesn't support stencel shadows...?
Posted By: Pappenheimer

Re: Slightly improved Zelda code - 12/16/05 22:26

Quote:

i have tried to use this code in my game and all i get is a black screen when i run my level anyone know why?




Did the demo work for you? If so, there must something wrong in the code that your additional codings.
Posted By: mo1e

Re: Slightly improved Zelda code - 12/16/05 22:27

what demo?
Posted By: Pappenheimer

Re: Slightly improved Zelda code - 12/16/05 22:30

Quote:

what demo?



Quote:

AxysPhenomenon
Senior Member
****

Reged: Nov 23 2004
Posts: 327
Loc: Australia

Re: Slightly improved Zelda code [Re: koen]
#598671 - Tue Dec 06 2005 02:41 AM



Here's the download:

www.accessphenomenon.com/zelda.zip

If you read this, this demo has a better camera than the code I've actually posted in this thread. The camera in this demo is the same as the Axys camera, it will not clip! Download this file and enjoy the camera

Edited by AxysPhenomenon (Tue Dec 06 2005 04:20 AM)



Posted By: mo1e

Re: Slightly improved Zelda code - 12/16/05 22:38

thanks lol never saw this
Posted By: mo1e

Re: Slightly improved Zelda code - 12/16/05 22:43

the demo works just the script doesnt work in my game lol
Posted By: Pappenheimer

Re: Slightly improved Zelda code - 12/17/05 22:00

I had a closer look at your demo and your code.

I'm quite impressed, I'm walking through the level, move the camera, added a block with flag one set to test the ladder code. I walking, jumping, climbing up and enjoy the feeling of a level of Zelda.

It is a great standalone code of thousand lines, easy to use and to understand, and probably easy to adjust and to expand...

A marvelous contribution! Thank you very much!
Posted By: Loopix

Re: Slightly improved Zelda code - 12/18/05 07:10

This is indeed an awesome contibution...very non-coder user friendly. You should consider to work out a new template set for conitec Thanks a lot and keep up the good work!
Posted By: darkstein

Re: Slightly improved Zelda code - 12/18/05 14:41

the script doesent work i my game??
Posted By: Pappenheimer

Re: Slightly improved Zelda code - 12/18/05 19:23

Sorry, darkstein, what shall we answer?

You don't give any hint, any error message that we can analyse, nothing!

Do you expect that we know why it doesn't work in your game from the mere nothing that you give us as information?

Are you german? Then post your questions in german, if it is to difficult for you to explain your problem in english.

For example, some informations that you should give:

Which script or part of script from which version of the demo?
How did you integrate the script in your game?
What is the behaviour of your game, and what error messages do you get?
...
Posted By: darkstein

Re: Slightly improved Zelda code - 12/21/05 12:54

the error i get is:

< var temp2{6};
start.wdl 43:5 Error (): Twice defined temp2

i'm making an adventure
i include it in my main script
Posted By: Pappenheimer

Re: Slightly improved Zelda code - 12/21/05 21:05

Quote:

the error i get is:

< var temp2{6};
start.wdl 43:5 Error (): Twice defined temp2

i'm making an adventure
i include it in my main script




"twice defined temp2" means that in your wdls "var temp2" appears two times! You have to erase one of them. And then you have to try wether it works. Otherwise undo the erase, and erase the other one instead!
Probably one time in Accys' code and one time in the other scripts that you use.
If you work with the script editor you can use the search option "find texts in files" (icon: spyglass with folder)!
Posted By: KoH

Re: Slightly improved Zelda code - 12/24/05 11:08

Very good code. Although I have no imediate use for it, it is still fun to play with. With a few modifications it could be made better. For example: rotating the camera while moving. Also, sideways climbing on things like wire fences where this would be apropriate.
Posted By: darkstein

Re: Slightly improved Zelda code - 12/24/05 16:38

when i use this code i cant pick up any gun??
Posted By: Pappenheimer

Re: Slightly improved Zelda code - 12/25/05 20:13

Nope! Not with a bit of programming!

That's the thing about coding: if you use too different scripts with the same entiy involved, and they have not been programed for the explicit purpose to work together in the wished ombination (like the templates), than you have to take a look into both scripts, understand how each is prgramed, have to make a concept how you combine them, and have to add some lines of code to make them fitting together.
And often this is very complicating.

I think the zelda code is quite easy to be combined with other code, while I have experienced that the code of the templates can not be combined easely with other codes.
Posted By: laethyn

Re: Slightly improved Zelda code - 12/26/05 19:02

Thanks, gave me the idea for a solution to a 3rd person camera that will not clip

let me know what you think about the feasability of this solution:

A mdl cone tipped on it's side, the point of this cone will be set to the .x, .y, and .z of the player. The camera .x, .y and .z location will be set to the base of the cone (ie the wide round part).

To tip and rotate the camera is a simple matter of changing the tile and pan of the cone mdl, and of course, the mdl will collide and glide along anything within the map.

Now I just need to build it .... lol

Also, a custom system would allow, perhaps, a setting which allows the camera to get through certain objects, and set their transparency (perhaps trees, NPCs, etc). Anyways, just an idea.
Posted By: KoH

Re: Slightly improved Zelda code - 12/26/05 19:40

I don't know how to implement it, but if it is possible it sounds good.
Posted By: draculaFactory

Re: Slightly improved Zelda code - 02/03/06 00:43

Omg! I love you! LOL.
Posted By: molotov

Re: Slightly improved Zelda code - 04/17/06 15:20

Thanks, I'm using the improved Zelda code and its really great. But I'm having a problem with the animation part, the climbing and ledge animation are already created but the problem is that I can't make my "pulling up the ledge animation" work. Is there somebody that has a perfectly working animation for the "pulling up part" and is willing to share it?

Thanks anyway for the great Zelda code, I love working with it.
Posted By: darkstein

Re: Slightly improved Zelda code - 04/17/06 16:35

coulde someone edit the acttack in this code so that the player shoots fireballs
Posted By: molotov

Re: Slightly improved Zelda code - 04/21/06 15:32

Can someone help me? When I apply the improved zelda code and do a running jump against a wall with a ledge on top and jump a little higher than the ledge, my player gets stuck on the wall and doesn't fall down and graps the ledge.

Hope someone can help me,
Posted By: kasimir

Re: Slightly improved Zelda code - 04/23/06 13:33

I like this code - it works quite easy, but i miss something: one ramp/ascent is to hight - the player can walk up this ramp without no problems. I think that should be corected to limit this!

Greetings Kasimir
Posted By: gamespider

Re: Slightly improved Zelda code - 04/27/06 07:11

some problems...............

1.)the ladder climbing script. When the player is down, he can grab the ladder and climb upwards and downwards. But when I approach the ladder from the top, the player doesnt grab the ladder and simply falls down. Anyone know what Im talking about?

2.)Ive found that the first set of trace instructions in if(movement_mode == 3) have no use and the script works fine even if I comment it.

3.)instructions in the if(movement_mode==2) and if (movement_mode==12) branches are IDENTICAL.
Posted By: gamespider

Re: Slightly improved Zelda code - 04/27/06 07:16

sorry for double posting..... just remembered...

The following code in the first if(movement_mode==0) branch:

IF (z_force < -2) { //are we falling?

vec_set(temp,my.x); //scan in front of player to see if he has hit a wall
temp.x += 30 * cos(my.pan);
temp.y += 30 * sin(my.pan);
temp.z = my.z + player_head_height; //scan at head height
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(my.x,temp);
IF(result == 0) {
ledge_grab_test = 0;
} ELSE {
IF (result > 0) && (ledge_grab_test == 0) {
vec_to_angle(temp,normal.x);
IF (abs(ang(my.pan - (temp.pan - 180))) < 30) {
temp2.pan = (temp.pan - 180); //make player face towards ladder
vec_set(temp,target.x); //scan to see if there is space up above player for it to grab onto ledge
temp.x += 10 * cos(temp2.pan);
temp.y += 10 * sin(temp2.pan);
temp.z += player_head_height - 2; //scan at head height
target.z += 10;
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(temp.x,target.x);
// vec_to_angle(temp,target.x);
IF (result > 0) { //if we have a wall in the way, and the surface above is less than a 10 degree slant
vec_set(temp,my.x); //scan to see if there is space up above player for it to grab onto ledge
temp.z += player_head_height - 2; //scan at head height
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(temp.x,target.x);
IF (result == 0) { //scan above head to make sure we didn't hit a roof
ledge_grab_test = 1;
movement_mode = 10;
my.pan = temp2.pan; //make player face towards ladder
}
}
}
}
}


can be safely replaced by the following with NO problems at all. tested it out myself.... Asu can see, the code is much shorter and easier to execute...

IF (z_force < -2) { //are we falling?

vec_set(temp, my.x);//trace straight from belly
temp.x += 30 * cos(my.pan);
temp.y += 30 * sin(my.pan);
temp.z += 30;
vec_set(temp3, my.x);
temp3.z += 30;
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(temp3, temp);
if(result> 0 && ledge_grab_test == 0)
{
//IF (abs(ang(my.pan - (temp.pan - 180))) < 30)
//{
vec_to_angle(temp,normal.x);
temp2.pan = (temp.pan - 180);
vec_set(temp, my.x);
temp.z += 42;
vec_set(temp3.x, my.x);
temp3.z += 42;
temp3.x += 30 * cos(my.pan);
temp3.y += 30 * sin(my.pan);
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(temp, temp3);
if(result ==0)
{
vec_set(temp,my.x); //scan to see if there is space up above player for it to grab onto ledge
temp.z += 50; //scan at head height
trace_mode = ignore_me+ignore_sprites+ignore_models;
result = trace(temp.x,target.x);
if(result == 0)
{
ledge_grab_test = 1;
movement_mode = 10;
//move_vec.z =0;
my.pan = temp2.pan; //make player face towards ladder
}






}
}

//IF (abs(ang(my.pan - (temp.pan - 180))) < 30)
//}
else
{
ledge_grab_test = 0;
}

}
else
{
ledge_grab_test = 0;
}
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 04/27/06 13:18

Gamespider! Really good cleaning up of the code. It is quite messy and buggy, it was my first attempt at a movement script like that.

The difference between:
if(movement_mode==2) and if (movement_mode==12)

I think I used one for climbing up when you were at the top of a ladder and the other was for climbing up if you had grabbed onto a ledge, as there may have been slightly different behaviour and different code for each if statement.

The (movement_mode == 3), I think I added that to stop the player getting stuck in certain circumstances or just so it can work in with whatever animation may be used. I think it was meant to move the player forward when it nears the top of pulling itself up onto a ledge.

But if you can understand this code, how it is working, and be able to clean it up like that, you are on your way to doing some great stuff. Soon you'll be making code alot better than that 8)
Posted By: Serlink

Re: Slightly improved Zelda code - 04/28/06 01:33

Quote:

Finally found some time to test this out. Nice work. Everyone's after a demo...here the script applied in my old new templates tester level:

http://www.geocities.com/hainesrs/tester2.zip




Anyone have this test level??? or any test level using this code?
If so can you post it again?
The camara code and me are not getting along, I wish I could hack Keith Blount fighting cam in to this code. I've tryed but just cannt get it to work.
Thanks
Sam
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 04/28/06 03:29

It's here:

Zelda Code Implemented

But I'm not planning on renewing my subscription to that URL when the time comes next month, so that link wont be active for long, if it's still in demand afterwards perhaps I'll upload it elsewhere.
Posted By: Orange Brat

Re: Slightly improved Zelda code - 04/28/06 05:54

Just to eliminate the pending wave of confusion:

http://www.accessphenomenon.com/zelda.zip

I'll see about re-uploading my original test zip once I sort some stuff out. I don't know why I deleted it...all of the other various tester levels seem to still be there.
Posted By: gamespider

Re: Slightly improved Zelda code - 04/28/06 06:00

It was really nothing. what i did was to trace straight from 30 quant above the player origin. If ithit a wall, the code traces straight from 42 quants above the origin. If it hits nothing, the player grabs the ledge....

therefore it grabs a ledge if there is a wall below a certain point and no wall above it....a characteristic property of a ledge...

@ axys,
I did not say that there was anything wrong with the (movement_mode == 3) branch. It is absolutely necessary tostop the player getting stuck.What i said was that the first set of trace instructions in (movement_mode == 3) branch is unnecessary

However, That still doesnt aanswer my first question.....
1. What about grabbing a ladder from the top???
Posted By: BlueBeast

Re: Slightly improved Zelda code - 04/28/06 06:32

I'd like to jump in too... it was only mentioned briefly, but what about jumping? Is the jumping pretty good?

My jump will land me on the next block above me if there is one... technically, I could ascend a 10 story bulding from the inside, 1 floor at a time, just by jumping... but then, this was a simple 'lets see what it does' code.. so how is the jumping in the Zelda code?
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 04/28/06 06:48

I'm not too sure about grabbing a ledge from the top, can you walk backwards off a ladder's top and grab it as you fall? Can you jump up to a ladder and grab onto it mid air? I can't remember if I set it up so that you can only use a ladder if you are on the ground or not. As to how you'd get that to work, allow the player to grab onto the ladder even if he is airborne, that might work. I think that the ultimate way to get ladders working the best, is to have trigger areas where if the player enters it, ie walks to the top of a ladder, he automatically climbs onto it, it may be tricky to program.

@BlueBeast
I'd say the jumping is average, not the best, the jumping height changes slightly when the frame rate is low, which is a bit annoying, and you can bob in the ground and stuff when you land, otherwise it works pretty cool, the animations with the jumping are good.
Posted By: gamespider

Re: Slightly improved Zelda code - 04/28/06 07:26

Nope tried out everything..
The player doesnt grab the ladder by walking backwards....

I will try toget it working as soon as possible.
Posted By: Serlink

Re: Slightly improved Zelda code - 04/28/06 12:05

Quote:


I'll see about re-uploading my original test zip once I sort some stuff out. I don't know why I deleted it...all of the other various tester levels seem to still be there.




yes please upload. like to see more test with this code. I got an enemy fighting back but player is having some problems, i'll work on that tonight
thanks
Sam
ps I have been useing the Serlink name ever since Zelda first came out, God that was a long time a go.
Posted By: gamespider

Re: Slightly improved Zelda code - 05/01/06 11:54

Got it fixed!

Just do a trace as usual to see if the player has ladder in front. If trace finds ladder, go as usual. Then trace down for the same thing. If a block with the ladder flag set exists below the player, make him grab the ladder by changing his z position along with reqd animations for ladder grabbing. after the anim's completed, set movement_mode = 1 for ladder movement...

my home internet broke down. Im browsing from a cafe. So I dont have the file right now. Will post as soon as possible....
Posted By: spazle

Re: Slightly improved Zelda code - 05/03/06 11:20

hai Guy's

First, Access, Thanks for contributing this for us, it is a great script!

Second: Iam going to use this script for a game Iam making. Is there a simple way to adjust the script so the Lock-on function is always on, without holding the right mousebutton. I want my player to strafe all the time and with mouse_y movements it'll rotate the player. Like in the Acces Phenomenon demo. Ive compaired the Access Phenomenon script with the zelda script, but I don't know what to modify.

Someone can help me a hand?
(I hope Ive explained my question just right..)

Thanx in advance
Spazle
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 05/04/06 12:40

I think I did it a sneaky way in the AP demo, simply put:

mouse_right = 1;

somewhere at the top of the script, that way it is like holding down the right mouse button all the time. But then I think I wanted to use the mouse_right button in other ways so I ended up storing mouse_right value in another variable before setting it to 1.
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/04/06 14:48

..how should i use this code?.. ^_^..this code is exactly what im looking for.any step by step tutorials on how to use this,mr.AP?or maybe the latest example file for this?
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 05/05/06 07:53

Quote:

..how should i use this code?.. ^_^..this code is exactly what im looking for.any step by step tutorials on how to use this,mr.AP?or maybe the latest example file for this?



Look back through prevoius posts and find the download. It wont be up for long though, I'll have to reupload soon or something
Posted By: spazle

Re: Slightly improved Zelda code - 05/05/06 10:01

Hehe tnx,

thats a pretty sneaky way to handle it indeed, but works fine for me as I wasn't intend the use the right button anyway.

I think the camera code with al the non clipping and smooth movement is the best ever! However is there a way to modify it so I can use the mouse wheel (micky.z) to zoom in and out. So I can zoom trough the head and into the eyes of the player? (with all the smooth movement if possible?)

thanks again
spazle
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/05/06 10:31

Quote:

Quote:

..how should i use this code?.. ^_^..this code is exactly what im looking for.any step by step tutorials on how to use this,mr.AP?or maybe the latest example file for this?



Look back through prevoius posts and find the download. It wont be up for long though, I'll have to reupload soon or something



..yeah i think i found a link on the first page,but it's broken.anyway,
the camera's a little shaky when the player is jumping;and the transition between the animation frames are a bit fast,unlike the original code you have posted before you added the battle or something.
..enough comments. nice work,dude.for over a month i have searched for something like this;and finally i have found it.
any plans for:
attack combos?
attacking while jumping?
how bout a "hurt" animation state?
..more power!!
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 05/05/06 10:36

Change the dist_total variable (default 200) based on micky.z and the camera will zoom in and out.

The camera code is very good, it is also very small only 100 lines of code or something. I have Doug or Dan to thank for it (I'm not sure which one made the template scritps ). It was easy to get the camera not to clip but to get it to move smoothy was hard, I looked into the template 3rd person camera and the technique it uses is very nice, I think I commented about what happens in the pan_back() function.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 05/05/06 10:44

Hey AdrianX

Here's the link to the download:

http://www.accessphenomenon.com/zelda.zip

The camera in that download/demo is very different to the code I first posted but can't go back and edit The code for the camera in that demo is the same as the one I'm using in Axys. I'm gonna release a small Axys demo for the A6 contest this month so hopefully it'll be on Acknex Unlimited as a learning resource, the code will be viewable so if you ever get the time to scour through some 50,000 lines of code (10,000 in the player action wdl), you can see a very messy but excellent working movement script, that contains attack combos, attacking whilst jumping and a few cool hurt anims, where Axys kinda flies back onto the ground and flips up. You'll be able to fight enemies and stuff. You gotta see it to know how cool it is, but if I could do the whole thing over again I would make it as much like Zelda as I could, with a vast array of weapons and gadgets and a really cool character with tons of animations that could do a whole load of moves. It wont be code like this that can be copied and used freely in your own project unfortunately, but it'll be there to learn from and understand how to achieve a movement script like that.
Posted By: frazzle

Re: Slightly improved Zelda code - 05/05/06 10:52

WOW, some really incredible and mind stunning words I have
read there AxysPhenomenon, they gave my eyes serious eye cancer

I can't wait to try the zip file out... at home lol
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/05/06 12:31

..wow..and when will this contest be?..i can't wait!
keep up the good work!
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/05/06 13:37

..there seems to be a problem with the lock_on_object action.it can't be recognized by WED when i attach that action to a model.
..and oh,how can i add footstep sounds?
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 05/05/06 23:33

Adrian, there's several ways to do footstep sounds I'm sure you can find something like that in the AUM's or if you search the forums. One way to do it is just a matter of playing a sound when the animation value goes past a certain amount and setting a variable to stop the sound playing again unti the animation resets or something. Also details of that contest can be found in The Amazing AUM 56 of The Great George.

Screens of Axys:

http://www.churness.com/axys/Screenshots/AxysShotZ%20(3).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(6).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(15).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(61).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(83).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(88).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(120).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(122).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(142).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(149).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(174).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(202).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(216).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(224).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(248).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(252).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(258).jpg
http://www.churness.com/axys/Screenshots/AxysShotZ%20(1).jpg
Posted By: bupaje

Re: Slightly improved Zelda code - 05/05/06 23:39

@Axys Don't forget the official http://au.conitec.net/ if you want to load the file somewhere that will remain available.
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/06/06 00:41

..ok.my idea is to play the footstep sound every "x" frames or something like that..to tell you the truth im a total noob when it comes to C-script;so forgive me if i ask questions like that. ^_^'
..anyway,how bout the lock_on action?i attached that action to an entity and everytime i try to run the level a warning message pops up telling me that the game can't find the lock on action.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 05/06/06 01:04

Thanks Bupaje I've emailed Acknex the code.

@adrian - I don't know what is going on that is very weird with the lock_on_object() action, but I don't know if that is because I have changed some things in that demo rather than the initial code, but the lock on stuff wasn't actually refined or really worked on, it was a default thing I quickly threw together.
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/06/06 01:14

..but the player's basic attack will still work on enemies i created even if the lock code is not used,right?..okay,i think will not use the lock_on_object action for now.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 05/06/06 03:58

All the lock on code did was force the player to pan towards the closest enemy, it wasn't used for combat at all it was an attempt at implementing the Zelda lock on, the current lock on system doesn't work well at all imo, I should get twilight princess (when it comes out) and have a good look at the combat, camera and lock on features that has.
Posted By: Pappenheimer

Re: Slightly improved Zelda code - 05/07/06 09:02

Nice shots! The most colorful monsters I've seen!
Posted By: molotov

Re: Slightly improved Zelda code - 05/07/06 10:43

Hey, Adrian, Maybe I can help you with the lock_on code, because I've got it working after some initial problems. The things that are inportant are;
You have to put this line "function scan_event;" on top of your script.
Secondly you have to place the object( in wed) you want to lock on, after you place and assign the player action to a model. Otherwise the lock_on target won't regonise the player and you get a error. I think you can also solve this problem in your script with "prog_late", but I don't know for sure.
Hope this will help you.
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/07/06 14:07

..okay molotov,i'll try that out as soon as possible.
@axys ..holding down the control button or the left mouse button makes the player attack continuously;how can i make it so that the player only attack once even if the attack button is being held down?
..and is it intentional to make the attack animation start at the second or third frame and then cycle through the whole animation again?what i did was to change the line "my.animdist-=20*time" to my.animdist=0; in the function basic attack;the animiation started alright but the animation is too fast..
..and there's a bug (i think): jumping(or falling down) from a very high place and hitting the attack button while on the air will immediately pull the player to the ground where he's supposed to land..
..thanks in advance! ^_^
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/08/06 10:05

@molotov: it still didn't work..
..still have any ideas on how to make it work?
Posted By: molotov

Re: Slightly improved Zelda code - 05/08/06 15:04

Adrian, do you get a error message?, if so, what does it say.
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/08/06 23:07

..well,WED still can't recognize the lock_on_object action..it's something like "lock_on_object" action not found or something.
..anyway,you know how to stop the "autofiring" of the attack? (holding down the contol button makes the player attacking continuously.i want to make it so that the player must press the attack button again so to attack instead of just holding it down).
Posted By: Serlink

Re: Slightly improved Zelda code - 05/09/06 01:21

Maybe something like this:

while (key_whatever == 1) {wait (1);} // can't use autofire on a sword

Serlink
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/16/06 10:33

Quote:

Maybe something like this:

while (key_whatever == 1) {wait (1);} // can't use autofire on a sword

Serlink



..didn't work..or maybe i don't know where to put it..
Posted By: Inestical

Re: Slightly improved Zelda code - 05/16/06 15:09

if(key_whatever == 1)
{
while(key_whatever == 1){wait(1);}
...
}

like that
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/17/06 07:46

Quote:

if(key_whatever == 1)
{
while(key_whatever == 1){wait(1);}
...
}

like that



..still didn't work.all it did was keeping the player from attacking(freezing the animation) until i release the attack key..
Posted By: darkstein

Re: Slightly improved Zelda code - 05/17/06 08:08

could someone post a new version with al the updates from the forum
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 05/23/06 08:09

The code is now on Acknex Unlimited

http://coniroot.de/~pirvu/au/scripts/zeldacode.zip
Posted By: darkstein

Re: Slightly improved Zelda code - 05/23/06 09:50

is that with al the updates from the forum ?
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 05/23/06 11:05

It is the most updated version you can get of it. It is updated from the initial code posted in the first thread and has a better camera.
Posted By: AdrianX

Re: Slightly improved Zelda code - 05/24/06 09:33

..could you specify which parts you have updated?..but it's ok if you couldn't..i'll try to look for it myself.. ^_^
..thanks again for this code!
Posted By: djAMS

Re: Slightly improved Zelda code - 05/24/06 09:53

Kann mir jemand sagen wie ich die Kamera so einstelle das wenn ich die maus nach ober bewege die Kamera auch nach oben dreht ?

(kann kein english, musste mal deutsch reinlabern)
Posted By: Marky Mark

Re: Slightly improved Zelda code - 06/09/06 17:37

The links are not working for the demo level
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 06/09/06 22:54

Quote:

The links are not working for the demo level





Quote:

The code is now on Acknex Unlimited

http://coniroot.de/~pirvu/au/scripts/zeldacode.zip



Posted By: Why_Do_I_Die

Re: Slightly improved Zelda code - 06/10/06 05:54

had downloaded this some time ago but hadnt checked it out , messed around with it earlier today and have to say am VERY impressed , thnx a lot Axys , this is the type of code that should be included in the templates , not that cheap movement scripts made by the GameStudio staff that make the engine feel like a paper engine. Really liked the scripts , very very proffesional , love the animation blending , really looking forward to using these in a project i hope to work on in the near future.
Posted By: silencer

Re: Slightly improved Zelda code - 06/13/06 07:22

Has anyone converted this to c_trace successfully? I have tried but have gotten many errors. Any help would be appreciated!
Posted By: sPlKe

Re: Slightly improved Zelda code - 06/22/06 17:57

i would love a battle system update, with more combos in the basic attack and maybe a second attack that is slow but powerfull, attacking while jumping and loosing health when jumoping from too high^^...
Posted By: DoC

Re: Slightly improved Zelda code - 06/22/06 21:26

more important are enemys ^^
Posted By: sPlKe

Re: Slightly improved Zelda code - 06/22/06 21:41

yeah, that you can add your basic enemy script to the mix^^
Posted By: CD_saber

Re: Slightly improved Zelda code - 07/05/06 14:46

I managed to combine the zelda code with the swordfighting code from the AUM. The player now has an enemy and is able to die. Now I am working on different attacks. The problem is that the object lock does not work for the enemy (I don't know why) and that it has no gravity.

Does anyone want to have the code ?

Cheers, Tim
Posted By: Orange Brat

Re: Slightly improved Zelda code - 07/05/06 16:12

I can't recall if I've posted this in this thread, but this system have perfect wall clipping/collision. There's no clipping whatsoever; thus I'm going to try and integrate the method used in it in my pending re-release of my animation blending/3rd person camera suite package. If successfully, it will be the single greatest contribution I've ever made and possibly ever by anyone. Yes, I'm being a bit boasty, but the truth must be told.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 07/06/06 01:16

Quote:

but the truth must be told.



You're a 1337 3DGS coder, it's a fact as long as 3DGS remains in existantance! *hands Orange Brat 720,320 1337 3DGS points*

CD_sabre, the lock on system was never any good, it didn't work very well and wasn't really implemented...The code in general, as good as it works, has bad framework and isn't very flexible.
Posted By: Mysterious

Re: Slightly improved Zelda code - 07/09/06 07:09

Hey very NICE work

but may I ask you a question ...

I see in one of the zelda screenshot a sword blur ... can you help me ... I want to make some thing like that sword effect but I can't find a good way yet...

thanks and GOOOOOOOOOOOOOD job MAN

Mysterious
Posted By: Kotakide

Re: Slightly improved Zelda code - 07/14/06 03:13

Quote:


I see in one of the zelda screenshot a sword blur ... can you help me ...




I think, it's not a blur effect, but it's a sword swing effect, it's look like the sword just leave the trail behind it and the sword itself is not blur.
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 07/14/06 03:34

Quote:

Hey very NICE work

but may I ask you a question ...

I see in one of the zelda screenshot a sword blur ... can you help me ... I want to make some thing like that sword effect but I can't find a good way yet...

thanks and GOOOOOOOOOOOOOD job MAN

Mysterious



Thanks dude. Check this thread:
Sword effect
Posted By: gagamBRYAN

Re: Slightly improved Zelda code - 12/04/08 16:19

hi,
can anyone knows the updated link for this?.. im afraid that the links are broken.
thanks in advance! smile
Posted By: DavidLancaster

Re: Slightly improved Zelda code - 12/05/08 00:29

Woah you resurrected an ancient thread!!!!!

You're mostly on your own with this one, here is code from Axys for the sword swipe:

download Axys Minigame Bonanza from here:
http://au.conitec.net/

Look at the code and specifically find the function:

minisword_attach

swordstreak.mdl is your friend too.

Regards,

David
© 2024 lite-C Forums