Author Topic: [HELP] Developing my first mod, could use some guidance  (Read 11733 times)

Offline Harudoku

  • Squaddie
  • *
  • Posts: 5
    • View Profile
[HELP] Developing my first mod, could use some guidance
« on: June 10, 2015, 02:40:47 am »
My friends and I have a bit of an LP planned, and I'm considering trying to mod to rebalance a lot of the items in the game to add more compelling choices, change the starting balance of funding and move funding from one country to another (new) one, etc; I've already hit my first snag in trying to make everything work, the solving of which would seem (to me) to be the first step towards really understanding how to work with OpenXCom's Rulesets.

Namely, I'd like to learn how to add a new ammo type for the basic rifle, if only to learn more about what all gets involved. I've managed to make a ruleset that gets the new ammo type to show up on the list, albeit on the bottom and not underneath the rifle, but, worryingly, OpenXCom crashes any time I try to open the Rifle entry in ufopaedia. What I have so far:
Code: [Select]
items:
  - type: STR_RIFLE
    compatibleAmmo:
      - Sniper-Rifle_Clip 
  - type: Sniper-Rifle_Clip
    size: 0.1
    costBuy: 300
    costSell: 225
    weight: 4
    bigSprite: 2
    floorSprite: 2
    hitSound: 13
    hitAnimation: 26
    power: 65
    damageType: 1
    clipSize: 5
    battleType: 2
ufopaedia:
  - id: Sniper-Rifle_Clip
    type_id: 4
    section: STR_NOT_AVAILABLE
Making a new sprite and changing the animation can come later, but for now I'd like to learn how to make it show up at the right spot on the list, not crash the game upon viewing the entry in UFOPaedia, etc. Any help is appreciated!

Oh, and if I'm posting this in the wrong spot, let me know.
« Last Edit: June 10, 2015, 02:51:43 am by Harudoku »

Offline Dioxine

  • Commander
  • *****
  • Posts: 5460
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: [HELP] Developing my first mod, could use some guidance
« Reply #1 on: June 10, 2015, 03:38:21 am »
Firstly, you need to add a listOrder to your clip, like this:

Code: [Select]
    clipSize: 5
    battleType: 2
    listOrder: 3260

The number above is purely random; I don't know what is the vanilla listorder for the rifle clip, these are hard coded and need to be overriden manually like in the example above, you have to find out in the documentation. Anyway the listorder for your clip needs to be higher for it to show below the rifle clip. You can also try finding out by trial-and-error, start around 3001 and try going up/down by a 100 (vanilla items are ordered 100, 200, 300 etc, each next being +100 compared to the previous).

And, to avoid the crash, you need an Ufopedia entry for your clip, like this:

Code: [Select]
ufopaedia:
  - id: STR_SNIPER_RIFLE_CLIP
    type_id: 4
    section: STR_NOT_AVAILABLE
« Last Edit: June 10, 2015, 03:42:31 am by Dioxine »

Offline Harudoku

  • Squaddie
  • *
  • Posts: 5
    • View Profile
Re: [HELP] Developing my first mod, could use some guidance
« Reply #2 on: June 10, 2015, 03:45:21 am »
Firstly, you need to add a listOrder to your clip, like this:

Code: [Select]
    clipSize: 5
    battleType: 2
    listOrder: 3260

The number above is purely random; I don't know what is the vanilla listorder for the rifle clip, these are hard coded and need to be overriden manually like in the example above, you have to find out in the documentation.
Figured it had to be something like that, but help me with this:
1) Where would I find this documentation? You answered this decently well in your edit
2) If I can't add this there, where would I do so? Figured it out, under the clip. Thanks.

And, to avoid the crash, you need an Ufopedia entry for your clip, like this:

Code: [Select]
ufopaedia:
  - id: STR_SNIPER_RIFLE_CLIP
    type_id: 4
    section: STR_NOT_AVAILABLE
For what it's worth, I do have something of that nature in my block of code:
Code: [Select]
ufopaedia:
  - id: Sniper-Rifle_Clip
    type_id: 4
    section: STR_NOT_AVAILABLE
What exactly am I looking to change here?

Related question, how do I keep the syntax consistent (rename it "STR_SNIPER_RIFLE_CLIP") while keeping it as "Sniper Rifle Clip" in-game?

