-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab96803
commit 0a122b2
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#define SCRIPT_REALNAME "gl_g_ap_rollover" | ||
|
||
#include "headers/fo2tweaks/fo2tweaks.h" | ||
|
||
#define EVENT_turn_start 1 | ||
#define EVENT_turn_end 0 | ||
variable max_rollover = 0; | ||
variable leftover_ap; | ||
variable leftover_ap_map = 0; | ||
|
||
procedure combatturn_handler begin | ||
variable event = get_sfall_arg; | ||
variable who = get_sfall_arg; | ||
variable leftover_ap; | ||
variable current_ap = get_critter_current_ap(who); | ||
|
||
// End turn: save leftover AP | ||
if event == EVENT_turn_end then begin | ||
ndebug(obj_name(who) + ": end turn"); | ||
leftover_ap = current_ap; | ||
if leftover_ap > 0 then begin | ||
ndebug("leftover: " + leftover_ap); | ||
// Limit to max | ||
if leftover_ap > max_rollover then begin | ||
leftover_ap = max_rollover; | ||
end | ||
ndebug(obj_name(who) + " has " + leftover_ap + " rollover AP"); | ||
leftover_ap_map[who] = leftover_ap; | ||
end | ||
end | ||
|
||
// Start turn: restore leftover AP | ||
if event == EVENT_turn_start then begin | ||
ndebug(obj_name(who) + ": start turn"); | ||
variable rollover_ap = leftover_ap_map[who]; | ||
if rollover_ap > 0 then begin | ||
leftover_ap_map[who] = leftover_ap; | ||
ndebug(obj_name(who) + " has " + current_ap + " current AP and " + rollover_ap + " rollover AP"); | ||
set_critter_current_ap(who, current_ap + rollover_ap); | ||
ndebug(obj_name(who) + " now has " + get_critter_current_ap(who) + " AP"); | ||
leftover_ap_map[who] = 0; | ||
end | ||
end | ||
|
||
end | ||
|
||
procedure gamemode_handler begin | ||
variable old_mode = get_sfall_arg_at(1); | ||
variable new_mode = get_game_mode; | ||
if mode_started(COMBAT, old_mode, new_mode) then begin | ||
leftover_ap_map = create_array_map; | ||
end | ||
end | ||
|
||
procedure start begin | ||
if game_loaded then begin | ||
max_rollover = fo2tweaks_setting(sec_main, "ap_rollover"); | ||
if max_rollover > 0 then begin | ||
ndebug(max_rollover); | ||
register_hook_proc(HOOK_COMBATTURN, combatturn_handler); | ||
register_hook_proc(HOOK_GAMEMODECHANGE, gamemode_handler); | ||
if leftover_ap_map == 0 then begin | ||
leftover_ap_map = create_array_map; | ||
end | ||
set_unspent_ap_bonus(0); | ||
ndebug("enabled"); | ||
end | ||
end | ||
end |