Code: Select all
Get ship array of race blah blah
do your check here ...
inc Counter
end
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
Code: Select all
Get ship array of race blah blah
do your check here ...
inc Counter
end
Code: Select all
001 $Races = array alloc: size=0
002 append Argon to array $Races
003 append Boron to array $Races
004 append Split to array $Races
005 append Paranid to array $Races
006 append Teladi to array $Races
007 append Xenon to array $Races
008 append Yaki to array $Races
009 append Pirates to array $Races
010
011 $RaceCount = size of array $Races
012 $Counter = 0
013 while $Counter < $RaceCount
014 |$Race = $Races[$Counter]
015 |$M3s = get ship array: of race $Race class/type=M3
016 |
017 |$Count = size of array $M3s
018 |while $Count
019 ||dec $Count =
020 ||$Ship = $M3s[$Count]
021 ||$Ship -> set name to 'Done!'
022 ||$Race = $Ship -> get owner race
023 ||$GCheck = $Ship -> get local variable: name='ej.weapon.change'
024 ||$Valid = [TRUE]
025 ||skip if $GCheck != [TRUE]
026 |||$Valid = [FALSE]
027 ||skip if $Race != Player
028 |||$Valid = [FALSE]
029 ||if $Valid
030 |||
031 |||$Ship -> set local variable: name='ej.weapon.change' value=[TRUE]
032 |||
033 * Not Pirate or Yaki M3 - Loses random amount of PBGs
034 |||$Ship -> set name to 'Checks'
035 |||$Amount = $Ship -> get amount of ware Plasma Burst Generator in cargo bay
036 |||if $Amount != 0 AND $Race != Pirates AND $Race != Yaki
037 ||||$AmountTake = $Amount + 1
038 ||||$Rand1 = = random value from 0 to $AmountTake - 1
039 ||||$Take = - $Rand1
040 ||||= $Ship -> add $Rand1 units of Plasma Burst Generator
041 |||else if $Amount == 0
042 ||||display subtitle text: text='No PBGs onboard' duration=300 ms
043 |||end
044 |||
045 * Pirate or Yaki M3 - Loses new random amount of PBGs, divided by 2.
046 |||
047 |||$Amount = $Ship -> get amount of ware Plasma Burst Generator in cargo bay
048 |||if $Amount != 0 AND $Race == Pirates OR $Race == Yaki
049 ||||$AmountTake = $Amount + 1
050 ||||$Rand2 = = random value from 0 to $AmountTake - 1
051 ||||$Take = ( - $Rand2 ) / 2
052 ||||= $Ship -> add $Rand1 units of Plasma Burst Generator
053 |||else if $Amount == 0
054 ||||display subtitle text: text='No PBGs onboard' duration=300 ms
055 |||end
056 |||
057 ||end
058 |end
059 end
060 inc $Counter =
061 return null
Code: Select all
59 inc $Counter =
60 end
Code: Select all
$array = array alloc: size=5
$size = size of array $array
while $size
dec $size =
$someval = $array[$size]
* Do stuff
= wait 1 ms
end
Code: Select all
001 $Races = array alloc: size=0
002 append Argon to array $Races
003 append Boron to array $Races
004 append Split to array $Races
005 append Paranid to array $Races
006 append Teladi to array $Races
007 append Xenon to array $Races
008 append Yaki to array $Races
009 append Pirates to array $Races
010
011 $RaceCount = size of array $Races
012 while $RaceCount
013 |dec $RaceCount =
014 |$Race = $Races[$RaceCount]
015 |$M3s = get ship array: of race $Race class/type=M3
016 |
017 |$Count = size of array $M3s
018 |while $Count
019 ||dec $Count =
020 ||$Ship = $M3s[$Count]
021 ||$Race = $Ship -> get owner race
022 ||$GCheck = $Ship -> get local variable: name='ej.weapon.change'
023 ||$Valid = [TRUE]
024 ||skip if $GCheck != [TRUE]
025 |||$Valid = [FALSE]
026 ||skip if $Race != Player
027 |||$Valid = [FALSE]
028 ||if $Valid
029 |||
030 |||$Ship -> set local variable: name='ej.weapon.change' value=[TRUE]
031 |||
032 * Not Pirate or Yaki M3 - Loses random amount of PBGs
033 * Minimum is half!
034 |||$Amount = $Ship -> get amount of ware Plasma Burst Generator in cargo bay
035 |||if $Amount > 0 AND $Race != Pirates AND $Race != Yaki
036 ||||$AmountTake = $Amount + 1
037 ||||$Minimum = $Amount / 2
038 ||||$Rand1 = = random value from $Minimum to $AmountTake - 1
039 ||||$Take = - $Rand1
040 ||||= $Ship -> install $Take units of Plasma Burst Generator
041 ||||= $Ship -> add $Take units of Plasma Burst Generator
042 |||else if $Amount == 0
043 |||end
044 |||
045 * Pirate or Yaki M3 - Loses new random amount of PBGs, divided by 2.
046 * Only loses half of the random value.
047 |||$Amount = $Ship -> get amount of ware Plasma Burst Generator in cargo bay
048 |||if $Amount > 0 AND $Race == Pirates OR $Race == Yaki
049 ||||$AmountTake = $Amount + 1
050 ||||$Rand2 = = random value from 0 to $AmountTake - 1
051 ||||$Take = ( - $Rand2 ) / 2
052 ||||= $Ship -> install $Take units of Plasma Burst Generator
053 ||||= $Ship -> add $Take units of Plasma Burst Generator
054 |||else if $Amount == 0
055 |||end
056 |||
057 @ |||= wait 5 ms
058 ||end
059 |end
060 end
061 return null
Note that you've also introduced more rounding errors - few RelVals are exactly divisible by 1000, and for anything under 1000 (M5s) it will be zero.EmperorJon wrote:Well, as that seems working ish for now I've returned to my previous script with the RelVal problem, and solved the overflow.
Instead of RelVal x number / 1000s... whatever...
I got (RelVal/1000s) x (number/1000s)
I KNOW!That's not better, it's worse.
I DON'T KNOW!So you'll have to use a different mechanism, like multiplying by 10000 and then dividing by your number.
So I have to get 65555784 x 1000000factor = 80.7212
except for M6M, M7 & M7M: factor = 65.555784
(one-off exceptions are SS_SH_A_M1: factor = 49.892, SS_SH_A_M2 & SS_SH_T_M2: factor = 50.299)
Initial base ship price = factor * Production RelVal (NPC)
Code: Select all
$wtcode = [PLAYERSHIP] -> get ware type code of object
$price = get average price of ware $wtcode
GRR!Why are you messing around with RelVals anyways?
You know that you can get the value of a ship simply by the standard command (although it's not really accurate)?
When you save objects in arrays and the objects die, a null reference stays in the array, so no data is saved. If you want the data to be persistent, you have to save them seperately.Problem is, there's an empty array somewhere. I'm using the same style of array, to get wares of a ship. Problem is, the ships dead. I was wondering if it saved that data, as I've used the technique for position before, but I'm now guessing it doesn't. Which sort of throws out my entire script. You're paid an amount for the ship + an amount for onboard items... Any ideas on this guys?
That's interesting...So, I can get an array for a ship which is dead. Called in a Killed signal.
If I do this for wares onboard as an array, it's empty.