Page 1 of 1

Controlling Damage

Posted: 18 Mar 2010, 02:13
by SanadaUjiosan
Alright, I have a question.

Code: Select all

	      damage                  = {
	        default = 10,
		planes  = 30,
	        subs    = 0.3,
	      },
I see this in the unitdefs in CA, and I wonder what's going on exactly. The core reason why I'm asking is I'd like to adjust/control the damage like what this tidbit of script implies, but I basically don't want to be limited to planes and subs. An example is that I'd like a shot to do more damage to a "mech" than it would a "tank."

I wonder how I can control this, because I don't see default, planes or subs as the Category (the stuff like LAND and FIXEDWING in the CA scripts) and I'm wondering how the engine knows exactly what a plane and sub is. Are these hardcoded parts of the engine and I'll just have to make do, or is there an easy way for me to assign different damages to category's like tanks and mechs, and how would I exactly assign my tanks and mechs to these roles so it'll all work in the end?

Re: Controlling Damage

Posted: 18 Mar 2010, 02:34
by KingRaptor
http://trac.caspring.org/browser/trunk/ ... ordefs.lua

As seen in the file, CA's armordefs.lua automatically assigns units to the PLANES armor category based on the canFly tag and the ELSE category if they don't have another armorcat, all other categories are manually defined.

If for whatever reason you don't want to use armordefs.lua, you can simply place a file named armor.txt in the root of the mod archive, for instance:

Code: Select all

[small] {
	dagger=1;
	sword=1;
	warhammer=1;
	claymore=1;
	dronelauncherm=1;
	wraith=1;
	probe=1;
	gunstar_cannon=1;
	gunstar_torpedo=1;
}
[large] {
	carrier=1;
	supportcarrier=1;
	queencarrier=1;
	starbase=1;
	starslayer=1;
	comet=1;
	meteor=1;
	minelayer=1;
	eclipse=1;
	imperator=1;
	imperator_turret_plasma=1;
	imperator_hangar=1;
	imperator_hive=1;
	imperator_turret_am=1;
	imperator_turret_cannon=1;
	imperator_turret_pd=1;
}
[magsmall] {
	mace=1;
	longbow=1;
}
[drone] {
	dronem=1;
}
[torpedo] {
	torpedo=1;
	ftorpedo=1;
	shuriken=1;
}
(the numbers don't mean anything, they're just there for the parser)

Re: Controlling Damage

Posted: 19 Mar 2010, 19:44
by SanadaUjiosan
Ok, well, of course I could not get it working. Here's what happened.

Tried your Armor.txt because it sounded simpler, so I made one and this is what it looks like:

Code: Select all

[Mech]
{
	bengineer1=1;
	bbasicmech=1;
	bsnipermech=1;
	bsiegemech=1;
	bmissilemech=1;
	bengineer2=1;
	bheavymech=1;
	bheavysiegemech=1;
	bheavymissilemech=1;
}
It's short for testing purposes.

In my unit def, I then set the attack values in a way so I could easily see if it was doing what I wanted it to. Here's an example:

Code: Select all

	      damage                  = {
	        default = 9999999,
		Mech = 1,

	      },
So if the unit got killed in one blow, I'd know it didn't work. Well, it didn't work. I then tried the armordefs.lua but that didn't work either and I have a feeling I just did it wrong. So I'm more interested in getting the .txt to work, just because it seems simpler, and I'm okay with simple. I like simple.

So, what did I do wrong?

Re: Controlling Damage

Posted: 20 Mar 2010, 01:34
by FLOZi
You should really embrace lua if you want to go far with Spring modding. Armor.txt in particular is an historical peculiarity which should never have happened.

S44 armourdefs.lua example:

http://spring1944.svn.sourceforge.net/v ... iew=markup

A brief example:

Code: Select all

local armorDefs = {
  dudes  =  {
    "myfirstdude", -- these are unitdef names
    "myseconddude",
  },
  trukz = {
    "myfirsttruk",
    "mysecondtruk",
  },
}
return armorDefs
Then in a weapon:

Code: Select all

--weapontags
damage = {
  default = 10,
  dudes = 100,
  trukz = 1,
}
(The only thing possibly wrong here, is that armourDefs may expect a named map, because trepan didn't bother to ask a modder how armor.txt worked when he converted it to lua. I guess i should really test that before posting this. I'll go test it now.)

Re: Controlling Damage

Posted: 20 Mar 2010, 01:43
by FLOZi
SIGH. Yeah, ffs. You need to add this tidbit:

Code: Select all

for categoryName, categoryTable in pairs(armorDefs) do
  local t = {}
  for _, unitName in pairs(categoryTable) do
    t[unitName] = 1
  end
  armorDefs[categoryName] = t
end
before the "return armorDefs" :roll:

Re: Controlling Damage

Posted: 20 Mar 2010, 02:30
by SanadaUjiosan
Thank you very much Flozi, that worked.

Quick question, is it possible for a unit to belong to two different armor types? Sort of like the Categories, say a unit has "Tank" and "Mech" armor, what would happen? Would it take both the Tank and Mech damage values, or just the Tank or Mech damage values, depending on what the weapon is? I'm asking this mostly out of curiousity, I may or may not use it.

I'm pretty sure this has been apparent to those who've helped me, but I have no background in all of this. No coding background, no idea how programs or any that works. I don't know anything about lua, other than what I could figure out in unit defs and animation scripts. What may seem obvious to you guys would go right by me unnoticed. I appreciate the help.

Re: Controlling Damage

Posted: 20 Mar 2010, 05:15
by FLOZi
Most likely it'd do the damage of either the first or last armour def it found.

Re: Controlling Damage

Posted: 13 Apr 2015, 13:40
by 8611
https://springrts.com/wiki/Armordefs.lua

armor.txt is old, but if someone wants to document that it would be better on wiki too.