Skip to content

Instantly share code, notes, and snippets.

@mike1072
Created May 20, 2014 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike1072/c6ce2a4a2803e07cd7b6 to your computer and use it in GitHub Desktop.
Save mike1072/c6ce2a4a2803e07cd7b6 to your computer and use it in GitHub Desktop.
// add weapon breakage to non-magical iron weapons for the iron crisis in BG1
ACTION_IF (GAME_IS ~tutu tutu_totsc bgt bgee~) BEGIN
ACTION_DEFINE_ARRAY iron_weapons BEGIN
AX1H01
BLUN02
BLUN04
BLUN06
BLUN08
DAGG01
DAGG06
DAGG07
HALB01
HAMM01
SPER01
SW1H01
SW1H04
SW1H07
SW1H12
SW1H17
SW1H20
SW1H43
SW1H46
SW1H48
SW2H01
END
// Tutu and BGEE trigger weapon breakage by spell
OUTER_SET iron_crisis_opcode = 146 // cast spell
OUTER_SET iron_crisis_param1 = 1 // level to cast at
// BGT triggers weapon breakage by setting a variable that is checked later via script
ACTION_IF (GAME_IS ~bgt~) BEGIN
OUTER_SET iron_crisis_opcode = 309 // set variable
OUTER_SET iron_crisis_param1 = 1 // value to set variable to
END
ACTION_PHP_EACH iron_weapons AS i => weapon BEGIN
ACTION_FOR_EACH resource IN ~%weapon%~ ~_%weapon%~ BEGIN // cover both regular and Tutu files
ACTION_IF (FILE_EXISTS_IN_GAME ~%resource%.itm~
&& (GAME_IS ~bgt~ OR FILE_EXISTS_IN_GAME ~%resource%.spl~)) BEGIN
COPY_EXISTING ~%resource%.itm~ ~override~
LPF ~DELETE_ITEM_EFFECT~ // remove any existing effect
INT_VAR
opcode_to_delete = iron_crisis_opcode
END
LPF ~ADD_ITEM_EFFECT~
INT_VAR
opcode = iron_crisis_opcode
target = 1 // self
parameter1 = iron_crisis_param1
timing = 1 // instant
probability1 = 1 // 1% chance to trigger
header = 1 // add to first header
type = 1 // melee
STR_VAR
// the associated .spl to cast for Tutu and BGEE is named the same as the .itm resource
// and the associated script variable for BGT is named the same as the .itm resource
resource = EVALUATE_BUFFER ~%SOURCE_RES%~
END
END
END
END
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment