Usage of the chance option

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
Browser_ice
Posts: 231
Joined: Sun, 5. Feb 06, 18:15

Usage of the chance option

Post by Browser_ice » Sun, 8. Oct 17, 14:49

Up until a few days ago, I thought the chance option was pretty simple. I thought it only needed a value from 0 to 100 resulting in a % interpretation.

However, recently, I have see usages that makes me wonder how this chance command is reacting.

example:

chance=-84 ==> results in what ?

chance=180 ==> results in what ?

chance=-184 ==> results in what ?
Steam X-Superbox, playing XR
WIndows-7
Intel I5
16Gb Memory
Nvgidia GT 960

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 9987
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Mon, 9. Oct 17, 00:22

Hi Browser_ice,

To my best knowledge your initial thought is correct, i.e. chance values 0 ... 100 correspond to the associated %. That is the same as weight values, for example

Code: Select all

<do_any>
	       <signal_cue_instantly cue="md.EuclidsDangerZonesEvent1.EuclidsDangerZonesE1" param="$Epos" weight="$C1"/>     
	       <signal_cue_instantly cue="md.EuclidsDangerZonesEvent2.EuclidsDangerZonesE2" param="$Epos" weight="$C2"/>    
	       <signal_cue_instantly cue="md.EuclidsDangerZonesEvent3.EuclidsDangerZonesE3" param="$Epos" weight="$C3"/>     
	       <signal_cue_instantly cue="md.EuclidsDangerZonesEvent4.EuclidsDangerZonesE4" param="$Epos" weight="$C4"/>     
	       <signal_cue_instantly cue="md.EuclidsDangerZonesEvent5.EuclidsDangerZonesE5" param="$Epos" weight="$C5"/>     
</do_any>
where $C1$ to $C5$ are values between 0 and 100.
I'm curious: Where did you see chance values greater than 100?

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

Browser_ice
Posts: 231
Joined: Sun, 5. Feb 06, 18:15

Post by Browser_ice » Mon, 9. Oct 17, 18:47

mining.ship.collect.xml

Code: Select all

         <!-- find pickup (filtered by ownership) and target -->
            <set_value name="$pickuptarget" exact="false"/>
            <set_value name="$skill" exact="(this.combinedskill - 50) * 3" />
            <find_asteroid_in_cluster name="$pickup" cluster="this.cluster" refobject="this.ship" canpickup="true" multiple="true" maxdistance="4km" viewangle="360deg" ware="$checkware" />
            <do_all exact="$pickup.count" counter="$i" reverse="true">
              <do_if value="$pickup.{$i}.owner">
                <remove_value name="$pickup.{$i}" />
              </do_if>
              <do_elseif value="not $pickup.{$i}.canbepickedup">
                <debug_text text="'[Ship=%1, Skills=%5, Mining] %2 in %3 (: %4) cannot be picked up!'.[this.ship.knownname, $pickup.{$i}, $pickup.{$i}.zone.knownname, $.knownname, (this.combinedskill - 50) * 3]" chance="$debugchance"/>
                <remove_value name="$pickup.{$i}" />
              </do_elseif>
              <do_elseif value="$pickup.{$i}.wares.{$checkware}.count le 0" chance="$skill">
                <remove_value name="$pickup.{$i}" />
              </do_elseif>
            </do_all>
