Skip to content
Permalink
Browse files

Split common ground/container scripts into separate ones. Should do i…

…t for #19.
  • Loading branch information
burner1024 committed Feb 16, 2020
1 parent 679ecac commit efeb54ec662d7b398ed5df5f960535c23d5cfa70
@@ -1,4 +1,6 @@
DEFINE_PATCH_MACRO G_REPLACE_TRAP_SCRIPTS BEGIN
// makes sure each trap in an area has a script unique for that area
// doesn't actually create the scripts, just calculates the names and writes them into the area
DEFINE_PATCH_MACRO MAKE_TRAP_SCRIPTS_UNIQUE BEGIN
WHILE (str_num > 0) BEGIN
str_num -= 1
str_script_off = str_off + (str_num * str_size) + rel_script_off
@@ -44,12 +44,42 @@ OUTER_SET new_trap_ind = 0 // global var for all areas
APPEND ~STATE.IDS~ ~0x80101FEF CD_STATE_NOTVALID~ UNLESS ~CD_STATE_NOTVALID~ // Adds CD_STATE_NOTVALID state
CLEAR_IDS_MAP


// separate scripts which have both Open and Entered triggers
<<<<<<<< .../tnt-inlined/easy_traps/entered_opened.baf
OR(2)
Entered([ANYONE])
Opened([ANYONE])
>>>>>>>>
<<<<<<<< .../tnt-inlined/easy_traps/entered.baf
Entered([ANYONE])
>>>>>>>>
<<<<<<<< .../tnt-inlined/easy_traps/opened.baf
Opened([ANYONE])
>>>>>>>>
OUTER_SET i = 0
ACTION_PHP_EACH trap_double_trigger AS trap => num BEGIN
ground_name = "g_gtr%i%.bcs"
COPY_EXISTING ~%trap%.bcs~ ~override/%ground_name%.bcs~ // ground script is new
R_B_B ~.../tnt-inlined/easy_traps/entered_opened.baf~ ~.../tnt-inlined/easy_traps/entered.baf~
BUT_ONLY
COPY_EXISTING ~%trap%.bcs~ ~override/%trap%.bcs~ // container/door script has "entered" removed
R_B_B ~.../tnt-inlined/easy_traps/entered_opened.baf~ ~.../tnt-inlined/easy_traps/opened.baf~
BUT_ONLY
traref = $trap_type(~%trap%~)
OUTER_TEXT_SPRINT $trap_type(~%ground_name%~) ~%traref%~
OUTER_TEXT_SPRINT $new_ground_trap(~%trap%~) ~%ground_name%~
i+=1
END

// clear faulty scripts, assign new ground ones
COPY_EXISTING_REGEXP GLOB ~.*\.are$~ override
GET_OFFSET_ARRAY reg_array ARE_V10_REGIONS
PHP_EACH reg_array AS int => reg_off BEGIN
READ_SHORT (reg_off + ARE_REGION_trapped) is_trapped
READ_ASCII (reg_off + ARE_REGION_script) reg_script
PATCH_IF (is_trapped == 0 AND VARIABLE_IS_SET $trap_type(~%reg_script%~)) BEGIN //if it's not trapped but script exists and is a known trap type
// if it's not trapped but script exists and is a known trap type then remove
PATCH_IF (is_trapped == 0 AND VARIABLE_IS_SET $trap_type(~%reg_script%~)) BEGIN
READ_ASCII reg_off reg_name (32) NULL
PATCH_LOG ~Found faulty region: area %SOURCE_FILE%, region %reg_name%, script %reg_script%, trap status is %is_trapped% - clearing.~
LPF ALTER_AREA_REGION
@@ -60,7 +90,16 @@ COPY_EXISTING_REGEXP GLOB ~.*\.are$~ override
trap_remove = 0
STR_VAR
region_name = ~%reg_name%~
door_script = ~~
region_script = ~~
END
END
// replace with new
PATCH_IF is_trapped == 1 AND VARIABLE_IS_SET $trap_double_trigger(~%reg_script%~) BEGIN
new_trap_script = $new_ground_trap(~%reg_scrip%~)
LPF ALTER_AREA_REGION
STR_VAR
region_name = ~%reg_name%~
region_script = ~%new_trap_script%~
END
END
END
@@ -69,7 +108,8 @@ COPY_EXISTING_REGEXP GLOB ~.*\.are$~ override
READ_SHORT (cont_off + ARE_CONTAINER_trapped) is_trapped
READ_SHORT (cont_off + ARE_CONTAINER_trap_detected) is_detected
READ_ASCII (cont_off + ARE_CONTAINER_script) cont_script
PATCH_IF (is_trapped == 0 AND VARIABLE_IS_SET $trap_type(~%cont_script%~)) BEGIN //if it's not trapped but script exists and is a known trap type
// if it's not trapped but script exists and is a known trap type
PATCH_IF (is_trapped == 0 AND VARIABLE_IS_SET $trap_type(~%cont_script%~)) BEGIN
READ_ASCII cont_off cont_name (32) NULL
PATCH_LOG ~Found faulty container: area %SOURCE_FILE%, container %cont_name%, script %cont_script%, trap status is %is_trapped% - clearing~
LPF ALTER_AREA_CONTAINER
@@ -91,7 +131,8 @@ COPY_EXISTING_REGEXP GLOB ~.*\.are$~ override
PHP_EACH door_array AS int => door_off BEGIN
READ_SHORT (door_off + ARE_DOOR_trapped) is_trapped
READ_ASCII (door_off + ARE_DOOR_script) door_script
PATCH_IF (is_trapped == 0 AND VARIABLE_IS_SET $trap_type(~%door_script%~)) BEGIN //if it's not trapped but script exists and is a known trap type
// if it's not trapped but script exists and is a known trap type
PATCH_IF (is_trapped == 0 AND VARIABLE_IS_SET $trap_type(~%door_script%~)) BEGIN
READ_ASCII door_off door_name (32) NULL
PATCH_LOG ~Found faulty door: area %SOURCE_FILE%, door %door_name%, script %door_script%, trap status is %is_trapped% - clearing~
LPF ALTER_AREA_DOOR
@@ -129,19 +170,19 @@ COPY_EXISTING_REGEXP GLOB ~.*\.are$~ override
str_size = reg_size
str_num = reg_num
rel_script_off = ARE_REGION_script
LPM G_REPLACE_TRAP_SCRIPTS
LPM MAKE_TRAP_SCRIPTS_UNIQUE

str_off = cont_off
str_size = cont_size
str_num = cont_num
rel_script_off = ARE_CONTAINER_script
LPM G_REPLACE_TRAP_SCRIPTS
LPM MAKE_TRAP_SCRIPTS_UNIQUE

str_off = door_off
str_size = door_size
str_num = door_num
rel_script_off = ARE_DOOR_script
LPM G_REPLACE_TRAP_SCRIPTS
LPM MAKE_TRAP_SCRIPTS_UNIQUE

BUT_ONLY

@@ -79,7 +79,6 @@ ACTION_DEFINE_ASSOCIATIVE_ARRAY trap_type BEGIN
GSPEAR => ~@135~
GSLIME => ~@136~
GVENT => ~@137~

//Watcher's keep traps
GT001 => ~@138~
GT002 => ~@139~
@@ -175,3 +174,41 @@ ACTION_DEFINE_ASSOCIATIVE_ARRAY trap_type BEGIN
// WQXSTON => ~Stone trap~

END

// these are both container and ground, need to separate them
// all 1's, just need to check them with VARIABLE_IS_SET later
ACTION_DEFINE_ASSOCIATIVE_ARRAY trap_double_trigger BEGIN
GDARTS => 1
GSPEAR => 1
GSLIME => 1
GVENT => 1
GT001 => 1
GT002 => 1
GT003 => 1
GT004 => 1
GT005 => 1
GT006 => 1
GT007 => 1
GT008 => 1
GT009 => 1
GT010 => 1
GT011 => 1
GT012 => 1
GT013 => 1
GT014 => 1
GT015 => 1
GT016 => 1
GT017 => 1
GT018 => 1
GT019 => 1
GT020 => 1
GT021 => 1
GT022 => 1
GT023 => 1
GT024 => 1
GT025 => 1
GT026 => 1
GT027 => 1
GT028 => 1
GT029 => 1
END

0 comments on commit efeb54e

Please sign in to comment.
You can’t perform that action at this time.