Page 1 of 2

Altering of player legal status via XML script

Posted: Fri Jul 24, 2009 4:41 pm
by Lestradae
Perhaps someone knows how to alter the player's legal status in an XML script?

On the wiki I only found how to set the legal rank but not how to add to or subtract from it.

If someone could enlighten me on the issue I would be most pleased :wink:

Thanks in advance

L

Posted: Fri Jul 24, 2009 7:23 pm
by Rustybolts
Not sure if this helps but it mentions setting local variables
Quote:
Mission Variables

As of 1.65? these methods can also be used with script local variables by suppling a "local_" variable rather than a "mission_" varaible. The difference is that "mission_" variables are stored within a save file and "local_" variables are not saved with the game and are only valid localy, within a mission script.
set: mission_variable <value>
// sets the mission_variable to the value given
// the value can be a particular string or numeric value,
// or a queriable state

reset: mission_variable <value>
// sets the mission_variable to be UNDEFINED

increment: mission_variable
// increases the mission variable's value by 1.0

decrement: mission_variable
// decreases the mission variable's value by 1.0

add: mission_variable <value>
// adds the value given to the mission_variable
// the value can be a number or a queriable state
// like shipsFound_number

subtract: mission_variable <value>
// subtracts the value given from the mission_variable
// the value can be a number or a queriable state
// like shipsFound_number

so
can you not
Code:
set: local_legal <value>
then
Code:
setLegalStatus: local_legal

or to add
Code:
add: local_legal <value>


Maybe i hope this works

.

Posted: Fri Jul 24, 2009 7:25 pm
by Lestradae
Hi rustybolts!

