nschlein
Registered:1490985144 Posts: 174
Posted 1597856170
Reply with quote
#1
Okay, got a fun one for you all. I want to spawn a bunch of random ships, change them to derelicts after *mumble mumble*, and then "reactivate" the vessels after the players *mumble mumble mumble*. (I also want this to work across mods, which is one reason I'm not using Hull IDs.) Anyone know of a way to record and recall a randomly generated hull ID after it is created and within the same mission script? (And no--I don't know how to write outside scripts or reference information stored in the log file.) (Just occurred to me that I could disable ship systems and pin a generic mesh on top of them. That might be easiest, if I can actually get the darn things to NOT MOVE, which seems to be a problem. Would require a lot of constantly running code otherwise.) Thanks in advance!
ryleyra
Registered:1399599588 Posts: 3,214
Posted 1597858234
Reply with quote
#2
Unfortunately, I know of no way to record the hull id of a ship, destroy it, and then recreate it without having the hull id itself to start with. Meaning it can't be random or can only be random in the sense of "I have a number of possibilities for this so-called random ship". Another idea, though, would be to relocate your original ship along the Y axis, and immobilize it so it can't move. IIRC you can set enemy ships at y locations above 500 or below -500, they will just tend back towards the "valid" plane as long as they can move. The ship should be invisible as long as it is out of sensor range, but you'd have to set range to something other than Unlimited. If not, you will have the ship icon and the derelict icon on top of each other, which might be acceptable.
Darrin
Registered:1518310287 Posts: 434
Posted 1597866271
Reply with quote
#3
Quote:
Originally Posted by nschlein I want to spawn a bunch of random ships, change them to derelicts after *mumble mumble*, and then "reactivate" the vessels after the players *mumble mumble mumble*. (I also want this to work across mods, which is one reason I'm not using Hull IDs.)
Hmm. Sounds a little similar to Mike's "Mission to Hell". When you go to the Hell sector, it's full of derelicts that come to life/reactivate as you get close to them. Quote:
Originally Posted by nschlein Anyone know of a way to record and recall a randomly generated hull ID after it is created and within the same mission script? (And no--I don't know how to write outside scripts or reference information stored in the log file.)
Well, you can number all the possible hull IDs 1 through X, generate a random integer between 1 and X, and save the value of that integer in another variable. The code could then iterate through all the possible HullIDs until it found the one that had been randomly selected. You could brute-force it, but it would be long and tedious to write. Assuming it's stock Artemis 2.7.5, there aren't an exceptionally large number of HullIDs? And you might want to sort out stuff like stations, cargo tugs, etc. Does it have to be absolutely random? Would semi-random work? For example, if there were only 10-12 possible ships... for a player that hadn't played through the mission multiple times, it would look pretty random even though there are only a limited number of possible ships. That would cut down a little of the tedious codework. Quote:
Originally Posted by nschlein (Just occurred to me that I could disable ship systems and pin a generic mesh on top of them. That might be easiest, if I can actually get the darn things to NOT MOVE, which seems to be a problem. Would require a lot of constantly running code otherwise.)
The Science scanner would still show it as an active shielded ship rather than a wreck/derelict. You can disable impulse/maneuver on ships, but they will self-repair if you don't keep disabling them every few seconds or so. Getting them to hold still is also tricky... I've had some success with using POINT THROTTLE to tell the ship to go to the exact point where I created it with Throttle 0.0, but it may still wiggle a bit. Quote:
Originally Posted by ryleyra Another idea, though, would be to relocate your original ship along the Y axis, and immobilize it so it can't move. IIRC you can set enemy ships at y locations above 500 or below -500, they will just tend back towards the "valid" plane as long as they can move. The ship should be invisible as long as it is out of sensor range, but you'd have to set range to something other than Unlimited. If not, you will have the ship icon and the derelict icon on top of each other, which might be acceptable.
I haven't had much success with hiding ships at the top or bottom of the Y axis. They have a habit of showing up anyway, even with sensor ranges limited. I believe the weapons console, for example, will show a ship as "nearby" within the x/z range even if the y coordinate is outside sensor range.
__________________ Call Sign (EF/TSN): Bassellope
nschlein
Registered:1490985144 Posts: 174
Posted 1597880703
Reply with quote
#4
Thanks. That actually helps a lot. I’m building this for a quantity neutral scenario, with 8 Neutral ships per player ship. Each ship is pulled from its own limited list of ships, with identical pull lists for each additional player. The idea is the ships have been damaged/destroyed by an event and the players are needed to provide assistance. Moving them out of sensor range should work beautifully.
ryleyra
Registered:1399599588 Posts: 3,214
Posted 1597941561
Reply with quote
#5
If moving them out of sensor range in the Y coordinate doesn't work, you can always move them to an inaccessible part of the map. Unfortunately, you can't move them outside of the 100,000 x 100,000 grid but you can block off that part of the map where you "hide" the ships. If you really want to get sneaky, move them to the edge of the map opposite from the ship's current location.
HaydenBarca
Registered:1537152273 Posts: 455
Posted 1597975083
Reply with quote
#6
Yeah, taking advantage of the "nebula blocks scanners" tag you could either: 1) Make one corner of the map a nebula surrounded by mines and "store" the ships there 2) (maybe) use Ryley's idea of moving it above the legal Y axis and see if you can create a nebula up there as well to block scanners Ryan
nschlein
Registered:1490985144 Posts: 174
Posted 1597993701
Reply with quote
#7
Ok, one wrinkle: these are allied neutral ships. Won’t they provide sensor data? I’m thinking that changing their side value while “off-screen” would alter that behavior. Anyone know if that is true?
HaydenBarca
Registered:1537152273 Posts: 455
Posted 1598020786
Reply with quote
#8
Strangely enough, allies won't provide sensor data if they don't show up on a map due to "nebula blocks scanners". Surely a bug, but it might be helpful to you until/if it's fixed. You can set up a quick test to confirm, but I observed this recently.
gallstonetracy
Registered:1585106089 Posts: 41
Posted 1601349202
Reply with quote
#9
The ship should be invisible as long as it is out of sensor range.
Mike Substelny
Administrator
Registered:1375273622 Posts: 2,990
Posted 1601516544
Reply with quote
#10
Consider this strategy:At the beginning of the script generate 48 (or however many) random NPC ship names as variables. Give the variables names like A0, A1, A2, . . . H5, H6 where A-H are the eight ships for each side and 1-6 are player side values. Create the NPC ships and write the variables to their name fields. When *mumble mumble* happens destroy the NPC ships and replace each with a derelict by that same name. As the players do their *mumble mumble* for a derelict delete the derelict and respawn the ship. Unfortunately I can't tell if this will work for you because I don't know what *mumble mumble* means. In making your *mumble mumble* events you may need more than a variable with the names of the ships and derelicts. You may need the names hard coded into the script. Also, this script sounds like a perfect test for Doug's new Mission Macro language:
https://github.com/dougreichard/artemis_macro_language
__________________"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight." - Winston Churchill
nschlein
Registered:1490985144 Posts: 174
Posted 1601884947
Reply with quote
#11
Quote:
At the beginning of the script generate 48 (or however many) random NPC ship names as variables. Give the variables names like A0, A1, A2, . . . H5, H6 where A-H are the eight ships for each side and 1-6 are player side values. Create the NPC ships and write the variables to their name fields. Wait...Are you saying that I can make a variable produce a LETTER STRING? As in... <set_variable name="A1" value="Wasp" integer="yes" /> ...and then I can generate a ship with variable name A0 and get the Wasp??? I didn't think that was possible, but if so it changes several things in other scripts. I think what you're suggesting, in any case, is basically this: Set Variables A0-H0, A1-H1, to various names If player_0 exists Create ship name A0 (through H0) Set variable player0 =1 (Repeat for players 1-8) (MUMBLE MUMBLE happens) Save XYZ of ships A0-H7 Destroy Ships A0-H7 If variable player0=1, create derelict name A0-H at XYZ (repeat for all players) If players proximity/whatever to A0 Destroy A0 Create Ship A0 at XYZ The first *mumble mumble* is a major triggering event which supposedly knocks out the sensors, IFF, and other systems on ships in the sector. Shouldn't be a problem. The *mumble mumble mumble* is basically proximity testing, although I'd like to add some other bits as well. I'd think that would work with the variables... I don't mind hardcoding the names of the ships if needed; what I'm struggling with is tracking the Hull_IDs of randomly generated ships so I can respawn those same vessels, which I still don't think this can do. I think what I'll need to do is periodically stick them way out of plane and in a nebula. I would also like some of the ships to be enemies who power up when the players get too close. Also...can we generate a derelict ship of any hull type? I've never tried. Quote:
Also, this script sounds like a perfect test for Doug's new Mission Macro language:
I tried looking into this, and I definitely think it would help with this and another script I've already made, but the instructions need some clarifying and are a bit beyond me at this point.
Mike Substelny
Administrator
Registered:1375273622 Posts: 2,990
Posted 1601906269
Reply with quote
#12
If your script creates an AI ship with no name the server will give it a random name. In that case there is nothing you can do with it. But if you are willing to write a lot more code, your script can create random characters in several variables and concatenate them together into a variable. Then your script can create a ship with a known name like "XXX" and immediately change the name to the variable. The "hulk" object always looks the same - like a chunk ripped from a Kralien cruiser. If you like, you can wrap a generic object around it but it's hardly worth the bother. In my experience 90% of crews keep the main screen on Long Range Scan all the time and never look at the pretty artwork in the game.
__________________"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight." - Winston Churchill
McMik
Registered:1502215051 Posts: 22
Posted 1610662403
Reply with quote
#13
Quote:
Originally Posted by Mike Substelny But if you are willing to write a lot more code, your script can create random characters in several variables and concatenate them together into a variable. Then your script can create a ship with a known name like "XXX" and immediately change the name to the variable.
That is exactly the task I have to solve right now. How can i concatenate variables in a mission script?
The name "EnemyName" should vary by concatenating a prefix plus a consecutive number. For example: KR01, KR02, KR03, etc.
I set the prefix <set_vatiable name = "Prefix" value = "KR0" />
I initialize the variable for the number: <set_vatiable name = "Count" value = "1" />
I increased the value of the number by +1 per iteration <set_vatiable name = "Count" value = "Count + 1" />
Now "EnemyName" should be set so that each iteration prefix plus count are concatenated. <create type = "enemy" x = "10" y = "0.0" z = "10" angle = "0" name = "EnemyName" hullID = "2002" sideValue = "3" Fleet number = "- 1" />
How does it work?
Darrin
Registered:1518310287 Posts: 434
Posted 1610818421
· Edited
Reply with quote
#14
Quote:
Originally Posted by
McMik How does it work?
Artemis doesn't have "concatenate" or an easy way to convert data types. However, the scripting language... how do I put this delicately... isn't always the sharpest crayon in the box. Sometimes you can sneak things past it by pointing and yelling "Look over there!" When you're referring to a named object, sometimes you can combine text with another variable, such as an integer, and the game will treat the combined "name" property as a string. Look at this "Destroy all randomly named ships " thread for an example. Here's a destroy command that combines text with integer variables:<destroy name = "A|firstnumber||secondnumber|" /> It doesn't always work. There are some properties that don't let you combine text and integers. And it's not always clear when the scripting language will or will not evaluate a variable. For example, with your "<set_varable name = "Prefix" value = "KR0" />" statement, you could use |firstnumber| in the "name" property, but I don't think that works when assigning the "value" property. Very much a trial-and-error kinda thing.
__________________ Call Sign (EF/TSN): Bassellope
Mike Substelny
Administrator
Registered:1375273622 Posts: 2,990
Posted 1611257959
· Edited
Reply with quote
#15
Here is the code for creating a randomly named Cargo ship that will follow Comms orders from the Armada IV Sandbox. The name always starts with a C which is followed by three random digits. In your script you will want to remember all of the names for later by saving them in variables.-<event name="Create Cargo">
<if_gm_button text="Create Neutral/Terran Cargo"/>
<create name="XXXX" angle="270" type="neutral" hullKeys="Bulk Cargo" raceKeys="Terran friendly" use_gm_position=""/>
<set_variable name="firstdigit" integer="yes" randomIntHigh="9" randomIntLow="0"/>
<set_variable name="seconddigit" integer="yes" randomIntHigh="9" randomIntLow="0"/>
<set_variable name="thirddigit" integer="yes" randomIntHigh="9" randomIntLow="0"/>
<add_ai name="XXXX" type="FOLLOW_COMMS_ORDERS"/>
<set_ship_text name="XXXX" newname="C|firstdigit||seconddigit||thirddigit|"/>
</event>
__________________"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight." - Winston Churchill