Author Topic: Alternative Repair Ai  (Read 2625 times)

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Alternative Repair Ai
« on: April 28, 2010, 12:59:02 PM »
Because my compiler refuses to work with Eddy-B's repair code, I want my AI to cheat.
Initproc
Code: [Select]
CreateTimeTrigger(1, 0, 20000, "Repairallaibuildings");
After AIproc
Code: [Select]
SCRIPT_API void Repairallaibuildings()
{
Unit u;
PlayerBuildingEnum enum1(2, mapNone);
while (enum1.GetNext(u))
{
if (u.IsVehicle()) continue;
{
SetDamage(0);
}
}
}
But it can't find SetDamage.
Can you help me, and does it work after all?
Praise the mighty light towers!!!

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
Alternative Repair Ai
« Reply #1 on: April 28, 2010, 02:01:30 PM »
u.SetDamage(0);


Also, that will make vehicles indestructible, because IsVehicle will return false for buildings.
"Nothing from nowhere, I'm no one at all"

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Alternative Repair Ai
« Reply #2 on: April 28, 2010, 02:18:20 PM »
Is there a IsBuilding?
And why did you say undestructible? I thought my TimeTrigger fires only once(in 200 marks)?
Praise the mighty light towers!!!

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
Alternative Repair Ai
« Reply #3 on: April 28, 2010, 02:24:24 PM »
Oh, it's not in AIProc. My bad.

Still, IsVehicle() will return true if the object is a vehicle and false if it's not. (eg. u.IsVehicle() will return a false if u is a building)

But, you're using a building enumerator. That only counts buildings, so adding that if is redundant.
« Last Edit: April 28, 2010, 02:25:19 PM by Hidiot »
"Nothing from nowhere, I'm no one at all"

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Alternative Repair Ai
« Reply #4 on: April 28, 2010, 02:55:28 PM »
It works now! Thanks.
(And by replacing the 20000 by 15, the buildings indeed are invincible)
Praise the mighty light towers!!!

Offline evecolonycamander

  • Hero Member
  • *****
  • Posts: 602
Alternative Repair Ai
« Reply #5 on: April 28, 2010, 03:43:15 PM »
Hey this is kinda ovious(pardon spelling) but won't an enmy that self repairs its self in the middle of battle be Realy unfair?
''The blight cant get us up here!''
-famous last words
--------------o0o--------------
Outpost 2: EoM project status: Re-planning

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Alternative Repair Ai
« Reply #6 on: April 28, 2010, 06:40:36 PM »
You bet!  Welcome to the primitive world of OP2 AI!
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Alternative Repair Ai
« Reply #7 on: April 28, 2010, 09:19:12 PM »
If I ever get around to it, a certain map of mine will impliment this AI "cheating" to make it actually difficult.
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names