hello ,
all i need to know how to activate a code for a security card that open the door , we have an global variable that name card_check when the player got the card the card_check flag will be ON else it's off . if the card_check is ON the switch of the will work it's C_scan .now how to the player pick up the security card by event entity that===> that what i need
and it's the simple code
//Actions library that contains some actions to be used in any game project
///////////////////////////////
#include <acknex.h>
#include <default.c>
#define ON 1
#define OFF 2
var card_check=OFF;
function entity()
{
if(event_type == EVENT_ENTITY)
{
card_check=ON;
}
}
function detect()
{
if (event_type == EVENT_DETECT)
{
}
}
function scan()
{
if(card_check==ON)
{
if (event_type == EVENT_SCAN && key_o)
{
key_check=ON;
}
else if (event_type == EVENT_SCAN && key_c)
{
key_check=OFF;
}
}
}
}
action card()
{
}
action switch_key()
{
var switch_scan_range = 80;
var switch_scan_cone_horizontal = 90;
var switch_scan_cone_vertical = 90;
my.emask |= ENABLE_DETECT;
my.event = detect;
while(1)
{
c_scan(my.x,my.pan,vector(switch_scan_cone_horizontal,switch_scan_cone_vertical,switch_scan_range),SCAN_ENTS | SCAN_LIMIT|IGNORE_ME);
wait(1);
}
}
action door()
{
var door_step=3;
var door_full_trip=200;
var counter=0;
var door_travelled_dist = 0.0;
while(1)
{
if( key_check==ON)
{
if (door_travelled_dist < door_full_trip)
{
door_travelled_dist += door_step*time_step;
my.z+=door_step*time_step;
}
else
{
my.z += door_full_trip -door_travelled_dist ;
door_travelled_dist = door_full_trip;
}
}
if(key_check ==OFF)
{
if (door_travelled_dist > 0)
{
door_travelled_dist -= door_step*time_step;
my.z-=door_step*time_step;
}
else
{
my.z -= -door_travelled_dist ;
door_travelled_dist = 0;
}
}
wait(1);
}
wait(1);
}
action Hero_Animation()
{
var walk_percentage;
var death_percentage;
var run_percentage;
var crouch_percentage;
var idle_percentage;
var crawl_percentage;
var jump_percentage;
var attack_percentage;
my.emask |= ENABLE_SCAN;
my.event = detect;
my.event = scan;
my.event = entity;
while (1)
{
ent_animate(my,"idle",idle_percentage, ANM_CYCLE); // "walk" animation loop
idle_percentage += 5 * time_step; // 3 = animation speed for "walk"
if (key_d)
{
my.pan += 10*time_step; // increase the pan angle of the car
}
if (key_a)
{
my.pan -= 10*time_step; // decrease the pan angle of the car
}
if(key_s)
{
c_move (me, vector(-5 * time_step,0, 0), nullvector, GLIDE);
ent_animate(my,"walk",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 5 * time_step; // 3 = animation speed for "walk"
}
if(key_w)
{
c_move (me, vector(15 * time_step, 0, 0), nullvector, GLIDE);
ent_animate(my,"walk",walk_percentage, ANM_CYCLE); // "walk" animation loop
walk_percentage += 10 * time_step; // 3 = animation speed for "walk"
wait (1);
}
if(key_shift && key_w)
{
c_move (me, vector(15 * time_step, 0, 0), nullvector, GLIDE);
ent_animate(my,"run",run_percentage, ANM_CYCLE); // "walk" animation loop
run_percentage += 5 * time_step; // 3 = animation speed for "walk"
}
if(key_ctrl)
{
ent_animate(my,"crouch",crouch_percentage, 0); // "walk" animation loop
}
if(key_n)
{
c_move (me, vector(2 * time_step, 0, 0), nullvector, GLIDE);
ent_animate(my,"crawl",crawl_percentage, ANM_CYCLE); // "walk" animation loop
crawl_percentage += 3.5 * time_step; // 3 = animation speed for "walk"
}
if(key_space)
{
ent_animate(my,"jump",jump_percentage, ANM_CYCLE); // "walk" animation loop
jump_percentage += 10 * time_step; // 3 = animation speed for "walk"
}
if(mouse_left)
{
ent_animate(my,"attack",attack_percentage, ANM_CYCLE); // "walk" animation loop
attack_percentage += 10 * time_step; // 3 = animation speed for "walk"
}
wait(1);
}
}