Currently the developers are putting their own money into JC2-MP to keep the servers online.

Please take a few seconds of your time and disable your AdBlock plugin for our website.

Ad revenue is not going to developers, it is used purely for covering our hosting costs.

 

You are also free to donate, which removes all ads from our website!

Patch 0.3 was just released! Full changelog here: https://t.co/4A50m6IKen

7 months ago

December 12, 2017, 03:09:45 pm
  • [Release] Settlement Triggers 5 2
Currently:  

Author Topic: [Release] Settlement Triggers  (Read 2328 times)

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 448
    • View Profile
[Release] Settlement Triggers
« on: January 01, 2016, 05:26:01 pm »
Settlement Triggers


*Visualizations not included

Download from GitHub here

Description

- This is a utility script that uses ShapeTriggers from Just Cause 2's binaries to determine a player's proximity to each of Panau's mapped settlements; 369 in total.
- An event is fired for the entering and exiting of each settlement.
- PlayerEnterSettlement and PlayerExitSettlement fire on both the server and client.
- LocalPlayerEnterSettlement and LocalPlayerExitSettlement fire on the client.
- The firing of events can be toggled with the "fire_local" and "fire_network" variables.
- Arguments for the event callbacks are player and settlement.
- Accessible settlement properties are id, name, position, and angle.

Example Usage

This script could be used for creating or destroying location-specific assets, but here is a simpler example than that:

Code: Lua
  1. Events:Subscribe("LocalPlayerEnterSettlement", function(args)
  2.     Chat:Print(string.format("You have entered %s.", args.settlement.name), Color.White)
  3. end)
  4.  
  5. Events:Subscribe("PlayerExitSettlement", function(args)
  6.     Chat:Print(string.format("%s has exited %s.", args.player, args.settlement.name), Color.White)
  7. end)

Notes

- Offset ShapeTrigger components do not appear to be working properly, so I split Panau City's trigger components into multiple triggers.
- Thanks to jaxm and SK8RJOSH for the settlement names
« Last Edit: January 13, 2016, 05:34:07 am by SinisterRectus »

Lord_Farquaad

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: [Release] Settlement Triggers
« Reply #1 on: January 01, 2016, 06:18:04 pm »
This is really awesome!  Thanks for releasing this.  I can already see a few uses...

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 448
    • View Profile
Re: [Release] Settlement Triggers
« Reply #2 on: January 01, 2016, 06:48:09 pm »
Enjoy. It's pretty simple right now, as the only argument fired is the settlement name. I could expand it to include an ID, location, player, type, maybe even a Settlement class for both the client and server, but I wanted to keep it simple for now. And the most important part is the trigger data. Let me know how it works for you.
« Last Edit: January 01, 2016, 07:12:29 pm by SinisterRectus »

JasonMRC

  • Donator
  • Hero Member
  • *****
  • Posts: 603
    • View Profile
Re: [Release] Settlement Triggers
« Reply #3 on: January 01, 2016, 07:18:47 pm »
Sweet. I'll definitely have to take a look at this.

I think type(city, village, military base, airport, etc however you deem it) and position would be useful as event arguments.

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: [Release] Settlement Triggers
« Reply #4 on: January 03, 2016, 02:03:57 am »
This is great Is there a way to use different trigger sizes without adding a whole new triiggers table or adding them to the current table?

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 448
    • View Profile
Re: [Release] Settlement Triggers
« Reply #5 on: January 03, 2016, 02:45:48 am »
The numbers aren't meant to be changed, since they are straight out of the game itself, but if you must, you can adjust the arrays in triggers.lua and city_triggers.lua. Values such as {250,100,100} are the sizes.

I'm still debating what to do as far as making this more feature-filled.

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: [Release] Settlement Triggers
« Reply #6 on: January 03, 2016, 05:05:27 am »
I was thinking i could adapt it to use my own table of Vector3 positions and then add different trigger points Instead of currently iterating using distances. Would this be less intensive, keep my client FPS up?

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 448
    • View Profile
Re: [Release] Settlement Triggers
« Reply #7 on: January 03, 2016, 05:58:26 am »
I'd say that, because they don't require continous monitoring, triggers are more efficient than distance or bounding box checks, especially when you have a lot of positions or need to use a rotated box.

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 448
    • View Profile
Re: [Release] Settlement Triggers
« Reply #8 on: January 13, 2016, 03:59:23 am »
I've completely overhauled this script to include client and server events and additional settlement properties (id, name, position, angle). See the original post for more information. Please report any bugs.
« Last Edit: January 13, 2016, 04:01:58 am by SinisterRectus »

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 448
    • View Profile
Re: [Release] Settlement Triggers
« Reply #9 on: November 22, 2016, 02:29:27 pm »
Apologies to anyone who tried to use this script and ran into an issue. It seems that my hack for having multiple trigger components did not take other players into account. For example, if two players entered a trigger and only one left, the events would not properly fire. This should now be fixed as of about a month ago.

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: [Release] Settlement Triggers
« Reply #10 on: November 23, 2016, 01:43:07 am »
OMG, i toyed with this script for a while and ran in to an issue and thought i was doing something wrong, so i out it on the shelf until i had more time.