OpenXcom Forum
Modding => Work In Progress => Topic started by: Aldorn on May 20, 2014, 02:03:00 pm
-
I have some questions about referecing external files (sprites, sounds, ... )
I made some tests and have some answers, but ideally I would like to know opinion from some developper, to be sure...
These questions are interesting while trying to merge many mods
1) Is it allowed to use same number as reference inside two different RuleSet files ?
ANSWER is : YES
Example :
Mod_Crafts_Weapon1.rul
items:
- type: STR_WEAPON1
bigSprite: 10001
floorSprite: 10002
handSprite: 10003
Mod_Crafts_Weapon2.rul
items:
- type: STR_WEAPON2
bigSprite: 10001
floorSprite: 10002
handSprite: 10003
2) Is there any limit to these numbers, while referencing any of following properties ?
(I mean : could I use 10000, 100000, 1000000 ?)
CF ANSWER IN YELLOW
crafts:
- type: STR_MY_NEW_CRAFT
[b]sprite[/b]: 100001
items:
- type: STR_MY_NEW_WEAPON
[b]bigSprite[/b]: 10001
[b]floorSprite[/b]: 10002
[b]handSprite[/b]: 10003
[b]bulletSprite[/b]: 10004
[b]fireSound[/b]: 10005
[b]hitSound[/b]: 10006
[b]hitAnimation[/b]: 10007
armors:
- type: STR_MY_NEW_ARMOR
[b]spriteSheet[/b]: 1001
[b]spriteInv[/b]: 1002
3) ListOrder
3a) In case two items (of same nature) having same listOrder in same RuleSet file, will they be sorted :
- alphabetically ?
- by order of appearence ?
3b) In case two items (of same nature) having same listOrder in different RuleSet files, will they be sorted :
- alphabetically ?
- by order of reading RuleSet files ?
ANSWER is : BY ORDER OF APPEARANCE (ALSO BASED ON MOD ORDER FIRST, LINE ORDER SECOND) IF LISTORDER NOT SPECIFIED, ELSE CF BELOW
3c) Is there any limit to listOrder (1000, 10000, 100000, ...) ?
ANSWER is : NO
ANSWER OF SupSuper
Some clarifications:
- Every ruleset has a safe numeric ID range of 0..999. No rulesets can conflict within this range, except when modifying original resources. If you exceed this, then all bets are off (we'll probably just use string IDs for everything in the future), so don't try to guess and avoid other mod's IDs, you'll just make it worse.
- If a numeric ID matches an original resource, than it's treated as such, otherwise it's treated as a new resource. If you don't wanna keep track of where the original resources end and the new ones start for everything, it's probably safe to always start at 100.
- listOrders are different. They apply globally to every ruleset combined, and have no limit.
- Every item by default gets a listOrder based on the mod order first, line order second, unless manually specified.
- If multiple items specify the same listOrder, they'll be next to each other. Which comes first depends on how the algorithm is feeling that day, as it's not stable (https://en.wikipedia.org/wiki/Stable_sort#Stability).
EDIT : other interesting information related to BaseBit, IntIcon or bulletSprite -> https://openxcom.org/forum/index.php?topic=2031.msg21679#msg21679 (https://openxcom.org/forum/index.php?topic=2031.msg21679#msg21679)
-
1) Is it allowed to use same number as reference inside two different RuleSet files ?
Example :
Mod_Crafts_Weapon1.rul
items:
- type: STR_WEAPON1
bigSprite: 10001
floorSprite: 10002
handSprite: 10003
Mod_Crafts_Weapon2.rul
items:
- type: STR_WEAPON2
bigSprite: 10001
floorSprite: 10002
handSprite: 10003
Yes, it's fine - they won't conflict with each other, as every ruleset is considered a separate data set.
Otherwise we'd have mod conflicts all the time... :)
2) Is there any limit to these numbers, while referencing any of following properties ?
(I mean : could I use 10000, 100000, 1000000 ?)
crafts:
- type: STR_MY_NEW_CRAFT
[b]sprite[/b]: 100001
items:
- type: STR_MY_NEW_WEAPON
[b]bigSprite[/b]: 10001
[b]floorSprite[/b]: 10002
[b]handSprite[/b]: 10003
[b]bulletSprite[/b]: 10004
[b]fireSound[/b]: 10005
[b]hitSound[/b]: 10006
[b]hitAnimation[/b]: 10007
armors:
- type: STR_MY_NEW_ARMOR
[b]spriteSheet[/b]: 1001
[b]spriteInv[/b]: 1002
I'm not sure - the system seems to be quite robust, but not infinitely so. Generally speaking, it would be very hard to add enough items to force such great numbers. It's best to stick to low numbers when possible.
3) ListOrder
3a) In case two items (of same nature) having same listOrder in same RuleSet file, will they be sorted :
- alphabetically ?
- by order of appearence ?
Frankly I don't know right now. I just make sure this never happens. :P
3c) Is there any limit to listOrder (1000, 10000, 100000, ...) ?
See above - there are limits, but they're extremely high, and it's not necessary to go there.
-
Yes, it's fine - they won't conflict with each other, as every ruleset is considered a separate data set.
Otherwise we'd have mod conflicts all the time... :)
that's just straight up WRONG.
don't use numbers for sprites over 1000... ever. trust me.
no, unless the sprite is within the original range (ie:replacing original graphics), then it will have to be defined in each ruleset.
by order of appearance, including mod load order.
no limit to listOrder.
-
don't use numbers for sprites over 1000... ever.
lol. First ruleset I examined when I started modding had 12000, so I started there with the numeration for my mods: basically I've been always using more than 1000 everywhere.
-
you're gonna have so many compatibilty errors...
-
Ok
Nice that it is per ruleset file
So if I report to wiki https://www.ufopaedia.org/index.php?title=Ruleset_Reference_%28OpenXcom%29#Items (https://www.ufopaedia.org/index.php?title=Ruleset_Reference_%28OpenXcom%29#Items), "as low as possible" means :
- bigSprite => from 57 (as 0..56 used by engine for original items)
- floorSprite => from 73 (as 0..72 used by engine for original items)
- handSprite => from 16 (as 0..15 used by engine for original items)
-
This is my numeration. I could just go over them.
Bigobs, Floorob:
(UNITS):
300 MIB0
301 MIB1
302 MIB2
303 WASPITE
304 CYBERMITE
305 MIB3
306 GAZER
307 HOLODRONE
64 ARMORED VEST
77 ARMORED VEST
Bigobs, Floorob, (Handsprite):
(ITEMS):
12004(to 12011) MACHINE PISTOL
12005 MACHINE PISTOL CLIP
12012(to 12019) SNIPER RIFLE
12013 SNIPER RIFLE CLIP
... so.. are 100 and 300 (for items, i'd like to keep them separated) good numbers to start from?
-
Some clarifications:
- Every ruleset has a safe numeric ID range of 0..999. No rulesets can conflict within this range, except when modifying original resources. If you exceed this, then all bets are off (we'll probably just use string IDs for everything in the future), so don't try to guess and avoid other mod's IDs, you'll just make it worse.
- If a numeric ID matches an original resource, than it's treated as such, otherwise it's treated as a new resource. If you don't wanna keep track of where the original resources end and the new ones start for everything, it's probably safe to always start at 100.
- listOrders are different. They apply globally to every ruleset combined, and have no limit.
- Every item by default gets a listOrder based on the mod order first, line order second, unless manually specified.
- If multiple items specify the same listOrder, they'll be next to each other. Which comes first depends on how the algorithm is feeling that day, as it's not stable (https://en.wikipedia.org/wiki/Stable_sort#Stability).