The resulting value of (this.combinedskill - 50) * 3 remains the same throughout this script. So when a later debug_text displayed it in the same script, it was sometimes showing negative numbers:
Line 216: [Scripts] 23238.85 *** aicontext<mining.ship.collect,0x12041>: [Ship=Miner-Large-Gaz, Skills=-87, Mining] movement started (destination: 31768m)
Line 459: [Scripts] 23319.44 *** aicontext<mining.ship.collect,0x12041>: [Ship=Miner-Large-Gaz, Skills=-87, Mining] movement stopped, preparing to mine
Line 470: [Scripts] 23323.79 *** aicontext<mining.ship.collect,0x12041>: [Ship=Miner-Large-Gaz, Skills=-87, Mining] starting to launch drones
Line 691: [Scripts] 23381.25 *** aicontext<mining.ship.collect,0x22c52>: [Ship=CdB Récolteur de plasma Midir, Skills=21, Mining] collected 421 units of Plasma in zone Première Etape in 21.0884 seconds (19.9837 units/s)
Line 765: [Scripts] 23398.56 *** aicontext<mining.ship.collect,0x22c52>: [Ship=CdB Récolteur de plasma Midir, Skills=21, Mining] collected 346 units of Plasma in zone Première Etape in 17.3161 seconds (19.9837 units/s)
Line 766: [Scripts] 23398.56 *** aicontext<mining.ship.collect,0x22c52>: [Ship=CdB Récolteur de plasma Midir, Skills=21, Mining] OOZ mining: try other ware (Plasma)
Line 795: [Scripts] 23405.45 *** aicontext<mining.ship.collect,0x12041>: [Ship=Miner-Large-Gaz, Skills=-87, Mining] collected 8000 units of Hydrogène (761.6 units/s on average)
Line 796: [Scripts] 23405.45 *** aicontext<mining.ship.collect,0x12041>: [Ship=Miner-Large-Gaz, Skills=-87, Mining] stop launching drones
Line 797: [Scripts] 23405.45 *** aicontext<mining.ship.collect,0x12041>: [Ship=Miner-Large-Gaz, Skills=-87, Mining] less than 5 percent free cargo space
Line 798: [Scripts] 23405.83 *** aicontext<mining.ship.collect,0x11df1>: [Ship=Miner-XL-All, Skills=-150, Mining] collected 75 units of Cristaux in zone Héritage de Magellan in 21.2933 seconds (3.55067 units/s)
Line 853: [Scripts] 23419.84 *** aicontext<mining.ship.collect,0x22c52>: [Ship=CdB Récolteur de plasma Midir, Skills=21, Mining] collected 425 units of Plasma in zone Première Etape in 21.2749 seconds (19.9837 units/s)
Line 854: [Scripts] 23419.84 *** aicontext<mining.ship.collect,0x22c52>: [Ship=CdB Récolteur de plasma Midir, Skills=21, Mining] OOZ mining: try other ware (Plasma)
Line 870: [Scripts] 23425.30 *** aicontext<mining.ship.collect,0x11df1>: [Ship=Miner-XL-All, Skills=-150, Mining] collected 69 units of Cristaux in zone Héritage de Magellan in 19.4659 seconds (3.55067 units/s)
Line 871: [Scripts] 23425.40 *** aicontext<mining.ship.collect,0x227da>: [Ship=CA Mineur de glace Sequana, Skills=-60, Mining] OOZ mining: try other ware (Glace)
In move.generic.xml, it shows one other usage to which I have no idea why it is even coded: chance="0". I mean that if the result of chance=0 is really the equivalent of 0%, then it would not even run that script. Right ?

Code: Select all

        <!-- long distance -->
        <do_if value="$bigship">
          <do_if value="(this.sector == $destination.sector) or ($nojump == true)">
            <debug_text text="'Long distance trip. Using engine booster...'" chance="$debugchance" />
            <run_script name="'move.nohighway'" result="$nohighwayresult">
              <param name="target" value="$destination" />
              <param name="position" value="$position" />
              <param name="debugchance" value="$debugchance" />
            </run_script>
            <run_script name="'move.nohighway'" chance="0" />
            <debug_text text="'boost complete. Moving into final position.'" chance="$debugchance" />
            <do_if value="@$nohighwayresult">
              <do_if value="$endintargetzone">
                <!-- no need to move to a safepos now, we're happy just being here -->
                <return />
              </do_if>
            </do_if>
Steam X-Superbox, playing XR
WIndows-7
Intel I5
16Gb Memory
Nvgidia GT 960

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13817
Joined: Sun, 20. Nov 05, 23:45

Post by UniTrader » Mon, 9. Oct 17, 20:08

Browser_ice wrote:In move.generic.xml, it shows one other usage to which I have no idea why it is even coded: chance="0". I mean that if the result of chance=0 is really the equivalent of 0%, then it would not even run that script. Right ?

Code: Select all

...
removing blocking actions like <wait/> or <run_script/> (or changing the order of them) would break savegames. therefore if such a command is not needed anymore because of changes in the script the easiest way to deactivate it is to give it a chanc="0" ;)


for the former case i guess the intention is to randomize the behavior in a certain skill range, and above this range always perform the action, and below it dont perform the action (in other words greater 100 will default to 100 and less than 0 will default to 0)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 9987
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Tue, 10. Oct 17, 02:53

UniTrader wrote: .......
for the former case i guess the intention is to randomize the behavior in a certain skill range, and above this range always perform the action, and below it dont perform the action (in other words greater 100 will default to 100 and less than 0 will default to 0)
Indeed, bare in mind that this occurs within a <do_all> node and hence the variable chances are a neat trick to avoid some of the actions to be executed ;-)

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

Post Reply

Return to “X Rebirth - Scripts and Modding”