Just when I thought I was out...

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Roberto wrote:
I'm almost done on the AI/ship side of things - I just need to modify planetinfo.plist so the frigate doesn't always appear in the same place.
Check for ships wont work in a planetinfo.plist. At this point the system is set up. There are no special ships in it yet. You can also remeve a few lines by using a else statement

Code: Select all

						<key>conditions</key>
						<array>
						<string>pseudoFixedD100_number lessthan 50</string>
						</array>
						<key>do</key>
						<array>
						<string>addShipsAtPrecisely: taranis_frigate 1 pwm 145000 -29000 60500</string>
						</array>
						<key>else</key>
						<array>
						<string>addShipsAtPrecisely: taranis_frigate 1 pwm 250024.81 25.77 -102991.52</string>
						</array>
pseudoFixedD100_number will ALWAYS generate the same number for a certain system. Useful for random additions of station. once selected, the system will always get the same random station. Makes a system more consistent. In your case you probably want the normal D100_number
You might be right on ATTACKED actually
In the line: UPDATE = ("rollD: 12600", decreaseAlertLevel, scanForLoot);, rollD is a priority message so the result is immediately executed. scaonForLoot is not so if it finds something, it only reacts on the found thing on the following update. ATTACKED is also priority, but will not be triggered at the update moment but when the actual shot takes place.
User avatar
Roberto
---- E L I T E ----
---- E L I T E ----
Posts: 318
Joined: Sun Jun 11, 2006 1:16 pm
Location: London, UK

Post by Roberto »

Check for ships wont work in a planetinfo.plist.
It's been working fine for me. But now that I've added another possible location (I plan to have four, so I doubt I can use "else"), the frigate isn't appearing. Not sure if it's a problem with pseudoFixedD100_number or my code-structuring.
pseudoFixedD100_number will ALWAYS generate the same number for a certain system. Useful for random additions of station. once selected, the system will always get the same random station. Makes a system more consistent. In your case you probably want the normal D100_number
Hmm. In that case, is there any way of using d100_number and accessing the number it generates multiple times? Ultimately, I want a 5% chance of the frigate appearing in the system, and within that, a 25% chance of it appearing in each of the four possible locations.

*EDIT* I guess I could do something like this:

Code: Select all

<key>conditions</key>
					<array>
					<string>shipsFound_number lessthan 1</string>
					<string>d100_number lessthan 5</string>
               </array>
					<key>do</key>
					<array>
						<key>conditions</key>
						<array>
						<string>d100_number lessthan 25</string>
						</array>
						<key>do</key>
						<array>
						<string>addShipsAtPrecisely: taranis_frigate 1 pwm 145000 -29000 60500</string>
						</array>
						<key>else</key>
						<array>
						       <key>conditions</key>
						       <array>
						       <string>d100_number lessthan 34</string>
						       </array>
						       <key>do</key>
						       <array>
						       <string>addShipsAtPrecisely: taranis_frigate 1 pwm 250024.81 25.77 -102991.52</string>
						       </array>
...and have an else for that one too, within which there's a 50% chance for each of the two remaining positions.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

You also have the option to save the generated random number in a temporary mission variable:

Code: Select all

<string>set: mission_tmp_d100 [d100_number]</string>
then get rid of that variable once you're done with it:

Code: Select all

<string>reset: mission_tmp_d100</string>
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Roberto
---- E L I T E ----
---- E L I T E ----
Posts: 318
Joined: Sun Jun 11, 2006 1:16 pm
Location: London, UK

Post by Roberto »

Hmm. I considered that, but I'm guessing it wouldn't work/be practical in planetinfo (or would it?). I suppose I don't *have* to do this in planetinfo... but to my mind the frigate is a "system" thing rather than a "mission" thing :)
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

How do you mean? Mission variables are available to all legacy scripts (but not AIs, which are similar but separate).
User avatar
Roberto
---- E L I T E ----
---- E L I T E ----
Posts: 318
Joined: Sun Jun 11, 2006 1:16 pm
Location: London, UK

Post by Roberto »

Ah! Then I'm an ignorant loon! :oops:
User avatar
Roberto
---- E L I T E ----
---- E L I T E ----
Posts: 318
Joined: Sun Jun 11, 2006 1:16 pm
Location: London, UK

Post by Roberto »

OK, here's what I have now (I'll add more possibilities later):

