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: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

alertConditionChanged

Post by spara »

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
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: alertConditionChanged

Post by phkb »

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: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: alertConditionChanged

Post by another_commander »

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
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: alertConditionChanged

Post by phkb »

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