Me and Betel were interested to mimick the <RandomItem> tag in some way in code and generate loot items for a station.
The final goal was to create a function that would fill a station with goodies depending on the systemlevel.
This would make most of the stations less repetitive and at the same time the random generated loot would increase in level during the game itself.
After a couple of evenings of work we got 2 functions:
the first, made by Betel is called intSystemLevelToString and generate directly the levelstring for the itmCreateRandom (like "---uc --")
It accepts 3 lambda variables, so it's possible to apply systemlevel modifiers and get various level curves like C, or UCU, or RUCUR.
the second function, made by me, is called intRandomStationItems and generate random loot that can be filtered by type (armor, shield, weapon, other), by modifiers and randomly enhanced.
Are you guys interested ?
Do you want to see more features ?
New Mod: Random Station Items (released!)
I'm very interested. I want it to put it in an OnDestroy tag so that I can remove all items from a station that sells stuff, and replace it with some more loot which is where your function will really help.
I would like a feature that creates a mix of X number of items weighted (as a percent) between Devices, Weapons, Fuel, or Commodities that appear for a system level.
ie.
(CreateRandomItemFunction number number number number number number string)
number: number of item groups to create
number: %chance for a device (shield, ICX, CPU, etc.) to be chosen
number: %chance for a Weapon to be chosen
number: %chance for fuel to be chosen
number: %chance for commodities to be chosen
string: itmCreateRandom level string
if something else will serve my purpose stated at the top of this post better, I want that too.
I would like a feature that creates a mix of X number of items weighted (as a percent) between Devices, Weapons, Fuel, or Commodities that appear for a system level.
ie.
(CreateRandomItemFunction number number number number number number string)
number: number of item groups to create
number: %chance for a device (shield, ICX, CPU, etc.) to be chosen
number: %chance for a Weapon to be chosen
number: %chance for fuel to be chosen
number: %chance for commodities to be chosen
string: itmCreateRandom level string
if something else will serve my purpose stated at the top of this post better, I want that too.
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
F50 your function is already done in game (not in that format but still) but yes you can make a helper function do that if you wanted
These items will be put in the onCreate tag so you can buy or loot them normally. You can use the function to create new stuff in onDestroy if you wanted after you got rid of all the items already in there.
These items will be put in the onCreate tag so you can buy or loot them normally. You can use the function to create new stuff in onDestroy if you wanted after you got rid of all the items already in there.
Crying is not a proper retort!
- digdug
- Fleet Admiral
- Posts: 2620
- Joined: Mon Oct 29, 2007 9:23 pm
- Location: Decoding hieroglyphics on Tan-Ru-Dorem
The loot items are the same items sold at the station, so basically you can fill a station with all the goods you want, provided that you remove the <RandomItem> tags in the stationtype iteself and let the functions do their work.Periculi Posted: Fri Apr 11, 2008 1:57 am
How will the random items effect the station vendors?
some testing, just created 10000 randomly enhanced 10th level weapons:
http://img155.imageshack.us/img155/9053 ... onswm2.jpg
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
Periculi that can be done by getting rid of all the items in onDestroy and then adding new ones (adding new ones can be done with our function)
Crying is not a proper retort!
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
I suppose we can add that but that will be a post .99 feature (only stations you can buy from for now we have to wait for other stations)
Do you think arresting should be gone too? Otherwise why make them vulnerable in the first place.
Just so you know now we have arbitrary curves (meaning we can put in any curve we want without extra code) 8)
Do you think arresting should be gone too? Otherwise why make them vulnerable in the first place.
Just so you know now we have arbitrary curves (meaning we can put in any curve we want without extra code) 8)
Crying is not a proper retort!
- digdug
- Fleet Admiral
- Posts: 2620
- Joined: Mon Oct 29, 2007 9:23 pm
- Location: Decoding hieroglyphics on Tan-Ru-Dorem
I'm working on the code to damage randomly the items to be added, and it's tricky because shpDamageItem works only from ships and accepts only itemListPointers.
At the end we will mimick the looot of the tinker station, using however a function designed to be much more flexible. (and more used in the future)
At the end we will mimick the looot of the tinker station, using however a function designed to be much more flexible. (and more used in the future)
- digdug
- Fleet Admiral
- Posts: 2620
- Joined: Mon Oct 29, 2007 9:23 pm
- Location: Decoding hieroglyphics on Tan-Ru-Dorem
work done so far:
intRandomStationItems damages/enhances items correctly using a dummy ship as the "place" to damage them and a couple of helper functions to get the category of the item and enhance it using an appropriate array of enhancements.
Betel function now has 2 more parameters (optional), used to cap the level string.
My function has the possibility to pass an optional custom array directly to the station for enhancing items, bypassing the internal random array. (more flexibility)
intRandomStationItems damages/enhances items correctly using a dummy ship as the "place" to damage them and a couple of helper functions to get the category of the item and enhance it using an appropriate array of enhancements.
Betel function now has 2 more parameters (optional), used to cap the level string.
My function has the possibility to pass an optional custom array directly to the station for enhancing items, bypassing the internal random array. (more flexibility)
- digdug
- Fleet Admiral
- Posts: 2620
- Joined: Mon Oct 29, 2007 9:23 pm
- Location: Decoding hieroglyphics on Tan-Ru-Dorem
So, here it is!
http://xelerus.de/index.php?s=mod&id=123
Here a quick guide on how to use the new global functions:
(intRandomStationItems itemFilter levelString loopCount percentEnhanced percentDamaged [enhancementArray] [modList])
itemFilter = 1st string used by itmCreateRandom
levelString = 2nd string of itmCreateRandom, can be used normally as "ucu" or you can use the amazing function intSystemLevelToString (made by Betel)
loopCount = number of items to generate
percentEnhanced = % of items enhanced
percentDamaged = % of items damaged (remember enhancing and damaging the same item will give you a normal item)
[enhancementArray] = custom array for enhancing items, if you don't want to use the default one. Here an example of 3 random armor enhancing arrays (randomized):
(random '(((0x0001 0x0002 0x0002 0x0003) (0) (0) (0)) ((0x0002 0x0002 0x0002 0x0002) (0) (0) (0)) ((0) (0) (0) (0))))
[modList] = is an optional parameter that is CAT to the itemFilter, this is not used right now but was added to increase flexibility in code.
------------------------------
(intSystemLevelToString percent modifier curve [min] [max])
percent = % of systemlevel to compute for generating the curve, 100 will give you a level more in the curve for each level of systemlevel, 50 will increase the curve by 1 level for each 2 systemlevels, and so on...
modifier = can be positive or negative, it is added to the calculated level for the curve
curve = has to be formatted like this '(2 u c u) where 2 is the second letter of the curve (c in this case) and is the central level of the calculated itemlevel. (more explanations can be given by Betel )
min and max are optional parameters used to limit the maximum and minimum level of the curve, useful to cap the itemlevel of some stations.
There are other 2 helper functions:
intCategoryToIndex convert the category of the item to an index used in the array of enhancements, it is called by intRandomEnhanceItems automatically.
intRandomEnhanceItems is the actual function that enhance items, it is called by intRandomStationItems.
http://xelerus.de/index.php?s=mod&id=123
Here a quick guide on how to use the new global functions:
(intRandomStationItems itemFilter levelString loopCount percentEnhanced percentDamaged [enhancementArray] [modList])
itemFilter = 1st string used by itmCreateRandom
levelString = 2nd string of itmCreateRandom, can be used normally as "ucu" or you can use the amazing function intSystemLevelToString (made by Betel)
loopCount = number of items to generate
percentEnhanced = % of items enhanced
percentDamaged = % of items damaged (remember enhancing and damaging the same item will give you a normal item)
[enhancementArray] = custom array for enhancing items, if you don't want to use the default one. Here an example of 3 random armor enhancing arrays (randomized):
(random '(((0x0001 0x0002 0x0002 0x0003) (0) (0) (0)) ((0x0002 0x0002 0x0002 0x0002) (0) (0) (0)) ((0) (0) (0) (0))))
[modList] = is an optional parameter that is CAT to the itemFilter, this is not used right now but was added to increase flexibility in code.
------------------------------
(intSystemLevelToString percent modifier curve [min] [max])
percent = % of systemlevel to compute for generating the curve, 100 will give you a level more in the curve for each level of systemlevel, 50 will increase the curve by 1 level for each 2 systemlevels, and so on...
modifier = can be positive or negative, it is added to the calculated level for the curve
curve = has to be formatted like this '(2 u c u) where 2 is the second letter of the curve (c in this case) and is the central level of the calculated itemlevel. (more explanations can be given by Betel )
min and max are optional parameters used to limit the maximum and minimum level of the curve, useful to cap the itemlevel of some stations.
There are other 2 helper functions:
intCategoryToIndex convert the category of the item to an index used in the array of enhancements, it is called by intRandomEnhanceItems automatically.
intRandomEnhanceItems is the actual function that enhance items, it is called by intRandomStationItems.
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
a few clarifications
(armorList shieldList weaponList defaultList)
Each list is made up of enhancements that will be chosen randomly on enhancement (even 0 meaning no enhancement)
Nil is not allowed for the inner lists. (it might work but not in the format so we didn't test it)
Where the itemLevelOnCurve is the index in the list that you want the item level to be at.
For example (2 c - c - c) will have a curve around the first -.
(intSystemLevelToString 100 5 '(2 c - c - c))
Will give you in a level one system (so 1 + 5 gives you an item level of 6) "----c -c-c"
Any questions?
that example isn't the most clear and doesn't state the format. The format is an enhancementArray is a list of four lists.digdug wrote: [enhancementArray] = custom array for enhancing items, if you don't want to use the default one. Here an example of 3 random armor enhancing arrays (randomized):
(random '(((0x0001 0x0002 0x0002 0x0003) (0) (0) (0)) ((0x0002 0x0002 0x0002 0x0002) (0) (0) (0)) ((0) (0) (0) (0))))
(armorList shieldList weaponList defaultList)
Each list is made up of enhancements that will be chosen randomly on enhancement (even 0 meaning no enhancement)
Nil is not allowed for the inner lists. (it might work but not in the format so we didn't test it)
The format for the list in this case is (itemLevelOnCurve curveLetter^1)digdug wrote: curve = has to be formatted like this '(2 u c u) where 2 is the second letter of the curve (c in this case) and is the central level of the calculated itemlevel.
Where the itemLevelOnCurve is the index in the list that you want the item level to be at.
For example (2 c - c - c) will have a curve around the first -.
(intSystemLevelToString 100 5 '(2 c - c - c))
Will give you in a level one system (so 1 + 5 gives you an item level of 6) "----c -c-c"
Any questions?
Crying is not a proper retort!