Skip to content

Commit

Permalink
Allow to actually put Enclave turrets into maintenance, preventing th…
Browse files Browse the repository at this point in the history
…em from any actions temporarily. Closes #189.
  • Loading branch information
burner1024 committed Mar 9, 2024
1 parent e4f4159 commit 9cbd6c9
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 56 deletions.
16 changes: 12 additions & 4 deletions scripts_src/enclave/qcgengrd.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
#define NAME SCRIPT_QCGENGRD
#define TOWN_REP_VAR (GVAR_TOWN_REP_ENCLAVE)

/**
* Alert turrets on level if they are not in maintenance.
*/
#define alert_turrets_level(gvar_turret_level_security) \
if global_var(gvar_turret_level_security) != TURRET_MAINTENANCE then \
set_global_var(gvar_turret_level_security, TURRET_ALERT)


#include "../headers/command.h"
#include "../headers/modreact.h"

Expand Down Expand Up @@ -169,18 +177,18 @@ procedure damage_p_proc begin

if (cur_map_index == MAP_ENCLAVE_BARRACKS) then begin
set_global_var(GVAR_ENCLAVE_ENEMY_GUARD,1);
set_global_var(GVAR_ENCLAVE_TURRET_GUARD,TURRET_ALERT);
alert_turrets_level(GVAR_ENCLAVE_TURRET_GUARD);
end else if (cur_map_index == MAP_ENCLAVE_PRESIDENT) then begin
set_global_var(GVAR_ENCLAVE_ENEMY_PRESIDENT,1);
set_global_var(GVAR_ENCLAVE_TURRET_PRESIDENT,TURRET_ALERT);
alert_turrets_level(GVAR_ENCLAVE_TURRET_PRESIDENT);
end else if (cur_map_index == MAP_ENCLAVE_TRAP_ROOM) then begin
set_global_var(GVAR_ENCLAVE_ENEMY_TRAPS,1);
end else if (cur_map_index == MAP_ENCLAVE_REACTOR) then begin
set_global_var(GVAR_ENCLAVE_ENEMY_REACTOR,1);
set_global_var(GVAR_ENCLAVE_TURRET_SCIENCE,TURRET_ALERT);
alert_turrets_level(GVAR_ENCLAVE_TURRET_SCIENCE);
end else if (cur_map_index == MAP_ENCLAVE_DETENTION) then begin
set_global_var(GVAR_ENCLAVE_ENEMY_DETENTION,1);
set_global_var(GVAR_ENCLAVE_TURRET_DETENTION,TURRET_ALERT);
alert_turrets_level(GVAR_ENCLAVE_TURRET_DETENTION);
end
end

Expand Down
117 changes: 69 additions & 48 deletions scripts_src/enclave/qcturret.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
procedure start;
procedure critter_p_proc;
procedure map_enter_p_proc;
procedure Security_Check(variable Security);
procedure Security_Check;
procedure damage_p_proc; //added by killap
procedure get_gvar_security;

import variable Frank_Ptr;
variable countdown;
variable gvar_security = GVAR_ENCLAVE_TURRET_MAIN;

procedure start begin
gvar_security = get_gvar_security;
end

procedure map_enter_p_proc begin
Expand All @@ -53,57 +56,62 @@ procedure map_enter_p_proc begin
item:=self_item(PID_HEAVY_DUAL_MINIGUN);
wield_obj(item);
end
gvar_security = get_gvar_security;
end

procedure critter_p_proc begin
if (cur_map_index == MAP_ENCLAVE_DETENTION) then begin
set_self_team(TEAM_ENCLAVE);
set_self_ai(AI_GUN_TURRET);
call Security_Check(GVAR_ENCLAVE_TURRET_DETENTION);
end

else if (cur_map_index == MAP_ENCLAVE_PRESIDENT) then begin
set_self_team(TEAM_ENCLAVE);
set_self_ai(AI_GUN_TURRET);
call Security_Check(GVAR_ENCLAVE_TURRET_PRESIDENT);
end

else if (cur_map_index == MAP_ENCLAVE_BARRACKS) then begin
set_self_team(TEAM_ENCLAVE);
set_self_ai(AI_GUN_TURRET);
call Security_Check(GVAR_ENCLAVE_TURRET_GUARD);
end

else if (cur_map_index == MAP_ENCLAVE_REACTOR) then begin
set_self_team(TEAM_ENCLAVE);
set_self_ai(AI_GUN_TURRET);
call Security_Check(GVAR_ENCLAVE_TURRET_SCIENCE);
end

