Page 1 of 1

Transform units

Posted: Wed Jul 25, 2018 10:55 pm
by Remuneration
I have a unit transformer, it must to transform to transformedunit1 or transformedunit2 conditions by build upgrades. its looks must be changed after it.

When I trying to realise this, game is crash:

Code: Select all

OpenRA engine version release-20180307
Red Alert 2 mod version release-20180307
on map 1a848cb4377fc30745fe9ada0914e29d05dc5b8b (Arctic Circle by Westwood Studios).
Date: 2018-07-25 22:24:55Z
Operating System: Windows (Microsoft Windows NT 6.2.9200.0)
Runtime Version: .NET CLR 4.0.30319.42000
Exception of type `OpenRA.YamlException`: ActorInfo("transformedunit1") failed to initialize because of the following:
Missing:
OpenRA.Traits.IMouseBoundsInfo 
Unresolved:
OpenRA.Mods.Common.Traits.TooltipInfo: { OpenRA.Traits.IMouseBoundsInfo }

   в OpenRA.ActorInfo.TraitsInConstructOrder() в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\GameRules\ActorInfo.cs:строка 131
   в OpenRA.Actor..ctor(World world, String name, TypeDictionary initDict) в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\Actor.cs:строка 98
   в OpenRA.World.CreateActor(Boolean addToWorld, String name, TypeDictionary initDict) в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\World.cs:строка 252
   в OpenRA.World.CreateActor(String name, TypeDictionary initDict) в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\World.cs:строка 247
   в OpenRA.Mods.Common.Traits.Production.<>c__DisplayClass5.<DoProduction>b__4(World w) в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Mods.Common\Traits\Production.cs:строка 91
   в OpenRA.World.Tick() в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\World.cs:строка 359
   в OpenRA.Game.InnerLogicTick(OrderManager orderManager) в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\Game.cs:строка 605
   в OpenRA.Game.LogicTick() в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\Game.cs:строка 629
   в OpenRA.Game.Loop() в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\Game.cs:строка 759
   в OpenRA.Game.Run() в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\Game.cs:строка 799
   в OpenRA.Game.InitializeAndRun(String[] args) в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\Game.cs:строка 253
   в OpenRA.Program.Main(String[] args) в c:\games\RTS\OPENRA-ra2\engine\OpenRA.Game\Support\Program.cs:строка 37
How to write use conditions and upgrades to make this workabe?

Code: Select all

transformer:
	Tooltip:
		Name: transformer
	Production:
		Produces: transformations
	Mobile:
		Speed: 10
	Health:
		HP: 1500
	Exit:
	RevealsShroud:
		Range: 4c0
	-Guard:
	-AttackFrontal:
	QuantizeFacingsFromSequence:
		Sequence: stand
	WithProductionOverlay@WELDING:
		Sequence: transformprocess
	GrantConditionOnPrerequisite@transformedunit1:
		Prerequisites: transformedunit1
		Condition: transformedunit1
	GrantConditionOnPrerequisite@transformedunit2:
		Prerequisites: transformedunit2
		Condition: transformedunit2
	RenderSprites@transformedunit1:
		Image: transformedunit1
		RequiresCondition: transformedunit1
	RenderSprites@transformedunit2:
		Image: transformedunit2
		RequiresCondition: transformedunit2

transformedunit1:
	AlwaysVisible:
	Tooltip:
		Name: transformedunit1
	Buildable:
		BuildPaletteOrder: 50
		Prerequisites: transformer
		Queue: transformations
		BuildDuration: 590
		BuildDurationModifier: 40
		Description: transformedunit1
	Valued:
		Cost: 50
	RenderSprites:
		Image: transformedunit1
	ProvidesPrerequisite@upgradename:

