Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion code/blight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ void BuildingLightClass::AI(void)
return;
}

bool resumed_sweep = false;

Coord coord = PositionCoord;
switch (Behavior) {
default:
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
29 changes: 20 additions & 9 deletions code/taction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
/// </summary>
/// <returns>bool; Was at least one spotlight changed?</returns>
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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object comes from whichever event finally springs the trigger, not necessarily from Event 35 detect. This restricts every building-sourced Follow action (like Attacked) and can select the wrong tower when another building event completes a latched Event 35 trigger. Restrict only when explicit spotlight-detection prov is available; else preserve the all-tagged fallback.


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);
}

Expand Down
17 changes: 16 additions & 1 deletion code/trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down