
Maybe others with similar problems can learn, too.
Greetings,
ScRaT
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
Code: Select all
001 $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig'
002 if $Checks != [TRUE]
003 |[THIS] -> set local variable: name='ej.bounty.doublesig' value=[TRUE]
004 |send incoming message 'Wow, it actually working' to player: display it=[TRUE]
005 |
006 * Basic stats...
007 |$arr = get warearray for [THIS]
008 |$mil = get global variable: name='ej.player.which.military'
009 |
010 |$att = [THIS] -> get attacker
011 |$race = [THIS] -> get owner race
012 |skip if $att == Player
013 ||$attrace = $att -> get owner race
014 |$bounty = [THIS] -> get local variable: name='ej.bounty'
015 |if $bounty == null
016 ||$bounty = 0
017 |end
018 |send incoming message 'Step1. Stats' to player: display it=[TRUE]
019 |
020 * Multipliers for attackers.
021 |
022 * All races x2 for X,K,Y and Enemy Race
023 * All races x2 for their Enemy
024 * All races x2 for Pirates except Teladi (x1)
025 * All races x0 for any other kills. You dont get paid for friendly fire!
026 |
027 * If the players military, or the race of the attacker is...
028 |
029 |if $mil OR $attrace == Argon
030 ||if $race == Paranid OR $race == Pirates
031 |||$multiplier = 2
032 ||else
033 |||$multiplier = 0
034 ||end
035 ||
036 |else if $mil OR $attrace == Boron
037 ||if $race == Split OR $race == Pirates
038 |||$multiplier = 2
039 ||else
040 |||$multiplier = 0
041 ||end
042 ||
043 |else if $mil OR $attrace == Split
044 ||if $race == Boron OR $race == Pirates
045 |||$multiplier = 2
046 ||else
047 |||$multiplier = 0
048 ||end
049 ||
050 |else if $mil OR $attrace == Paranid
051 ||if $race == Argon OR $race == Pirates
052 |||$multiplier = 2
053 ||else
054 |||$multiplier = 0
055 ||end
056 ||
057 |else if $mil OR $attrace == Teladi
058 ||if $race == Pirates
059 |||$multiplier = 1
060 ||else
061 |||$multiplier = 0
062 ||end
063 ||
064 * If the the race of the attacker is... (player cant join mil. for these races)
065 ||
066 |else if $attrace == Yaki
067 ||$multiplier = 2
068 ||
069 |else if $attrace == Terran
070 ||$multiplier = 0
071 ||
072 |else if $attrace == ATF
073 ||$multiplier = 0
074 ||
075 |else if $attrace == Pirates
076 ||if $race == Teladi
077 |||$multiplier = 1
078 ||else
079 |||$multiplier = 2
080 ||end
081 ||
082 |else if $attrace == Enemy Race
083 ||$multiplier = 2
084 ||
085 |else if $attrace == Kha'ak
086 ||$multiplier = 2
087 ||
088 |else if $attrace == Xenon
089 ||$multiplier = 2
090 ||
091 |else
092 ||send incoming message 'Unknown military or race as killer, may cause problems.' to player: display it=[TRUE]
093 |end
094 |
095 * If the killed ship is X,K,Y or ER, it x2 to the killer to overide x0s above!
096 |
097 |if $race == Xenon OR $race == Kha'ak OR $race == Yaki OR $race == Enemy Race
098 ||$multiplier = 2
099 |end
100 |
101 |send incoming message 'Step2. Multis' to player: display it=[TRUE]
102 * Works out worth of ship.
103 |
104 |$waretype = [THIS] -> get ware type code of object
105 |$shipbase = get average price of ware $waretype
106 |
107 |send incoming message 'Step3. Values' to player: display it=[TRUE]
108 |
109 * Works out worth of ships items as minimal
110 |$count = size of array $arr
111 |while $count
112 ||dec $count =
113 ||$item = $arr[$count]
114 ||$amountware = [THIS] -> get amount of ware $item in cargo bay
115 ||$itemworth = get min price of ware $item
116 ||$worth = $worth + ( $itemworth * $amountware )
117 ||send incoming message 'Counting through the ships wares...' to player: display it=[TRUE]
118 |end
119 |
120 * Works out worth of ships items plus the base ship cost
121 |$finalworth = $worth + $shipbase
122 |
123 * Player is killer - recieves previous bounties plus worth, affected by a Xplier.
124 |if $attrace == Player
125 ||$finalpayout = ( $bounty + $finalworth ) * $multiplier
126 ||add money to player: $finalpayout
127 ||send incoming message 'You just recieved...' to player: display it=[TRUE]
128 ||
129 * Player isnt killer - killer gets worth added to its bounty, which is now found.
130 |else if $attrace != Player
131 ||$bounty = $att -> get local variable: name='ej.bounty'
132 ||if $bounty == null
133 |||$bounty = 0
134 |||$bounty = ( $bounty + $finalworth ) * $multiplier
135 |||$att -> set local variable: name='ej.bounty' value=$bounty
136 ||end
137 |end
138 end
139
140 * Notes
141
142 * Killed ships belonging to player pass the item & ship worth on when killed.
143 * As you, the pilot, is not dead, theres no bounty.
144
145 * Bounties betweem race doesnt matter.
146 * EG. Pirate kills Xenon, Player as Argon mil. kills Pirate.
147 * Bounty passed on contains a Xenon kill by the pirate.
148 * Surely thats good for the military!? No. Reasoning as such:
149 * Pirate survives Xenon attack, is obviously skilled & a threat therefore.
150 * Pirate -> Xenon bounty is passed on to the player.
151 * Lets say the multiplier has made it huge, Pirates killing Boron.
152 return null
Code: Select all
001 $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig'
002 if $Checks != [TRUE]
003 |[THIS] -> set local variable: name='ej.bounty.doublesig' value=[TRUE]
004 |send incoming message 'Wow, it actually working' to player: display it=[TRUE]
005 |
006 |$Maintype = array alloc: size=0
007 |append 8 to array $Maintype
008 |append 9 to array $Maintype
009 |append 10 to array $Maintype
010 |append 11 to array $Maintype
011 |append 12 to array $Maintype
012 |append 13 to array $Maintype
013 |append 14 to array $Maintype
014 |append 15 to array $Maintype
015 |append 16 to array $Maintype
016 |$MainCount = size of array $Maintype
017 |while $MainCount
018 ||dec $MainCount =
019 ||$MaintypeNumber = $Maintype[$MainCount]
020 ||$Subtypes = get number of subtypes of maintype $MaintypeNumber
021 ||$SubCount = size of array $Maintype
022 ||while $SubCount
023 |||dec $SubCount =
024 |||$SubtypeNumber = $Subtypes[$SubCount]
025 |||$wareonboard = get ware from maintype $MaintypeNumber and subtype $SubtypeNumber
026 |||$Amount = [THIS] -> get amount of ware $wareonboard in cargo bay
027 |||$Min = get min price of ware $wareonboard
028 |||$worth = $Amount * $Min
029 ||end
030 |end
Code: Select all
001 $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig'
002 if $Checks != [TRUE]
003 |[THIS] -> set local variable: name='ej.bounty.doublesig' value=[TRUE]
004 |send incoming message 'Wow, it actually working' to player: display it=[TRUE]
005 |
006 |$Maintype = array alloc: size=0
007 |append 8 to array $Maintype
008 |append 9 to array $Maintype
009 |append 10 to array $Maintype
010 |append 11 to array $Maintype
011 |append 12 to array $Maintype
012 |append 13 to array $Maintype
013 |append 14 to array $Maintype
014 |append 15 to array $Maintype
015 |append 16 to array $Maintype
016 |$MainCount = size of array $Maintype
017 |while $MainCount
018 ||dec $MainCount =
019 ||$MaintypeNumber = $Maintype[$MainCount]
020 ||$Subtypes = get number of subtypes of maintype $MaintypeNumber
021 ||$SubCount = size of array $Maintype
022 ||while $SubCount
023 |||dec $SubCount =
024 |||$SubtypeNumber = $Subtypes[$SubCount]
025 |||$wareonboard = get ware from maintype $MaintypeNumber and subtype $SubtypeNumber
026 |||$Amount = [THIS] -> get amount of ware $wareonboard in cargo bay
027 |||$Min = get min price of ware $wareonboard
028 |||$worth = $Amount * $Min
029 |||skip if $Tot.OnboardWorth != null
030 ||||$Tot.OnboardWorth = 0
031 |||$Tot.OnboardWorth = $Tot.OnboardWorth + $worth
032 ||end
033 |end
034 |
035 |
036 * Basic stats...
037 |$mil = get global variable: name='ej.player.which.military'
038 |if $mil != null
039 ||
040 ||$att = [THIS] -> get attacker
041 ||$race = [THIS] -> get owner race
042 ||skip if $att == Player
043 |||$attrace = $att -> get owner race
044 ||$bounty = [THIS] -> get local variable: name='ej.bounty'
045 ||if $bounty == null
046 |||$bounty = 0
047 ||end
048 ||send incoming message 'Step1. Stats' to player: display it=[TRUE]
049 ||
050 * Multipliers for attackers.
051 ||
052 * All races x2 for X,K,Y and Enemy Race
053 * All races x2 for their Enemy
054 * All races x2 for Pirates except Teladi (x1)
055 * All races x0 for any other kills. You dont get paid for friendly fire!
056 ||
057 * If the players military, or the race of the attacker is...
058 ||
059 ||if $mil OR $attrace == Argon
060 |||if $race == Paranid OR $race == Pirates
061 ||||$multiplier = 2
062 |||else
063 ||||$multiplier = 0
064 |||end
065 |||
066 ||else if $mil OR $attrace == Boron
067 |||if $race == Split OR $race == Pirates
068 ||||$multiplier = 2
069 |||else
070 ||||$multiplier = 0
071 |||end
072 |||
073 ||else if $mil OR $attrace == Split
074 |||if $race == Boron OR $race == Pirates
075 ||||$multiplier = 2
076 |||else
077 ||||$multiplier = 0
078 |||end
079 |||
080 ||else if $mil OR $attrace == Paranid
081 |||if $race == Argon OR $race == Pirates
082 ||||$multiplier = 2
083 |||else
084 ||||$multiplier = 0
085 |||end
086 |||
087 ||else if $mil OR $attrace == Teladi
088 |||if $race == Pirates
089 ||||$multiplier = 1
090 |||else
091 ||||$multiplier = 0
092 |||end
093 |||
094 * If the the race of the attacker is... (player cant join mil. for these races)
095 |||
096 ||else if $attrace == Yaki
097 |||$multiplier = 2
098 |||
099 ||else if $attrace == Terran
100 |||$multiplier = 0
101 |||
102 ||else if $attrace == ATF
103 |||$multiplier = 0
104 |||
105 ||else if $attrace == Pirates
106 |||if $race == Teladi
107 ||||$multiplier = 1
108 |||else
109 ||||$multiplier = 2
110 |||end
111 |||
112 ||else if $attrace == Enemy Race
113 |||$multiplier = 2
114 |||
115 ||else if $attrace == Kha'ak
116 |||$multiplier = 2
117 |||
118 ||else if $attrace == Xenon
119 |||$multiplier = 2
120 |||
121 ||else
122 |||send incoming message 'Unknown military or race as killer, may cause problems.' to player: display it=[TRUE]
123 ||end
124 ||
125 * If the killed ship is X,K,Y or ER, it x2 to the killer to overide x0s above!
126 ||
127 ||if $race == Xenon OR $race == Kha'ak OR $race == Yaki OR $race == Enemy Race
128 |||$multiplier = 2
129 ||end
130 ||
131 ||send incoming message 'Step2. Multis' to player: display it=[TRUE]
132 * Works out worth of ship.
133 ||
134 ||$waretype = [THIS] -> get ware type code of object
135 ||$shipcost = get average price of ware $waretype
136 ||$shipbase = $shipcost / 5
137 ||
138 ||send incoming message 'Step3. Values' to player: display it=[TRUE]
139 ||
140 * Works out worth of ships items plus the base ship cost
141 ||$finalworth = $worth + $shipbase
142 ||
143 * Player is killer - recieves previous bounties plus worth, affected by a Xplier.
144 ||if $attrace == Player
145 |||$finalpayout = ( $bounty + $finalworth ) * $multiplier
146 |||add money to player: $finalpayout
147 |||$stringfinal = convert number $finalpayout to string
148 |||send incoming message $stringfinal to player: display it=[TRUE]
149 |||
150 * Player isnt killer - killer gets worth added to its bounty, which is now found.
151 ||else if $attrace != Player
152 |||$bounty = $att -> get local variable: name='ej.bounty'
153 |||if $bounty == null
154 ||||$bounty = 0
155 ||||$bounty = ( $bounty + $finalworth ) * $multiplier
156 ||||$att -> set local variable: name='ej.bounty' value=$bounty
157 |||end
158 ||end
159 |end
160 end
161
162 * Notes
163
164 * Killed ships belonging to player pass the item & ship worth on when killed.
165 * As you, the pilot, is not dead, theres no bounty.
166
167 * Bounties betweem race doesnt matter.
168 * EG. Pirate kills Xenon, Player as Argon mil. kills Pirate.
169 * Bounty passed on contains a Xenon kill by the pirate.
170 * Surely thats good for the military!? No. Reasoning as such:
171 * Pirate survives Xenon attack, is obviously skilled & a threat therefore.
172 * Pirate -> Xenon bounty is passed on to the player.
173 * Lets say the multiplier has made it huge, Pirates killing Boron.
174 return null
Code: Select all
040 ||$att = [THIS] -> get attacker
...
042 ||skip if $att == Player
043 |||$attrace = $att -> get owner race
...
144 ||if $attrace == Player
One easy method to observe how your code is executed are debug statements, which write some values to your logbook. Just check on an easy test case, whether all variables have the correct value, etc.Not only that, it works even though I put in a check to make sure you're part of the 'military'. Still pays you. And doesn't appear to pay 1/5th, more like a half.
Code: Select all
001 $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig'
002 if $Checks != [TRUE]
Code: Select all
if not get global variable 'ej.bounty.doublesig'
Code: Select all
skip if not get global variable: name = 'ej.bounty.doublesig'
return null
set global variable: name = 'ej.bounty.doublesig' value=[TRUE]
Code: Select all
029 |||skip if $Tot.OnboardWorth != null
030 ||||$Tot.OnboardWorth = 0
Code: Select all
037 |$mil = get global variable: name='ej.player.which.military'
038 |if $mil != null
Code: Select all
153 |||if $bounty == null
154 ||||$bounty = 0
155 ||||$bounty = ( $bounty + $finalworth ) * $multiplier
Code: Select all
if not $bounty
$bounty = ( $bounty + $finalworth ) * $multiplier
As I said, you can only check those with debug messages.1. Another one of those errors is causing an problem with it
2. It really can't get the wares of a 'husk'
Code: Select all
$text = sprintf: fmt='Wares on board: %s, Worth: %s', $warearray, $worth, null, null, null
write to player logbook $text
Look harder.EmperorJon wrote:No. It's not. And as far as I can see I'm not treating it so.
Code: Select all
020 ||$Subtypes = get number of subtypes of maintype $MaintypeNumber
021 ||$SubCount = size of array $Maintype
022 ||while $SubCount
023 |||dec $SubCount =
024 |||$SubtypeNumber = $Subtypes[$SubCount]
Code: Select all
001 $Checks = [THIS] -> get local variable: name='ej.bounty.doublesig'
002 if $Checks != [TRUE]
003 |[THIS] -> set local variable: name='ej.bounty.doublesig' value=[TRUE]
004 |send incoming message 'Wow, it actually working' to player: display it=[TRUE]
005 |
006 |$Maintype = array alloc: size=0
007 |append 8 to array $Maintype
008 |append 9 to array $Maintype
009 |append 10 to array $Maintype
010 |append 11 to array $Maintype
011 |append 12 to array $Maintype
012 |append 13 to array $Maintype
013 |append 14 to array $Maintype
014 |append 15 to array $Maintype
015 |append 16 to array $Maintype
016 |$MainCount = size of array $Maintype
017 |while $MainCount
018 ||dec $MainCount =
019 ||$MaintypeNumber = $Maintype[$MainCount]
020 ||$Subtypes = get number of subtypes of maintype $MaintypeNumber
021 ||$SubCount = size of array $Maintype
022 ||while $SubCount
023 |||dec $SubCount =
024 |||$SubtypeNumber = $Subtypes[$SubCount]
025 |||$wareonboard = get ware from maintype $MaintypeNumber and subtype $SubtypeNumber
Code: Select all
017 |while $MainCount
018 ||dec $MainCount =
019 ||$MaintypeNumber = $Maintype[$MainCount]
020 ||$SubtypeNumber = get number of subtypes of maintype $MaintypeNumber
022 ||while $SubtypeNumber
023 |||dec $SubtypeNumber =
025 |||$wareonboard = get ware from maintype $MaintypeNumber and subtype $SubtypeNumber
This may work, but it's ugly as hell.006 |$Maintype = array alloc: size=0
007 |append 8 to array $Maintype
008 |append 9 to array $Maintype
009 |append 10 to array $Maintype
010 |append 11 to array $Maintype
011 |append 12 to array $Maintype
012 |append 13 to array $Maintype
013 |append 14 to array $Maintype
014 |append 15 to array $Maintype
015 |append 16 to array $Maintype
016 |$MainCount = size of array $Maintype
017 |while $MainCount
Code: Select all
$maintype = 8
while $maintype <= 16
$subtype = get number of subtypes of maintype $maintype
while $subtype
dec $subtype=
$ware = get ware from maintype $maintype and subtype $subtype
*/ Do anything you want here /*
end
inc $maintype=
end
But wouldn't it be better, if you understood why your script is working?I thought so, but it seems to be working fine. I just loaded a ship with expensive guns and killed it and got paid loads?