FONT* arial_font = "Arial#20b";
//ACTION TEXTS
STRING* Light_candle_str = "LIGHT CANDLE [HOLD ACTION]";
STRING* Light_torch_str = "LIGHT TORCH [HOLD ACTION]";
STRING* Keep_candle_lit_str = "KEEP CANDLE LIT [ACTION]";
STRING* AT_opencabinet = "OPEN CABINET [HOLD ACTION]";
STRING* AT_lockedcabinet = "THIS CABINET IS LOCKED, YOU DON'T HAVE THE KEY!";
//TEMP ACTION STR
STRING * action_str = "text";
TEXT* action_text =
{
font = arial_font;
string = action_str;
layer = 15;
flags = CENTER_X;
}
..........
action candle_stick(){
var light_snd_once = 0;
var lighting_snd;
var action_panel_trigger = 0;//triggers the Hold action panel
var wick_vec_num = 130;
if(my.skill3 == 0){wick_vec_num = 130;}
else{wick_vec_num = my.skill3;}
if(my.skill5 == 0){wick_vec_num = 130;}
else{wick_vec_num = my.skill5;}
// 130 is for a standard candle / wall candle
// 49 is for a skull candle
var light_displacement = 30;//how far from the fire is the light source?
var light_timer = 0;//how long has it taken to light the flame?
var light_time = 10;//how long it takes to light the flame
VECTOR wick_pos, temp_vec;
if(is(my,POLYGON)){set(my,POLYGON);}
else{set(my,PASSABLE);}
my.material = mtl_levelDefaultNM;
while(1){wait(1);
while(left_hand_slot == lighter_slot){wait(1);//if there is no lightsource then wait until there is one.
while(!fire_source){wait(1);}
if(is(my,FLAG6)){vec_set(wick_pos.x,vector(my.x,my.y,my.z));wick_pos.z += 125;}
else{vec_for_vertex(wick_pos,me,wick_vec_num);}//vector position in the modle
if (my.skill1==0) {//if im not lit
if(vec_dist(wick_pos.x,fire_source.x) <= source_min_dist && light_timer < light_time){
//.............................................
//action bar has been determined
//the player is now ready to follow instructions
if(is(action_text, SHOW)){//if the action key is on screen
if(action_keys==1){//if action keys have been pressed
if(light_snd_once == 0 && light_timer >= 6){lighting_snd=ent_playsound(me,candle_ignite_snd,100);light_snd_once = 1;}
light_timer += 0.5;//start the timer
//progress_bar_y = light_timer * 25;//calculations
progress_bar_y = floor(light_timer)*25;
set(progress_bar_pan,SHOW);//show the progressbar
}
else{//action has been released
snd_stop(lighting_snd);
light_snd_once = 0;
reset(progress_bar_pan,SHOW);//reset progress bar
light_timer = 0;//reset lighting time
}
}
//.............................................
//the action bar has not been determined yet
else{
action_panel_trigger = 1;//has been trigger to make sure action can be removed
if(is(my,FLAG7)==0 && is(my,FLAG6)==0){str_cpy(action_str, "LIGHT CANDLE [HOLD ACTION]");}
if(is(my,FLAG7)==1 || is(my,FLAG6)==1){str_cpy(action_str, "LIGHT TORCH [HOLD ACTION]");}
iconlist_x = 64;iconlist_y = 0;// set to lighter icon
set(action_text,SHOW);//show the action map
set(iconlist_pan,SHOW);//show the icon map
}
//.............................................
}//light source is close, lighting up
if(vec_dist(wick_pos.x,fire_source.x) > source_min_dist){//light source is not close enough
if(action_panel_trigger == 1){//if it hasn't been reset yet...
action_panel_trigger = 0;//reset it
reset(progress_bar_pan,SHOW);//remove these panels
reset(action_text,SHOW);
reset(iconlist_pan,SHOW);
}
light_timer = 0;
}
if(light_timer >= light_time){//if the light source has lit me up
reset(progress_bar_pan,SHOW);//remove these panels now
reset(action_text,SHOW);
reset(iconlist_pan,SHOW);
vec_set(temp_vec.x,wick_pos.x);//temp how holds the wicks location
//if the light is on the wall, then it needs to be moved away:
//FLAG8FLAG8FLAG8FLAG8FLAG8FLAG8FLAG8FLAG8FLAG8FLAG8FLAG8FLAG8
if(is(my,FLAG8)){//for wall lights only
temp_vec.x += light_displacement * cos(my.pan-90);
temp_vec.y += light_displacement * sin(my.pan-90);
}
//temp_vec.z += candle_light_height;//prepare to move the light upwards so its not pushing through the this model
if(is(my,FLAG6)){
candle_light_height = torch_height;
//temp_vec.z += candle_light_height;
you = ent_create("cube.mdl",temp_vec.x,floortorch_fire);
}//create the candles lightsource
else{
candle_light_height = candle_height;
temp_vec.z += candle_light_height;
if(is(my,FLAG7)){you = ent_create("cube.mdl",temp_vec.x,torch_fire);}//create the candles lightsource
else{you = ent_create("cube.mdl",temp_vec.x,candle_fire);}
}
you.skill1 = candle_max_light;
my.skill2 = handle(you);//the candles lightsource is now stored for using later
my.skill1=1;//I am now lit
light_timer = 0;//reset the light_timer for relighting
}
}
if(my.skill1 == 1){//if I am lit
you = ptr_for_handle(my.skill2);//I must be reminded you is the candles lightsource
if(you.skill1 > 85 && you.skill1 < 200){
if(vec_dist(wick_pos.x,fire_source.x) < source_min_dist){//if the light_source is close enough
if(is(action_text, SHOW)){//if the action key is on screen
if(action_keys==1){//if action keys have been pressed
you = ptr_for_handle(my.skill2);//I must be reminded you is the candles lightsource
you.skill1 = candle_max_light;
action_panel_trigger = 0;//reset it
reset(action_text,SHOW);//remove these panels
reset(iconlist_pan,SHOW);
}
}
//.............................................
//the action bar has not been determined yet
else{
action_panel_trigger = 1;//has been trigger to make sure action can be removed
str_cpy(action_str, "KEEP CANDLE LIT [ACTION]");
iconlist_x = 64;iconlist_y = 0;// set to lighter icon
set(action_text,SHOW);//show the action map
set(iconlist_pan,SHOW);//show the icon map
}
//.............................................
}
}
if(vec_dist(wick_pos.x,fire_source.x) > source_min_dist || you.skill1 < 81){//door is not close enough
if(action_panel_trigger == 1){//if it hasn't been reset yet...
action_panel_trigger = 0;//reset it
reset(action_text,SHOW);//remove these panels
reset(iconlist_pan,SHOW);
}
}
}
if(left_hand_slot != lighter_slot){reset(progress_bar_pan,SHOW);reset(action_text,SHOW);reset(iconlist_pan,SHOW);}
}
}
}