Author Topic: GraceTimer on custom empires?  (Read 5401 times)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
GraceTimer on custom empires?
« on: February 06, 2011, 10:16:57 PM »
Does this work:
Code: [Select]
GetEmpire(caiid).GraceTimer=(99999)
Because I think it doesn't, my AI plants flowers and doesn't follow it's rules, but I don't want the other AI to be frozen. So is there any correction?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: GraceTimer on custom empires?
« Reply #1 on: February 07, 2011, 01:22:56 AM »
I think that you have to apply it to an asteroid.

SetGraceTime(float gracetime)    Sets the grace time for the current owner of the asteroid - stops the owner's AI from doing anything with the asteroid while the grace timer is still above 0.

Globals.AI.GraceTimer (int)    may also have some effect.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: GraceTimer on custom empires?
« Reply #2 on: February 07, 2011, 01:37:12 AM »
SetGraceTime(float gracetime) will go to normal number after the roid is captured?

Scenario:
If Empire 2 owns the roid and the gracetime is set to an inf+++ number and when Empire 3 captures it then gracetimer goes back to normal, or will it stay the same?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: GraceTimer on custom empires?
« Reply #3 on: February 07, 2011, 02:38:41 AM »
Ehh...No idea. You could always use OnAsteroidTaken() to reset it when it is captured.

Something like this:
Code: [Select]
function OnAsteroidTaken(id, owner)
     if id = 5 and owner ~= 1 then
          GetAsteroid(5):SetGraceTimer(600)
     end
end

That (I think) would set the Gracetime of Asteroid 5 to 600 seconds, unless the conquerer was the player. Whether the conquered AI will then start attacking it again, I don't know.

Globals.AI.GraceTimer=(9999999999999999999) would set the GraceTime of EVERY AI to such a ridiculously high number as to be infinite, and stop the game playing the AI at all. Math.huge is the Lua equivalent of infinity.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: GraceTimer on custom empires?
« Reply #4 on: February 07, 2011, 02:46:53 AM »
Ok, so if I want to leave my AI to have gracetime to be a ridicilously high number(99999), what is then the normal gracetime for the normal ai?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: GraceTimer on custom empires?
« Reply #5 on: February 07, 2011, 04:12:40 PM »
Gracetimer is simply "how long should the default AI be switched off for?"

If you want them to become active as soon as an asteroid is taken, do it like this:

Code: [Select]
function OnAsteroidTaken(id, owner)

if owner == 2 then
-- default AI
GetAsteroid(id):SetGraceTime(0)
elseif owner == 3 then
-- my AI
GetAsteroid(id):SetGraceTime(99999)
end

end