Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
locqust

Avatar / Picture

Registered:
Posts: 70
Reply with quote  #1 
Hey all,

Trying to create a script where friendly background ships are randomly generated within certain areas of the map then travel to another randomly generated exit point. I've played around a bit and the best I could do was create a ship at 100000,0,100000, then use randomly generated starting and exit beacons. Place the ship at the starting beacon and let it go.
Thing is although the ships appear to be using different starting points like I intended. They all seem to be heading to the same exit point which seems to be 0,0,0. Despite the fact I clear the AI commands on a separate event and tell it to head to the exit beacon.

This is an example of SS-1, SS-2 to SS-8 follow the same pattern.

Can anybody see why they would ignore the generated exit point and just head to the top of the map? Some of the ships have starting points at the top and then head down to a Starbase, but even these hug along the top of the map.


<event name_arme="Roll for a ship" id_arme="39a64f24-7733-4d96-98a0-7a9e4c5514b9" parent_id_arme="7c887be4-cf6a-4cdb-b5a9-05ba8fde69e0">
<if_variable name="federation space" comparator="EQUALS" value="1.0" />
<if_timer_finished name="Generate Ships" />
<if_variable name="Generate Ships" comparator="EQUALS" value="0.0" />
<set_variable name="Generate Ships" randomIntLow="1" randomIntHigh="8" />
<log text="rolling for a ship" />
</event>

<event name_arme="Create SS1" id_arme="b36c191d-efd6-44ac-a8c1-cc2ce64e2df4" parent_id_arme="7c887be4-cf6a-4cdb-b5a9-05ba8fde69e0">
<if_variable name="federation space" comparator="EQUALS" value="1.0" />
<if_timer_finished name="Generate Ships" />
<if_variable name="Generate Ships" comparator="EQUALS" value="1.0" />
<if_not_exists name="SS-1" />
<create type="neutral" x="100000.0" y="0.0" z="100000.0" angle="0.0" name="SS-1" raceKeys="Starfleet player standard support" hullKeys="player" />
<set_variable name="MaxShips" value="MaxShips + 1" />
<set_variable name="ss1place" value="1.0" />
<log text="generate ss1" />
</event>

<event name_arme="SS1 locations" id_arme="0e4e12fa-ea49-4f05-84a6-4b9296da4f05" parent_id_arme="b3fd3f99-deb9-4e4d-996a-3c2de8b38d55">
<if_variable name="Generate Ships" comparator="EQUALS" value="1.0" />
<if_variable name="federation space" comparator="EQUALS" value="1.0" />
<if_variable name="ss1place" comparator="EQUALS" value="1.0" />
<if_variable name="Terran-system" comparator="EQUALS" value="2.0" />
<set_variable name="RandomX1" randomIntLow="75800" randomIntHigh="91000" />
<set_variable name="RandomZ1" randomIntLow="79800" randomIntHigh="93200" />
<create type="genericMesh" x="RandomX1" y="0.0" z="RandomZ1" angle="0.0" name=" " meshFileName="dat\mine.dxs" textureFileName="dat\black32.png" colorRed="0.0" colorGreen="0.0" colorBlue="0.0" />
<set_variable name="RandomX2" randomIntLow="2680" randomIntHigh="94700" />
<set_variable name="RandomZ2" randomIntLow="800" randomIntHigh="2300" />
<create type="genericMesh" x="RandomX2" y="0.0" z="RandomZ2" angle="0.0" name=" " meshFileName="dat\mine.dxs" textureFileName="dat\black32.png" colorRed="0.0" colorGreen="0.0" colorBlue="0.0" />
<set_variable name="ss1place" value="2.0" />
<log text="put a beacon down" />
</event>

