Invisible unit. Is it possible?

Dune 2000.

Information and discussion for custom maps and mods.
Post Reply
Adrian
Posts: 73
Joined: Wed Feb 12, 2020 5:44 pm

Invisible unit. Is it possible?

Post by Adrian »

Can I make a unit invisible? Without compiling the game.

I remember, there was the code for original (vanilla) Dune 2000, somewhere in internet. And I made invisible harvester.

SirCake
Posts: 393
Joined: Thu Feb 04, 2016 5:40 pm

Re: Invisible unit. Is it possible?

Post by SirCake »

Yes you can.

You can create a custom map with custom rules in it.
Then if you play that map in singleplayer skirmish you will have the invisible harvester.
If you want to play that map with others online you have to upload it to resource.openra.net (resource center) first, then you can play online.

Yaml editing is fairly easy. A few lines of "code" will get it done (its not code)
Example for an invisible Red Altert harvester (append to the end of the map.yaml file you can find when opening an .oramap like a zip file):

Code: Select all

rules:
	HARV:
		Cloak:
I think thats it. :) The rest I think you can work out ;)

See https://docs.openra.net/en/latest/release/traits/#cloak

Cheers,
SirCake

Adrian
Posts: 73
Joined: Wed Feb 12, 2020 5:44 pm

Re: Invisible unit. Is it possible?

Post by Adrian »

Thank you very much! It works (with some corrections).

Another question.
Now it works for all harvesters.
Can I on/off visibility for chosen harvester?

Something like this
(the example below does not work):

Code: Select all

	Actor61: harvester
		Owner: Atreides
		Facing: 96
		Location: 7,21
        	-Cloak:
Error:
Exception of type `System.InvalidOperationException`: Cannot locate type: -CloakInit

-------

In general, can I change a value for one unit?

I try to change speed, for example.

Code: Select all

	Actor61: harvester
                (...)
		Location: 7,21
		Mobile:
			Speed: 96
I got error:
Exception of type `System.InvalidOperationException`: Cannot locate type: MobileInit

SirCake
Posts: 393
Joined: Thu Feb 04, 2016 5:40 pm

Re: Invisible unit. Is it possible?

Post by SirCake »

In general, you can't have a single unit have different rules of the other units of the same type.
So all HARV harvesters must behave exactly the same (all cloaked).

What you can do is create a new unit type HARV1, which is similar to HARV except for cloak.

You can do this easily by using inheritance, but you also need to define the animation explicitly again:
(Not tested, Image may have to have all CAPITAL letters, try it)

Code: Select all

HARV2:
	Inherits: HARV
	Cloak:
	RenderSprites: 
		Image: harv
If you need to turn it on/off cloak first tell me what causes it to turn on/off. It depends what to do next.

Adrian
Posts: 73
Joined: Wed Feb 12, 2020 5:44 pm

Re: Invisible unit. Is it possible?

Post by Adrian »

Thank you once more!
It works too.
But it takes some (slightly long) time to understand how to write it in Dune 2000. Not HARV, but harvester, for example.
The correct code is below.
(And it really does not work without RenderSprites)

Code: Select all

Rules: d2k|rules/campaign-rules.yaml, d2k|rules/campaign-tooltips.yaml, d2k|rules/campaign-palettes.yaml, rules.yaml
	harvester2:
		Inherits: harvester
		Cloak:
			IsPlayerPalette: true
		RenderSprites:
			Image: harvester
If you need to turn it on/off cloak first tell me what causes it to turn on/off. It depends what to do next.
In most simple case, player (me :-) ) has invisible harvesters, and enemy has not :-)

In general, different harvesters for different sides (opponents). I did it.

Theoretically, it wolud be interesting to turn on invisibility under some conditions, during gameplay.
I slightly understand LUA code for Dune 2000.

Post Reply