else if (cur_map_index == MAP_ENCLAVE_END_FIGHT) then begin
set_self_ai(AI_GUN_TURRET);
if (global_var(GVAR_ENCLAVE_TURRET_HELP_PLAYER) == 1) then begin
set_self_team(TEAM_PLAYER);
if (countdown == 10) then
attack(Frank_Ptr);
countdown+=1;
end
else begin
set_self_team(TEAM_ENCLAVE);
// if (global_var(GVAR_ENCLAVE_FRANK_DEAD) != 0) then
// call Security_Check(GVAR_ENCLAVE_TURRET_MAIN);
end
end
/**
* Get turret security GVAR corresponding to current level.
*/
procedure get_gvar_security begin
variable cur_map = cur_map_index, ret;
switch cur_map begin
case MAP_ENCLAVE_DETENTION:
ret = GVAR_ENCLAVE_TURRET_DETENTION;
case MAP_ENCLAVE_PRESIDENT:
ret = GVAR_ENCLAVE_TURRET_PRESIDENT;
case MAP_ENCLAVE_BARRACKS:
ret = GVAR_ENCLAVE_TURRET_GUARD;
case MAP_ENCLAVE_REACTOR:
ret = GVAR_ENCLAVE_TURRET_SCIENCE;
default: // MAP_ENCLAVE_END_FIGHT
ret = GVAR_ENCLAVE_TURRET_MAIN;
end
return ret;
end

else begin
set_self_team(TEAM_ENCLAVE);
set_self_ai(AI_GUN_TURRET);
call Security_Check(GVAR_ENCLAVE_TURRET_MAIN);
end
procedure critter_p_proc begin
// Maintenance: sleep for 1-3 minutes. See terminal qiturtrm.ssl.
if global_var(gvar_security) == TURRET_MAINTENANCE then begin
set_self_team(TEAM_LONER);
return;
end

set_self_ai(AI_GUN_TURRET);

if (cur_map_index == MAP_ENCLAVE_END_FIGHT) then begin
if (global_var(GVAR_ENCLAVE_TURRET_HELP_PLAYER) == 1) then begin
set_self_team(TEAM_PLAYER);
if (countdown == 10) then
attack(Frank_Ptr);
countdown+=1;
end
else begin
set_self_team(TEAM_ENCLAVE);
end
end
else begin
set_self_team(TEAM_ENCLAVE);
call Security_Check();
end
end

procedure Security_Check(variable Security) begin
if ((global_var(Security) == TURRET_NORMAL) and (cur_map_index != MAP_ENCLAVE_END_FIGHT)) then begin
procedure Security_Check begin
ndebug("security check start");
// Maintenance: sleep for 1-3 minutes. See terminal qiturtrm.ssl.
if global_var(gvar_security) == TURRET_MAINTENANCE then return;

ndebug("not in maintenance");
if ((global_var(gvar_security) == TURRET_NORMAL) and (cur_map_index != MAP_ENCLAVE_END_FIGHT)) then begin
if (self_can_see_dude) then begin
if (party_size > 1) then begin
attack(dude_obj);
Expand All @@ -120,7 +128,8 @@ procedure Security_Check(variable Security) begin
end
end

else if (global_var(Security) == TURRET_ALERT) then begin
else if (global_var(gvar_security) == TURRET_ALERT) then begin
ndebug("in alert");
if (self_can_see_dude) then
attack(dude_obj);
end
Expand All @@ -146,6 +155,11 @@ end

//added by killap
procedure damage_p_proc begin
ndebug("damaged");

// Maintenance: sleep for 1-3 minutes
if global_var(gvar_security) == TURRET_MAINTENANCE then return;

if (cur_map_index == MAP_ENCLAVE_DETENTION) then
set_global_var(GVAR_ENCLAVE_TURRET_DETENTION,TURRET_ALERT);
else if (cur_map_index == MAP_ENCLAVE_BARRACKS) then
Expand All @@ -156,3 +170,10 @@ procedure damage_p_proc begin
set_global_var(GVAR_ENCLAVE_TURRET_SCIENCE,TURRET_ALERT);
end
//end added

procedure combat_p_proc begin
if (fixed_param == COMBAT_SUBTYPE_TURN) and (global_var(gvar_security) == TURRET_MAINTENANCE) then begin
script_overrides;
ndebug("I am disabled and won't attack!");
end
end
13 changes: 9 additions & 4 deletions scripts_src/enclave/qiturtrm.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ variable current_userid := 0; //added by killap
#define BIRD 4
//end

/**
* Reactivate turrets on current level.
*/
#define TIMER_REACTIVATE 1

procedure start begin
end

Expand Down Expand Up @@ -147,7 +152,7 @@ procedure look_p_proc begin
end

procedure timed_event_p_proc begin
if (fixed_param == 1) then
if (fixed_param == TIMER_REACTIVATE) then
call Alarm_Reactive;
end

Expand Down Expand Up @@ -536,9 +541,9 @@ procedure Node026 begin
Reply(251);

if (hacked_system) then //added by killap
CompOption(252,Node020a);
CompOption(121,Node020a);
else
CompOption(252,Node020);
CompOption(121,Node020);
CompOption(253,Node026a);
end

Expand All @@ -556,7 +561,7 @@ procedure Node026a begin
else
set_global_var(GVAR_ENCLAVE_TURRET_MAIN,TURRET_MAINTENANCE);

add_timer_event(self_obj,(random(1,3)*ONE_GAME_MINUTE),1);
add_timer_event(self_obj, (random(1,3)*ONE_GAME_MINUTE), TIMER_REACTIVATE);
end

procedure Node027 begin
Expand Down

0 comments on commit 9cbd6c9

Please sign in to comment.