transformedunit2:
	AlwaysVisible:
	Tooltip:
		Name: transformedunit2
	Buildable:
		BuildPaletteOrder: 50
		Prerequisites: transformer
		Queue: transformations
		BuildDuration: 590
		BuildDurationModifier: 40
		Description: transformedunit2
	Valued:
		Cost: 50
	RenderSprites:
		Image: transformedunit2
	ProvidesPrerequisite@upgradename:

Re: Transform units

Posted: Thu Jul 26, 2018 7:29 am
by MustaphaTR
You need Interactable or Selectable on the unit.

Re: Transform units

Posted: Thu Jul 26, 2018 9:50 am
by Remuneration
When I add Selectabe trait nothing changed, crash is hapend when transformedunit1 upgrade is finished

Re: Transform units

Posted: Thu Jul 26, 2018 11:03 am
by abcdefg30
Try adding "Interactable:" to "transformedunit1" and "transformedunit2" (like Mustapha suggested, probably a misunderstanding here).

Re: Transform units

Posted: Thu Jul 26, 2018 12:21 pm
by Remuneration
Did it, there is no crash now, but RequiresCondition: trait is not work, and unit use transformedunit1 sprites before upgrade...

hmm... add transformedunit2 code, second GrantConditionOnPrerequisite and second RenderSprites traits to transformer, and now have another crach: "Actor transformer has multiple traits of type `OpenRA.Mods.Common.Traits.Render.RenderSprites`"

i'm in confuse, how to use logic of conditions to change sprites, name, speed, armament e.t.c. of unit?

Re: Transform units

Posted: Thu Jul 26, 2018 12:33 pm
by MustaphaTR
You need ConditionManager on the actor for conditions to work.

Re: Transform units

Posted: Thu Jul 26, 2018 5:29 pm
by Remuneration
Add ConditionManager on the actor, but nothing changed

Re: Transform units

Posted: Fri Jul 27, 2018 2:27 pm
by Graion Dilach
I think you're lacking a lot of basic functional traits to get your units working. Do note that all the default units all have a template to inherit from.

Re: Transform units

Posted: Sat Jul 28, 2018 9:36 am
by Remuneration
1in1 nothing changed without inherits too.
"unit use transformedunit1 sprites before upgrade..."

Re: Transform units

Posted: Mon Jul 30, 2018 4:26 am
by Nolt
To be honest Graion nailed it with his answer, you need to either list EVERY SINGLE TRAIT needed to make the action function or one of the basic inheritances that do the same, see this example, the first thing you see is the basic actor type inheritance, its gonna tell the unit basic things like death animations or how much space it uses on a cell. (Inherits: ^Soldier)

Code: Select all

E1:
	Inherits: ^Soldier
	Inherits@AUTOTARGET: ^AutoTargetGroundAssaultMove
	Buildable:
		Queue: Infantry
		BuildAtProductionType: Soldier
		BuildPaletteOrder: 10
		Prerequisites: ~barracks, ~techlevel.infonly
		Description: General-purpose infantry.\n  Strong vs Infantry\n  Weak vs Vehicles, Aircraft
	Selectable:
		Class: E1
	Valued:
		Cost: 100
Also, you do not have any trait that could link up the transformation on condition, just a few provides prerequisites on the main actor that are not linked to anything, afaik the vanilla OpenRA codebase does not include a transform on condition trait, (unlike Graions fork, which does)

Re: Transform units

Posted: Mon Jul 30, 2018 9:34 am
by Remuneration
Yes, of course I tested with "Inherits: ^Animal" which inverit "^Soldier" and nothing changed...
" vanilla OpenRA codebase does not include a transform on condition trait"
What did it mean?
"RequiresCondition: transformedunit1" is not enoth?
maybe i need to add something like "ProvidesCondition@upgradename:" to transformedunit1&2?
Link from upgrades to buildings in vanilla d2k mod is work, i tryed repit same way...

Maybe it will be more understandable if someone show this functional on existing game unit? RA2 dog, like exaple - how can I change it name, or it sprites using upgrade?