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

CC.camera -> Camera altitude/vertical angle

5 comments in this topic

Recommended Posts

94
[AOD_C]
Members
105 posts
1,405 battles

Hello, I'm not experienced with modding, but I've been digging through the scripts for the nonogram sights and I've been thinking of tweaking the modern variant to fit my own tastes.  The Unknown scripts seem to be a flavor of lisp crossed with a markup language and actionscript, and aren't too difficult to wade through (with the documentation in the Modder's Manual's here).  What I don't understand is the camera entity and what values I can pull from it. 

The nonogram sights get their fov values from 

(var cameraComponent:gfx = "$datahub.getSingleEntity(CC.camera).camera")

 

My question:  I want to get the vertical angle or altitude of the camera, so I can calculate the angle of the camera relative to the water's surface. I really like the Nonogram Modern sight, andI want to put ellipses where the NG Modern sight has speed marks, scaling the ellipses vertically compared to the angle of the camera looking down at the water. 

sight.png

 Looking at components.xml, I see that the Camera entity has

<property	name="heightPercent"		type="Number"		/>
<property	name="directionLineAngle"	type="Number"		/>

Would it be possible to calculate the camera's vertical view angle based off heightPercent or direction angle from the CC.camera entity? (I've attached visual illustrations of what I'm trying to describe).

angle.png

 

Edit:

Digging through components.xml, I've also found 

	<component	name="HeightOffset"	sync="false">
		<property	name="value"				type="Number"		/>
	</component>

and

	<component	name="ScreenPosition"	>
		<property	name="position"				type="Point"		/>
		<property	name="behindCamera"			type="Boolean"		/>

		<!-- Which function to use to calculate the position:
			Lesta.getScreenPositionByWorldPosition or
			UIMath.getScreenPositionByWorldPositionExtended
			uses the first one by default -->
		<property	name="extended"				type="Boolean"		/>
		<property	name="heightOffset"			type="Number"		/>
	</component>

Would HeightOffset.value or ScreenPosition.heightOffset be what I'm looking for? If that value is the camera's height, then my angle is arccos(heightOffset / shootDistance), if my math is right.  I want to scale my ellipse height by 1 - (0.5 * pi / arccos(heightOffset / shootDistance) ) if radians and 1 - (90 / arccos(heightOffset / shootDistance) ) if degrees.  Does Unbound 2.0 have the arccos function?

Edited by C4Cypher

Share this post


Link to post
Share on other sites
Developers
509 posts
24 battles
17 hours ago, C4Cypher said:

Does Unbound 2.0 have the arccos function?

Hi, there is no such function.

  • Thanks 1

Share this post


Link to post
Share on other sites
94
[AOD_C]
Members
105 posts
1,405 battles

Thanks.  I realized that I don't need to mess with trig functions.  I can get what I need just from the ratio between the height of the camera and the distance from the camera and the point of aim.  Where I'm struggling now is how to determine the height of the camera, as the Nonogram sight already calculates the distance.  I know there are HeightOffset and ScreenPosition entities, and I've experimented with 

(var _heightOffsetComponent:gfx = "$datahub.getSingleEntity(CC.heightOffset).heightOffset")
	(var _heightOffset:number = "heightOffset.value")

But I  lack understanding of $datahub, the getSingleEntity call, the getPrimaryEntity call, the CC object and the underlying entity structure to know how to appropriately query those values.

I'm very grateful for the Unbound 2.0 documentation in the manuals section ... is there a place where I can find a refrence on $datahub and CC ... or, alternatively, an xml file I can unpack that would give me a better idea of the hierarchy I'm trying to query?

I'm also trying to figure out which log file to dig through to find if I'm kicking out any syntax errors in my unbound scripts.

Edited by C4Cypher

Share this post


Link to post
Share on other sites
Developers
509 posts
24 battles
18 hours ago, C4Cypher said:

is there a place where I can find a refrence on $datahub and CC ... or, alternatively, an xml file I can unpack that would give me a better idea of the hierarchy I'm trying to query?

Unfortunately, there is no description of the datahab, I can only say that it contains collections of components with entities, in the source files you can understand how to access them.

18 hours ago, C4Cypher said:

I'm also trying to figure out which log file to dig through to find if I'm kicking out any syntax errors in my unbound scripts.

These errors are not displayed in any file, since this is not provided by the game client. All errors are eliminated at the development stage.

  • Thanks 1

Share this post


Link to post
Share on other sites
94
[AOD_C]
Members
105 posts
1,405 battles

Success!

I managed to figure out how to get the ellipses to scale properly, and height percent scales them the way I want them to by modifying the scaleX and scaleY layout properties.

(bind _scaleX "((_w * 2) / RADIUS) / 2")
(bind _scaleY "((_h * 2) / RADIUS) / 2")
(block
    (style
      (position = "absolute")
      (bind top 0)
      (bind left 0)
	  (bind scaleX "_scaleX")
	  (bind scaleY "_scaleY")
    )

Additionally ... the component camera.heightPercent seems to be very close to the ratio I'm looking for, even if I don't know the exact camera height when heightPercent = 100%  The end result is exactly as I imagined.  If I could figure out how to determine what the camera's altitude is at when heightPercent = 100%, I could further tweak the scaling of the sight along the Y-axis.

nm_ellipse_01.thumb.png.324c00327e42ab122c320227aab8b0a1.png

nm_ellipse_02.thumb.png.9cc987c329739e9fac7d00dce2c951e3.pngnm_ellipse_03.thumb.png.0dabb0d762a8c10b847dfe5131f4b4ab.png

 I'm hesitant to go further at this point, or even actually use this sight outside of training battles because while this sight doesn't do much more than the Nonogram Modern sight, just scaling it along the Y axis as a factor of height, the wording of the rules seems fairly strict forbidding:

Applications and mods that help a player to aim in any way that is not already available in the game, that includes any predictive aiming mods.

If what I have here violates these rules, I won't use the sight. If it does fall within the rules, I have a github repository (currently set to private) ... I'd be happy to share my work.   My primary goal here was the challenge of seeing if I could figure out how to do what I imagined in my opening post, I find the Nonogram Modern sight to be very useful. It's fun tweaking and figuring things like this out and I couldn't resist the idea of trying to improve it to fit my tastes.

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

×