alertConditionChanged

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2552
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

alertConditionChanged

Post by spara » Tue Mar 06, 2018 6:13 pm

I'm trying to get alertConditionChanged event to trigger for the main station with a ship script attached to the station by shooting the station. In the debug console system.mainStation.alertCondition shows that the alert condition has changed. Should this work or am I missing something obvious?

User avatar
phkb
Commodore
Commodore
Posts: 2402
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: alertConditionChanged

Post by phkb » Tue Mar 06, 2018 10:43 pm

I think this is a bug. I've had a look, and it appears the station version of the alertConditionChanged event is only triggered if the AI functions increaseAlertLevel and decreaseAlertLevel are executed. The standard station AI routine (the JS one, not the plist one) uses the behaviour behaviourStationLaunchDefenseShips to control the alertCondition. However, in the priority AI functions, behaviourStationLaunchDefenseShips just sets the alertCondition directly to 3 (condition red), rather than performing an increaseAlertLevel function. Therefore, the alertConditionChanged event never fires.

Not sure what the fix is yet (if this is indeed the problem).

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 5396
Joined: Wed Feb 28, 2007 7:54 am

Re: alertConditionChanged

Post by another_commander » Wed Mar 07, 2018 6:27 am

Could we check and confirm if this occurs in 1.84 and 1.82 too (can't do it right now myself)?

User avatar
phkb
Commodore
Commodore
Posts: 2402
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: alertConditionChanged

Post by phkb » Wed Mar 07, 2018 7:50 pm

For all these tests I used this code in the Javascript debug console to add the event listener for alertConditionChanged.

Code: Select all

S.mainStation.script.alertConditionChanged = function(newCond, oldCond) {log(this.name, "got here");}
Here's the procedure and results of my tests:

Test 1
1. Add event script to main station
2. Launch, spin, fire on station.
Result: No event triggered

Test 2
1. Restart game, add event script to main station
2. Switch station AI to "stationAI.plist"
3. Launch, spin, fire on station
Result: Event is triggered.

Results were the same in 1.80, 1.82, 1.84, 1.86 (in each case, vanilla install with only the debug OXP)

Post Reply