Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Dart_Tech

Registered:
Posts: 30
Reply with quote  #1 
So I'm just about done with a random ship pathing system where random ships pop up and are assigned a brain stack to follow.

I noticed a problem when they attempted to spawn on the bottom or left side of the screen, they were not facing the right way and had to make slow U-turns to get going. I looked up at the angles and they were correct....

I decided to do some testing with this code:

Code:
<create type="neutral" raceKeys="friendly" hullKeys="Science Vessel science" name="0" x="20000" y="0" z="20000" angle="0" fleetnumber="-1"/>
<create type="neutral" raceKeys="friendly" hullKeys="Science Vessel science" name="90" x="22000" y="0" z="20000" angle="90" fleetnumber="-1"/>    
<create type="neutral" raceKeys="friendly" hullKeys="Science Vessel science" name="180" x="24000" y="0" z="20000" angle="180" fleetnumber="-1"/>    
<create type="neutral" raceKeys="friendly" hullKeys="Science Vessel science" name="270" x="26000" y="0" z="20000" angle="270" fleetnumber="-1"/>  
  

I have 4 identical ships next to eachother giving them different angles and naming them as such. I would expect the 0 to face up, 90 to face right, 180 to face down and 270 to face left.

Instead I got this (See attached). I took a screenshot as soon as they spawnwed. I tried the Transport hull 4 times then the science one 2 times.

I ran another test useing legacy code without the fleet seeing if that was the issue:

Code:
<create type="neutral" hullID="1503" name="0" x="20000" y="0" z="20000" angle="0" />
<create type="neutral" hullID="1503" name="90" x="22000" y="0" z="20000" angle="90" />    
<create type="neutral" hullID="1503" name="180" x="24000" y="0" z="20000" angle="180"/>    
<create type="neutral" hullID="1503" name="270" x="26000" y="0" z="20000" angle="270"/>  
 

Exact same result.

I am running 2.5.101.

Can anyone check these results? If this is a bug and I cant get these turned around that puts a BIG dent in my project. Are any of those settings wrong?

Attached Images
png Angles.png (49.80 KB, 11 views)

Mike Substelny

Avatar / Picture

Administrator
Registered:
Posts: 1,692
Reply with quote  #2 
You have run into one of the mathematical features that help keep Artemis mission scripting in the realm of an elite brotherhood. I think there are at least 2, and possible 3, different angle systems in the mission scripting language. You are attempting to meddle with the most difficult of them all.

Angles for AI ships are in radians, not degrees. Not only that, for AI ships angle 0 is dead south, not north. And on top of everything else, angles to the east are negative numbers <0 while angles to the west are positive numbers >0.

This feature added about two days to the time it took me to code "A Race for Distant Dawn."

__________________
"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight."
- Winston Churchill
Mike Substelny

Avatar / Picture

Administrator
Registered:
Posts: 1,692
Reply with quote  #3 
In "Race for Distant Dawn" I needed the script to be able to react to the facing of a friendly ship, to see if Comms had given it appropriate orders. Since you can't get a radian angle to an exact value I needed to see if it was between two values. This table shows the values I used in that script.

Comms ordered the ships to turn to the degree angle in the left column. The script then checked to see if the ship facing was between the two radian angles on the right.


Players Think in This Angle DegreesScript Thinks in These Angles Which Lie Between Radians
   
180-0.10.1
2701.561.58
90-1.56-1.58
10-2.96-2.97
2050.4370.435
3352.7062.704
2150.6120.61

__________________
"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight."
- Winston Churchill
Dart_Tech

Registered:
Posts: 30
Reply with quote  #4 
There REALLY should be a wiki page about this with that chart. Also there should be a hyperlink to it next to the "angle" parameter on the "create" command wiki page or when ever referenced. Would of saved me a lot of time and frustration. Thanks!
MarkBell

Avatar / Picture

Administrator
Registered:
Posts: 1,634
Reply with quote  #5 
You mean like http://artemiswiki.pbworks.com/w/page/117991854/Object%20Properties ?
__________________
Note - this is in no way intended to be an official position of Thom or Artemis, as I am not an official representative of the creator or game.
ryleyra

