Author Topic: AI  (Read 1953 times)

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
AI
« on: 2 May 2012, 00:43:18 »
...
« Last Edit: 22 June 2012, 04:05:59 by MoLAoS »

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: AI
« Reply #1 on: 2 May 2012, 12:50:16 »
well the first step for custom AI is disableAi(factionIndex).

The second step is converting Units to LuaOO - objects

The third step is implementing the reactions (what it should do) of a unit.

And the last step is to implement event-handler and action-triggering.



ok, that was obviously not your question....

I'd say it this way: for really changing the AI without performance-problems you need to build the changes in C++, Lua gets very slow with multiple loops.

MG got a couple of better support-methods for this during the last month, but it is still not, perfect. So far it seems to me, GAE can even handle less AI control.

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: AI
« Reply #2 on: 2 May 2012, 17:19:46 »
Maybe it would help do build some new Lua-methods in c++ (for selecting attacking, standing, moving units) because it's quite easy, compared to the rest and build the real AI in Lua?

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: AI
« Reply #3 on: 2 May 2012, 17:42:04 »
I don't understand what you mean. Do you mean create some new orders in C++ which modders can then call with Lua?
Yes, that what I thought about, and did in my mod.

How are you doing it? (I had about 100 ndex a global which is a nil value's in BattleGlest before but it's hard to give advices without seeing any code)

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: AI
« Reply #4 on: 2 May 2012, 19:37:03 »
Ok, let's start with the basics: Lua array is started at 1    arr[1], arr[2], arr[3], ...
but that's not the problem.

You should try this: if buildingcheck == 'buildning name' or buildingcheck == ' building name' or buildingcheck == ' building name' or buildingcheck == ' building name' ...  then


MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: AI
« Reply #5 on: 2 May 2012, 20:09:45 »
Yes it should be because or means in Lua (left side or if false or nil then look on the right side if thats false, return false, else the value of the right side which is as String and not a boolean)

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: AI
« Reply #6 on: 2 May 2012, 21:53:24 »
try to put
Code: [Select]
buildings = {}
record = 1

on the top of the unitCreated. I know that, would not be what you'd like to have, but it could be the bug.

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: AI
« Reply #7 on: 2 May 2012, 22:02:35 »
yes, it would

try
table.insert(buildings, buildingid)
instead of
buildings[record] = buildingid
record = record + 1

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: AI
« Reply #8 on: 2 May 2012, 22:34:42 »
well it seems, like you don't have access to your global variables in the <unitCreated> tag. Megaglest had this problem on some older releases ,too, but now it has a special <global> tag which avoids such errors.

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Re: AI
« Reply #9 on: 3 May 2012, 06:24:11 »
I assume it was somehow missed to load the globals in the <unitCreated> tag. That should be fixable within a few minutes, but I'm not familar with the GAE-sourcecode.

maybe another thing to test could be
buildings = buildings or {}
on top of each <unitCreated>. Then you should try to print the result to the console and check whether it works or not.

 

anything