![]() |
Triggers not working with scripts
Hi everyone, long time and so on ...
I've been away for some time doing other things but I'm currently in testing mode for a new mod I call "Fighter Command". But as I created missions that rely on (timed) triggers they simply doesn't work. At first I suspected my code but it seems triggers simply doesn't wotk at all for missions that supports a script (.cs) file. I created this litte file: Code:
using System; Has anyone else seen this? |
triggers do work with scripts, if there is an action- ie a spawn associated you must also make it happen in script.
I use something like this Code:
if ("trigger01".Equals(shortName) && active) // triggers 115 spawn |
I assumed triggers where managed automatically by the sim and that I could override the default behavior by overriding. But you're saying I need to actively trigger the action from within my script?
|
the orginal OnTrigger is defined in the Battle-Script:
Code:
public virtual void OnTrigger(int missionNumber, string shortName, bool active) So to get the old behavior you must insert code to spawn the Actors again for example with: Code:
public override void OnTrigger(int missionNumber, string shortName, bool active) |
correct - it would appear that using a script 'overrides' any trigger actions, therefore you must make the action happen in script.
Took me a week to figure this one out when starting writing campaign scripts:confused: Assumption is the mother of all 'foul' ups;) |
Quote:
First of all, you mention "the battle script" and even present the OnTrigger virtual method. Is the AMission class source code available somewhere?! If so, where can I find it? You then say... Quote:
In your override you check for 'missions' (if (this.missions.Count > 0)). Are those "sub missions" loaded by "this" mission? You then iterate those missions and calls their OnTrigger(), but only if they are "mission listeners". What is that? Then, if there's no (sub?) missions you move ahead and actively checks for any action to be triggered and calls its .Do() method if the trigger is active which makes sense of course but why is this done only if there's no (sub?) missions? Is this to allow those (sub?) missions to make the ultimate decision to act on the trigger or not? Finally, you present an override that starts with calling the default behavior. But then it goes ahead and forces the affected action to trigger regardless. Why is that? Thanks for taking the time mate! |
The first code is the orginal virtual method from ABattle (not from me, it contains also control structures for different missions), you don't have access to it via normal script, it was only a example how the orginal code looks like.
There is nothing interesting in AMission: Code:
public abstract class AMission |
Thanks chaps. Everything is clear now. :O)
|
Cant seem to get it to work...........:(
I have a trigger set for some Dorniers to spawn. The trigger is a air group entering an area and I see the Hud message but no dorniers spawn? Code:
public override void OnTrigger(int missionNumber, string shortName, bool active) |
All times are GMT. The time now is 06:52 AM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.