Need help adding new units

Information and discussion for custom maps and mods.
Post Reply
Dementor
Posts: 5
Joined: Sun Jun 07, 2015 11:25 pm

Need help adding new units

Post by Dementor »

Hello.

I seem to have a problem adding in new units.

The unit in question is a Tank Destroyer that I want to give to the Allies, to counter the Soviet's heavy vehicles. I named it after the sprite itself (t30td) and put it in the vehicle sequences file and allowed it to be built at the Allied war factory. It is armed with a machine gun against infantry and a new weapon I made to destroy tanks.

However when I try to load up the mod, it instantly crashes on me. I check to see if I missed anything and it seems that everything is in place.

I'm not sure what I am doing wrong.

Scott_NZ
Posts: 94
Joined: Thu Sep 13, 2012 9:09 am

Post by Scott_NZ »

You'll need to post your unit definitions, and the crash log called exception.log: https://github.com/OpenRA/OpenRA/wiki/F ... st-crashed

Dementor
Posts: 5
Joined: Sun Jun 07, 2015 11:25 pm

Post by Dementor »

I typed this out for my unit.

In the rules/vehicles file

T30TD:
Inherits: ^Tank
Buildable:
Queue: Vehicle
BuildPaletteOrder: 60
Prerequisites: atek, ~vehicles.allies, ~techlevel.unrestricted
Valued:
Cost: 1500
CustomBuildTimeValue:
Value: 1500
Tooltip:
Name: T30 Heavy Tank
Description: Heavy Tank With 150mm gun.\n Strong against ground units.
Selectable:
Health:
HP: 750
Armor:
Type: Heavy
Mobile:
Speed: 60
Crushes: wall, mine, crate, infantry
ROT: 2
RevealsShroud:
Range: 6c0
Turreted:
ROT: 4
Armament@PRIMARY:
Weapon: 150mm
LocalOffset: 900,0,340
Recoil: 171
RecoilRecovery: 30
MuzzleSequence: muzzle
Armament@SECONDARY:
Name: secondary
Weapon: M60mg
LocalOffset: -85,84,340, -85,-84,340
LocalYaw: -100,100
AttackTurreted:
WithMuzzleFlash:
RenderUnit:
WithTurret:
AutoTarget:
Explodes:
Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall
LeavesHusk:
HuskActor: 2TNK.Husk
Selectable:
Bounds: 30,30
Selectable:
Bounds: 44,38


In the sequences/vehicles file

t30td:
idle:
Start: 0
Facings: 32
turret:
Start: 32
Facings: 32
muzzle: gunfire2
Start: 0
Length: 5
icon: t30tdicon
Start: 0

And the stats on the new weapon, which i placed in the largecaliber file

#T30 150mm AT cannon
150mm:
ReloadDelay: 110
Range: 6c0
Report: TURRET1.AUD
Projectile: Bullet
Speed: 682
Image: 120MM
ContrailLength: 30
Warhead@1Dam: SpreadDamage
Spread: 128
Damage: 120
DeathType: 4
InvalidTargets: Air, Infantry
Versus:
None: 20
Wood: 75
Light: 75
Concrete: 50
Warhead@2Smu: LeaveSmudge
SmudgeType: Crater
Warhead@3EffGround: CreateEffect
Explosion: small_explosion
ImpactSound: kaboom12.aud
InvalidImpactTypes: Water
Warhead@4EffWater: CreateEffect
Explosion: small_splash
ImpactSound: splash9.aud
ValidImpactTypes: Water

And the error log

