diff --git a/code/blight.cpp b/code/blight.cpp index 7850a58..d8def10 100644 --- a/code/blight.cpp +++ b/code/blight.cpp @@ -177,6 +177,8 @@ void BuildingLightClass::AI(void) return; } + bool resumed_sweep = false; + Coord coord = PositionCoord; switch (Behavior) { default: @@ -188,6 +190,8 @@ void BuildingLightClass::AI(void) coord = Lerp(PositionCoord, Target->PositionCoord, 0.25); } else { Set_Behavior_Type(LIGHT_BEHAVIOR_SWEEP); + + resumed_sweep = true; } break; @@ -248,7 +252,7 @@ void BuildingLightClass::AI(void) BuildingClass * owner_building = (Owner->RTTI == RTTI_BUILDING) ? (BuildingClass *)Owner : NULL; - if (Behavior == LIGHT_BEHAVIOR_SWEEP) { + if (Behavior == LIGHT_BEHAVIOR_SWEEP && !resumed_sweep) { if (owner_building != NULL && owner_building->IsActive && owner_building->Is_Powered_On() && owner_building->Tag != NULL) { bool found = false; Cell cell = PositionCell; diff --git a/code/taction.cpp b/code/taction.cpp index 1eabdc7..c22700c 100644 --- a/code/taction.cpp +++ b/code/taction.cpp @@ -85,6 +85,7 @@ #include "tagtype.h" #include "team.h" #include "teamtype.h" +#include "tevent.h" #include "theme.h" #include "tracker.h" #include "trigger.h" @@ -2045,23 +2046,33 @@ bool TActionClass::TAction_RESHROUD(HouseClass * , ObjectClass * , TriggerClass /// the new behavior, so a scenario can have the searchlights start hunting on cue. /// /// bool; Was at least one spotlight changed? -bool TActionClass::TAction_CHANGE_SPOTLIGHT_BEHAVIOR(HouseClass * , ObjectClass * , TriggerClass * trig, Cell const & ) +bool TActionClass::TAction_CHANGE_SPOTLIGHT_BEHAVIOR(HouseClass*, ObjectClass* object, TriggerClass* trig, Cell const&) { + bool restrict_to_source = + Data.LightBehavior == LIGHT_BEHAVIOR_FOLLOW && + object != NULL && + object->RTTI == RTTI_BUILDING; + bool success = false; + for (int index = 0; index < Buildings.Count(); index++) { - BuildingClass * ptr = Buildings[index]; + BuildingClass* ptr = Buildings[index]; + if (ptr->Strength > 0 && - ptr->IsActive && - ptr->IsDown && - !ptr->IsInLimbo && - ptr->Class->HasSpotlight && - ptr->BuildingLight != NULL && - ptr->Tag != NULL && - ptr->Tag->Is_Trigger_Attached(trig)) { + ptr->IsActive && + ptr->IsDown && + !ptr->IsInLimbo && + ptr->Class->HasSpotlight && + ptr->BuildingLight != NULL && + ptr->Tag != NULL && + ptr->Tag->Is_Trigger_Attached(trig) && + (!restrict_to_source || ptr == object)) { + ptr->BuildingLight->Set_Behavior_Type(Data.LightBehavior); success = true; } } + return(success); } diff --git a/code/trigger.cpp b/code/trigger.cpp index cbedf69..544b849 100644 --- a/code/trigger.cpp +++ b/code/trigger.cpp @@ -293,7 +293,22 @@ bool TriggerClass::Should_Spring(TEventType event, ObjectClass * object, bool fo TEventClass * tevent = Class->FirstEvent; int index = 0; while (tevent != NULL) { - if (Is_Event_Tripped(index) || tevent->operator()(event, House_From_HousesType((HousesType)Class->House->HeapID), object, Timer, persistent, source)) { + bool event_tripped = Is_Event_Tripped(index); + + /* + ** A latched event only helps a persistent trigger when another event + ** still needs to be satisfied. Keep this exception scoped to Event 35 + ** rather than changing latch behavior for other trigger events. + */ + if (event_tripped && + tevent->Event == TEVENT_ENEMY_IN_SPOTLIGHT && + index == 0 && + tevent->Next == NULL && + event != TEVENT_ENEMY_IN_SPOTLIGHT) { + event_tripped = false; + } + + if (event_tripped || tevent->operator()(event, House_From_HousesType((HousesType)Class->House->HeapID), object, Timer, persistent, source)) { if (persistent) { if (tevent->Is_Time_Based() && tevent->Is_To_Flag_As_Tripped()) { Flag_Event_Tripped(index);