I checked your code and found some issues.
If you change a value inside the blueprint, you should be sure, that the value exist.
So please validate everything before you change it:
- Code: Select all
first validate that Intel.VisionRadius exist inside the blueprint, then change it.
if bp.Intel.VisionRadius then
bp.Intel.VisionRadius = bp.Intel.VisionRadius * 2.0
end
Your naval stuff simply don't worked because of an Typo:
you asked for:
- Code: Select all
Categories.Naval
but the word Naval should be in uppercase:
- Code: Select all
Categories.NAVAL
I am not shure what you want to do with "--remove structure death"
In case you want all weapon damage from this unit reduced to 0, then you can use this:
- Code: Select all
-- Find a MOBILE EXPERIMENTAL unit and set all weapon-damage to "0", so the unit can't damage other units
if Categories.MOBILE and Categories.EXPERIMENTAL then
-- check first if we have a weapon array inside the unit blueprint
if bp.Weapon then
-- Loop over all Weaponss
for _,weapon in bp.Weapon do
-- if we found a weapon, then check if we have a damage variable
if weapon.Damage then
LOG('processing >>>'..id..'<<< +MOBILE +EXPERIMENTAL : Weaponname: ('..(weapon.DisplayName or "Unknown")..') Changing damage from ('..(weapon.Damage)..') to "0"')
-- set the damage to 0
weapon.Damage = 0
end
end
end
end
Or if you want to make the unit indestructible you can use this:
(Well, you cant make it really indestructible without changing the unitscript. But you can make a unit untargetable for other units)
- Code: Select all
-- Find a MOBILE EXPERIMENTAL unit and make it untargetable, so you can't destroy the unit.
if Categories.MOBILE and Categories.EXPERIMENTAL then
-- do we have a Category Array ?
if bp.Categories then
LOG('processing >>>'..id..'<<< +MOBILE +EXPERIMENTAL : Make the Unit indestructible, adding UNTARGETABLE to Categories.')
-- add the line "UNTARGETABLE" to Categories:
table.insert(bp.Categories, 'UNTARGETABLE')
end
end
You added a comment that "bp.Defense.Shield.ShieldMaxHealth" is not working. I checked this, but it is working.
Please check it again.
Here is the full code Copy & past ready for your blueprint.lua file:
I also added some debuglines for the Debug-log Window.
- Code: Select all
local OldModBlueprints = ModBlueprints
function ModBlueprints(all_blueprints)
OldModBlueprints(all_blueprints)
for id,bp in all_blueprints.Unit do
-- build Category Array for faster access like "Categories.LAND" or "Categories.EXPERIMENTAL"
local Categories = {}
for _, cat in bp.Categories do
Categories[cat] = true
end
--units Double health
if Categories.LAND and not Categories.STRUCTURE and not Categories.EXPERIMENTAL then
if bp.Defense.MaxHealth then
LOG('processing >>>'..id..'<<< +LAND -STRUCTURE -EXPERIMENTAL : Changing MaxHealth from ('..(bp.Defense.MaxHealth)..') to "'..(bp.Defense.MaxHealth * 2.0)..'"')
bp.Defense.MaxHealth = bp.Defense.MaxHealth * 2.0
end
end
--land units double vision
if Categories.LAND then
if bp.Intel.VisionRadius then
LOG('processing >>>'..id..'<<< +LAND : Changing VisionRadius from ('..(bp.Intel.VisionRadius)..') to "'..(bp.Intel.VisionRadius * 2.0)..'"')
bp.Intel.VisionRadius = bp.Intel.VisionRadius * 2.0
end
end
--land units shield double health
if Categories.LAND and not Categories.STRUCTURE and not Categories.EXPERIMENTAL then
if bp.Defense.Shield.ShieldMaxHealth then
LOG('processing >>>'..id..'<<< +LAND -STRUCTURE -EXPERIMENTAL : Changing ShieldMaxHealth from ('..(bp.Defense.Shield.ShieldMaxHealth)..') to "'..(bp.Defense.Shield.ShieldMaxHealth * 2.0)..'"')
bp.Defense.Shield.ShieldMaxHealth = bp.Defense.Shield.ShieldMaxHealth * 2.0
end
end
--tech 1 no mass
if Categories.TECH1 and not Categories.STRUCTURE then
if bp.Economy.BuildCostMass then
LOG('processing >>>'..id..'<<< +TECH1 -STRUCTURE : Changing BuildCostMass from ('..(bp.Economy.BuildCostMass)..') to "0"')
bp.Economy.BuildCostMass = 0
end
end
--tech 2 half mass
if Categories.TECH2 and Categories.LAND and not Categories.STRUCTURE then
if bp.Economy.BuildCostMass then
LOG('processing >>>'..id..'<<< +TECH2 +LAND -STRUCTURE : Changing BuildCostMass from ('..(bp.Economy.BuildCostMass)..') to "'..(bp.Economy.BuildCostMass * 0.5)..'"')
bp.Economy.BuildCostMass = bp.Economy.BuildCostMass * 0.5
end
end
--tech 3 double mass
if Categories.TECH3 and not Categories.STRUCTURE then
if bp.Economy.BuildCostMass then
LOG('processing >>>'..id..'<<< +TECH3 -STRUCTURE : Changing BuildCostMass from ('..(bp.Economy.BuildCostMass)..') to "'..(bp.Economy.BuildCostMass * 2.0)..'"')
bp.Economy.BuildCostMass = bp.Economy.BuildCostMass * 2.0
end
end
--navel sail speed doubled
local NavalSpeedScale = 20
if Categories.NAVAL then
if bp.Physics.CatchUpAcc then
LOG('processing >>>'..id..'<<< +NAVAL : Changing CatchUpAcc from ('..(bp.Physics.CatchUpAcc)..') to "'..(NavalSpeedScale)..'"')
bp.Physics.CatchUpAcc = NavalSpeedScale
end
end
if Categories.NAVAL and not Categories.STRUCTURE then
if bp.Physics.MaxAcceleration then
LOG('processing >>>'..id..'<<< +NAVAL : Changing MaxAcceleration from ('..(bp.Physics.MaxAcceleration)..') to "'..(NavalSpeedScale)..'"')
bp.Physics.MaxAcceleration = NavalSpeedScale
end
end
if Categories.NAVAL then
if bp.Physics.MaxBrake then
LOG('processing >>>'..id..'<<< +NAVAL : Changing MaxBrake from ('..(bp.Physics.MaxBrake)..') to "'..(NavalSpeedScale)..'"')
bp.Physics.MaxBrake = NavalSpeedScale
end
end
if Categories.NAVAL and not Categories.STRUCTURE then
if bp.Physics.MaxSpeed then
LOG('processing >>>'..id..'<<< +NAVAL : Changing MaxSpeed from ('..(bp.Physics.MaxSpeed)..') to "'..(NavalSpeedScale)..'"')
bp.Physics.MaxSpeed = NavalSpeedScale
end
end
if Categories.NAVAL then
if bp.Physics.MaxSpeedReverse then
LOG('processing >>>'..id..'<<< +NAVAL : Changing MaxSpeedReverse from ('..(bp.Physics.MaxSpeedReverse)..') to "'..(NavalSpeedScale)..'"')
bp.Physics.MaxSpeedReverse = NavalSpeedScale
end
end
if Categories.NAVAL then
if bp.Physics.MaxSteerForce then
LOG('processing >>>'..id..'<<< +NAVAL : Changing MaxSteerForce from ('..(bp.Physics.MaxSteerForce)..') to "'..(NavalSpeedScale)..'"')
bp.Physics.MaxSteerForce = NavalSpeedScale
end
end
--remove structure death
--broken
--if Categories.ECONOMIC and not Categories.EXPERIMENTAL then
-- if bp.Weapon.damage then
-- LOG('broken >>>'..id..'<<< +Naval : Changing Weapon.damage from ('..(bp.Weapon.damage)..') to "0"')
-- bp.Weapon.damage = 0
-- end
--end
-- Find a MOBILE EXPERIMENTAL unit and set all weapon-damage to "0", so the unit can't damage other units
if Categories.MOBILE and Categories.EXPERIMENTAL then
-- check first if we have a weapon array inside the unit blueprint
if bp.Weapon then
-- Loop over all Weaponss
for _,weapon in bp.Weapon do
-- if we found a weapon, then check if we have a damage variable
if weapon.Damage then
LOG('processing >>>'..id..'<<< +MOBILE +EXPERIMENTAL : Weaponname: ('..(weapon.DisplayName or "Unknown")..') Changing damage from ('..(weapon.Damage)..') to "0"')
-- set the damage to 0
weapon.Damage = 0
end
end
end
end
-- Find a MOBILE EXPERIMENTAL unit and make it untargetable, so you can't destroy the unit.
if Categories.MOBILE and Categories.EXPERIMENTAL then
-- do we have a Category Array ?
if bp.Categories then
LOG('processing >>>'..id..'<<< +MOBILE +EXPERIMENTAL : Make the Unit indestructible, adding UNTARGETABLE to Categories.')
-- add the line "UNTARGETABLE" to Categories:
table.insert(bp.Categories, 'UNTARGETABLE')
end
end
end -- this end starts at : for id,bp in all_blueprints.Unit do
end -- this end starts at : function ModBlueprints(all_blueprints)