alertConditionChanged
Moderators: winston, another_commander, Getafix
alertConditionChanged
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?
- phkb
- 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
I think this is a bug. I've had a look, and it appears the station version of the
Not sure what the fix is yet (if this is indeed the problem).
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).
-
- Quite Grand Sub-Admiral
- Posts: 6683
- Joined: Wed Feb 28, 2007 7:54 am
Re: alertConditionChanged
Could we check and confirm if this occurs in 1.84 and 1.82 too (can't do it right now myself)?
- phkb
- 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
For all these tests I used this code in the Javascript debug console to add the event listener for
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)
alertConditionChanged
.
Code: Select all
S.mainStation.script.alertConditionChanged = function(newCond, oldCond) {log(this.name, "got here");}
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)