Jump to content


Photo

Custom unit stats in RACEunitstats.ai file


7 replies to this topic

#1 Finaldeath

Finaldeath
  • Project Team
  • 188 posts
  • Location:UK

Posted 01 March 2006 - 10:34 PM

Excedrin and Corsix, after I "interrogated" them about the AI, and custom stats, pointed me out this:

http://forums.revora...86

Getting rid of RACEcustomstats.ai and its relations, and getting a proper custom stats file, and related functions, to get the data in an updated version of unitstats.ai would be great.

Basically, things like troop cost, unit max's and bases, immunity to morale damage, and other things excedrin added to his sample code would be great.

A few more to allow better commander attachment and unit stat pairing off, also allows the race code to be continually moved to the stats files.

Basically, there are several reason for attempting this:
  • Allows one place for unit stats to be created and tweaked by the user to affect how the AI uses that unit
  • Removes the requirements of hardcoding things into the AI files, ie: anything which is "squad_" in strings anywhere in the /core AI folder!
    • This allows custom races to be added and perform at full functions straight away, with just a few variables.
  • Allows better use of commanders, among other things, since they'd be able to automatically ignore some units to attach to (eg: getting a space marine squad with lots of plasma isn't a good idea for a melee bodyguard), as well as knowing if a unit has a comparable HTH attack - since for example, chaos space marines and cultists both perform well enough in melee for melee commanders to use them to attack with.
  • Could mean a much easier and quicker way to sort out some things the AI has trouble with, in relation to units.
I will look into getting Excedrins ideas sorted with me doing the commander AI, removing the RACEcustomunitstats.ai files completely, and adding a new custom.ai file, with functions to:
  • Return any one of the AI stats, and enemy units should be passable too. Perhaps a function for each one.
    [list]
  • EG: self.custom:GetCanCapture() - gets and returns, if there, able_to_capture (boolean)
  • someone.custom:GetTrooperCost() - gets and returns, if there, troopercost (integer)
  • ally_unit.custom:GetMoraleImmune() - gets and returns, if there, moraleimmune (boolean)
  • ...and so on
These would work based on the squads name, unless I can get it to work with the unit setting the information on itself somehow, rather like how self.stats is set to GetUnitStats() or somesuch.

Would need some way to make sure this works with all enemy and allied units...

...so since I'm still not 100% sure on the workings of functions (ie: started a few days ago on it!) and the strange table-based storage of functions and how they work when not referencing self, especially with custom functions. Still might be able to get somewhere though :blush:

#2 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 02 March 2006 - 12:05 AM

To be honest, I'm not sure if I fully understood the changes, but it sound like A LOT of work. I'd delay this to 1.8 since I really want 1.7 to be released in the near future.

#3 Finaldeath

Finaldeath
  • Project Team
  • 188 posts
  • Location:UK

Posted 02 March 2006 - 12:28 AM

Oh, sure, along with the AI code commenting and documentation :blush:

If anything, with something like this, it'd basically allow us to define, very easily, the actual statistics of things, so we can analyze them.

There is something like it already present, it jsut needs replacing and cleaning up to be more consistant and usable.

#4 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 02 March 2006 - 07:35 AM

Will Excedrin release the program and sourcecode to automatically create a raceunitststs.ai from lua with all missing details ? Doing it by hand is clearly no option.

It won't help you with

Allows better use of commanders, among other things, since they'd be able to automatically ignore some units to attach to (eg: getting a space marine squad with lots of plasma isn't a good idea for a melee bodyguard),


as there is no way to determine wether a squad has plasma or not AFAIK.

Edited by LarkinVB, 02 March 2006 - 09:06 AM.


#5 Finaldeath

Finaldeath
  • Project Team
  • 188 posts
  • Location:UK

Posted 02 March 2006 - 11:42 AM

You're probably right about that :p I only see an update file.

Excedrins stuff might create the correct raceunits.ai file, but it won't mean that the extra information would ever be used.

I see no reason why some additional generation code, or manual entering, of things like "is_alright_in_melee" would be a good idea, or, I guess, checking weapon stats or something, heh.

Edited by Finaldeath, 02 March 2006 - 11:44 AM.


#6 Excedrin

Excedrin
  • Project Team
  • 154 posts

Posted 02 March 2006 - 06:13 PM

Will Excedrin release the program and sourcecode to automatically create a raceunitststs.ai from lua with all missing details ? Doing it by hand is clearly no option.

I use the RGDs and convert them to LUA, then process them and create a javascript file with stats for all units, then I process that to create unitstats.ai with a perl program. So, I can release any part of the pipeline, but it's not exactly a clean process. The generated javascript is already publicly available (for WA 1.41 http://dow.lerp.com/stats.html uses it, so it's http://dow.lerp.com/all.js ). Everything else is here, http://blkwidow.lerp.../~sic/dowstats/

It won't help you with

Allows better use of commanders, among other things, since they'd be able to automatically ignore some units to attach to (eg: getting a space marine squad with lots of plasma isn't a good idea for a melee bodyguard),


as there is no way to determine wether a squad has plasma or not AFAIK.


I used this for Orks in the Rebirth AI, since they're pretty good in ranged with heavy weapons. It's not totally accurate, since I didn't account for the NL cost, but it works in game.
	  local trooper_cost = 1
	  local squadname = self.squad_ai:GetStats():GetSquadName()
	  if Stats[squadname] then
		trooper_cost = Stats[squadname].troopercost
	  end
	  local calc_cost = self.squad_ai:GetNumTroopers() * trooper_cost
	  if self.squad_ai:GetProRatedCost() > calc_cost then
	  -- now that we have heavy weapons, we're ranged
		self.squad_ai:DoSetStance( SquadAI.STANCE_Hold )
		self.squad_ai:DoSetMeleeStance( SquadAI.MSTANCE_Ranged )
	  end


#7 Finaldeath

Finaldeath
  • Project Team
  • 188 posts
  • Location:UK

Posted 02 March 2006 - 07:55 PM

Clever :p knowing if they have any upgrades at all are a good idea for units like chaos space marines, cultists, marines, sluggas, and so on.

Will sort out some code to try and get this working once I work out how the AI works a bit more :)

#8 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 22 March 2006 - 11:23 AM

I use the RGDs and convert them to LUA, then process them and create a javascript file with stats for all units, then I process that to create unitstats.ai with a perl program. So, I can release any part of the pipeline, but it's not exactly a clean process.


If you can release the tool which creates all.js from lua I'd be happy !

EDIT: Didn't check the readme. Seems everything is already there.

EDIT2 : I didn't get it to work. A step by step instruction would be nice. How do I create a file like all.js. I guess I have to use squadjs.lua but don't know what it does need for input. So what is the shortest path from owning all dowpro luas to creating unitsts.ai ?

Edited by LarkinVB, 22 March 2006 - 01:31 PM.




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users