Thanks for the help!
« Last Edit: June 10, 2015, 03:47:24 am by Harudoku »

Offline XOps

  • Colonel
  • ****
  • Posts: 193
  • Guy who drowns first
    • View Profile
Re: [HELP] Developing my first mod, could use some guidance
« Reply #3 on: June 10, 2015, 04:17:07 am »
Default ruleset list order is here.
https://www.ufopaedia.org/index.php?title=Ruleset_List_Order_%28OpenXcom%29

Ruleset reference is here
https://www.ufopaedia.org/index.php?title=Ruleset_Reference_%28OpenXcom%29

Ruleset reference with nightly updates is here
https://www.ufopaedia.org/index.php?title=Ruleset_Reference_Nightly_%28OpenXcom%29

The coding for the UFOPaedia entry looks correct except for it probably should be STR_SNIPER_RIFLE_CLIP rather than Sniper-Rifle_Clip. I've never tried using lower case on string names, but I usually play it safe and keep everything capitals with underscores.

Related question, how do I keep the syntax consistent (rename it "STR_SNIPER_RIFLE_CLIP") while keeping it as "Sniper Rifle Clip" in-game?

Names and text are defined in the extraStrings section.
Code: [Select]
extraStrings:
  - type: en-US
    strings:
      STR_SNIPER_RIFLE_CLIP: Sniper Rifle Clip

I would recommend downloading a few mods and mimicking their code. That's how most modders get their start.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5460
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: [HELP] Developing my first mod, could use some guidance
« Reply #4 on: June 10, 2015, 04:19:13 am »
Related question, how do I keep the syntax consistent (rename it "STR_SNIPER_RIFLE_CLIP") while keeping it as "Sniper Rifle Clip" in-game?

You need to add language, like this:
Code: [Select]
extraStrings:
  - type: en-US
    strings:
      STR_SNIPER_RIFLE_CLIP: Sniper Rifle Clip

As for the Pedia problem - you have an entry, and you have bigob gfx defined. What else. Have you checked if your new clip works in the quick battle? The small lettering might be the problem here, or the "-" sign in the middle, but that's just guessing.

ugh nevermind, looks like XOps has beaten me to it :)

Offline Harudoku

  • Squaddie
  • *
  • Posts: 5
    • View Profile
Re: [HELP] Developing my first mod, could use some guidance
« Reply #5 on: June 10, 2015, 04:35:53 am »
Excellent, that all worked well and the changes were implemented very successfully. I'm really happy to see that this wonderful game still has a relatively active modding community! Thanks for the help.

Next question, can anyone direct me to a few mods I might study that could teach me to change sprites and insert new ones for things such as weapons, and maybe maps? I've been searching for download links to some of the more interesting ones on the site for reference, but it's been hard to work through some of it.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5460
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: [HELP] Developing my first mod, could use some guidance
« Reply #6 on: June 10, 2015, 05:12:42 am »
I'd suggest the following ones:

Solarius Scorch FMP (a compilation of a ton of mods - a vanilla improved):
https://www.openxcom.com/mod/final-mod-pack

Hobbes' UFO Redux - a smaller, less invasive improvement of vanilla, but more elegant and with a well-thought of story line. Also, he's the author of the best maps that are also used in this mod.
https://www.openxcom.com/mod/ufo-redux

Xeno Ops, by XOps - unfinished but huge, a pipmped-up XCom with a more hi-tec feel and tons of quality resources:
https://openxcom.org/forum/index.php/topic,2913.0.html

Offline Harudoku

  • Squaddie
  • *
  • Posts: 5
    • View Profile
