Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,633 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Entity event #335215
07/27/10 09:49
07/27/10 09:49
Joined: Jul 2010
Posts: 32
E
EID Offline OP
Newbie
EID  Offline OP
Newbie
E

Joined: Jul 2010
Posts: 32
hey all;
all i need to know that how to activate the entity event to open the door that work with security card .i have to make the player picked up the security card and go toward the switch of the door and the switch will scan the palyer if he have the security card or not. now we have a global variable that name card_check it's set to zero and when it's equal the switch will open the door. and here is the 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 key_check=0;// global variable should be to set to ON when the key_pressed
var card_check=OFF;

/////////////////////////////////////////// DOOR SECTION ///////////////////////////////////////////////////
function entity()
{
if(event_type == EVENT_ENTITY)
{
card_check=ON;
my.z=60;

}
}
function detect()
{
if (event_type == EVENT_DETECT)
{
}
}
function scan()
{
if(card_check==ON)
{
var light_state=1000;
if (event_type == EVENT_SCAN && key_z)
{
camera.ambient = light_state;
key_check=OFF;
}
else if (event_type == EVENT_SCAN && key_f)
{
camera.ambient = -light_state;
}
if (event_type == EVENT_SCAN && key_o)
{
key_check=ON;
}
else if (event_type == EVENT_SCAN && key_c)
{
key_check=OFF;
}
}
}
action card()
{
entity;
}
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);
}
}
function main()
{
//video_mode = 7;
level_load ("exeperment.wmb");
wait (2); // wait until the level is loaded
}

Re: Entity event [Re: EID] #335216
07/27/10 09:49
07/27/10 09:49
Joined: Jul 2010
Posts: 32
E
EID Offline OP
Newbie
EID  Offline OP
Newbie
E

Joined: Jul 2010
Posts: 32
ahmed eid

Re: Entity event [Re: EID] #335224
07/27/10 10:31
07/27/10 10:31
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Dont spam here around. 3 Posts about the same problem!

Edit: 4 posts mad

Last edited by Widi; 07/27/10 10:33.
Re: Entity event [Re: Widi] #335280
07/27/10 16:22
07/27/10 16:22
Joined: Jul 2010
Posts: 32
E
EID Offline OP
Newbie
EID  Offline OP
Newbie
E

Joined: Jul 2010
Posts: 32
i am sorry it's my first post in the fourm .. at all thanks if u have any solution for the problem


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1