Scripts / Something different - zones, freebie for the community

Author
Message
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 14th Aug 2017 20:23 Edited at: 22nd Aug 2017 08:15
So, no quaternions this time. Can't really say where this idea came from but someone may find it useful.

I'll explain how it's used first then we can discuss the uses which it can be put.

First define a zone using waypoints, the zone can be any shape with as many sides as needed the only rule is that the 'end' point should be close to the 'start' point.

Second place an always active entity inside the zone close to one of the waypoints and attach the script zone.lua. Give the entity the name of the zone.

Simple isn't it.

So what does it do?

The script provides a bunch of Lua functions:

PointIsInZone(x, z, zone) -- returns true if the specified point is inside the specified zone (note that zone is the name of the zone)

PlayerIsInZone(zone) -- returns true is the player is currently in the specified zone

ZonesPlayerIn() -- returns a list of all the zones the player is currently in (note zones can be nested so player can be in more than one)

MonitorZoneOn(zone) -- turns on monitoring of specified zone, once monitored the following two commands can be used:

PlayerEnteredZone(zone) -- returns true if the player has entered the specified zone since the last call to this function

PlayerExitedZone(zone) -- returns true if the player has exited the specified zone since the last call to this function

MonitorZoneOff(zone) -- turns off monitoring for specified zone

WptInZoneDefinition(x, y) -- a bit specialised, this one returns true if the specified waypoint position is used within a zone specification.
(the reason for this function is to allow waypoint following code to be able to ignore zones)

So how can this be used, take a look at the zone_test.lua script for some clues *Added correct script now *
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 14th Aug 2017 21:03
Picture shows zones in editor, fpm file to play with (may not work if you don't have the entities), video shows what it does.

Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Aug 2017 21:21
very nice, the player stuff can be done with normal zones but adjusting this to fit AI or other objects would be super handy for more precise requirements (rather than relying on distances for everything) - thanks
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 14th Aug 2017 22:20 Edited at: 14th Aug 2017 22:21
The main difference is that the zones can be any shape or size, normal zones are limited to what you can cover with a 5 vertex polygon.

It should also make scripts much easier to read as the zones names can be used directly within the calls so something like:

if PlayerEnteredZone('crypt') then ...

can be used which is very clear as to what is going on.
Been there, done that, got all the T-Shirts!
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 15th Aug 2017 00:07
Sweet. Thank you.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th Aug 2017 09:51
Just noticed the test script I put up in the first post is not the one for the fpm (or that shown in the video) oops, will fix it tonight after work.
Been there, done that, got all the T-Shirts!
PM
GraPhiX
Forum Support
19
Years of Service
User Offline
Joined: 15th Feb 2005
Playing:
Posted: 15th Aug 2017 10:10
this is very good and useful thank you for sharing Amen
Welcome to the real world!
Windows 10 Pro x64 - Core i7-7700K @4.2GHz - 32GB DDR4 RAM - GeForce GTX 1060-6G 6GB - 1TB NVe SSD
perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 15th Aug 2017 10:16
Hi AmenMoses

Quote: "The main difference is that the zones can be any shape or size, normal zones are limited to what you can cover with a 5 vertex polygon."


Just wanted to let you know, (and others) that you can add and delete nodes to "normal zones" trigger zones, etc.

To add a node: Hold shift and LMB click on an existing node, it will add one beside it.
To delete a node: Hold shift and RMB click on an existing node.
To delete the zone: Hold shift and RMB click on the main node (the largest star).


Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 CPUs), ~3.6GHz, Windows 10, 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768, Passmark 3528.
Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 15th Aug 2017 19:21 Edited at: 20th Aug 2017 17:53
I didn't know that, pity we can't get at the node positions from Lua though like you can with waypoints ... or can you?

I've added the correct script to the original post now btw, the one that goes with the fpm file.
Been there, done that, got all the T-Shirts!
PM
perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 15th Aug 2017 20:24
Quote: "pit we can't get at the node positions from Lua though like you can with waypoints ... or can you?"


Not sure, i know you couldn't get their position before lua was opened up, i haven't looked sense its been opened.
Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 CPUs), ~3.6GHz, Windows 10, 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768, Passmark 3528.
Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 20th Aug 2017 17:49 Edited at: 20th Aug 2017 17:54
I did say the zones can be any size and shape!

Picture shows a zone depicting the race track, the scipt I am developing for the buggy navigates using the PointIsInZone instruction,

Still need to iron out some steering niggles but here is a video of the result:

Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 21st Aug 2017 05:02
Brilliant.

Thank you for your continued work.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

