JC-MP

Scripting => Releases => Topic started by: SinisterRectus on January 01, 2016, 05:26:01 pm

Title: [Release] Settlement Triggers
Post by: SinisterRectus on January 01, 2016, 05:26:01 pm
Settlement Triggers

(http://i.imgur.com/fiTZB3yl.jpg) (http://i.imgur.com/fiTZB3y.jpg)
*Visualizations not included

Download from GitHub here (https://github.com/SinisterRectus/JC2MP-Settlements)

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
Title: Re: [Release] Settlement Triggers
Post by: Lord_Farquaad on January 01, 2016, 06:18:04 pm
This is really awesome!  Thanks for releasing this.  I can already see a few uses...
Title: Re: [Release] Settlement Triggers
Post by: SinisterRectus 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.
Title: Re: [Release] Settlement Triggers
Post by: JasonMRC 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.
Title: Re: [Release] Settlement Triggers
Post by: Darwood37 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?
Title: Re: [Release] Settlement Triggers
Post by: SinisterRectus 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.
Title: Re: [Release] Settlement Triggers
Post by: Darwood37 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?
Title: Re: [Release] Settlement Triggers
Post by: SinisterRectus 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.
Title: Re: [Release] Settlement Triggers
Post by: SinisterRectus 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.
Title: Re: [Release] Settlement Triggers
Post by: SinisterRectus 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.
Title: Re: [Release] Settlement Triggers
Post by: Darwood37 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.