Scripts / how can i change interaction radius of an object?

Author
Message
nuncio
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 28th Jan 2015
Location: Schleswig Holstein, Germany
Posted: 13th Aug 2015 02:05
hi there! what must i do to make the key NOT be accessable from on floor below or above the key? i want the message "press e to take key" to appear when i stand right in front of the key. how can i do this?
http://www.nuncio-rap.de
intel core i5-3570K CPU @ 3.40GHz; 8GB RAM // NVIDIA GeForce GTX560Ti
Teabone
Forum Support
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 13th Aug 2015 04:25 Edited at: 13th Aug 2015 04:30
I was playing with this the other day since there is a cone detection from left to right. Not sure about up and down though. Though it is indeed possible to do this. I'm just not that great at the math :p lol

FPSCx9 had the simple command for this. It was simply "INVIEW=1" as a condition. In GG you have to pretty much write up the LUA for this yourself checking all the axis coordinates. If you look in key.lua you'll see all the areas related to angle detecting, but you'd have to fine tune them in some way to work the way you want.
i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce 420 GT
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 13th Aug 2015 09:08 Edited at: 13th Aug 2015 09:09
There was a command plrfacing in fpsc and here is the lua code for it
Paste this code piece at the end of your script:


and then use it like this:


That is it. Of course you must change the value to your needs. For bigger objects you maybe need a high value, but for small objects it is very usefull.
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
nuncio
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 28th Jan 2015
Location: Schleswig Holstein, Germany
Posted: 14th Aug 2015 01:46
when i want to use this for a key, where do i have to insert this code? in the "key.lua"? where in the file do i have to put it in?
http://www.nuncio-rap.de
intel core i5-3570K CPU @ 3.40GHz; 8GB RAM // NVIDIA GeForce GTX560Ti
Teabone
Forum Support
18
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 14th Aug 2015 02:28
plrfacing that's the command I was actually referring to! Forgot about that one.
i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce 420 GT
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 14th Aug 2015 11:00
here:
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
SoUlFaThEr
9
Years of Service
User Offline
Joined: 20th Jul 2015
Location:
Posted: 14th Aug 2015 12:31
Could we reduce all that code into a function call and give it a name like PlayerLooking(e) ?

Kind of like if PlayerDist = GetPlayerDistance(e) where getplayerdistance is actually replacing 5 lines of code from earlier or older scripts.
The only stupid questions are those that were never asked.
PM
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 14th Aug 2015 14:31 Edited at: 14th Aug 2015 14:31
Of course you could, but this would not make much sense. But you could do this:


and if you place the plrfacing function in the global.lua you could also delete this part (line 23 until 43)
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
nuncio
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 28th Jan 2015
Location: Schleswig Holstein, Germany
Posted: 14th Aug 2015 23:52
@corno:
thank you for helping me! ehm: i have to place this code into a new lua file, save it and refer the key to this new file? is this right?
http://www.nuncio-rap.de
intel core i5-3570K CPU @ 3.40GHz; 8GB RAM // NVIDIA GeForce GTX560Ti
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 15th Aug 2015 11:51
Yes. But make sure you not overwrite key.lua, cause this could be updated one time and then this script is gone. Place it in another folder or rename it
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
nuncio
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 28th Jan 2015
Location: Schleswig Holstein, Germany
Posted: 15th Aug 2015 22:32
i copied the script into "key besser.lua" and attached it to the key. when i start testgame i get the error message scriptbank\key besser.lua:1: syntax error near 'Script'
http://www.nuncio-rap.de
intel core i5-3570K CPU @ 3.40GHz; 8GB RAM // NVIDIA GeForce GTX560Ti
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Aug 2015 22:40
you aren't allowed spaces so rename it key_besser.lua and make sure any function calls are the same name
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
nuncio
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 28th Jan 2015
Location: Schleswig Holstein, Germany
Posted: 15th Aug 2015 22:50 Edited at: 15th Aug 2015 22:53
ah!! i just found out, yes, thank you i just changed it and oh i still get this message. restart game guru?
http://www.nuncio-rap.de
intel core i5-3570K CPU @ 3.40GHz; 8GB RAM // NVIDIA GeForce GTX560Ti
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 15th Aug 2015 23:46
Have you changed script in entity properties dialog? You must choose this new file there, too.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 16th Aug 2015 00:36
make sure you copied the start correctly, there should be -- infront of the first couple lines, seems like you missed them
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
nuncio
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 28th Jan 2015
Location: Schleswig Holstein, Germany
Posted: 16th Aug 2015 03:00
yes in the file they are missing. i added it and renamed the file in the properties and now i'm starting a new try...
it doesn't work. well it actually works but it has no effect on the key.



this is the code i associated with the key it's called "keybesser.lua"

as you can see in the screenshot the radius of interaction has not become smaller. looks like it is still the same or even bigger?!
http://www.nuncio-rap.de
intel core i5-3570K CPU @ 3.40GHz; 8GB RAM // NVIDIA GeForce GTX560Ti

Attachments

Login to view attachments
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 16th Aug 2015 17:40 Edited at: 16th Aug 2015 17:45
change line 10 to a smaller value
if PlayerDist < 150 and g_PlayerHealth > 0 then
to
if PlayerDist < 100 and g_PlayerHealth > 0 then

you've also added the angle check twice, it should look like this



p.s. im 90% sure that function is actually incorrect if the value used is anything other than 20... i shall have to check it though
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
nuncio
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 28th Jan 2015
Location: Schleswig Holstein, Germany
Posted: 17th Aug 2015 00:39
thanks, now it's working a little better as you can see in the new sceenshot i can now move closer to the key before the text appears. is it possible to show the text just when you're standing in front of it?
http://www.nuncio-rap.de
intel core i5-3570K CPU @ 3.40GHz; 8GB RAM // NVIDIA GeForce GTX560Ti

Attachments

Login to view attachments
nuncio
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 28th Jan 2015
Location: Schleswig Holstein, Germany
Posted: 20th Aug 2015 08:41
what can i change to make the interaction radius a little smaller?
http://www.nuncio-rap.de
intel core i5-3570K CPU @ 3.40GHz; 8GB RAM // NVIDIA GeForce GTX560Ti
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 20th Aug 2015 11:32
Quote: "p.s. im 90% sure that function is actually incorrect if the value used is anything other than 20... i shall have to check it though"

Could be, because I not coded this myself and also not checked it. I just paste the standart code from the weapon code in a function. That´s all. If it is incorrect, al standart scripts are incorrect
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM

Login to post a reply

Server time is: 2024-12-22 05:38:17
Your offset time is: 2024-12-22 05:38:17