Re: [HELP] Developing my first mod, could use some guidance
« Reply #7 on: June 10, 2015, 05:33:32 am »
Excellent, thank you, this is what I was looking for. One last question before I start hacking at all these, because I hit another knot and I'm fairly sure I know the answer, but not yet how to apply it: Can I have a ranged stun weapon use anything but the default explosion hit sprite and noise? Seemed to just use the same sprites, but silent when I tried to do anything fancy with it.
Code: [Select]
items:
  - type: STR_TASER
    size: 0.1
    costBuy: 2450
    costSell: 1825
    weight: 6
    bigSprite: 5
    floorSprite: 5
    handSprite: 112
    bulletSprite: 5
    fireSound: 11
    compatibleAmmo:
      - STR_TASER_DART
    accuracySnap: 40
    accuracyAimed: 68
    tuSnap: 25
    tuAimed: 60
    battleType: 1
    listOrder: 2350
    invWidth: 1
    invHeight: 2
  - type: STR_TASER_DART
    size: 0.1
    costBuy: 120
    costSell: 90
    weight: 3
    bigSprite: 4
    floorSprite: 4
    hitSound: 19
    hitAnimation: 36
    power: 45
    damageType: 6
    clipSize: 3
    battleType: 2
    armor: 12
    listOrder: 2375

Offline XOps

  • Colonel
  • ****
  • Posts: 193
  • Guy who drowns first
    • View Profile
Re: [HELP] Developing my first mod, could use some guidance
« Reply #8 on: June 10, 2015, 05:42:58 am »
I would also recomend, Dioxine's Piratez Mod - The very first total conversion mod. Fun storyline, tons of weapons, numerous new enemies, and a massive difficulty spike.
https://openxcom.org/forum/index.php/topic,1898.0.html

Excellent, thank you, this is what I was looking for. One last question before I start hacking at all these, because I hit another knot and I'm fairly sure I know the answer, but not yet how to apply it: Can I have a ranged stun weapon use anything but the default explosion hit sprite and noise? Seemed to just use the same sprites, but silent when I tried to do anything fancy with it.
Code: [Select]
items:
  - type: STR_TASER
    size: 0.1
    costBuy: 2450
    costSell: 1825
    weight: 6
    bigSprite: 5
    floorSprite: 5
    handSprite: 112
    bulletSprite: 5
    fireSound: 11
    compatibleAmmo:
      - STR_TASER_DART
    accuracySnap: 40
    accuracyAimed: 68
    tuSnap: 25
    tuAimed: 60
    battleType: 1
    listOrder: 2350
    invWidth: 1
    invHeight: 2
  - type: STR_TASER_DART
    size: 0.1
    costBuy: 120
    costSell: 90
    weight: 3
    bigSprite: 4
    floorSprite: 4
    hitSound: 19
    hitAnimation: 36
    power: 45
    damageType: 6
    clipSize: 3
    battleType: 2
    armor: 12
    listOrder: 2375

It's the hitAnimation setting. It references a SMOKE.PCK frame.
https://www.ufopaedia.org/index.php?title=SMOKE.PCK

However, if it is an area of effect explosion then it references a frame in X1.PCK
https://www.ufopaedia.org/index.php?title=X1.PCK

I think this mod has a taser you could use as an example.
https://www.openxcom.com/mod/ryskeliinis-guns-n-gadgets-1st-pack

« Last Edit: June 10, 2015, 05:45:14 am by XOps »

Offline Dioxine

  • Commander
  • *****
  • Posts: 5460
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: [HELP] Developing my first mod, could use some guidance
« Reply #9 on: June 10, 2015, 05:46:07 am »
Yeah. You need to add
Code: [Select]
    blastRadius: 0

If you want a real "dart", without an explosion. However, if you want an explosion, you can only change the animation, the explosion sound is unmoddable afaik.

Offline hellrazor

  • Commander
  • *****
  • Posts: 2027
  • Deep Ruleset Digger & Bughunter
    • View Profile
    • Github Account
Re: [HELP] Developing my first mod, could use some guidance
« Reply #10 on: June 10, 2015, 02:41:09 pm »
Shameless self promote mode on :>

You can also check out my mod:
Modportal Link
Forum Link

Take a look into the Ruleset directory inside of the mod. If you wann know how to exchange Sprite, look at extraSprites.rul.

And be aware that your actual Filenames and the Filenames you call in the extraSprite Section match each other exactly. -> Case sensitivity

Also take a look here about general nameing advice and such.

String definition in extraStrings section should always be set into "".
so:
Code: [Select]
          STR_SNIPER_RIFLE: "Sniper Rifle"

For example.
« Last Edit: June 10, 2015, 03:06:50 pm by hellrazor »

