New upgrades system

For AI and campaign script related discussions and questions
Post Reply
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3755
Joined: 03 Aug 2006, 19:39

New upgrades system

Post by Per » 05 May 2013, 14:36

I have now pushed the new upgrades system to git master. I will try to describe it below. Feel free to ask, and suggest improvements. Note that campaign stats are not converted yet, so no upgrades currently have any effect in campaign.

There are now two new globals, one of which is very special, and one which is its mirror, so both are capitalized in direct contravention with the way all other globals are capitalized, to mark them as being special. These are 'Stats' and 'Upgrades'. The former is a read-only tree of values that tell you the original stats of game object types. The latter is a write-able array of similar trees, that tell you the current stats of these types, for each player.

'Stats' contains a lot of info that 'Upgrades' does not. This info cannot (yet) be changed during the game.

'Upgrades' and 'Stats' both contain real values, that is, the actual values used in the game. It used to be the case that upgrades were stored as percentage modifications. This is, however, still the case in the research.ini file.

Although upgrades are now completely controlled through javascript, almost all of the data is supplied in the research.ini file, and then interpreted in rules.js. For example, research.ini contains
results = "Cyborgs:Thermal:45"
for the "Cyborg Superdense Thermal Armor" tech. This string is parsed in rules.js to implement a 45% increase in thermal armour protection for cyborgs only. The 'results' value is a comma-delimited string list, but other than that may contain any information that rules.js needs. The game engine itself does not parse the contents of the 'results' strings.

Each body now has an optional 'class' field. This is also an arbitrary string that the game engine does not parse, but only forwards to javascript.

One important thing to note is that you can now set different upgrades for each component and building type. This allows a much more fine grained control of upgrades than previously possible. Also a number of new values can be modified during the game for weapons than previously, which may be interesting for game balancing.

You can now set initial 'productionPoints', 'powerPoints', 'repairPoints', 'researchPoints' and 'rearmPoints' for buildings in structure.ini directly.

I had to simplify the handling of structure modules somewhat for now. Adding better handling of modules is on my TODO list. Currently, modules do not add any hitpoints to their basic structure. Adding a module to a structure multiplies the effect of the basic structure, except for power, in which case it adds 50%. This is the same effect as before, but is now hard-coded.

It is a huge amount of changes that went into this, and I need help debugging it. The easiest way to do that is to play the game while having 'jsdebug' up, and watch that the values change as you'd expect when you research things.

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3755
Joined: 03 Aug 2006, 19:39

Re: New upgrades system

Post by Per » 05 May 2013, 14:46

List of attributes in 'Stats':

Body
+ Id
+ Weight
+ BuildPower
+ BuildTime
+ HitPoints
+ Power
+ Armour
+ Thermal (heat armour)
+ Resistance

Sensor
+ Id
+ Weight
+ BuildPower
+ BuildTime
+ HitPoints
+ Range

ECM
+ Id
+ Weight
+ BuildPower
+ BuildTime
+ HitPoints
+ Range

Repair
+ Id
+ Weight
+ BuildPower
+ BuildTime
+ HitPoints
+ RepairPoints

Construct
+ Id
+ Weight
+ BuildPower
+ BuildTime
+ HitPoints
+ ConstructorPoints

Weapon
+ Id
+ Weight
+ BuildPower
+ BuildTime
+ HitPoints
+ MaxRange
+ MinRange
+ HitChance
+ FirePause
+ ReloadTime
+ Rounds
+ Radius
+ Damage
+ RadiusDamage
+ RepeatDamage
+ RepeatTime
+ RepeatRadius
+ ImpactType (one of "KINETIC" or "HEAT")
+ RepeatType (one of "KINETIC" or "HEAT")
+ ImpactClass (weapon sub class)
+ RepeatClass (periodical effect weapon sub class)
+ FireOnMove

WeaponClass
+ (... list of weapon classes ...)

Building
+ Id
+ Type (one of "Wall", "Structure" or "Demolish")
+ ResearchPoints
+ RepairPoints
+ PowerPoints
+ ProductionPoints
+ RearmPoints
+ Armour
+ Resistance
+ Thermal
+ HitPoints

List of attributes in 'Upgrades':