Testmod Mod at Version release-20150424
Operating System: Windows (Microsoft Windows NT 6.2.9200.0)
Runtime Version: .NET CLR 4.0.30319.18449
Exception of type `System.IO.InvalidDataException`: Duplicate key 'Selectable' in C:\Program Files (x86)\OpenRA\mods/testmod/rules/vehicles.yaml:829
Inner Exception of type `System.ArgumentException`: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at OpenRA.MiniYaml.ToDictionary[TKey,TElement](Func`2 keySelector, Func`2 elementSelector)
at OpenRA.MiniYaml.ToDictionary[TKey,TElement](Func`2 keySelector, Func`2 elementSelector)
at OpenRA.MiniYaml.ToDictionary[TElement](Func`2 elementSelector)
at OpenRA.MiniYaml.ToDictionary()
at OpenRA.ActorInfo.GetParent(MiniYaml node, Dictionary`2 allUnits)
at OpenRA.ActorInfo.MergeWithParent(MiniYaml node, Dictionary`2 allUnits)
at OpenRA.ActorInfo..ctor(String name, MiniYaml node, Dictionary`2 allUnits)
at OpenRA.RulesetCache.<LoadMapRules>b__0(MiniYamlNode k, Dictionary`2 y)
at OpenRA.RulesetCache.<>c__DisplayClass15`1.<LoadYamlRules>b__10(MiniYamlNode wkv, Dictionary`2 wyy)
at OpenRA.RulesetCache.<>c__DisplayClass15`1.<LoadYamlRules>b__14(MiniYamlNode kv)
at OpenRA.Exts.ToDictionaryWithConflictLog[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, String debugName, Func`2 logKey, Func`2 logValue)
at OpenRA.RulesetCache.LoadYamlRules[T](Dictionary`2 itemCache, String[] files, List`1 nodes, Func`3 f)
at OpenRA.RulesetCache.LoadMapRules(Map map)
at OpenRA.RulesetCache.LoadDefaultRules()
at OpenRA.ModData.<.ctor>b__2()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at OpenRA.ModData.get_DefaultRules()
at OpenRA.Map.<PostInit>b__16()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at OpenRA.Map.PreloadRules()
at OpenRA.ModData.PrepareMap(String uid)
at OpenRA.Game.StartGame(String mapUID, WorldType type)
at OpenRA.Game.LoadShellMap()
at OpenRA.Mods.Common.LoadScreens.BlankLoadScreen.StartGame(Arguments args)
at OpenRA.Game.InitializeMod(String mod, Arguments args)
at OpenRA.Game.Initialize(Arguments args)
at OpenRA.Program.Run(String[] args)
at OpenRA.Program.Main(String[] args)

Scott_NZ
Posts: 94
Joined: Thu Sep 13, 2012 9:09 am

Post by Scott_NZ »

Easy. You have duplicate Selectable definitions for your unit, as the error message says.

Selectable:
Bounds: 30,30
Selectable:
Bounds: 44,38

You need to remove one of them.

Dementor
Posts: 5
Joined: Sun Jun 07, 2015 11:25 pm

Post by Dementor »

It's still giving me the same error.

Testmod Mod at Version release-20150424
Operating System: Windows (Microsoft Windows NT 6.2.9200.0)
Runtime Version: .NET CLR 4.0.30319.18449
Exception of type `System.IO.InvalidDataException`: Duplicate key 'Selectable' in C:\Program Files (x86)\OpenRA\mods/testmod/rules/vehicles.yaml:827
Inner Exception of type `System.ArgumentException`: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at OpenRA.MiniYaml.ToDictionary[TKey,TElement](Func`2 keySelector, Func`2 elementSelector)
at OpenRA.MiniYaml.ToDictionary[TKey,TElement](Func`2 keySelector, Func`2 elementSelector)
at OpenRA.MiniYaml.ToDictionary[TElement](Func`2 elementSelector)
at OpenRA.MiniYaml.ToDictionary()
at OpenRA.ActorInfo.GetParent(MiniYaml node, Dictionary`2 allUnits)
at OpenRA.ActorInfo.MergeWithParent(MiniYaml node, Dictionary`2 allUnits)
at OpenRA.ActorInfo..ctor(String name, MiniYaml node, Dictionary`2 allUnits)
at OpenRA.RulesetCache.<LoadMapRules>b__0(MiniYamlNode k, Dictionary`2 y)
at OpenRA.RulesetCache.<>c__DisplayClass15`1.<LoadYamlRules>b__10(MiniYamlNode wkv, Dictionary`2 wyy)
at OpenRA.RulesetCache.<>c__DisplayClass15`1.<LoadYamlRules>b__14(MiniYamlNode kv)
at OpenRA.Exts.ToDictionaryWithConflictLog[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, String debugName, Func`2 logKey, Func`2 logValue)
at OpenRA.RulesetCache.LoadYamlRules[T](Dictionary`2 itemCache, String[] files, List`1 nodes, Func`3 f)
at OpenRA.RulesetCache.LoadMapRules(Map map)
at OpenRA.RulesetCache.LoadDefaultRules()
at OpenRA.ModData.<.ctor>b__2()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at OpenRA.ModData.get_DefaultRules()
at OpenRA.Map.<PostInit>b__16()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at OpenRA.Map.PreloadRules()
at OpenRA.ModData.PrepareMap(String uid)
at OpenRA.Game.StartGame(String mapUID, WorldType type)
at OpenRA.Game.LoadShellMap()
at OpenRA.Mods.Common.LoadScreens.BlankLoadScreen.StartGame(Arguments args)
at OpenRA.Game.InitializeMod(String mod, Arguments args)
at OpenRA.Game.Initialize(Arguments args)
at OpenRA.Program.Run(String[] args)
at OpenRA.Program.Main(String[] args)

Is it alright if I can upload my mod file here so that you can see if there are any problems or if there are missing files?

User avatar
Graion Dilach
Posts: 277
Joined: Fri May 15, 2015 5:57 pm

Post by Graion Dilach »

There's also a Selectable just under Tooltip.

Dementor
Posts: 5
Joined: Sun Jun 07, 2015 11:25 pm

Post by Dementor »

I see it now, thanks for the heads up.

I'm still kind of new to modding OpenRA and after looking at the different weapons, is there a way to upgrade your units, similar to how Generals does their upgrade system? I got ideas on different upgrades for units and I want to try implementing them.

User avatar
Graion Dilach
Posts: 277
Joined: Fri May 15, 2015 5:57 pm

Post by Graion Dilach »


Dementor
Posts: 5
Joined: Sun Jun 07, 2015 11:25 pm

Post by Dementor »

Thanks for the link, this will be really helpful.

Post Reply