Page 9 of 11

Posted: Wed Mar 12, 2008 10:05 pm
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.

Posted: Wed Mar 12, 2008 11:27 pm
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.

Posted: Thu Mar 13, 2008 12:56 am
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>

Posted: Thu Mar 13, 2008 1:08 am
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 :)

Posted: Thu Mar 13, 2008 8:20 am
by JensAyton
How do you mean? Mission variables are available to all legacy scripts (but not AIs, which are similar but separate).

Posted: Thu Mar 13, 2008 10:17 am
by Roberto
Ah! Then I'm an ignorant loon! :oops:

Posted: Thu Mar 13, 2008 11:08 am
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..."?)

Posted: Thu Mar 13, 2008 12:40 pm
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.

Posted: Sat Mar 15, 2008 1:10 pm
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>

Posted: Sat Mar 15, 2008 1:44 pm
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>

Posted: Sat Mar 15, 2008 2:00 pm
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.

Posted: Sat Mar 15, 2008 3:25 pm
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.

Posted: Sat Mar 15, 2008 4:13 pm
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.

Posted: Sat Mar 15, 2008 4:40 pm
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.

Posted: Sat Mar 15, 2008 4:47 pm
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?