Body
+ HitPoints
+ Power
+ Armour
+ Thermal
+ Resistance

Sensor
+ Range

ECM
+ Range

Repair
+ RepairPoints

Construct
+ ConstructorPoints

Weapon
+ MaxRange
+ MinRange
+ HitChance
+ FirePause
+ ReloadTime
+ Rounds
+ Radius
+ Damage
+ RadiusDamage
+ RepeatDamage
+ RepeatTime
+ RepeatRadius

Building
+ ResearchPoints
+ RepairPoints
+ PowerPoints
+ ProductionPoints
+ RearmPoints
+ Armour
+ Resistance
+ Thermal
+ HitPoints

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3755
Joined: 03 Aug 2006, 19:39

Re: New upgrades system

Post by Per » 05 May 2013, 14:50

Examples of how to use the new system:

Code: Select all

Upgrades[0].Body['Tiger'].Thermal += 10; // increase Tiger body's armour by 10
Upgrades[0].Body['Tiger']['Thermal'] += 10; // another way of doing exactly the same thing
Upgrades[0].Body['Tiger']['Thermal'] += Math.ceil(Stats.Body['Tiger']['Thermal'] * 10 / 100); // increase Tiger body's armour by 10%
In related changes, hackChangeMe() can no longer take -1, instead use new receiveAllEvents(bool) function for that purpose. All 'Power' settings in ini files are changed, since they used meaningless values, to 'PowerLevel' with 0..2 values that correspond to GUI power button settings.

The 'MISC' and 'EXPLOSIVE' weapon classes were previously interpreted as being KINETIC. They are now no longer allowed at all.

I will be updating the auto-generated documentation as time permits.

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: New upgrades system

Post by aubergine » 08 May 2013, 15:02

I'm struggling to get my head around the WeaponsClass element - are there any examples of that bit? I assume that a given weapon class will reference an array of weapon names or ids?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3755
Joined: 03 Aug 2006, 19:39

Re: New upgrades system

Post by Per » 08 May 2013, 16:15

aubergine wrote:I'm struggling to get my head around the WeaponsClass element - are there any examples of that bit? I assume that a given weapon class will reference an array of weapon names or ids?
WeaponClass contains currently hard-coded values (eg 'CANNON', 'MISSILE', 'ROCKET'...) that are defined in the code, and matches the Stats.Weapon[id].ImpactClass and Stats.Weapon[id].RepeatClass fields. It is used in rules.js to match upgrade rules with the correct weapon types (see https://github.com/Warzone2100/warzone2 ... es.js#L352).

Edit: I see that I made an error in the comments in the second post, where I switched ImpactClass / ImpactType and RepeatClass / RepeatType... Fixed now.

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: New upgrades system

Post by aubergine » 08 May 2013, 18:35

Is there a list of those anywhere? (still not wrapped my head around C code :s)

Also, what happens if someone forgets to ceil/floor/round a change to Updates object, eg:

Code: Select all

// this...
Upgrades[0].Body['Tiger']['Thermal'] += 10.5

// instead of this...
Upgrades[0].Body['Tiger']['Thermal'] += 10
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: New upgrades system

Post by aubergine » 08 May 2013, 18:43

Can scavenger faction Stats/Upgrades be accessed via these objects?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3755
Joined: 03 Aug 2006, 19:39

Re: New upgrades system

Post by Per » 08 May 2013, 19:01

List of weapon classes (called 'sub classes' in the C code) can be found here (the quoted strings): https://github.com/Warzone2100/warzone2 ... .cpp#L2138

If you forget to ceil or round, it defaults to floor.

Yes, scav upgrades can be accessed and changed, too.

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: New upgrades system

Post by aubergine » 08 May 2013, 19:23

Thanks.

Is Stats object separated in to players? I would imagine that the base stats are applicable to all players?

Code: Select all

// my assumption:
Stats.Body['Tiger'].Power
Upgrades[player].Body['Tiger'].Power
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3755
Joined: 03 Aug 2006, 19:39

Re: New upgrades system

Post by Per » 08 May 2013, 22:15

aubergine wrote:I would imagine that the base stats are applicable to all players?
Correct.

Post Reply