Scripts / A character changes state when player approaches

Author
Message
Enzo1400
6
Years of Service
User Offline
Joined: 26th Jul 2018
Location:
Posted: 20th Sep 2018 21:29
Hello to everybody. I've two questions, please.

1) In the GameGuru scriptbank there are many ai scripts, and others can be added. Now, I would like to position a character that, for example, is in ai_dance state, and after he changes to ai_neutral state when the player approaches to him. I've tried to use the lua function "dofile", but it doesn't work, also because I don't know lua programming yet. So, is it possible to call another lua ai script from a particular lua file? Another example: a character is in neutral state, but when the players approahces he changes in ai_soldier state. How can I do this, please?

2) A character is located between two blocks formed by something and the player can't pass. Is it possible to make move the character a little when the player approaches, so the player can pass? I've purchased in tgcstore.com a script for NPC talking so, similar to the first question, is it possible to add a script to an esistent lua script to make the character move or, in general, to call another ai script?

Thank you.
PM
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 22nd Sep 2018 07:46
Yes it’s possible, one way is by using ‘include’ and ‘switch’ script lua commands based around say the distance player is from character.

I’m not on comp to provide a snippet at the moment though.

Cheers.
Enzo1400
6
Years of Service
User Offline
Joined: 26th Jul 2018
Location:
Posted: 22nd Sep 2018 22:32
Thank you for the answer. If you post an example, when you have time, I would be grateful. Simply the player approaches a character ( < 100 or other) and the character changes his AI. Bye.
PM
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 22nd Sep 2018 23:52
Example snippet for switching script:



Cheers.

Enzo1400
6
Years of Service
User Offline
Joined: 26th Jul 2018
Location:
Posted: 23rd Sep 2018 20:28
Thank you for the script, but I'm new to GameGuru...
I've created a file called ai_npc_general_greet_init.lua and I've tried to use ai_dance, ai_neutral and spinloop.lua, but not working. I can't switch between the ai when the player approaches the character. Moreover, does the function "include" refer to the scriptbank folder, or I can create another custom folder that contains the files? Please, may you write me a complete lua script for example? Thank you in advance.
PM
Enzo1400
6
Years of Service
User Offline
Joined: 26th Jul 2018
Location:
Posted: 25th Sep 2018 23:53
I've solved 1) in this way, using spinloop.lua and ai_neutral, both in scriptbank folder:



Thank you to all!
PM

Login to post a reply

Server time is: 2024-12-22 20:36:01
Your offset time is: 2024-12-22 20:36:01