Scripts / Helicopter Script

Author
Message
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 8th Mar 2016 00:20
Hire guys. I'm a Lua novice. I'm trying to write a script to have a helicopter follow the player. The main problem seems to be that the artist has designed this excellent chopper so MoveForward actually moves it sideways. I've tried rotating the model in a modelling app but the result was unexpected. Any help would be appreciated. Thanks.



Julian
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Mar 2016 18:20
use fixnewy = 90 or 270 in the fpe file to make it face the correct direction.

for the script all you need is

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 8th Mar 2016 21:46
Julian
PM
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 8th Mar 2016 21:49
I added ambient sound to the script so the choppers get louder when closer. Thanks for the help.
Julian
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 9th Mar 2016 13:07
Here's a small challenge for you smallg, along the same idea, but how would you change the script so that it would fly towards an entity you have named in the helicopters ifused field?

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 9th Mar 2016 13:43 Edited at: 9th Mar 2016 13:45
@ Belidos
I think "AIEntityGoToPosition(EntObjNo,ai_start_x[e],ai_start_z[e])", before
"RotateToPlayerSlowly(e,3)", and so on, might help.

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 9th Mar 2016 18:50 Edited at: 9th Mar 2016 18:51
as far as im aware you can't find out the value of the 'ifused' field so it's not possible but you could check for an entity with a specific name or number if you stored it in the name field instead.

i dont think using AIEntityGoToPosition will work as the entity would need to be following the terrain, maybe if you had the origin point of the object way below it to simulate height? im not 100% sure.

anyway i have a RotateToEntity(e,t) function that would work fine.

so something like this (put the entity number of the target in the 'name' field of the entity with this script)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 9th Mar 2016 19:27
Quote: "i dont think using AIEntityGoToPosition will work as the entity would need to be following the terrain, maybe if you had the origin point of the object way below it to simulate height? im not 100% sure."

You are right, even if you know IE (0,0,0), it does not always would be the same in every models out there, so the script would becames as customizable, since each one has to customized it, to fit their needs.

Nice script as usually.

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 9th Mar 2016 20:59
I knew you could do it smallg

The reason I asked is because I noticed in the video they kind of all merge together because collisions off to make them move, so I thought if they had a target each to go to behind out of site you would get a much smoother fly by, like this:


i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.
Honkeyboy
3D Media Maker
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 9th Mar 2016 22:14
lol I love this forum theres always something mad going on ......wicked
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 10th Mar 2016 18:16
Yeah. Collision detection is an issue. But I can't see a way around having physics off. Maybe there's a way to detect the distance between entities.
Julian
PM
gamerpro980
User Banned
Posted: 16th May 2016 08:17
can you give me the script attachment
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 5th Jul 2016 21:15 Edited at: 5th Jul 2016 21:15
Smallg.... has something changed in LUA, this script doesn't seem to work for me anymore, it gives the following error:


i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.

Attachments

Login to view attachments
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 5th Jul 2016 22:30
Quote: " (put the entity number of the target in the 'name' field of the entity with this script)"

you likely just need to set the name of the entity to the entity number of the target.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 5th Jul 2016 22:40
I did, that's when it gave me the error

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Jul 2016 12:59
ok, tested and it seems to be because the init(e) section is not loaded for all objects before the main(e) - therefore the object is not being loaded before it is trying to access it (if you placed the target after the helicopter)
a simple check and return will fix it
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 7th Jul 2016 13:03
Thanks SG, i'll check it out when I get home tonight.

I wonder why it just suddenly stopped working, something must have changed in GG during an update.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.

Login to post a reply

Server time is: 2024-05-04 08:51:14
Your offset time is: 2024-05-04 08:51:14