Jump to content
Sign in to follow this  
You need to play a total of 5 battles to post in this section.
MedvedevTD

[Unbound 2] Practical example on how to work with the “Compass” element

1 comment in this topic

Recommended Posts

Administrator
42 posts

Hi, everyone!
 

As the time goes by, old solution are being changed and replaced by new one. While it’s a normal process for any game, such changes might often bring changes to game modification methods as well.

In this topic I’d like to post a solution, that’ll allow to work with “Compass” element and its part in the current game state.
 

There are, in fact two solutions.
 

First is a partial work with the battle_layout.xml file an editing the compass.unbound file

It’s suitable for quick deployment, but has several take offs (issues with scaling, no versatility in display resolution, extra files baggage) Besides, during the game client optimization some files are simply being removed.
 

Second solution is working with Unbound 2

The solution itself follows these steps:

-    Create Mod_compass.unbound file
 

Add following code to it:

Spoiler

(def element CompassContainer () layout=true dispatch_size_change=true
    (scope
        (var selfAvatarEntity:gfx =  "$datahub.getSingleEntity(CC.playerAvatar)")
        (var isAlive:bool = "selfAvatarEntity.health.isAlive"  (event "selfAvatarEntity.health.evIsAliveChanged"))
 
        (var stageComponent:gfx = "$datahub.getSingleEntity(CC.stage).stage")
        (var stageWidth:number = "stageComponent.width" (event "stageComponent.evStageSizeChanged"))
        (var stageHeight:number = "stageComponent.height" (event "stageComponent.evStageSizeChanged"))
        (var compassScaleRatio:number = "0.6")
        (var leftOffset:number = "stageWidth / 2 - COMPASS_SIZE * compassScaleRatio / 2 - 20")
        (var bottomOffset:number = "stageHeight / 2 - COMPASS_SIZE * compassScaleRatio / 2 - 250")
    )
    (style
        (position = "absolute")
        (width = "COMPASS_SIZE")
        (height = "COMPASS_SIZE")
    )
 
    (controller $Instance renderer='CompassContainerInstance'
        (bind enabled "isAlive")
        (exprs
            (bind scaleX "compassScaleRatio")
            (bind scaleY "compassScaleRatio")
            (style
                (bind left "leftOffset")
                (bind bottom "bottomOffset")
            )
        )
    )
)

 

For comparison – the original code in compass.unbound looks like this:

Spoiler

(def element CompassContainer () layout=true dispatch_size_change=true
	(scope
		(var selfAvatarEntity:gfx =  "$datahub.getSingleEntity(CC.playerAvatar)")
		(var isAlive:bool = "selfAvatarEntity.health.isAlive"  (event "selfAvatarEntity.health.evIsAliveChanged"))
	)
	(style
		(position = "absolute")
		(bind width "COMPASS_SIZE")
		(bind height "COMPASS_SIZE")
	)

	(controller $Instance renderer='CompassContainerInstance'
		(bind enabled "isAlive")
	)
)

 

-  Add following line to unbound_settings.xml file:

<file>./gui/unbound2/pc/battle/Mod_compass.unbound</file>

NB! This row is being processed  by the alphabet order

At first the special symbols, i.e. (!) are being processes

Then the upper case letters in alphabet order (A,B.C,D)

Then lower case letters in alphabet order (a,b,c,d)

 

It's crucial that you at first process the modified file, and only then - the original file

Spoiler

443286969a6c516f011b35b62b03739e.png


 

Element positioning settings

(var compassScaleRatio:number = "0.6") – this variable is responsible for object scaling with 1.0 is 100% of object size

(var leftOffset:number = "stageWidth / 2 - COMPASS_SIZE * compassScaleRatio / 2 - 20") – this variable is responsible for location on horizontal axis, with 20 being a gap compensation from battle_layout ; and in current settings it sets sets the element in the center

(var bottomOffset:number = "stageHeight / 2 - COMPASS_SIZE * compassScaleRatio / 2 - 250") – this variable is responsible for location on vertical axis with 250 being a shift from the center

 


 

You can remove the “extra” circle from the compass by simply adding a piece of additional code with commented value of compass element to our modified file

Spoiler

(def element CompassContainerInstance () layout=true
	(scope
		(var aircarrierEntity:gfx = "$datahub.getSingleEntity(CC.aircarrier)")
		(var squadronCameraMode:str = "aircarrierEntity.aircarrier.squadronCameraMode" (event "aircarrierEntity.aircarrier.evSquadronCameraModeChanged"))
		(var isLastLookCamera:bool = "squadronCameraMode != SquadronCameraModes.DEFAULT")
	)
	(style
		(position = "absolute")
		(bind width "COMPASS_SIZE")
		(bind height "COMPASS_SIZE")
	)

###	(element Compass
###		(style (position = "absolute"))
###	)

	(element ShipDollAirDefenseSectors
		(style
			(position = "absolute")
			(top = 100px)
			(left = 100px)
		)
	)

	(element ShipDoll
		(style
			(position = "absolute")
			(top = 100px)
			(left = 100px)
		)
		(bind visible "aircarrierEntity == null || !isLastLookCamera")
	)

	(element Frustum "200"
		(style (position = "absolute"))
	)

	(element GunsRotator
		(style (position = "absolute"))
	)

	(element CrosshairRotatorLock)
)

 

In the end we’ll see this:

Spoiler

6579a06b9154287f84e76de51bb5e8b9.jpg

 


 

Also, one more thing 🙂

Here I attached an example of ready solution : gui.zip

I have full trust in you that you do realize that unbound_settings.xml can sometimes be changed and that you’ll always compare it with the original file from every version patch (well, you’ll still need to put in the line) – it’s really not that troublesome, I swear! 🙂

 

Also also,

This mod will Not break any other mod and is compatible with any other modifications.

 

Best regards, 

Share this post


Link to post
Share on other sites
Sign in to follow this  

×