2024-12-31 22:36:04 +00:00
extends EventBase
func _init ( ) :
id = " AzazelCorruptionAttemptEvent "
func registerTriggers ( es ) :
es . addTrigger ( self , Trigger . EnteringRoom )
func react ( _triggerID , _args ) :
2025-01-05 20:57:26 +00:00
if not ( GM . pc . getLocation ( ) . begins_with ( " main_hall " ) or ( GM . pc . getLocation ( ) in [ " main_bathroom1 " , " hall_ne_corner " ] ) ) or GM . main . isVeryLate ( ) :
2024-12-31 22:36:04 +00:00
return false
if GM . main . getModuleFlag ( " IssixModule " , " Hiisi_Had_Encounter_Scene_Today " , false ) == false and RNG . chance ( 5.0 ) :
if activateHiisiScenes ( ) :
return true
2025-01-05 20:57:26 +00:00
if GM . pc . getLocation ( ) == " hall_ne_corner " :
return false
2024-12-31 22:36:04 +00:00
if not ( GM . main . getModuleFlag ( " IssixModule " , " Quest_Status " , 0 ) < 1 ) : # Do not show those if player started the quest as Azazel doesn't have a reason to corrupt the player
return false
if activateAzazelScenes ( ) :
return true
return false
func activateHiisiScenes ( ) - > bool :
var scene_index = GM . main . getModuleFlag ( " IssixModule " , " Hiisi_Encounter_scene " , 1 )
2025-01-21 22:31:46 +00:00
if scene_index == - 1 or GM . main . getModuleFlag ( " IssixModule " , " Hiisi_Affection " , - 1 ) < scene_index * 3 or scene_index > 3 :
2025-01-05 20:57:26 +00:00
return false
if scene_index != 3 and GM . pc . getLocation ( ) == " hall_ne_corner " : # This scene only shows on that tile
2024-12-31 22:36:04 +00:00
return false
if scene_index == 1 : # Different conditions per Hiisi's scenes
var pawns = findFreePawnsNearby ( )
if pawns . size ( ) > 1 :
GM . main . setModuleFlag ( " IssixModule " , " Hiisi_Had_Encounter_Scene_Today " , true )
runScene ( " HiisiWanderScene1 " , [ RNG . pick ( pawns ) ] )
return true
elif scene_index == 2 :
if GM . pc . getLocation ( ) in [ " main_bathroom1 " ] :
return false
var path = GM . world . calculatePath ( GM . pc . getLocation ( ) , " main_bathroom1 " )
GM . main . setModuleFlag ( " IssixModule " , " Hiisi_Had_Encounter_Scene_Today " , true )
GM . pc . setLocation ( path [ 1 ] )
runScene ( " HiisiWanderScene2 " )
return true
return false
func activateAzazelScenes ( ) - > bool :
if GM . main . getModuleFlag ( " IssixModule " , " Azazel_Had_Corruption_Scene_Today " , false ) == false and RNG . chance ( 2.0 ) :
var scene_index = GM . main . getModuleFlag ( " IssixModule " , " Azazel_Corruption_Scene " , 1 )
2025-01-21 22:31:46 +00:00
if scene_index == - 1 or GM . main . getModuleFlag ( " IssixModule " , " Azazel_Affection_given " , - 1 ) < scene_index * 3 or scene_index > 4 : # Player disabled corruption scenes, their affection score is too low or we ran out of them
2024-12-31 22:36:04 +00:00
return false
GM . main . setModuleFlag ( " IssixModule " , " Azazel_Had_Corruption_Scene_Today " , true )
runScene ( " AzazelCorruption " + str ( scene_index ) )
return true
return false
# Taken from PawnInteractionBase.gd
func findFreePawnsNearby ( ) - > Array :
var result : Array = [ ]
var pawns = GM . main . IS . getPawnsNear ( GM . pc . getLocation ( ) , 2 )
for pawn in pawns :
if ( ! pawn . canBeInterrupted ( ) or ! pawn . isInmate ( ) or pawn . isPlayer ( ) ) :
continue
result . append ( pawn . charID )
return result
func getPriority ( ) :
return 5