OpenXcom Forum

OpenXcom => Suggestions => Topic started by: SeanEBlog on May 26, 2013, 01:06:07 pm

Title: Clip ammo checking. (Now the variable elerium thread)
Post by: SeanEBlog on May 26, 2013, 01:06:07 pm
One thing I feel that urks me is that perfectly good bullets are discarded after a battle because they are no longer part of a full clip. Could we add in a system that adds up all remaining rounds of ammo returns an appropriate number of clips back after battle? Or takes the ammo from partially depleted clips and adds them to a third item type group "stray rounds", which can be manufactured back into clips at a later time.

I think the such a system could be used to add some variability to how game handles elerium as well. Instead of each elerium unit being multiplied by 50 at the end of each round, each elerium unit could be a "clip" type item with an amount of actual elerium inside, a amount which is influenced by appropriate factors, such as ship type and time spent flying around, and a random plus or minus factor.

Also, this system would also allow aliens such as floaters and cyberdisks to carry (or spawn on death) units of elerium, as it makes sense that their bodies contain small amounts of elerium.
Title: Re: Clip ammo checking.
Post by: Volutar on May 26, 2013, 01:40:42 pm
Ammo from clips is already counted and re-packed, with dropping last unfinished clips.
Title: Re: Clip ammo checking.
Post by: Morbo on May 27, 2013, 07:24:42 am
Ammo from clips is already counted and re-packed, with dropping last unfinished clips.

Can you clarify on that? That wasn't very clear at all, especially the last part. So do half used clips still inside guns "disappear" after the mission is over like original vanilla xcom? Or do they get "topped" up back to a full clip and added back to inventory?
Title: Re: Clip ammo checking.
Post by: Warboy1982 on May 27, 2013, 07:45:07 am
Can you clarify on that? That wasn't very clear at all, especially the last part. So do half used clips still inside guns "disappear" after the mission is over like original vanilla xcom? Or do they get "topped" up back to a full clip and added back to inventory?


to clarify:

individual rounds are totalled
that number is divided by the clip size
you get that number returned to your stores.
the remainder is lost, so at most, you will lose less than a single clip.
Title: Re: Clip ammo checking.
Post by: SeanEBlog on May 27, 2013, 11:36:12 pm
Yeah, turns out what I wanted was already in the game (https://www.ufopaedia.org/index.php?title=Differences_to_X-COM_%28OpenXcom%29#Battlescape). I was still playing with the habit of using as few soldiers as possible to preserve ammo.
Title: Re: Clip ammo checking. (whoops)
Post by: redv on May 30, 2013, 10:37:33 am
individual rounds are totalled
that number is divided by the clip size
you get that number returned to your stores.
the remainder is lost, so at most, you will lose less than a single clip.
Warboy, this commit was not accepted. https://github.com/SupSuper/OpenXcom/pull/351 (https://github.com/SupSuper/OpenXcom/pull/351)
Now uses other algorithm:
1. rounds counting for each tile separately;
2. for each tile, for each type of rounds, calculated  total_clips = total_rounds / clip_size + 0.5;
3. for each tile, total_rounds total_clips added to base's store.
https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/DebriefingState.cpp#L1028 (https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/DebriefingState.cpp#L1028)

For example:
I use Heavy Canon and AC-HE rounds for demolition walls on the second floor.
I need 2-3 shots per mission.
Possible buy only one AC-HE clip and use this clip to end of the game)
Title: Re: Clip ammo checking. (whoops)
Post by: Volutar on May 30, 2013, 12:46:30 pm
Weird. Why TILES are mentioned for clips recover? How TILES are related to that?
I thought only clip type and number of bullets in each are matter.
Title: Re: Clip ammo checking. (whoops)
Post by: AMX on May 30, 2013, 10:24:56 pm
Yes, this seems kind of bizarre.
Why per tile?
And why should half-full clips count as full?
Title: Re: Clip ammo checking. (whoops)
Post by: redv on May 30, 2013, 10:54:06 pm
This is normal.
Anyway after battle need go around all tiles and get all items from the floor.
https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/DebriefingState.cpp#L743 (https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/DebriefingState.cpp#L743)

The problem in the following calculation.
Title: Re: Clip ammo checking. (whoops)
Post by: moriarty on May 30, 2013, 11:16:29 pm
redv, but in this way, ammo rounds are basically created from thin air, right? as long as you don't use more than half a clip, it magically refills at the end of the battle?

this seems very wrong to me. it would be way better to count all remaining rounds, use those to fill the available clips, and discard any non-full clips. including the one that's possibly only missing one round, but in terms of believability, that's still better than magically regenerating bullets.
Title: Re: Clip ammo checking. (whoops)
Post by: Yankes on May 31, 2013, 01:06:07 am
At least could call rand() to determine if clip is salvaged or throw away.
Title: Re: Clip ammo checking. (whoops)
Post by: 54x on May 31, 2013, 09:46:11 am
redv, but in this way, ammo rounds are basically created from thin air, right? as long as you don't use more than half a clip, it magically refills at the end of the battle?

this seems very wrong to me. it would be way better to count all remaining rounds, use those to fill the available clips, and discard any non-full clips. including the one that's possibly only missing one round, but in terms of believability, that's still better than magically regenerating bullets.

At least could call rand() to determine if clip is salvaged or throw away.

Yep, I'd say do a weighted RAND based on the remaining rounds in the clip to determine whether the last clip is discarded. Over the course of your game this should roughly result in using clips at roughly the same rate as you shoot through a clip's worth of rounds.
Title: Re: Clip ammo checking. (whoops)
Post by: moriarty on May 31, 2013, 11:24:36 am
weighted RAND for last clip is fine, but first and foremost we shouldn't check per tile. that's a really weird way of doing it.

imagine 10 soldiers with standard rifles, each with one clip containing 20 bullets. each soldier fires 5 shots. at the end of the battle, in the current system, you lose no bullets at all, since each clip has more than half of its bullets remaining. you get 50 bullets for free!

instead, the system should check for the total amount of bullets (10*15=150) and refill the available clips, resulting in 7 full clips and 2 empty ones, which are discarded, and one clip with 10 bullets, so you could argue that this one should be either discarded or turned into a full clip with a 50% chance.
Title: Re: Clip ammo checking. (whoops)
Post by: redv on May 31, 2013, 11:55:44 am
Added a commit for the calculation of clips, left after battle:
https://github.com/SupSuper/OpenXcom/pull/496 (https://github.com/SupSuper/OpenXcom/pull/496)
Title: Re: Clip ammo checking. (whoops)
Post by: moriarty on May 31, 2013, 12:49:31 pm
the way you did it is probably the cleanest way. (dropping the partially loaded remaining clip, that is)



as for the other part of the thread's topic: changing Elerium to be an ammo-like item would totally make sense to me. it is treated like fuel for in-game purposes like refueling advanced XCom craft, but comes only in chunks of 50 off the battlefield. when manufacturing, you have stuff that uses 1 unit of elerium per unit manufactured.

a change that turns battlescape Elerium into a "container" which holds a maximum of 50 units would also add variety to UFO crash sites: the explosion of a crashed UFO's power source should be scaled according to how much Elerium was left in it when it blew. If you hunted a UFO across half the globe before shooting it down, you might end up with a far less damaged crashsite.

of course, this could create balancing issues, because you will receive less elerium per power source - but I don't know if that's a bad thing. Elerium shortage could add some late-game fun, when you suddenly have to resort to more conventional technology.

I'd say this is worth a try. Is there anybody who could program the necessary changes as an optional game mechanic?
Title: Re: Clip ammo checking. (whoops)
Post by: SeanEBlog on May 31, 2013, 12:56:43 pm
the way you did it is probably the cleanest way. (dropping the partially loaded remaining clip, that is)



as for the other part of the thread's topic: changing Elerium to be an ammo-like item would totally make sense to me. it is treated like fuel for in-game purposes like refueling advanced XCom craft, but comes only in chunks of 50 off the battlefield. when manufacturing, you have stuff that uses 1 unit of elerium per unit manufactured.

a change that turns battlescape Elerium into a "container" which holds a maximum of 50 units would also add variety to UFO crash sites: the explosion of a crashed UFO's power source should be scaled according to how much Elerium was left in it when it blew. If you hunted a UFO across half the globe before shooting it down, you might end up with a far less damaged crashsite.

of course, this could create balancing issues, because you will receive less elerium per power source - but I don't know if that's a bad thing. Elerium shortage could add some late-game fun, when you suddenly have to resort to more conventional technology.

I'd say this is worth a try. Is there anybody who could program the necessary changes as an optional game mechanic?

Don't forget that I also suggested that certain aliens would also spawn elerium containers on death.
(https://i372.photobucket.com/albums/oo170/SeanEBlog/ammocheckingvert.png)
Title: Re: Clip ammo checking. (whoops)
Post by: moriarty on May 31, 2013, 01:02:36 pm
right, absolutely, this would make sense. Cyberdiscs (those that don't explode, anyway), Sectopods, Floaters... ooh, btw, shouldn't floaters have a chance of exploding when killed? I just started a new thread about Elerium-Explosions on the battlefield https://openxcom.org/forum/index.php/topic,1284.0.html (https://openxcom.org/forum/index.php/topic,1284.0.html)... perhaps this should be included :)
Title: Re: Clip ammo checking. (whoops)
Post by: redv on May 31, 2013, 01:16:04 pm
I use Elerium 115 for recharging aircraft's Plasma Beam:
Code: [Select]
  - type: STR_PLASMA_BEAM_UC
    sprite: 5
    sound: 9
    damage: 140
    range: 52
    accuracy: 50
    reloadCautious: 12
    reloadStandard: 12
    reloadAggressive: 12
    ammoMax: 50
    rearmRate: 5
    launcher: STR_PLASMA_BEAM
    clip: STR_ELERIUM_115
    projectileType: 5

It is interesting idea about random quantity of Elerium in PS.
Title: Re: Clip ammo checking. (whoops)
Post by: moriarty on May 31, 2013, 01:33:12 pm
It is interesting idea about random quantity of Elerium in PS.

I wouldn't go for random (although that's still better than a fixed 50 units), but would make it fuel-like: the longer a UFO flies around, the less elerium remains. this must be carefully timed, though, unless you find a really good explanation for landed UFOs without elerium... that still take off and fly away when the battle is aborted :D
Title: Re: Clip ammo checking. (whoops)
Post by: winterheart on May 31, 2013, 04:08:08 pm
I wouldn't go for random (although that's still better than a fixed 50 units), but would make it fuel-like: the longer a UFO flies around, the less elerium remains. this must be carefully timed, though, unless you find a really good explanation for landed UFOs without elerium... that still take off and fly away when the battle is aborted :D

We can even calculate this based on Avenger/Lightning Elerium consuming. Lightning have 30 units Elerium, that sufficient for 15,500 miles or 1 unit of E-115 for each 516 miles. If so, then standard fully loaded (50 unit) UFO Power Source allow up to 25,800 miles without refueling.
Title: Re: Clip ammo checking. (whoops)
Post by: redv on May 31, 2013, 05:54:59 pm
Lightning have 30 units Elerium, that sufficient for 15,500 miles or 1 unit of E-115 for each 516 miles.

But UFOs fly to Earth from Mars ;)
Title: Re: Clip ammo checking. (whoops)
Post by: moriarty on May 31, 2013, 06:15:09 pm
I'd say they will be more fuel-efficient than a hastily-reverse-engineered human prototype fighter.

Flight from earth to mars is probably less of a problem than atmospheric flight in a planet's gravity field :)