Home   Help Search Login Register  

Author Topic: Activating areas by players in MP  (Read 2728 times)

0 Members and 1 Guest are viewing this topic.

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Activating areas by players in MP
« on: 21 Jul 2009, 09:26:36 »
Hey gents,

was thinking about how to keep track of all player positions in MP via scripting, and without using any triggers.

Possible approach:
Activation distance is set to 500m. Areas are represented by markers, set to markersize 0,0 so they can't be seen but you can still use them for storing information. For example, set its color or set its rotation if a player is inside a 500m radius. That way you could activate anything that needs to be done if a player is near, like spawning civilians & enemy forces & special structures.

A MP script handling player activated markers would need to handle 3 situations:
1. Sole player is inside a marker radius
2. Sole player is outside "
3. Several players are inside a marker. 1 player left the marker radius while others are still inside the marker.

Obviously, the 3rd is the tricky one. Imo this can't be done without all scripts synced via a clock signal. For example: if every player checks his position every 1 second, a script would need 2 seconds (2 clocks) to solve the problem of the 3rd situation:

- 1st clock signal: 1st and 2nd player are inside the marker
- 2nd clock signal: 1 is outside, 1 is inside the marker. (we can't know if the marker setting is right now or was overwritten with a false setting)
- 3rd clock signal: only 1 player is signalling: i'm inside

So basically the script would only need to signal once that a player left the marker but only if he was inside the same marker before.


What i'd like to know is if somebody has a more easier approach to this. Anyone?

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Activating areas by players in MP
« Reply #1 on: 21 Jul 2009, 10:59:26 »
I haven't done much MP scripting so please don't hit me if I miss the obvious. What's the problem with using triggers here?
try { return true; } finally { return false; }

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re: Activating areas by players in MP
« Reply #2 on: 21 Jul 2009, 11:24:37 »
Well, 1st: if you got the whole island covered by many it affects performance. You have no control over how fast they update their triggerlists (i believe they do this every 0.5 seconds right?). In case your mission doesnt need information that fast its wiser to use scripts.

In my case i need to spawn Ai units when a player is nearing a city or another strategic area and it doesn't matter if he's 500m or 480m away.

2nd: can you make triggers react just to human players and not to player side AI? How about a player that has lost connection?

3rd: you can delete or create new markers and their scripts with full control over their parameters. You can do this with triggers too but i think you cannot define all kinds of parameters in those, can you?

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Activating areas by players in MP
« Reply #3 on: 21 Jul 2009, 17:32:36 »
It is probably easier just to use triggers than mess around with complex code on the off-chance that it is overall faster than running the triggers. If you get to a point where triggers really are grinding the FPS, then start worrying about alternatives.

Code: (condition that picks up only players) [Select]
({ isPlayer _x } count thisList) > 0
thisList would still contain AI and players together, but easy enough to filter that list using isPlayer if you need to.

You can delete and recreate triggers quite happily, but the only problem is that you can't read all the existing trigger information from them (you can in Arma2). You'd need to store this information elsewhere.

A player that has lost connection is dealt with differently depending on whether ai is disabled.
« Last Edit: 22 Jul 2009, 17:49:11 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re: Activating areas by players in MP
« Reply #4 on: 21 Jul 2009, 18:29:50 »
Okay, thx for all the infos guys. I'll do some tests. If i find something interesting i'll report back.  :yes: