OpenXcom Forum

Modding => Work In Progress => Topic started by: drages on June 15, 2017, 12:35:43 am

Title: An help about Extra Sprite handling!
Post by: drages on June 15, 2017, 12:35:43 am
Hey people

I want to add some sprites (weapon big/hand/floors for now) to the FMP mod, mostly i replace the old and vanilla ones.

But i got a problem. When i add extra sprites, hand sprites, sometimes it goes crazy. The weapon starts to use another random extra sprite, even changes only at some directions only. I change the ID numbers of the sprites and as a result, the buggy one gets fixed but another one corrupted. I just can't figure it out by myself.

Can you give me some hints about it? What could be the problem?

Thx
Title: Re: An help about Extra Sprite handling!
Post by: Wolfstarr on June 15, 2017, 01:02:13 am
Hi Drages, can you post some of your files and code so we can have a look?
Title: Re: An help about Extra Sprite handling!
Post by: Meridian on June 15, 2017, 10:23:26 am
Seeing your changes would help.

In general:
- you can't use extra sprite index > 999 in vanilla, it might collide with other mods (in OXCE+ you can)
- two mods cannot share any extra sprites... which means, if you are making a mod for FMP (i.e. not directly changing FMP), you need to define the new sprite AND also all its usage... even if you are using the same sprite index... the reason is that the game puts an offset to all extra sprites, e.g. bigob with index 345 will become 1345 in FMP and 2345 in your mod
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 15, 2017, 02:37:22 pm
Seeing your changes would help.

In general:
- you can't use extra sprite index > 999 in vanilla, it might collide with other mods (in OXCE+ you can)
- two mods cannot share any extra sprites... which means, if you are making a mod for FMP (i.e. not directly changing FMP), you need to define the new sprite AND also all its usage... even if you are using the same sprite index... the reason is that the game puts an offset to all extra sprites, e.g. bigob with index 345 will become 1345 in FMP and 2345 in your mod

I will upload my files. But I just edit the FMP, add my extra sprite to rul file as next number. For example if the final handop is 735, I add 736. So I don't make any complex thing or another mod.

So I add or edit this new sprite ID at items rul file. Everything looks OK. But when I start a quick battle, bigops work fine but some of the handops go crazy. Some works but others uses the handops I added with different id's. And their position is not correct too.

For example I added new laser sprites, they worked fine. Then I added new plasma sprites but some of them used the laser sprites with wrong positions. Even stranger, the plasma rifle uses some directions correctly from right handops I added, but other directions are from heavy laser with wrong position.

I tried to change sprite id's and some of them corrected but now others bugged.

I got a massy standart folder which I add my mods and working folders. Could this mess create this bugs?

Thx again.
Title: Re: An help about Extra Sprite handling!
Post by: ohartenstein23 on June 15, 2017, 03:03:09 pm
With sprites that have multiple parts (facings, animation frames, etc.), each part takes 1 index, so for example, handobs take 8 indices. If the last handob index is 735 and you start a new one at 736, you're replacing 7 of the facings for the handob referenced at 735. To not overlap, you should start at 735 + 8 = 743 for your index.  For bullet sprites, it's more complicated; each sprite is 35 frames, but the ruleset reference is (sprite index) / 35.  So for example bulletSprite: 12 is really referencing sprite frames 420 to 454, and bulletSprite: 13 starts at 455.

