Author Topic: Weapons that use their own clipSize: for ammo vanish when empty?  (Read 2056 times)

Offline The Martian

  • Colonel
  • ****
  • Posts: 264
  • "It implores you to listen to its arguments..."
    • View Profile
If the clipSize: of a weapon like the Laser Rifle is changed from -1 (Infinite) to a positive value it vanishes when the clip (In this case the weapon itself) is depleted.

Code: [Select]
Example code:
  - type: STR_LASER_RIFLE_ALT
    size: 0.2
    costSell: 36900
    weight: 8
    bigSprite: 0
    floorSprite: 0
    handSprite: 8
    bulletSprite: 6
    fireSound: 11
    hitSound: 19
    hitAnimation: 36
    power: 60
    damageType: 4
    accuracyAuto: 46
    accuracySnap: 65
    accuracyAimed: 100
    tuAuto: 34
    tuSnap: 25
    tuAimed: 50
    clipSize: 5 # Changed from -1
    battleType: 1
    twoHanded: true
    invWidth: 1
    invHeight: 3

(Question): Is there a way to override this and make the weapon just display the standard "Out of ammo" message instead of vanishing?
(Answer): "That's currently not possible."
« Last Edit: January 17, 2018, 01:46:17 pm by The Martian »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 5867
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #1 on: January 16, 2018, 11:24:13 am »
(Question) Is there a way to override this and make the weapon just display the standard "Out of ammo" message instead of vanishing?

Yes, you can define the ammo item (like for a normal rifle) and then it will not vanish.

PS: the vanishing for a weapon which is its own ammo is a feature, not a bug... it is meant to be used with consumable weapons (e.g. throwing knives)

Offline The Martian

  • Colonel
  • ****
  • Posts: 264
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #2 on: January 16, 2018, 11:49:50 am »
I tried to attach a placeholder ammo item to the Laser Rifle via compatibleAmmo: however the weapon starts with a loaded clip size of 0.

Is there a different command for attaching the ammo item to weapon?

The weapon already seems to have all of the damage output code that is normally found on a clip, is there something additional that needs to be incorporated from ammo clip item code or am I going about this the wrong way?


Code: [Select]
  - type: STR_LASER_RIFLE_ALT
    size: 0.2
    costSell: 36900
    weight: 8
    bigSprite: 0
    floorSprite: 0
    handSprite: 8
    bulletSprite: 6
    fireSound: 11
    hitSound: 19
    hitAnimation: 36
    power: 60
    damageType: 4
    accuracyAuto: 46
    accuracySnap: 65
    accuracyAimed: 100
    tuAuto: 34
    tuSnap: 25
    tuAimed: 50
    clipSize: 5
    compatibleAmmo:
      - FAKE_AMMO
    battleType: 1
    twoHanded: true
    invWidth: 1
    invHeight: 3


PS: the vanishing for a weapon which is its own ammo is a feature, not a bug... it is meant to be used with consumable weapons (e.g. throwing knives)
Very cool! 

Is there a way to extend this feature's operation to empty medical kit items or is it limited to standard weapons?

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 5867
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #3 on: January 16, 2018, 01:49:45 pm »
is there something additional that needs to be incorporated from ammo clip item code or am I going about this the wrong way?

Not fake ammo... real ammo (with clip size, damage, etc.).

Very cool!
Is there a way to extend this feature's operation to empty medical kit items or is it limited to standard weapons?

In OXCE+ it works also for medikits... in vanilla only for firearms and melee I think.

Offline The Martian

  • Colonel
  • ****
  • Posts: 264
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #4 on: January 17, 2018, 07:11:28 am »
Yes, you can define the ammo item (like for a normal rifle) and then it will not vanish.

I tried adapting the Rifle code by giving it a setting of clipSize: 6.

This made it display "AMMO: ROUNDS LEFT=6" on the inventory screen and 0 rounds left on the combat screen.

The message "No Ammunition Loaded!" displays when firing the rifle is attempted.


Code: [Select]
items:
  - type: STR_RIFLE_ALT
    size: 0.2
    costBuy: 3000
    costSell: 2250
    weight: 8
    bigSprite: 1
    floorSprite: 1
    handSprite: 0
    bulletSprite: 2
    fireSound: 4
    compatibleAmmo:
      - STR_RIFLE_CLIP_ALT
    accuracyAuto: 35
    accuracySnap: 60
    accuracyAimed: 110
    tuAuto: 35
    tuSnap: 25
    tuAimed: 80
    battleType: 1
    clipSize: 6
    twoHanded: true
    invWidth: 1
    invHeight: 3
#
  - type: STR_RIFLE_CLIP_ALT
    size: 0.1
    costBuy: 200
    costSell: 150
    weight: 3
    bigSprite: 2
    floorSprite: 2
    hitSound: 22
    hitAnimation: 26
    power: 30
    damageType: 1
    clipSize: 20
    battleType: 2

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 5867
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #5 on: January 17, 2018, 10:25:20 am »
Rifle item needs clipSize: 0 and rifle clip item clipSize: 6.

Just look at the normal rifle...

Offline The Martian

  • Colonel
  • ****
  • Posts: 264
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #6 on: January 17, 2018, 10:36:27 am »
I justed altered the Rifle item's clipSize: to 0 and the clip item's clipSize: to 6.

The rifle is no longer displaying the number of rounds left on the inventory screen and the "No Ammunition Loaded!" message is still being displayed when the rifle is fired.

STR_RIFLE_ALT should be a copy/paste of STR_RIFLE with only the above changes.


Code: [Select]
  - type: STR_RIFLE_ALT
    size: 0.2
    costBuy: 3000
    costSell: 2250
    weight: 8
    bigSprite: 1
    floorSprite: 1
    handSprite: 0
    bulletSprite: 2
    fireSound: 4
    compatibleAmmo:
      - STR_RIFLE_CLIP_ALT
    accuracyAuto: 35
    accuracySnap: 60
    accuracyAimed: 110
    tuAuto: 35
    tuSnap: 25
    tuAimed: 80
    battleType: 1
    clipSize: 0
    twoHanded: true
    invWidth: 1
    invHeight: 3
#
  - type: STR_RIFLE_CLIP_ALT
    size: 0.1
    costBuy: 200
    costSell: 150
    weight: 3
    bigSprite: 2
    floorSprite: 2
    hitSound: 22
    hitAnimation: 26
    power: 30
    damageType: 1
    clipSize: 6
    battleType: 2

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 5867
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #7 on: January 17, 2018, 10:52:01 am »
I took your ruleset and it works for me... see attached.

Just a very stupid question... did you load the weapon?

Offline The Martian

  • Colonel
  • ****
  • Posts: 264
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #8 on: January 17, 2018, 11:16:44 am »
If I load the clip into the rifle it functions exactly like a standard X-Com Rifle.

I'm trying to create a weapon like the default X-Com laser rifle except with limited charges and no ability to reload it while in mission.

Preferably the rifle item should auto-reload each mission without having an ammo item.

Alternatively it would also work if the ammo item is required but can't be reloaded when spent and is not destroyed when used up during the mission.

Functionally what I'm trying for is a clipSize: -1 weapon with no ammo clip item but with limited shots instead of infinite.
« Last Edit: January 17, 2018, 11:33:30 am by The Martian »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 5867
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #9 on: January 17, 2018, 11:55:03 am »
That's currently not possible.

Offline The Martian

  • Colonel
  • ****
  • Posts: 264
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #10 on: January 17, 2018, 12:16:55 pm »
In that case I'll work around it. The ability to create weapons that are consumed on use is still pretty interesting by itself. ^_^

Thank you for the help.

Offline yrizoud

  • Commander
  • *****
  • Posts: 1024
    • View Profile
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #11 on: January 20, 2018, 03:27:15 am »
You can also make items that are never recovered after battle. If you have some in the transport, you can enter battle, lift off, and they're all gone even if you never used them... So it mostly works for alien technology,  you can have their ammo (clips) disappear as the energy somehow leaves the weapon after battle, and XCOM has to invent and manufacture their own power sources.
Or it may be a god choice for civilian items that you can actually find in battlefield, may use during firefight, but can't really bring home after battle.

Offline The Martian

  • Colonel
  • ****
  • Posts: 264
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #12 on: January 30, 2018, 05:46:34 am »
That is very useful, thank you for sharing the information.

Offline RSSwizard

  • Colonel
  • ****
  • Posts: 439
    • View Profile
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #13 on: January 30, 2018, 09:59:22 pm »
That's currently not possible.
"Its simple, we kill the batman" - Joker

I got the answer right here for your next version.
Code: [Select]
isConsumable: false
For a weapon (battletype) that has this property make it check for clipsize, if there is a clipsize then the item is not destroyed when its ammo count reaches 0 (it just sits there in the inventory unable to be reloaded). Im not sure if this would play around well with weapons that have multiple ammo types since I think we're all a little fuzzy on how that works.

Ideal for all of those battery-powered or juiced up weapons that really have to be reloaded back at the base workshop, but which are too powerful or useful to have infinite shots. Would have been great for emulating limited vanilla laser guns without giving them clips. Also useful for "3/day" or "1/encounter" style rpg powers.

(eg, laser pistols and laser rifles with 30 shots, heavy lasers with 20 shots, if you run out they're just unusable for the rest of the mission, you get the firepower but its balanced because you'd have to carry additional weapons or multiple pistols if you want to keep spamming it - this be like the Halo Combat Evolved plasma guns)
(I kinda use this tactic in Piratez with flintlock pistols, like real pirates would do, I just carry like 4 pistols rather than bother with the extensive reloading cost for em, also called a "new york reload" after NYPD cops who would carry a spare revolver rather than reload one)


Another way around this which might be more flexible for other uses is adding something like:
Code: [Select]
consumedItem: STR_SOME_ITEM
destroyItem: STR_SOME_ITEM
When the item is consumed it is transformed into the consumedItem... an empty first aid kit, a discharged laser pistol, a weapon which becomes damaged but repairable after a certain number of shots. Then you can have the item refurbished at the workshop to get a working version again.
(such a thing could cause crashes or hiccups if the new item is a different inventory size, such as a 1x2 pistol becoming a 2x3 pile of parts, guess the modder would simply need to be warned against that if its a thing)

If an item transformation upon its destruction is available then destroyItem would also be useful for other reasons. I guess if the other property wasnt on it this would would still produce the same result upon being consumed... but there is a difference between an item being used up, and being left on the ground to be shot/blown up.
(would be especially useful for corpses, for example allowing zombies to be killed without spawning a chrissy, but if the body is destroyed thats when the chrissy pops out. Or units which still leave something behind if overkilled so that you can still get something from the corpse, but not as much. And other items that have to be protected, and if they're destroyed you end up with an item that gets recovered with a sharp penalty associated with it... likewise Reactor Cores and such that are stable as long as you dont hurt them, but if you kill them they become nuclear timebombs)

Offline The Martian

  • Colonel
  • ****
  • Posts: 264
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Weapons that use their own clipSize: for ammo vanish when empty?
« Reply #14 on: January 30, 2018, 11:23:55 pm »
That would be really useful!

I can see the potential for hundreds of different items being created from that code addition.