Xiotex - Torn tendons and scripted AI

The only place you'll ever hear the truth
User avatar
Phelanpt
level5
level5
Posts: 1837
Joined: Thu Aug 10, 2006 4:20 am
Location: Portugal

Postby Phelanpt » Thu Feb 05, 2009 5:21 pm

Nice. :)
RabidZombie
level5
level5
Posts: 2414
Joined: Fri Nov 18, 2005 10:09 pm

Postby RabidZombie » Thu Feb 05, 2009 6:40 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.
User avatar
NeatNit
level5
level5
Posts: 2929
Joined: Mon Jan 28, 2008 2:41 pm
Location: Israel
Contact:

Postby NeatNit » Thu Feb 05, 2009 9:03 pm

I've never seen one. Then again I was never a very active mod downloader. Any examples from memory?
RabidZombie
level5
level5
Posts: 2414
Joined: Fri Nov 18, 2005 10:09 pm

Postby RabidZombie » Thu Feb 05, 2009 9:22 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.
User avatar
Xarlaxas
level5
level5
Posts: 1525
Joined: Sat Apr 15, 2006 4:48 pm
Location: Edinburgh
Contact:

Postby Xarlaxas » Thu Feb 05, 2009 9:32 pm

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! ^.^
User avatar
Byron
level2
level2
Posts: 147
Joined: Tue May 13, 2008 3:48 pm

Postby Byron » Thu Feb 05, 2009 9:38 pm

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!
User avatar
Xarlaxas
level5
level5
Posts: 1525
Joined: Sat Apr 15, 2006 4:48 pm
Location: Edinburgh
Contact:

Postby Xarlaxas » Thu Feb 05, 2009 9:42 pm

Hah! Well, back to 100% then. :P

Your work ethic impresses and scares me!
RabidZombie
level5
level5
Posts: 2414
Joined: Fri Nov 18, 2005 10:09 pm

Postby RabidZombie » Thu Feb 05, 2009 9:50 pm

Xarlaxas wrote:Your work ethic impresses and scares me!


Indeed. Although I do the same when I actually want to get something done. Nothing will stop me.
User avatar
Byron
level2
level2
Posts: 147
Joined: Tue May 13, 2008 3:48 pm

Postby Byron » Thu Feb 05, 2009 10:31 pm

Xarlaxas wrote:Hah! Well, back to 100% then. :P

Your work ethic impresses and scares me!


Nah, Mark would have fired me. :lol:
User avatar
Xarlaxas
level5
level5
Posts: 1525
Joined: Sat Apr 15, 2006 4:48 pm
Location: Edinburgh
Contact:

Postby Xarlaxas » Thu Feb 05, 2009 10:41 pm

Yes, yes I would. <.< >.>
User avatar
Byron
level2
level2
Posts: 147
Joined: Tue May 13, 2008 3:48 pm

Postby Byron » Wed Feb 11, 2009 1:32 am

Got the first script driven AI unit working. So far the script looks like:


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.
User avatar
Byron
level2
level2
Posts: 147
Joined: Tue May 13, 2008 3:48 pm

Postby Byron » Wed Feb 11, 2009 2:15 am

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 :)
User avatar
Pox
level5
level5
Posts: 1786
Joined: Sat Mar 03, 2007 11:23 am
Location: Melbourne

Postby Pox » Wed Feb 11, 2009 3:02 am

Oooh, curious-but-shy toroids. They have personality already! :P
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Wed Feb 11, 2009 3:04 am

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
User avatar
Byron
level2
level2
Posts: 147
Joined: Tue May 13, 2008 3:48 pm

Postby Byron » Wed Feb 11, 2009 10:22 am

You will see soon (as I am preparing a dual build again) that the actual oscillation while there is not an issue visually since it is smoothed out by the steering force functions.

Return to “Introversion Blog”

Who is online

Users browsing this forum: No registered users and 4 guests