Jump to content

OnRange triggers in a25


SciGuy42
 Share

Recommended Posts

I am trying to upgrade my campaign to a25 and have found that OnRange triggers must have changed somehow. I first defined the trigger using the following code:

cmpTrigger.RegisterTrigger("OnRange", "RangeAction", {
        "entities": cmpTrigger.GetTriggerPoints("A"), // central points to calculate the range circles
        "players": [1], // only count entities of player 1
        "maxRange": 40,
        "requiredComponent": IID_UnitAI, // only count units in range
        "enabled": true,
    });

I have a simple RangeAction defined as:


Trigger.prototype.RangeAction = function(data)
{
    warn("The OnRange event happened with the following data:");
    warn(uneval(data));
};

When I load the scenario I get no errors upon loading but then when I move the unit close to the trigger point, I get the following error:

WARNING: Trigger.js: called a trigger 'RangeAction' for event 'OnRange' that wasn't found

Note that I am following the example in: /maps/scenarios/trigger_demo.js

I cannot spot any difference between how the trigger_demo.js uses the OnRange trigger and mine. Any clues?

 

 

I am also including the .js file here.

Macedonia_2.js

Link to comment
Share on other sites

Unfortunately I am also having trouble with the simple IntervalAction trigger. I register the trigger as per the tutorial with no issues:

cmpTrigger.RegisterTrigger("OnInterval", "IntervalAction", {
        "enabled": true,
        "delay": 10 * 1000,
        "interval": 5 * 1000,
    });

The action is defined as:


Trigger.prototype.IntervalAction = function(data)
{
    warn("The OnInterval event happened with the following data:");
    warn(uneval(data));
};

Then 10 seconds in the game, I get this error:

WARNING: Trigger.js: called a trigger action 'undefined' that wasn't found

I think I followed everything from the trigger_demo.js example to the tee as before.

Link to comment
Share on other sites

24 minutes ago, nwtour said:

@SciGuy42 FYI You need to put the new version in the mod folder  (To make it work in the release version)

simulation/components/Trigger.js

 

 

Trigger.js 10 kB · 0 downloads

Thanks, the interval action now seems to be working as expected. However, the OnRange trigger is still giving me the same error once the unit gets close to the trigger point:

WARNING: Trigger.js: called a trigger 'RangeAction' for event 'OnRange' that wasn't found!!!

I added the !!! at the end just to verify that it is using the new file.

Link to comment
Share on other sites

1 hour ago, Stan` said:

There was https://code.wildfiregames.com/D3979

https://code.wildfiregames.com/D3904

Does it work if you remove Action from IntervalAction?  I suppose wraitii may have forgotten to update the maps...

Do you mean remove the word Action when registering the trigger but still keep the function as RangeAction? Or remove Action from both the name when registering the trigger as well as from the function name?

Link to comment
Share on other sites

7 minutes ago, Silier said:

I assume I had to replace with the file on the right. After I did that, I am now getting the following error when a unit gets close to the trigger point, tested with both my scenario and the Trigger Demo:

ERROR: JavaScript error: simulation/components/Trigger.js line 346
this.triggers.triggers is undefined
  Trigger.prototype.CallTrigger@simulation/components/Trigger.js:346:6
  TriggerPoint.prototype.OnRangeUpdate@simulation/components/TriggerPoint.js:75:13

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...