2 * Elite - The New Kind.
4 * Reverse engineered from the BBC disk version of Elite.
5 * Additional material by C.J.Pinder.
7 * The original Elite code is (C) I.Bell & D.Braben 1984.
8 * This version re-engineered in C by C.J.Pinder 1999-2001.
10 * email: <christian@newkind.co.uk>
38 * The following holds the Elite Planet Stock Market.
45 struct stock_item stock_market
[NO_OF_STOCK_ITEMS
]=
47 {"Food", 0, 0, 19, -2, 6, 0x01, TONNES
},
48 {"Textiles", 0, 0, 20, -1, 10, 0x03, TONNES
},
49 {"Radioactives", 0, 0, 65, -3, 2, 0x07, TONNES
},
50 {"Slaves", 0, 0, 40, -5, 226, 0x1F, TONNES
},
51 {"Liquor/Wines", 0, 0, 83, -5, 251, 0x0F, TONNES
},
52 {"Luxuries", 0, 0, 196, 8, 54, 0x03, TONNES
},
53 {"Narcotics", 0, 0, 235, 29, 8, 0x78, TONNES
},
54 {"Computers", 0, 0, 154, 14, 56, 0x03, TONNES
},
55 {"Machinery", 0, 0, 117, 6, 40, 0x07, TONNES
},
56 {"Alloys", 0, 0, 78, 1, 17, 0x1F, TONNES
},
57 {"Firearms", 0, 0, 124, 13, 29, 0x07, TONNES
},
58 {"Furs", 0, 0, 176, -9, 220, 0x3F, TONNES
},
59 {"Minerals", 0, 0, 32, -1, 53, 0x03, TONNES
},
60 {"Gold", 0, 0, 97, -1, 66, 0x07, KILOGRAMS
},
61 {"Platinum", 0, 0, 171, -2, 55, 0x1F, KILOGRAMS
},
62 {"Gem-Stones", 0, 0, 45, -1, 250, 0x0F, GRAMS
},
63 {"Alien Items", 0, 0, 53, 15, 192, 0x07, TONNES
},
70 * Generate the Elite stock market.
71 * The prices and quantities are affected by the planet's economy.
72 * There is also a slight amount of randomness added in.
73 * The random value is changed each time we hyperspace.
77 void generate_stock_market (void)
83 for (i
= 0; i
< NO_OF_STOCK_ITEMS
; i
++)
85 price
= stock_market
[i
].base_price
; /* Start with the base price */
86 price
+= cmdr
.market_rnd
& stock_market
[i
].mask
; /* Add in a random amount */
87 price
+= current_planet_data
.economy
* stock_market
[i
].eco_adjust
; /* Adjust for planet economy */
88 price
&= 255; /* Only need bottom 8 bits */
90 quant
= stock_market
[i
].base_quantity
; /* Start with the base quantity */
91 quant
+= cmdr
.market_rnd
& stock_market
[i
].mask
; /* Add in a random amount */
92 quant
-= current_planet_data
.economy
* stock_market
[i
].eco_adjust
; /* Adjust for planet economy */
93 quant
&= 255; /* Only need bottom 8 bits */
95 if (quant
> 127) /* In an 8-bit environment '>127' would be negative */
96 quant
= 0; /* So we set it to a minimum of zero. */
98 quant
&= 63; /* Quantities range from 0..63 */
100 stock_market
[i
].current_price
= price
* 4;
101 stock_market
[i
].current_quantity
= quant
;
105 /* Alien Items are never available for purchase... */
107 stock_market
[ALIEN_ITEMS_IDX
].current_quantity
= 0;
112 void set_stock_quantities(int *quant
)
116 for (i
= 0; i
< NO_OF_STOCK_ITEMS
; i
++)
117 stock_market
[i
].current_quantity
= quant
[i
];
119 stock_market
[ALIEN_ITEMS_IDX
].current_quantity
= 0;
123 int carrying_contraband (void)
125 return (cmdr
.current_cargo
[SLAVES
] + cmdr
.current_cargo
[NARCOTICS
]) * 2 +
126 cmdr
.current_cargo
[FIREARMS
];
130 int total_cargo (void)
136 for (i
= 0; i
< 17; i
++)
138 if ((cmdr
.current_cargo
[i
] > 0) &&
139 (stock_market
[i
].units
== TONNES
))
141 cargo_held
+= cmdr
.current_cargo
[i
];
149 void scoop_item (int un
)
154 if (universe
[un
].flags
& FLG_DEAD
)
157 type
= universe
[un
].type
;
159 if (type
== SHIP_MISSILE
)
162 if ((cmdr
.fuel_scoop
== 0) || (universe
[un
].location
.y
>= 0) ||
163 (total_cargo() == cmdr
.cargo_capacity
))
165 universe
[un
].flags
|= FLG_TARGET
;
167 damage_ship (128 + (universe
[un
].energy
/ 2), universe
[un
].location
.z
> 0);
171 if (type
== SHIP_CARGO
)
173 trade
= rand255() & 7;
174 cmdr
.current_cargo
[trade
]++;
175 info_message (stock_market
[trade
].name
);
180 if (ship_list
[type
]->scoop_type
!= 0)
182 trade
= ship_list
[type
]->scoop_type
+ 1;
183 cmdr
.current_cargo
[trade
]++;
184 info_message (stock_market
[trade
].name
);
190 damage_ship (universe
[un
].energy
/ 2, universe
[un
].location
.z
> 0);