Jump to content
Sign in to follow this  
MattyDienhoff

Trigger works as intended in editor but not in MP

Recommended Posts

I'm working on a multiplayer mission called Tourist set on Everon. In it, 1-10 players simply roam around the island, and there are vehicles, infrastructure, vehicle and pedestrian traffic, and weapons hidden around the island. Attention to detail is the name of the game here, and my main aim, besides making a mission to make decent use of all the nice civilian vehicles in OFP, was to make something different. It could probably be considered a hugely amped-up Status Quo.

Players can simply cruise around or find weapons and kill each other (players respawn at the hospital) or the AI-controlled civilians and soldiers on the island. By way of law enforcement there are several squads of armed Resistance soldiers, and in the older versions I simply left trucks full of Resistance soldiers parked around the island with guard waypoints so they'd go and attack the player/s if they started causing trouble. This worked but not particularly well, because sometimes the soldiers would go driving off and park in the middle of a field, etc.

So instead, I put each squad of soldiers inside inaccessible barracks around the island, gave them a collective "stop" order so they wouldn't move around, created a trigger called "general alarm", that would activate if any player's rating fell below 0 (which would mean they had become renegade, like you do if you kill friendlies), and synchronized that with all of the squad's waypoints so they'd come out, get in their trucks, and head to their next waypoint as soon as any player starts causing trouble.

This is the trigger.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">condition: (rating player <0)

on activation: ""_x stop false"" forEach units bravo; ""_x stop false"" forEach units charlie; ""_x stop false"" forEach units delta; ""_x stop false"" forEach units echo; ""_x stop false"" forEach units foxtrot;

It also plays a music track to make it easy to identify when exactly it's been triggered, for debugging purposes.

But so far it hasn't worked particularly well, there's a kink in it somewhere. Who exactly the term "player" applies to seems to be ambiguous and subjective. In my tests, if the host commits crimes the trigger activates, but if any of the clients do the same nothing happens, so I named all of the players and tried this instead.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">condition: (rating p1 <0) or (rating p2 <0) or (rating p3 <0) or (rating p4 <0) or (rating p5 <0) or (rating p6 <0) or (rating p7 <0) or (rating p8 <0) or (rating p9 <0) or (rating p10 <0)

This seems to work fine in the mission editor, but in-game the trigger doesn't activate. crazy_o.gif

Does anyone have any advice?

Share this post


Link to post
Share on other sites

Nice idea. Sounds like the basic beginnings of a GTA type concept. Something you could take as far as you wanted to I think.

As for the issue who knows. In mp things normally work well on the host machine but not the clients. I am aware of a command called 'local'. Now if you go back to your original method using the 'player' syntax and then try (I'm making no promises) the following syntax in the script the trigger calls:

if not local player then exit

which I think in code translates to:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!(local player):exit;

Now one would think that the player would be local to the machine running the script client or otherwise. So this bit should cause all machines to run a copy of the script with their local player as the subject unit. Those machines where their local player has a rating above zero will simply exit, but the one where the local player has been naughty will activate the script. I have some more advice but I'd make sure this is working before you look at the next idea I have.

Suggested Improvement:

If I were you I'd have two triggers. One which is aimed at being run by the host machine and causes the reaction, and the other as the sensor.

In the first trigger have its condition field activated by a global variable being made true such as 'alarmvariable' for example. In the activation field run the script causing the police to react to the player's misadventures.

In the second (sensor) trigger run the above syntax (assuming it works ok after you've tested it) where the machine checks to see if the local player's rating is below zero. If it is, then make the variable 'alarmvariable' become true. Try to avoid using 1's and 0's in place of true and false as I've had scripts react badly to this before. They seem to prefer typical boolean state strings rather than 1's and 0's. There is a command which I can't remember that broadcasts the state of this variable to all machines on the network and overrides the value of this variable stored on all other machines with the one you broadcast. This command can originate in the host or client it doesn't matter. Even if this originates from a client it will set the 'alarmvariable' to true on the host's machine.

Now if you start to have problems with duplicate scripts executing on client machines that you dont want do the following. Make a game logic and call it 'server'. IIRC game logics are always local to the host never the client. In the script which causes the reactions have the following syntax at the top:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!(local server):exit;

To be ultra-clean you might be able to remove the () brackets but I'm not sure. This should stop duplicate scripts running on client machines where this is perceived to be a problem (it often isn't so I hear).

So the concept is to use a sensor script to broadcast the variable value to true from any machine when the player is naughty, then have the reaction script execute only on the host machine. Should stand a much better chance of working smile_o.gif

*Edit* The broadcast command is publicvariable. Example:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">publicvariable "alarmvariable"

Include the inverted commas.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×