cannot get event_shoot

Posted By: CItrok

cannot get event_shoot - 02/07/10 22:22

I am not able to trigger the EVENT_SHOOT event.

I want to detect shoot event when moving "ent1" entity into "ent2", when supposedly the shoot event happen than a text is drawn.

Bellow is the code. What is wrong?

P.S. I will sugest 3gs team to improve the help. For the beginners is quite hard to get it fast and most of the example given in the manual are ambiguous whereas the examples given in the tutorial are clear so far as I'm concerned. What do you think about that?

///////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

ENTITY* ent1 = NULL;
ENTITY* ent2 = NULL;
ENTITY* ent3 = NULL;


function click_event1()
{


if(event_type == EVENT_SHOOT){
draw_text("Shoot event!!!",100,10,vector(255,255,255));
}
}

action cube1()
{
my.emask|=(ENABLE_SHOOT );
var i;var pos[3];
my.event = click_event1;

while (1)
{

if (key_s) c_move (my, vector(2*time_step , 0, 0), nullvector, ACTIVATE_SHOOT);
if (key_a) c_move (my, vector(-2*time_step , 0, 0), nullvector, ACTIVATE_SHOOT);

if (key_z) c_move (my, vector(0 , 2*time_step, 0), nullvector, ACTIVATE_SHOOT);
if (key_x) c_move (my, vector(0 , -2*time_step, 0), nullvector, ACTIVATE_SHOOT);

wait (1);
}
}


function main()
{
video_mode = 9;
ph_check_distance = 1;
mouse_mode = 2;
level_load ("work10.wmb");
vec_set(camera.x,vector(-550, -30, 100));

ent1=ent_create("modul2.mdl", vector(400, 300, -70), cube1);
c_setminmax(ent1);
set(ent1,POLYGON);

ent2=ent_create("baza.mdl", vector(-100, 300, -70), NULL);
c_setminmax(ent2);
set(ent2,POLYGON);

camera.pan = 0;


while(1)
{
camera.y -= (factor*joy_force.x);
camera.x += (factor*joy_force.y);
if (joy_4)camera.pan+=(0.3*factor);
if (joy_5)camera.pan-=(0.3*factor);
if (joy_3) camera.z += 1;
if (joy_2) camera.z -= 1;

if (joy_8) camera.tilt += (0.1*factor);
if (joy_9) camera.tilt -= (0.1*factor);


if (joy_1 && joy_2)
{

vec_set(camera.x,vector(-550, -30, 100));

}

mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;




wait(1);
}


}
Posted By: Aku_Aku

Re: cannot get event_shoot - 02/08/10 22:31

I would try to detect does any collision event happen?
Add the ENABLE_IMPACT and ENABLE_ENTITY attributes to one of your object.
Test the event with if(event_type == EVENT_IMPACT) and if(event_type == EVENT_BLOCK).

And last but not least, if you read the manual careful, you can see, the EVENT_SHOOT will be triggered by c_trace.
Posted By: CItrok

Re: cannot get event_shoot - 02/09/10 23:03

Thanks a lot Aku_Aku, I will consider your advices. Maybe I will solve it this week.
© 2024 lite-C Forums