Scripts / Function for sending an AI entity to a location

Author
Message
Saintyboy
8
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 9th Oct 2015 00:57
Cant seem to find a function for this
Although I found this
AIEntityGoToPosition(EntObjNo,500,500)
but it doesn't work

any ideas anyone?
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 9th Oct 2015 16:37
It does work for character entities. Are you getting the EntObjNo with EntObjNo = g_Entity[e]['obj'] ? You might have to first initialise with AISetEntityControl(EntObjNo,AI_MANUAL) also - can't remember exactly

Cheers.
Saintyboy
8
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 9th Oct 2015 16:56
Thanks for the reply cybernescense, is 'obj' the name of the entity or the id no?
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 9th Oct 2015 18:18
use it like that (if it's not being called inside the actual ai script then you will need to change 'e' to match the entity number though)
they will move from their current position to the new one though, it's not an instant move.
for an instant move you want to use

CollisionOff(e)
SetPosition(e,x,y,z)
AIEntityGoToPosition(g_Entity[e]['obj'],x,z)
CollisionOn(e)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Saintyboy
8
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 9th Oct 2015 21:40
Again, thanks smallg but is 'obj' the name of the entity or the id no or is that how is should be written?
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 9th Oct 2015 22:18
sorry if i wasnt clear, i said use it like that
it's just a reference from the standard AI code, you can't and shouldn't change it - only the 'e' value will change.
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
hiredgunz48
8
Years of Service
User Offline
Joined: 9th Sep 2015
Location: Seattle, Washington
Posted: 13th Oct 2015 20:13
Sorry to just jump in here, but thought it better than a new thread about the same thing. I'm trying to have an AI soldier walk from one point to a specific point on the map (to a range area to train the player who has to follow the AI soldeir). The AI soldier doesn't move though. Here's my attempt:



Thanks in advance,

Jan

Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 13th Oct 2015 21:13
you probably just need to set him armed or unarmed before


life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
hiredgunz48
8
Years of Service
User Offline
Joined: 9th Sep 2015
Location: Seattle, Washington
Posted: 13th Oct 2015 21:29 Edited at: 13th Oct 2015 21:31
Thankyou smallg,

I tried with CharacterControlUnarmed(e), and CharacterControlArmed(e) and the soldier is still refusing to obey orders. Time for a court marshal?
Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 13th Oct 2015 23:55
then i guess he's not on the terrain?
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
hiredgunz48
8
Years of Service
User Offline
Joined: 9th Sep 2015
Location: Seattle, Washington
Posted: 14th Oct 2015 00:16
appears to be... flat surface, but rotates to the player rather than the flower objective. I've checked the flower's x,z and the player's and completely different, yet I understand the AIEntityGoToPosition is supposed to rotate the AI soldier to their objective's direction... I'll figure it out eventually, but thanks very much for your suggestions

best,

Jan
Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram
hiredgunz48
8
Years of Service
User Offline
Joined: 9th Sep 2015
Location: Seattle, Washington
Posted: 14th Oct 2015 00:36
Got it ... had to change the AIEntityGoToPosition to the below and it works now.



The "e" wasn't working.... Duh

Thanks again for responding
Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram
hiredgunz48
8
Years of Service
User Offline
Joined: 9th Sep 2015
Location: Seattle, Washington
Posted: 14th Oct 2015 02:17 Edited at: 14th Oct 2015 03:45
Okay, ignore everything above The "e" does work, and the EntObjNo variable means you have to stand at a 90 degree angle for the solder to go to the objective point. Here is the correct code for the soldier to move to the static objective's point is case someone else is looking for this ...(apologies if this is already somewhere on the forum)

Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram
Isagabe
9
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 14th Oct 2015 12:59
Thank you to those who contributed to this thread. I have been pulling my hair out with this one for a while now. This bit of code made all the difference. Not sure I would have figured it out by myself.
hiredgunz48
8
Years of Service
User Offline
Joined: 9th Sep 2015
Location: Seattle, Washington
Posted: 14th Oct 2015 18:53 Edited at: 14th Oct 2015 18:58
Well, there is a caveat with the code of mine.. it's works... sometimes, and other times it doesn't. I will continue to see if I can find the condition that makes the character just face the player and ignore leaving for the objective point, and other times going to the objective point. It could be some other code of mine that is interfering though...

Oh, and I pretty much just stole the code from the ai_soldier.lua and other code on the forum.. yes, i'm talking about you smallg

best,

Jan
Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram
hiredgunz48
8
Years of Service
User Offline
Joined: 9th Sep 2015
Location: Seattle, Washington
Posted: 15th Oct 2015 04:25
Hi, I've written a script to show complete dialog at once, then the AI soldier is supposed to move to a certain xz of a static object elsewhere in the map. Sometimes the AI soldier moves to the coordinates using AIEntityGoToPosition() just fine for 1 or 2 test moves, but then stops moving at all (except to rotate to the player). I'm not sure if I've made a coding mistake or something else is interfering. Gameguru goes through all the code just fine, displaying the 3 lines of text, Prompt, then the AIEnityGoToPostion() code, but AI goes nowhere. Would anyone mind checking if I've made some error?



Thanks in advance for any help.
Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram
hiredgunz48
8
Years of Service
User Offline
Joined: 9th Sep 2015
Location: Seattle, Washington
Posted: 15th Oct 2015 10:32
Okay... it appears the building and player right in front of the AI soldier was confusing him, so I rotated him to his right, walked forward a couple steps and he had a clear shot to the objective. No problem now.

Thanks,

jan
Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram

Login to post a reply

Server time is: 2024-05-04 22:26:35
Your offset time is: 2024-05-04 22:26:35