Xiotex - Torn tendons and scripted AI
-
RabidZombie
- level5

- Posts: 2414
- Joined: Fri Nov 18, 2005 10:09 pm
Byron wrote:Phelanpt wrote:Get well soon, Byron!
I love the idea for allowing external AI, but I'm not so fond of the automated repository, it would make it too easy to allow malicious code to execute.
Don't worry - the scripts can only do anything within the sandbox confines of the game itself. All possible filesystem access or anything beyond the API of the game alone is being stripped.
Ah, good old Gmod 9 viruses. Those were the days.
-
RabidZombie
- level5

- Posts: 2414
- Joined: Fri Nov 18, 2005 10:09 pm
NeatNit wrote:I've never seen one. Then again I was never a very active mod downloader. Any examples from memory?
There were only a few. The one I remember most was one that'd make the server automatically send the virus to all connecting clients. Once the clients had left and started their own game, the lua file would be automatically run and would likely a) make all connecting clients download it, b) rebind all controls and/or c) exploit a bug in the API and overwrite an important file in C:\Windows preventing the PC from booting (if Windows was installed to C:\). The last one was the particularly vicious one.
Weatherproof wrote:Quoting Microsoft here:
'Byron, you have some serious work focus abilities to have carried on that conversation last night without even mentioning that you were just in an accident! Rest up and our thoughts will be with you.'
Same here.
I also concur with Microsoft there! You are truly impressive to be able to keep on going after injuring yourself so badly, I wish you a speedy recovery so you can get back to your work! ^.^
Xarlaxas wrote:Weatherproof wrote:Quoting Microsoft here:
'Byron, you have some serious work focus abilities to have carried on that conversation last night without even mentioning that you were just in an accident! Rest up and our thoughts will be with you.'
Same here.
I also concur with Microsoft there! You are truly impressive to be able to keep on going after injuring yourself so badly, I wish you a speedy recovery so you can get back to your work! ^.^
Get back to work? I was using my iPhone to keep in touch and direct the team from the hospital bed. I haven't had a day off yet
Bah - tis only a flesh wound!
-
RabidZombie
- level5

- Posts: 2414
- Joined: Fri Nov 18, 2005 10:09 pm
Got the first script driven AI unit working. So far the script looks like:
It's a fairly simple script with the AI constantly following the player. So what happens is every frame the 'OnUpdate' function on the unit gets called and the script it contains is run. Xiotex has a few API functions exposed that LUA can call. For the moment this API list is small and they are mainly directives but I am adding functions to get useful information out of the game so a state based AI can be written.
The most amazing thing is how little CPU time it's taking to execute the scripts. The script is small but the overhead of calling a script seems to be really small so there is hope that complex scripts would not take up too much time.
Code: Select all
function OnUpdate()
Xiotex.SetPlayerAsTarget()
Xiotex.Seek()
end
It's a fairly simple script with the AI constantly following the player. So what happens is every frame the 'OnUpdate' function on the unit gets called and the script it contains is run. Xiotex has a few API functions exposed that LUA can call. For the moment this API list is small and they are mainly directives but I am adding functions to get useful information out of the game so a state based AI can be written.
The most amazing thing is how little CPU time it's taking to execute the scripts. The script is small but the overhead of calling a script seems to be really small so there is hope that complex scripts would not take up too much time.
An interesting script is:
Which makes the AI fly towards the player but stop when it gets within 100 units and just hovers there. If the player moves away it chases again. However if you move towards the AI it runs away
Code: Select all
function OnUpdate()
Xiotex.SetPlayerAsTarget()
if Xiotex.GetDistanceToPlayer() > 100 then
Xiotex.Seek()
else
Xiotex.Flee()
end
end
Which makes the AI fly towards the player but stop when it gets within 100 units and just hovers there. If the player moves away it chases again. However if you move towards the AI it runs away
Byron wrote:An interesting script is:Code: Select all
function OnUpdate()
Xiotex.SetPlayerAsTarget()
if Xiotex.GetDistanceToPlayer() > 100 then
Xiotex.Seek()
else
Xiotex.Flee()
end
end
Which makes the AI fly towards the player but stop when it gets within 100 units and just hovers there. If the player moves away it chases again. However if you move towards the AI it runs away :)
I don't know if this would make any difference, as I don't know how fast it updates or whatnot, but might I suggest that you add a third case, and do something like this (and pardon the syntax -- I don't know anything about LUA):
Code: Select all
function OnUpdate()
Xiotex.SetPlayerAsTarget()
if Xiotex.GetDistanceToPlayer() > 100 then
Xiotex.Seek()
elseif Xiotex.GetDistanceToPlayer() < 99 then
Xiotex.Flee()
else
Xiotex.DoNothing()
end
end
Otherwise I can see the AI oscillating between 99 and 100 every other frame, which might not be a big deal (assuming that the framerate is good enough and the difference between 99 and 100 is small enough), but has the potential to be annoying. You might even have a smaller flee radius, so that the AI only flees if it gets within, say, 75 distance units -- that would make the AI faster to stop when approaching, but "braver" in terms of running away when the player approaches.
xander
Who is online
Users browsing this forum: No registered users and 4 guests