Offline hellrazor

  • Commander
  • *****
  • Posts: 2027
  • Deep Ruleset Digger & Bughunter
    • View Profile
    • Github Account
Re: [HELP] Developing my first mod, could use some guidance
« Reply #11 on: June 10, 2015, 02:58:00 pm »
Internal Forum linking isn't working anymore...
Since links now all have a unique PHP Seesion Id for each user...


Works again...
« Last Edit: June 10, 2015, 03:02:38 pm by hellrazor »

Offline Harudoku

  • Squaddie
  • *
  • Posts: 5
    • View Profile
Re: [HELP] Developing my first mod, could use some guidance
« Reply #12 on: June 11, 2015, 06:27:54 pm »
Alright, thanks, all this has really given me some framework to work with, and I'm much further along than I was when I started. However, I've hit another snag that I can't easily figure out on my own and could use some more guidance.

To try to ensure I fully understood the nuances of the sprite engine, I tried porting over XOp's Knife, to get the basics of each of the different sprite and sound types. I troubleshooted a few different things and managed to get it close to working... but openXcom always seems to crash on hit, when I swing at any target.

Code: [Select]
items:
  - type: STR_KNIFE
    size: 0.02
    costBuy: 75
    costSell: 50
    weight: 1
    bigSprite: 1000
    floorSprite: 1000
    handSprite: 1000
    power: 21
    strengthApplied: true
    damageType: 7
    clipSize: -1
    tuMelee: 15
    accuracyMelee: 90
    battleType: 3
    invWidth: 2
    invHeight: 1
    meleeSound: 1000
    meleeHitSound: 999
    meleeAnimation: 1000
    skillApplied: true
    listOrder: 2001
extraSprites:
  - type: BIGOBS.PCK
    files:
      1000: resources/harumod/BIG/knife.gif
  - type: FLOOROB.PCK
    files:
      1000: resources/harumod/FLOOR/knife.gif
  - type: HANDOB.PCK
    files:
      1000: resources/harumod/HAND/knife/
  - type: HIT.PCK
    width: 128
    height: 40
    subX: 32
    subY: 40
    files:
      1000: Resources/harumod/HIT/knife.gif
extraSounds:
  - type: BATTLE.CAT
    files:
      1000: Resources/harumod/SOUND/knifeswing.ogg
      999: Resources/harumod/SOUND/knifehit.ogg
I've checked several times, and all of the different files point to the right spots, and as well, the sounds (likely) aren't the issues, as the crash happens (mind you, at the END of the animation) even if I revert the sounds to the default. Notably, though, I don't think it ever gets to start playing knifehit.ogg. Any insight? Am I missing something? Thanks!

Offline Dioxine

  • Commander
  • *****
  • Posts: 5460
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: [HELP] Developing my first mod, could use some guidance
« Reply #13 on: June 15, 2015, 11:38:10 pm »
Indexing is prone to go haywire as you surpass 1000 object limit OXCom imposes on mods. BTW 1000 objects means 0...999, NOT 0...1000!

Your knife HIT animation frames would be indexed 1000...1003, likely causing a clash with the vanilla melee hit which is indexed 0...3. Since HIT.PCK contains only a single object (4 frames), try changing your knife hit animation index from 1000 to 4 - if anything, to eliminate the possibility of wrong idexing. Do the same with all other assets declared - the first safe sound number is around 55 afaik, handob 128 or 136 I think, bigob and floorob similarly but quite likely lower. Don't ever go over 999, this is asking for trouble.

Also a minor suggestion, avoid anything that weighs less than 3, maybe 2, because an object weighing 1 can be thrown an insane distance away (3x further than a grenade). Unless this has been "fixed" somehow.

Offline Zeno

  • Squaddie
  • *
  • Posts: 6
    • View Profile
Re: [HELP] Developing my first mod, could use some guidance
« Reply #14 on: June 30, 2015, 02:03:57 am »
Also a minor suggestion, avoid anything that weighs less than 3, maybe 2, because an object weighing 1 can be thrown an insane distance away (3x further than a grenade). Unless this has been "fixed" somehow.

Looking at the UFOPaedia page about throwing distance, and seeing the formula for it, wouldn't it be possible to avoid this problem if you reduced the strength value of the soldier to keep the numbers sane?