<event name_arme="SS1" id_arme="13cd5a55-9d55-4cca-b71e-e8ff5c1dc113" parent_id_arme="7c887be4-cf6a-4cdb-b5a9-05ba8fde69e0">
<if_exists name="SS-1" />
<if_variable name="apply-ss1" comparator="NOT" value="1.0" />
<if_variable name="ss1place" comparator="EQUALS" value="2.0" />
<set_relative_position name2="SS-1" distance="20" angle="0.0" name1=" " />
<set_variable name="RandomC" randomIntLow="1" randomIntHigh="5" />
<clear_ai name="SS-1" />
<add_ai type="TARGET_THROTTLE" targetName=" " value1="RandomC" name="SS-1" />
<add_ai type="FOLLOW_COMMS_ORDERS" name="SS-1" />
<set_variable name="apply-ss1" value="1.0" />
<set_variable name="ss1place" value="3.0" />
<set_variable name="Generate Ships" value="0.0" />
<set_timer name="Generate Ships" seconds="1" />
<log text="place ss1" />
</event>

<event name_arme="Destroy SS1" id_arme="5e463d99-e1f3-4952-838e-aa85e01bf240" parent_id_arme="7c887be4-cf6a-4cdb-b5a9-05ba8fde69e0">
<if_exists name="SS-1" />
<if_distance name1="SS-1" name2=" " comparator="LESS_EQUAL" value="20.0" />
<destroy name="SS-1" />
<destroy name=" " />
<destroy name=" " />
<set_variable name="apply-ss1" value="0.0" />
<set_variable name="MaxShips" value="MaxShips - 1" />
<set_variable name="Generate Ships" value="0.0" />
<set_timer name="Generate Ships" seconds="1" />
<set_variable name="ss1place" value="0.0" />
<log text="destroy ss1" />
</event>

ryleyra

Registered:
Posts: 3,214
Reply with quote  #2 
Okay, first of all, check out my post "New and Improved Sector Generator", here: http://artemis.forumchitchat.com/post/new-and-improved-sector-generator-7586807 I've implemented something very similar.

Second, in my experience, you should NOT generate random coordinates in the range 0-100000. Although the random number generator doesn't say this, it has a maximum of 65535, which is the maximum value of a standard integer variable. Since 65535 is less than 100000, I found the best way to generate coordinates was to generate them between 0 and 50000, and multiply by two when I assigned the coordinate.

You can see this in my script in a number of places.

I think that if you do this, create your ship at the random X and Z coordinates you give it, and then set the "exitPointX" "exitPointZ" properties correctly with random values, this should work, without having to resort to placing "beacons". The way you have it set up, the ships SHOULD all fly to the same beacon. (The TARGET_THROTTLE doesn't direct the ship to a static point, it directs it to the object's current location. The POINT_THROTTLE command was what you wanted, but exitPoint should work even better. Mind you, I have never tested exitPoint, I always leave the ships to go where they wish)

Edit: Also, you have a name collision. Name one of your beacons " " and the other "  ". If they have the same name, the script can't distinguish between them, and your ship is probably flying from the start beacon to the start beacon.

locqust

Avatar / Picture

Registered:
Posts: 70
Reply with quote  #3 
Thanks Ryleyra I didn't realise the random number generator had a limit!
I'll take the beacons out then and do it the way you suggested. Originally the exit beacon was so I wouldn't have to have a "destroy s when s is at coordinates x, y, z" on every map.
This is for a GMless sandbox-esque mission I'm working on so reusing create and destroy events is a must to keep the file size from ballooning up!
Must admit I did see your post after I put this up, had a quick look as it was late but basically you've managed to do everything I've been sat here trying to get working! My next bit was a random sector generator section for "unexplored space".
I'd been looking at how Arrew did his in his sandbox too and didn't notice his random generators also use a x2 in there for coordinates.
I'm not surprised I had name collision. I didn't want the names showing up on screen so used spaces, probably miscounted the number of spaces. If beacons go then the need for blank names go to so not too worried about that.
locqust

Avatar / Picture

Registered:
Posts: 70
Reply with quote  #4 
Thank Ryleyra, that worked a treat!
My ships are now spawning and going where I want them to. Even kept the destroy script as a global event like my create and generate ones so they can be reused on each sector.
Each sector now just has a placement and exit point event for each ship generated which is unique to that sector.
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.