Code: Select all

			<string>checkForShips: taranis_frigate</string>
				<dict>
					<key>conditions</key>
					<array>
					<string>shipsFound_number lessthan 1</string>
					<string>taranis_frigate_d100 undefined</string>
					</array>
					<key>do</key>
					<array>
					<string>set: taranis_frigate_d100 [d100_number]</string>
						<key>conditions</key>
						<array>
						<string>taranis_frigate_d100 equal 1</string>
						</array>
						<key>do</key>
						<array>
						<string>addShipsAtPrecisely: taranis_frigate 1 pwm 145000 -29000 60500</string>
						</array>
						<key>conditions</key>
						<array>
						<string>taranis_frigate_d100 equal 2</string>
						</array>
						<key>do</key>
						<array>
						<string>addShipsAtPrecisely: taranis_frigate 1 pwm 250024.81 25.77 -102991.52</string>
						</array>
					</array>
				</dict>
Do I need to have <dict>, </dict> around each conditions-and-do set? And how can I have taranis_frigate_d100 return to undefined when players exit the system? (Is there a way of specifying, "if *not* this system, then do this..."?)
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

(Is there a way of specifying, "if *not* this system, then do this..."?)
When you are writing a 1.69 and higher oxp you can use a NOTEQUAL in your condition.
User avatar
Roberto
---- E L I T E ----
---- E L I T E ----
Posts: 318
Joined: Sun Jun 11, 2006 1:16 pm
Location: London, UK

Post by Roberto »

Hmm. I'm still not sure how to do it, though:

Code: Select all

<key>conditions</key>
<array>
<string>?????????? notequal "0 141"????</string>
</array>
<do>
<array>
<string>set: taranis_frigate_d100 undefined???</string>
</array>
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Like this:

Code: Select all

<key>conditions</key> 
<array> 
<string>taranis_frigate_d100 notequal 5</string> 
</array> 
<do> 
<array> 
<string>reset: taranis_frigate_d100</string> 
</array>
User avatar
Roberto
---- E L I T E ----
---- E L I T E ----
Posts: 318
Joined: Sun Jun 11, 2006 1:16 pm
Location: London, UK

Post by Roberto »

If I did that, though, wouldn't it just keep on resetting? Ideally I want a 5% chance of the ship appearing the moment you enter the system, and no more chances until you exit and re-enter.

I guess I could always just have it reset under the strings for all the nearby systems, but I bet there's a more elegant solution.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

Roberto wrote:
If I did that, though, wouldn't it just keep on resetting? Ideally I want a 5% chance of the ship appearing the moment you enter the system, and no more chances until you exit and re-enter.
this should run 'blah blah blah' 5% of the time:

Code: Select all

<key>conditions</key>
<array>
<string>taranis_frigate_d100 lessthan 6</string>
</array>
<key>do</key> 
<array>

blah blah blah

<string>reset: taranis_frigate_d100</string>
</array>
reset is used to clear the variable taranis_frigate_d100, otherwise the next jump will still use the same number, and taranis_frigate_d100 won't be random any more.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Roberto
---- E L I T E ----
---- E L I T E ----
Posts: 318
Joined: Sun Jun 11, 2006 1:16 pm
Location: London, UK

Post by Roberto »

I know how to do the 5% bit; it's the "if not in system 0 141" bit I don't know how to express in code. I think I'll just go for the inelegant option, and have it reset in all the surrounding systems.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Roberto wrote:
I know how to do the 5% bit; it's the "if not in system 0 141" bit I don't know how to express in code. I think I'll just go for the inelegant option, and have it reset in all the surrounding systems.

Code: Select all

Conditions = ("galaxy_number equal 0"; "planet_number equal 144");
do = ();
else = ( "your stuff");
This will do nothing in system [0 141] otherwise it will do the else thing. But I thought you were doing the stuff in the planetinfo.plist. This will do it thing only once when the system is entered. So resetting it at the end of the code for the system you have should be enough. Not when entering other systems.
User avatar
Roberto
---- E L I T E ----
---- E L I T E ----
Posts: 318
Joined: Sun Jun 11, 2006 1:16 pm
Location: London, UK

Post by Roberto »

But I thought you were doing the stuff in the planetinfo.plist. This will do it thing only once when the system is entered.
Ahhh. I wasn't aware of this. Would it be worth adding this info to the Wiki?
Post Reply