I am not entirely sure, but I think that the solution you are suggesting only works for mission variables (such as being defined by us, the oxp'ers) but not for hardcoded variables that are already there in the core game, like the legal rating.

Then I could easily be wrong about that.

The scripting part I want to do looks like this:

Code: Select all

<key>Stations_owned_income_AAA</key>

        <array>
        <dict>

        <key>conditions</key>
        <array>
              <string>status_string equal STATUS_EXITING_WITCHSPACE</string>
              <string>mission_playerstation_AAA equal 1</string>
        </array>

        <key>do</key>
                  <array>
                     <string>awardCredits: 4000</string>
                     <string>???</string>
                  </array>

        </dict>
        </array>
The "<string>???</string>" part would be where I want to deduct from or add to the players legal rank. Basically this script checks if the player owns a certain station and if it is owned, gives him the income and alters his legal rating.

The income bit is already working, but as to the legal thing I am clueless. How would you apply your solution to the above ??? sequence? I am ready to experiment if need be ...

Thanks for the suggestion in any case :D

L

Posted: Fri Jul 24, 2009 8:01 pm
by Rustybolts

Code: Select all

<string>set :local_legal [legalStatus_number]</string 
<key>Stations_owned_income_AAA</key> 

<array> 
<dict> 

<key>conditions</key> 
<array> 
<string>status_string equal STATUS_EXITING_WITCHSPACE</string> 
<string>mission_playerstation_AAA equal 1</string> 
</array> 

<key>do</key> 
<array> 
<string>awardCredits: 4000</string> 
<string>add: local_legal 5</string> 
<string>setLegalStatus: local_legal</string> 
</array> 

</dict> 
</array>

Posted: Sat Jul 25, 2009 9:38 am
by Rustybolts
The line where i put

Code: Select all

<string>setLegalStatus: local_legal</string>
may have to be written

Code: Select all

<string>setLegalStatus: [local_legal]</string>
I dunno but its worth a shot
I used this code here to extract the format.

Code: Select all

<key>script_actions</key>
<array>
   <string>set: local_my_credits [credits_number]</string>
   <string>awardCredits: 1</string>
   <string>subtract: local_my_credits [credits_number]</string>
   <dict>
       <key>conditions</key>
       <array>
           <string>local_my_credits lessthan 0</string>
       </array>
       <key>do</key>
       <array>
           <string>awardCredits: -1</string>
           <string>"your stuff if scooped by player"</string>
       </array>
       <key>else</key>
       <array>
           <string>"your stuff if scooped by NPC ship"</string>
       </array>
   </dict>
</array>
But that doesnt use the local variable to award the credits.


Goodluck

Posted: Sun Jul 26, 2009 11:31 am
by Rustybolts
Tested my solution and works here's my code

Code: Select all

{
	test = (
		{
		conditions = ("galaxy_number equal 0"); 
            do = (
                        {
                            conditions = ( 
                                "planet_number equal 129"
								 ); 
                            do = (
								"set :local_legal [legalStatus_number]",
								"add: local_legal 64",
								"setLegalStatus: [local_legal]"
							);
						}
				);
		}
	);
}	
You can test the above code yourself it will change your legal status via the local variable legal once you have entered Zaonce in galaxy 1

Posted: Sun Jul 26, 2009 11:43 am
by Cmdr James
I think you can steal code for this from Anarchies. The salvage gang sell equipment which already changes legal status.

Posted: Sun Jul 26, 2009 3:24 pm
by Eric Walch
Rustybolts wrote:
The line where i put

Code: Select all

<string>setLegalStatus: local_legal</string>
may have to be written

Code: Select all

<string>setLegalStatus: [local_legal]</string>
I dunno but its worth a shot
Generally spoken there are commands that expect a value and those that expect a variable.
In cased a fixed number is expected for a command you can replace that with [variable]. Before Oolite executes a line it first replace everything between [] and than executes the new line.
String expansion works at all places except in a CONDITION line.

...

Posted: Mon Jul 27, 2009 5:22 pm
by Lestradae
So if I i.e. execute the following script:

Code: Select all

        <key>Stations_owned_income_AAA</key>

        <array>
        <dict>

        <key>conditions</key>
        <array>
              <string>status_string equal STATUS_EXITING_WITCHSPACE</string>
              <string>mission_playerstation_AAA equal 1</string>
        </array>

        <key>do</key>
                  <array>
                     <string>awardCredits: 4000</string>
                     <string>setLegalStatus: [local_legal]</string>
                     <string>add: local_legal 5</string>
                     <string>setLegalStatus: [local_legal]</string>
                  </array>

        </dict>
        </array>
... then the above example should, after each witchjump, add 4000 Cr to the player's fortune and raise his legal rank towards "Offender" or "Fugitive" by 5 points, is that correct?

:?:

L

Posted: Mon Jul 27, 2009 5:35 pm
by Rustybolts
It will but is there a top limit to your legal status .How high does this rating go i thought 64 but have found no evidence. You will need to find out and perform a check to see if this top limit has been reached. before adding more on to local legal otherwise it will just keep increasing.
Unless legal status has a cap it wont exceed not sure have not found the info

..

Posted: Tue Jul 28, 2009 6:06 am
by Lestradae
I am sorry to report that ...

Code: Select all

<key>do</key>
                  <array>
                     <string>setLegalStatus: [local_legal]</string>
                     <string>add: local_legal 5</string>
                     <string>setLegalStatus: [local_legal]</string>
                  </array> 
... isn't working: When I test this, the legal status stays as it is :(

Any ideas?

:?:

L

Posted: Tue Jul 28, 2009 6:12 am
by Rustybolts
Could this be why?
The bounty on the player, which determines legal status. It is halved at each witchspace jump.
In which case increase the amount you add.
If not are you meeting your conditions?

..

Posted: Tue Jul 28, 2009 7:01 am
by Lestradae
I add 10 - even if they were applied before the witchjump, there should still be five left after it - making me an Offender when Clean. And that doesn't happen.

The conditions are applied correctly - because the 4000 Cr get awarded as they should!

:?

L

Re: ..

Posted: Tue Jul 28, 2009 7:35 am
by Eric Walch
Lestradae wrote:
I am sorry to report that ...

Code: Select all

<key>do</key>
                  <array>
                     <string>setLegalStatus: [local_legal]</string>
                     <string>add: local_legal 5</string>
                     <string>setLegalStatus: [local_legal]</string>
                  </array> 
... isn't working: When I test this, the legal status stays as it is :(

Any ideas?
It does exactly what you ask. Just ask yourself at each line what it will do. And look at the code of Rustybolts that does work.

Re: ..

Posted: Tue Jul 28, 2009 11:04 am
by Lestradae
Eric Walch wrote:
Just ask yourself at each line what it will do. And look at the code of Rustybolts that does work.
Argh! :shock:

Blind, me, again. Thanks, Eric 8)

:idea:

L