GraPhiX
Forum Support
19
Years of Service
User Offline
Joined: 15th Feb 2005
Playing:
Posted: 21st Aug 2017 10:31
excellent stuff mmm I wonder, is it possible to use this on water?? ie for boats, jet ski's etc ?
Welcome to the real world!
Windows 10 Pro x64 - Core i7-7700K @4.2GHz - 32GB DDR4 RAM - GeForce GTX 1060-6G 6GB - 1TB NVe SSD
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 21st Aug 2017 21:01
Don't see why not.

I was just showing off the capabilities rather than a serious solution btw, if I was making a real race track I'd probably do it with zones within zones, i.e. create one zone encompassing the entire outside edge of the track, another slightly inside that, another inside that etc, then track the position of the vehicle as it changes zone.

So for example if the outside edge is zone 1 and the one inside that is zone 2 then as the vehicle crosses from zone 2 into zone one I would turn it back towards zone 2.

This enables you to have multiple vehicles, to overtake a vehicle in zone 2 you steer towards zone 3 for example.

I am planning on extending the MonitorZone bit to enable monitoring of any specified entity and to enable you to find out which zone(s) any monitored entity is currently in. If in addition to the track zones you add 'sector' zones then you could detect where around the track any particular car is, for example if we divide up the track into 16 sequential sectors and a car is in sector 8 say, then it only needs to do collision detection (or overtaking calculations) on cars in the same sector or the next (sector 9) any others it can safely ignore.

Should make it possible to write simplified AI scripts for the cars.

I'm sure others can think of many other uses for this, enemy soldiers for example could find out where others of their 'squad' are located and even send each other instructions like 'meet in zone D' and they could navigate from zone to zone (simply make lists of zones that the AI could look up to find the path from one to the other, maybe have a waypoint in each zone linked to another in the destination zone then the character simply locates the waypoint that is in his zone that connects to the one in the other zone and follows the path until it reaches the destination).

Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 21st Aug 2017 23:13 Edited at: 22nd Aug 2017 18:25
Grrrr, made the changes I described and a nice video to go with them and my vimeo account is buggered so I can't post it.

Oh well, here is the new script with new commands, they should be pretty obvious to figure out. I haven't fully tested them so let me know if you find any bugs.

Vimeo account working again so here it is:

Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 22nd Aug 2017 21:40
Something like this:

Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 23rd Aug 2017 20:49


So here we have 6 zones nested, i.e. each zone is an oval the same shape as the track with zone 1 on the inside and zone 6 the outside.

Each buggy stays in the zone it starts off in and they are currently all going at the same maximum speed.

Next step is to add collision detection and 'lane changing', i.e. each will attempt to get the inside line around the track but will avoid collisions with any of the other buggies whilst doing so.

I will add a slight speed disadvantage on the bends for being on the inside of the curve compared to outside (simply by adding a curve zone to each end and detecting when the buggy enters or leaves it) and add logic to attempt to overtake by switching 'lanes' and have a small 'boost' in acceleration when doing so.

Finally I'll allow the player to control one of the buggies, the only difference being a collision will result in rapid deceleration and maybe damage.

Anyone thought up any other uses for it yet or care to share any ideas?
Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 23rd Aug 2017 21:12
Just in case my description was too vague here is a pic:
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 24th Aug 2017 20:19


Speed control done, discovered a bug in the zones script so here is the fixed version.


Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
GraPhiX
Forum Support
19
Years of Service
User Offline
Joined: 15th Feb 2005
Playing:
Posted: 24th Aug 2017 21:54
brilliant work Mr now go and have your holidays
Welcome to the real world!
Windows 10 Pro x64 - Core i7-7700K @4.2GHz - 32GB DDR4 RAM - GeForce GTX 1060-6G 6GB - 1TB NVe SSD
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 30th Aug 2017 23:08
lol love what your doing here m8 as Graphix says go chill dude
Intel i5 4950 Quad core 3.3ghz AMD FX 6300 x6 cores 3.5ghz(unclocked)
8gb Ram 8gb Ram
AMD Radeon 7570 1gb AMD Radeon HD 6670 2gb
and a well fed mouse on a wheel

I only smile because i have absolutely no idea whats going on
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 10th Sep 2017 13:16 Edited at: 10th Sep 2017 13:28
This is an old level I made the first week I got GG which I've remade using the zones script (which simplified the 'goal' code somewhat).

What impresses me most is that even after all the churn of the last 18 months this level works the same now with the latest Beta as it did back at version 1.12 (I think that was the current version at the time).




All files attached bar the music as that file was too large.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM

Login to post a reply

Server time is: 2024-03-29 05:26:06
Your offset time is: 2024-03-29 05:26:06