If you don't want to worry about colliding with FMP sprite indices, I'd suggest making a separate mod where you can start the index count where you want, as long as you respect the reserved space for vanilla sprites (128 I think for handobs, look up on https://ufopaedia.org for the others).

Edit: Also, I would advise against putting stuff into the /path/to/openxcom/standard folder, as that's supposed to be the folder which contains only the files for making the vanilla game work, and any edits there would either be overwritten by or mess up an updated nightly version.  This is another reason to use the user/mods folder, so all of your WIP can easily be contained and moved from version to version and installation to installation.
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 15, 2017, 04:30:30 pm
This is the problem I had. I gave id's one to another without knowing this. Thx. I think it will handle my problem. I will test it when I get my pc..
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 18, 2017, 03:05:46 am
Hey ppl..

I got an answer about explosion sprites.. I want to use different explosions but i could not do it.. can u give me a hand? thx
Title: Re: An help about Extra Sprite handling!
Post by: Meridian on June 18, 2017, 10:22:14 am
Just take it from a different mod for inspiration, by random search I found this:

Modportal Link Hardmode Expansion (https://www.openxcom.com/mod/hardmode-expansion) <- Modportal downloads not working.
Dropbox Link Latest Version (https://openxcom.org/forum/index.php/topic,4971.0.html)

Groundcombat changes:
   Colored Explosions (Grey: Smoke, Yellow: HE, Stun: Purple)

Code: [Select]
extraSprites:
  - type: X1.PCK
    width: 1024
    height: 64
    subX: 128
    subY: 64
    files:
      56: Resources/Items/Hitanimation/SpriteSheet_SmokeExplosion.png
      64: Resources/Items/Hitanimation/SpriteSheet_StunExplosion.png

Also: https://www.ufopaedia.org/index.php/X1.PCK
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 18, 2017, 12:36:53 pm
Just take it from a different mod for inspiration, by random search I found this:

Code: [Select]
extraSprites:
  - type: X1.PCK
    width: 1024
    height: 64
    subX: 128
    subY: 64
    files:
      56: Resources/Items/Hitanimation/SpriteSheet_SmokeExplosion.png
      64: Resources/Items/Hitanimation/SpriteSheet_StunExplosion.png

Also: https://www.ufopaedia.org/index.php/X1.PCK

You help me so much, man! I figured it out  but this image is very little and animate so fast.. i will look for more explosions to use. and i could use the default explosion to edit.
Title: Re: An help about Extra Sprite handling!
Post by: Meridian on June 18, 2017, 12:57:03 pm
and i could use the default explosion to edit.

attached
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 18, 2017, 08:25:33 pm
Meridian, can i go over 1000 with nighties at sprite ID?

I revised and added many handobs with the ammunitions so the numbers go high fast.. i would need to erase many ammunitions handobs if i limit 1000..
Title: Re: An help about Extra Sprite handling!
Post by: Meridian on June 18, 2017, 08:47:41 pm
Meridian, can i go over 1000 with nighties at sprite ID?
I revised and added many handobs with the ammunitions so the numbers go high fast.. i would need to erase many ammunitions handobs if i limit 1000..

You can, but it might have side effects... conflicts with other mods.

If you want it only for personal use, there is a trick... put your mod on the very bottom of the mod list... since the conflicts can be only with mods with ID higher than your mod, having highest ID "solves" the issue.

If you want to publish it, people won't ever read any of instructions (100% guaranteed), so that won't work. Other options are:
a/ use OXCE+
b/ ask SupSuper/Warboy if they would be willing to merge the changes Yankes and I made to support 1000+ sprites into vanilla... the changes are relatively small and work quite well so far (both PirateZ and Xcom Files use this)

And as modding, how can i make an item alien specific as "alien artifact"

Not sure what you mean...

If you don't want xcom to ever be able to use an item, just put a dummy research as dependency, e.g. STR_UNOBTAINABLE
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 18, 2017, 09:00:50 pm
You can, but it might have side effects... conflicts with other mods.

If you want it only for personal use, there is a trick... put your mod on the very bottom of the mod list... since the conflicts can be only with mods with ID higher than your mod, having highest ID "solves" the issue.

If you want to publish it, people won't ever read any of instructions (100% guaranteed), so that won't work. Other options are:
a/ use OXCE+
b/ ask SupSuper/Warboy if they would be willing to merge the changes Yankes and I made to support 1000+ sprites into vanilla... the changes are relatively small and work quite well so far (both PirateZ and Xcom Files use this)

Hmmm... so maybe i can create another mod with only ammo handobs.. and yeah i should ask them to add this..

Btw, as sprites, I am thinking about something.. can we make the weapons images changes (big-floor-hand) when it uses different ammo. For example we got a laser weapon with yellow lights at it's sprites and it shoots yellow beams. But when i use different ammo, a red ammo, then the weapon sprites will change according to it and it will fire red beams. It's like coding a sprite change to ammo. I think it would be cool and fitting.
Title: Re: An help about Extra Sprite handling!
Post by: Meridian on June 18, 2017, 09:13:00 pm
Hmmm... so maybe i can create another mod with only ammo handobs..

Yeah, but you'll have to be careful not forgetting anything... and also put your extra-mod below your main-mod... otherwise it may/will overwrite changes from your extra-mod.

and yeah i should ask them to add this..

Here are the changes:
change 1/ https://github.com/Yankes/OpenXcom/commit/5d62e26e1341f0f4f22969fe40f5d5312ab8150e
change 2/ https://github.com/MeridianOXC/OpenXcom/commit/258581e6378f53994e67364eda51e307bf4917be

Btw, as sprites, I am thinking about something.. can we make the weapons images changes (big-floor-hand) when it uses different ammo. For example we got a laser weapon with yellow lights at it's sprites and it shoots yellow beams. But when i use different ammo, a red ammo, then the weapon sprites will change according to it and it will fire red beams. It's like coding a sprite change to ammo. I think it would be cool and fitting.

I think Yankes has support for all (or at least most) of this in OXCE/OXCE+ using "scripts".
I don't know how it works, but I've seen different bigobs for weapons with different ammo...

Be prepared for a steep learning curve for scripts... people that can help you are: Yankes and Ohartenstein.
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 18, 2017, 09:22:55 pm
Yeah, but you'll have to be careful not forgetting anything... and also put your extra-mod below your main-mod... otherwise it may/will overwrite changes from your extra-mod.

Here are the changes:
change 1/ https://github.com/Yankes/OpenXcom/commit/5d62e26e1341f0f4f22969fe40f5d5312ab8150e
change 2/ https://github.com/MeridianOXC/OpenXcom/commit/258581e6378f53994e67364eda51e307bf4917be

I think Yankes has support for all (or at least most) of this in OXCE/OXCE+ using "scripts".
I don't know how it works, but I've seen different bigobs for weapons with different ammo...

Be prepared for a steep learning curve for scripts... people that can help you are: Yankes and Ohartenstein.

Scripts are another world to conquer. Before i go for that kind additions, i need to handle my mod. I am working on it for some days non-stop... coding-editing-creating new images-checking other arts.. It's nice to have people here to get answer fast when i stuck.

If i go for scripts, i need to create my own exe and then maybe blow the FMP mod itself. If i don't lose my interest, i probably will recreate FMP from the beginning anyway. I am working at my first millstones for now..
Title: Re: An help about Extra Sprite handling!
Post by: Meridian on June 18, 2017, 09:30:50 pm
If i go for scripts, i need to create my own exe

Actually, you don't need a new exe... scripts are written in the ruleset files (and interpreted by existing exe)... not having to change the exe was the whole point of introducing scripts.
But as I said, it's not easy at the beginning... you need to have at least a little bit of experience with scripting or programming... or have someone do it for you :) Ohartenstein might volunteer, if you ask nicely :P
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 18, 2017, 09:53:24 pm
Actually, you don't need a new exe... scripts are written in the ruleset files (and interpreted by existing exe)... not having to change the exe was the whole point of introducing scripts.
But as I said, it's not easy at the beginning... you need to have at least a little bit of experience with scripting or programming... or have someone do it for you :) Ohartenstein might volunteer, if you ask nicely :P

Hmm.. then it's better then i guessed.. I downloaded the big mods and most of them comes with their own all files including exe.
Title: Re: An help about Extra Sprite handling!
Post by: ohartenstein23 on June 18, 2017, 10:21:22 pm
I have a script already written that changes sprites based on loaded ammo, IvanDogovich asked for it a while back to change the Piratez RPG sprites when a baby nuke is loaded.
Title: Re: An help about Extra Sprite handling!
Post by: ivandogovich on June 18, 2017, 10:51:57 pm
Hmm.. then it's better then i guessed.. I downloaded the big mods and most of them comes with their own all files including exe.

Yeah. Those that do, (X-PirateZ, Xcom-Files, etc.) are usually doing so because they require the OXCE+ executable to work.  Its easier just to package that into the mod, than to deal with all of the confusion that would come from players trying to use a vanilla OXC executable.   

If you are going to do things like the bigob sprites, etc, you still probably will want to package a version of OXCE+ with your mod when you publish.  ("Final Mod Pack - Extended Plus"??)
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 18, 2017, 11:16:21 pm
Yeah. Those that do, (X-PirateZ, Xcom-Files, etc.) are usually doing so because they require the OXCE+ executable to work.  Its easier just to package that into the mod, than to deal with all of the confusion that would come from players trying to use a vanilla OXC executable.   

If you are going to do things like the bigob sprites, etc, you still probably will want to package a version of OXCE+ with your mod when you publish.  ("Final Mod Pack - Extended Plus"??)

Then i need to have all FMP files together as a stand-alone. I will probably do it after non-script addition i plan to do.  For now, i don't plan to create big different things then vanilla.. some cool additions can help like more weapon aircrafts, this bigob changing.. My biggest fear is breaking something at FMP when i go for XCE+, because i am just a noob to correct a huge mod at this time. I don't know even what can be happen at all.

For example i looked for personal shields but sadly there is no way to probably do it. When i hear openxcom, i thought it will be already ultra modable version with no hardcode or limitation at all but as i see it has many points which stops modders at some ways..

I have a script already written that changes sprites based on loaded ammo, IvanDogovich asked for it a while back to change the Piratez RPG sprites when a baby nuke is loaded.

It's very nice. I got some cool energy weapons which could use some bigob changing per ammo! Can you pinpoint me the script and how to use it please?
Title: Re: An help about Extra Sprite handling!
Post by: ohartenstein23 on June 19, 2017, 02:16:25 am
Sure, I'm traveling this weekend, so I'll find the files later this week. I also made a script for personal shields, so you're in luck!
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 19, 2017, 02:51:30 am
Sure, I'm traveling this weekend, so I'll find the files later this week. I also made a script for personal shields, so you're in luck!

S working shield! Perfect. I hope it works for aliens too.
Title: Re: An help about Extra Sprite handling!
Post by: ohartenstein23 on June 20, 2017, 06:57:14 pm
Okay, here are the scripts.  First up, switching weapon sprites based on the loaded ammunition.  I've attached the mod I made for Ivan using his sprites to make the RPG in Piratez change its sprite when a Baby Nuke is loaded - this provides a good example of how the script works.  In your mod, you'll only need to copy over the file weaponSpriteBasedOnAmmoScript.rul, and then follow the example in the other ruleset file for each weapon/ammo combination you want to set up.  In the weapon ruleset definition, you just need the extra tag ALLOW_AMMO_TO_RESPRITE: 1 to enable the new feature in the script, then use the tags in the ammo item (NEW_BIGOB_FOR_WEAPON: <some number>, NEW_FLOOROB_FOR_WEAPON: <some number>, NEW_HANDOB_FOR_WEAPON: <some number>, and CURRENT_MOD_OFFSET: current) to pass the new sprite numbers back to the weapon.  Unfortunately this means that sharing ammo between two weapons that have this feature activated will cause them both to use the same set of sprites - this is a limitation of how I implemented the sprite switching, focused on making the ruleset as simple as possible.

As for the personal energy shields, I put together a sample ruleset for SuperCaffeineDude a little while back, if you just want to add it to armor definitions, that is available in this thread (https://openxcom.org/forum/index.php/topic,5435.msg83644.html#msg83644), with a short explanation of how to use it.  To have it work for the aliens as well, all you need to do is add the proper tags to their armor definitions.

If you want a more complete set of scripts for various other defensive options including having energy shields as a held item, look for the file YankesScripts.rul in the Piratez download.  It contains the armor-based energy shields I sent to SuperCaffeineDude as well as a few other things I've written, some of which are implemented in Piratez.
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 20, 2017, 09:23:51 pm
Okay, here are the scripts.  First up, switching weapon sprites based on the loaded ammunition.  I've attached the mod I made for Ivan using his sprites to make the RPG in Piratez change its sprite when a Baby Nuke is loaded - this provides a good example of how the script works.  In your mod, you'll only need to copy over the file weaponSpriteBasedOnAmmoScript.rul, and then follow the example in the other ruleset file for each weapon/ammo combination you want to set up.  In the weapon ruleset definition, you just need the extra tag ALLOW_AMMO_TO_RESPRITE: 1 to enable the new feature in the script, then use the tags in the ammo item (NEW_BIGOB_FOR_WEAPON: <some number>, NEW_FLOOROB_FOR_WEAPON: <some number>, NEW_HANDOB_FOR_WEAPON: <some number>, and CURRENT_MOD_OFFSET: current) to pass the new sprite numbers back to the weapon.  Unfortunately this means that sharing ammo between two weapons that have this feature activated will cause them both to use the same set of sprites - this is a limitation of how I implemented the sprite switching, focused on making the ruleset as simple as possible.

As for the personal energy shields, I put together a sample ruleset for SuperCaffeineDude a little while back, if you just want to add it to armor definitions, that is available in this thread (https://openxcom.org/forum/index.php/topic,5435.msg83644.html#msg83644), with a short explanation of how to use it.  To have it work for the aliens as well, all you need to do is add the proper tags to their armor definitions.

If you want a more complete set of scripts for various other defensive options including having energy shields as a held item, look for the file YankesScripts.rul in the Piratez download.  It contains the armor-based energy shields I sent to SuperCaffeineDude as well as a few other things I've written, some of which are implemented in Piratez.

They look great! but the biggest question is, does it work with nighties or should i do something else?
Title: Re: An help about Extra Sprite handling!
Post by: Solarius Scorch on June 20, 2017, 11:10:10 pm
They look great! but the biggest question is, does it work with nighties or should i do something else?

It needs OXCE+, of course.
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 20, 2017, 11:15:33 pm
It needs OXCE+, of course.

If I use it, will be there any problem with FMP?
Title: Re: An help about Extra Sprite handling!
Post by: Solarius Scorch on June 20, 2017, 11:27:39 pm
If I use it, will be there any problem with FMP?

No, it should work just fine.
But you might want to get the extra strings for OXCE+ additional options.
Title: Re: An help about Extra Sprite handling!
Post by: Meridian on June 21, 2017, 12:17:42 am
If I use it, will be there any problem with FMP?

Commendations will not work, you will need to replace them with earlier version (FMP 1.9.6 or earlier).
Otherwise should work OK.
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 21, 2017, 12:58:45 am
Thx. I will try it.

I collected very nice weapon branches from New and old mods. I noticed some very old mods too at this research, like xeno operations. I fall in love with the ufo designs. It's strange thati don't see those at other mods for years.

So with xce there won't be over 1000 Id at sites problem too which I will have probably.
Title: Re: An help about Extra Sprite handling!
Post by: Meridian on June 21, 2017, 10:35:53 am
So with xce there won't be over 1000 Id at sites problem too which I will have probably.

There is a new attribute in metadata.yaml in OXCE/OXCE+, which you can use to extend the reserved space for your mod.

Code: [Select]
reservedSpace: 1 # this is the default, max. ID you can use = 999

You can increase it to any number you want... but don't go too high if you don't need it.

Code: [Select]
reservedSpace: 2 # up to 1999
reservedSpace: 3 # up to 2999
reservedSpace: 4 # up to 3999
and so on...
Title: Re: An help about Extra Sprite handling!
Post by: drages on June 25, 2017, 10:59:52 am
Is there any tutorial about creating an alien? How to handle sprites and code them?