Registered:
Posts: 2,439
Reply with quote  #6 
There really needs to be a more in-depth guide to scripting, with all of the gotchas authors have unearthed over the years. Unfortunately, there has been very little attempt to tackle scripting on the wiki in the past. Lately, Dave Thaler and myself have tried to take a crack at it. Unfortunately, outside of an introductory tutorial page, I haven't had the time to dedicate to it.

Dave's done a lot on keeping the commands updated, and if it weren't for him, it would be WAY out of date. (In fact, I badly need to update the tutorial to correctly indicate that variables have both float and integer types now)

Most of the information on scripting is here, in this forum.
Dart_Tech

Registered:
Posts: 30
Reply with quote  #7 
Quote:
Originally Posted by MarkBell
You mean like http://artemiswiki.pbworks.com/w/page/117991854/Object%20Properties ?


Close...

http://artemiswiki.pbworks.com/w/page/51089094/command_create

"angle 0-360 Initial orientation, in degrees, of created object. 0 is facing upwards, value increases clockwise."

This is so wrong it makes my head hurt. If that was updated it would of made things easier.
Mike Substelny

Avatar / Picture

Administrator
Registered:
Posts: 1,692
Reply with quote  #8 
Actually I think it is accurate for player ships and some other classes of objects. Initial orientation for some things is in degrees with zero facing north. At other times the same object property is in radians with zero facing south.
__________________
"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight."
- Winston Churchill
ryleyra

Registered:
Posts: 2,439
Reply with quote  #9 
Quote:
Originally Posted by Mike Substelny
Actually I think it is accurate for player ships and some other classes of objects. Initial orientation for some things is in degrees with zero facing north. At other times the same object property is in radians with zero facing south.


I need to detail this. I'll do some research and post the results on the wiki.

Fish Evans

Registered:
Posts: 350
Reply with quote  #10 
This is bugged has been since 2.5

Quote:
    <create type="neutral" x="26738.0" y="0.0" z="34265.0" angle="-0.1" name="SY-61" hullID="9505" />
    <create type="neutral" x="20218.0" y="0.0" z="25447.0" angle="-0.1" name="SY-55" hullID="9505" />
    <create type="neutral" x="23953.0" y="0.0" z="30225.0" angle="-0.1" name="SY-170" hullID="9505" />


creates for example this - though every time the script runs the angles are differnt
[vsj8LNG] 
Ive tryed it with angles expressed in degrees and various radiens, results are always the same the object spawns with a random angle

Its annoying becuashe to object in question is a ship yard with out being able to specifie the angle the result is a bit of a mess on the main screen as aposed to awsomeness.
Dart_Tech

Registered:
Posts: 30
Reply with quote  #11 
What models/graphics are you using for te shipyard?
ryleyra

Registered:
Posts: 2,439
Reply with quote  #12 
Fish, would you mind posting this to the bug thread? I can do it if you'd rather.

Odd that I consider it a "bug" if the angles are being ignored, but not if they are in radians instead of degrees. [biggrin] But technically it can be said the command is working in the second case, but not in the first.

It's also possible the "angle" property was changed to something else for some reason. Although IIRC the default angle was never random.

Fish Evans

Registered:
Posts: 350
Reply with quote  #13 
Quote:
Originally Posted by Dart_Tech
What models/graphics are you using for te shipyard?


Custom Model as part of the TSN Expansion
ryleyra

Registered:
Posts: 2,439
Reply with quote  #14 
I've posted this to the bug thread, but after some testing, I think I have reached the conclusion that when first created, all objects but player ships are created pointing towards the center of the sector. I think this is consistent with the image Fish posted, although the generic meshes actually looks like they are oriented to point towards the station. There may be a random factor involved which randomizes the position from mission to mission, but if they always point in that general direction, I would conclude the angle is based on the center of the sector.

Player ships are created correctly. This bug has apparently been present since 2.4, it was introduced when the GM buttons were added, but the 2.3 version of Module_3_bases orients transports north and west as intended, when those functions are used. I suspect what Thom was trying to do is set a randomized default when no angle is specified, but ended up overriding the specified angle.

Fortunately, the object can be oriented properly at any time by using set_object_property with property="angle" after creation time. However, you have to remember the angle needs to be in radians. (so 0, 1.5708, 3.1416 & 4.7124 instead of 0, 90, 180 and 270)
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.