Home » MODDING HQ 1.13 » v1.13 Coding Talk » [IDEA] New Magazine System
Re: [IDEA] New Magazine System[message #335511] Fri, 05 September 2014 21:50 Go to previous messageGo to next message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
Smeagol,

I do remember you having the conversion for caliber in your mod, but I was thinking of ways to reduce the number of conversions and copied items...

You are my hero btw, your mod originally got me into this game.

Put me in coach! If someone wants to work with me on that (and this) let me know! I want to make this stuff happen.

We can move the attachment thing to another thread so we can stay on topic here...

Sevenfm,

That is awesome! How do we get that implemented for more mods. I am thinking getting down into the nitty gritty of attaching attachment rails to weapons before certain attachments can be used (because I am demanding). If you need any help (albeit basic) let me know!

Also, I am an ignorant American so I can't read or speak Russian Smile

[Updated on: Fri, 05 September 2014 22:01] by Moderator

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #335512] Fri, 05 September 2014 22:06 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
ormtnman
I think you can make a request/idea thread similar to this and try to convince someone to make it happen =)
Currently all we have is some raw experimental implementation and some ideas.
I agree that custom weapon pics should be implemented some day =)

p.s. If you make a new thread for this feature I will post there a video with custom pics for my favourite jagged gun - G53A3.

Report message to a moderator

Lieutenant

Re: [IDEA] New Magazine System[message #335514] Fri, 05 September 2014 22:21 Go to previous messageGo to next message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
No sooner said than done

http://www.ja-galaxy-forum.com/ubbthreads.php/topics/335513#Post335513

Back to the NMS topic, is anyone currently doing this, have something done, need help, etc? I can't state enough how much I want to get this done. I will even force myself to learn coding for this.

I am a sucker for the micromanagement things like this.

[Updated on: Fri, 05 September 2014 22:25] by Moderator

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #335515] Fri, 05 September 2014 22:33 Go to previous messageGo to next message
DepressivesBrot is currently offline DepressivesBrot

 
Messages:3658
Registered:July 2009
It seems you found yourself a good incentive to learn coding then Smile
We've never come further than discussing the why/why not and some general concepts.

Apropos concepts:
@Flugente
If you don't want to do it, would you at least be willing to write down the concepts for implementation that you indicated you had?

Report message to a moderator

Captain

Re: [IDEA] New Magazine System[message #335516] Fri, 05 September 2014 22:38 Go to previous messageGo to next message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
This is kind of a huge project (if you add together the xml work, coding, pictures, etc.) is anyone willing to help? I do have a life... and I won't if I am the only one working on this.

EDIT: Not to mention the ui work, which I have no (absolutely none) experience doing. I wouldn't even know where to start there.

[Updated on: Fri, 05 September 2014 22:42] by Moderator

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #335780] Sun, 14 September 2014 20:55 Go to previous messageGo to next message
Flugente

 
Messages:3509
Registered:April 2009
Location: Germany
DepressivesBrot
Apropos concepts:
@Flugente
If you don't want to do it, would you at least be willing to write down the concepts for implementation that you indicated you had?
Well, why not... might remove a bit of confusion. Here it is:

New Magazine System Implementation concept

This concept outlines how to implement a new system that allows to load magazines with single bullets. This also allows mixing ammotypes of the same caliber (without mixing it becomes easier, but even more pointless, so I won't outline that here).
The additional concept to mix different calibers in magazines, and have guns be able to use different calibers without relying on hacky item transformation is outlined in blue.
Barely useful, annoying bullshit that complicates everything but will be asked for by people that want stuff like this is marked in red.
After a while you will have completely lost your shit and debate why you ever wanted to code this. For this purpose, anal 'realistic' 'features' that mostly serve to let the player feel how much you hate them are marked in green.

Part 1: Basic Idea

The idea is to have ammo separated from magazines.
A magazine can be stacked with ammo.
A magazine can then be inserted into a gun, where we can see it as an attachment.
There are guns that do not accept a magazine, rather the ammo is transferred to them and then stored in the gun itself (speedloaders, shotguns...) .
The gun then fires the ammo from the magazine, in the order that the ammo was inserted into the magazine.
A gun fires ammo of one caliber.
A gun fires ammo of different calibers.
A magazine has a maximum number of ammo it can hold.
Different magazines can have different maximum numbers of ammo.
Guns can use different magazines.
A magazine holds ammo of one caliber, but the ammo types (AP, HP, Glaser, Tracer...) can be different for each ammo.
A magazine can hold ammo of different calibers.
Depending on gun, magazine, tactical/strategic screen, combat/no combat, EDB interface and the cycle of the moon, removing a magazine can leave one bullet in the gun chamber,which the gun can fire..

Part 2: Magazine and ammo setup

In the current state of JA2 1.13, bullets are always in a magazine (crates and boxes are just magazines that have no fitting gun). Whenever we put a mag in a gun, we then tell the gun 'you have x bullets now'. The mazine object vanishes, but we tell the gun what mag that was. From this it knows the ammotype. When removing the mag, a new object if the same itemnumber as the old mag is created, and we insert the correct number of ammo.

We can no longer do that:
  • While the mag is 'in' the gun, we still need to differentiate between ammo in the gun itself and ammo in the mag that is in the gun.
  • Magazine modifiers (+/- reliability etc.) require knowing the status of the magazine object.
  • Magazines can have attachments, because of course they do.
We create a new structure (pseudocode):
typedef struct
{
UINT8 usAmmoType;
UINT8 usCaliber;
} MAG_BULLET;
This structure is all that is required to know of a bullet. Having each bullet as an object is a hideous idea. The memory use alone is haunting. If anybody ever advises this, shoot them in the face.

Because of bullets in the gun chamber, both guns and magazines can hold ammo. Strictly speaking, a gun is now simply a magazine that also happens to be able to fire them.
Thus we need to store ammo on objects. Thus OBJECTTYPE needs a new member:

std::vector<MAG_BULLET> internalmagazine;

Now all objects could store ammo theoretically. We can't use a fixed-size array, as this would blow up all object sizes.
As the size of internalmagazine can vary, OBJECTTYPE saving and loading gets more complicated, so expand these routines accordingly. Reserving space will be especially trickier.
Note that changes to OBJECTTYPE require altering sector loading routines. This also requires different approaches according to map version.
It is very easy to render maps unplayable this way, so be careful in repairing that. Rendering maps permanently unplayable is unacceptable, unless getting your head smashed in with an axe by a guy from Bremen counts as 'acceptable' to you big grin
Upon loading ammo into a mag, create a new MAG_BULLET from the ammo and insert it into internalmagazine.
Upon inserting ammo, check wether there is still room in the magazine, return error if not.
Upon inserting ammo, check wether the caliber fits.

Magazine items need new data:
UINT16 usCapacity; // how many bullets this magazine can store. Will be 1 for most guns.
BOOLEAN fTransparent; // some mags are see-through
std::vector<UINT8> possiblecalibers; // calibers this magazine takes
BOOLEAN fLifo; // FiFo/LiFo extracting of bullets when unloading/chambering
BOOLEAN speedloader; // if true, magazine contents are transferred to the guns internalmagazine upon loading, the magazine object is not attached

Modders will come up with guns that take one magazine, but can have other magazines attached to it. You then need to internally store which magazine is decoration and which one you use to take ammo from.
Modders will come up with guns that feed from multiple magazines at the same time, like some futuristic shotgun that everybody agrees is crap but looks cool. You then need to remove ammo from the mags in an alternating manner, storing which mag you took ammo from last.
Modders will then come up with the urgent need to have a switch on the gun that toggles which mag ammo is currently taken from. This requires altering the above variable and to create a fuckload of UI for that. Nobody will ever use this, but this will be totally necessary for someone's masturbation routine game balance.

Calibers need new data:
UINT16 usAPLoadCost; // the cost of loading a single bullet of this caliber into a magazine
UINT16 usWeight; // the weight of a single bullet in grams. Data in Items.xml is in 100g-units, so adjust internal calculations accordingly
BOOLEAN fDirectLoading; // if set to true, a gun's internalmagazine can also be loaded with bullets by directly loading them into its magazine
UINT16 usPower; // power of the caliber, will be the base of damage calculations
UINT16 usRange; // base of range calculations
UINT16 usAccuraccy; // base of accuracy calculations

Guns need new data:
std::vector<UINT16> acceptedmagazines; // which magazines fit into this gun?
UINT16 usPower; // Combined with the caliber's usPower, calculate bullet damage from this
UINT16 usRange; // Combined with the caliber's usRange, calculate bullet range from this
UINT16 usAccuraccy; // Combined with the caliber's usAccuraccy, calculate bullet accuracy from this

You thought the mag adapters were gone? Silly you big grin Modders will demand more types of adapters:
  • Mag adapters on the gun that allow access to other magazines - kinda like the current ones.
  • Mag adapters on magazines, that then allow fitting those into guns that previously did not accept them. Have fun solving that, jackass.
  • They will demand the ability to attach rubber band, and then a second magazine to that, for quicker reloads. I'm sure you can figure out this one on your own.

Part 3: Loading and firing a gun

Magazines are attachments to guns now. This means there has to be set up in the first place, via Attachments.xml, AttachmentPoints and whatnot. This also means that Old Attachment System people effectively lose one attachment slot. They will complain about that, at which point you say F*** you, this requires New Attachment System because I say so and force this system to require NAS.
Once a mag is attached to the gun, load the first bullet (according to fLifo either from start or end of magazine) into the guns' internal magazine.
Don't do that, instead have the player cycle the gun by firing (similar to shotguns) first. Pointless, so important, apparently.
Whenever you fire the gun, fire the first bullet from its internalmagazine. If it's empty, and the magazine still has bullets, load from there. Some guns, like shotguns, require a manual cycling.
When firing a bullet, check its caliber and determine damage, range and accuracy. At this point, nerds would like to add all kinds of NCTH-modifiers to this, but as the only effect to cth calculations is input data, you can easily deflect that.
Caliber calculation require to come up with the new formulas in the first place, and loads of new data on guns and calibers. Once that is done, one might be able to differentiate caliber types without editing a ton of guns though, so this might be beneficial.

Part 4: Loading a magazine

Now for the ugly parts. First, we require loose bullets. Create new items - 'a handful of bullets' - for each ammotype and caliber. These serve the same function as crates. But unlike crates, we require them to be very small, so we can store them in our inventory. This is required if you want to load different ammotypes into a mag.
When clicking with a handful on a mag, check wether the ammo would fit the mag. If so, fill up the mag with it (realtime)/ add a single bullet (turnbased), AP cost taken from Caliber data.
Loading different ammotypes works in two ways: Either click on the mag with handfuls and switch them while doing so. You will realize this sucks on your second mag, which puts you well ahead of all the tools requesting this nonsense.
What needs to be done is a interface in the magazine's description box. This interface should show you how many bullets, and of what ammotype (and caliber) are already loaded, and in which order. This has to work for magazine sizes like 200+ too, so add a scrollbar and stuff.
This also needs a huge overview over all fitting ammo in your inventory (or sector inventory). It should list these bullets, and how many there are. Clicking on this deducts one bullet and adds it to the mag. Deducting requires looping over the entire secor inventory in this case to find a bullet object to deduct from, so will be slow if you are not careful.
Of course, we will also want to just grab a bullet from anywhere in the mag and remove it. Have fun setting up that bit with miniature mouse regions and callbacks.
Or better, don't. Decline doing so because that would dilute the realistic vision behind it. This saves you work, and anyone complaining will have to admit that they don't really care about realism at all and just want shit without knowing what that entails.
You need two more buttons on the magazine interface, one for removing one bullet, and one for removing all bullets. At that point someone will want a button fro 5, 10, 3, 7 etc. bullets.
Note that magazine weight calculation now depends on the weight of the empty mag and the numbers of bullets and their individual weight, which will vary from caliber to caliber.
Setting up this interface will take a lot more time than everything else combined. Whatever you do, nobody will like how it looks. Nobody will volunteer to draw a replacement.

Clicking with the mag on the gun or the mag attachment slot will replace the magazine item. This is fairly easy. This is tedious if you take into account all that multiple-mag nonsense. Does clicking with a mag on an attached mag with several mags attached replace the whole stack, or just one mag?

Part 5: Unloading a magazine from a gun
Removing the magazine attachment removes the mag. Clicking on the bullet count does the same. This is fairly easy.
This is fairly complicated. Players want guns to have a bullet in the chamber. At the same time, they do not want bullets to remain in guns they want to have empty. The question is as to when the chambered bullet should stay, and when it should be removed and added back to the magazine. Use these rules:
  • Remove attachment: remove mag, chambered bullet stays.
  • Click on gun bullet counter: Remove mag, put mag into inventory, remove chambered bullet, put it into players hand.
  • [Shift]+[Alt]+[f]+[whatever key it is today]: Remove mag, put mag into inventory, remove chambered bullet, put it magazine.
  • [Ctrl]+[Shift]+[Alt]+[chinese symbol for 'donkey']: Remove mag, remove bullets from mag, put mag into inventory, put bullets into inventory remove chambered bullet, put it into inventory.

Part 6: What's in a mag?
As magazines now have mixed ammotypes, we have problem indicating their ammo via colour. We could just use the colour of the first bullet, but that changes when firing. Besides, we cannot look into a gun's bullet chamber, can we now?
Solution: All ammo counters are grey now. Hu. That was easy for once.
If someone complains that mags with only one ammotype loaded should logically get that colour, declare how shocked you are of this unheard of, and frankly, insulting attack on your artistric integrity. As we don't know whether there are several ammotypes inside (we do, but just because we loaded a magazine by hand doesn't mean we will remember what's inside), we have no choice but to always go for the same colour.
New problem: One could look at the magazine description box to find out what loadout you use. How unrealistic! Simply block any indication of ammotype and caliber in that huge interface you created. If players will want to know what a mag has, they have to unload the entire thing, see for themselves, and then load it again. As the ones requesting this are so interested in realism, I am confident they will embrace this mechanic.
Alternatively, use the same mechanic as for the current bullet count: have knowledge depend on wisdom and experience. Transparent mags get a bonus.

The caliber system allows loading mags with a caliber into a gun that does not accept that caliber. Feel free to add all sorts of catastrophes when one shoots a bullet in this case. Damaging the gun won't be enough, as player's will load the fastest, crappy handgun they can find (PM) with .50 BMG and exploit these powerful one-shot devices. A high chance of injury to the firer should put a stop to that.
Provided 2 calibers use the same magazine, you will no longer know which magazine was meant for which gun. Combined with the above mechanic of catasthrophic damage if the wrong caliber was loaded, and taking into account that any sort of inventory sorting will stack magazines together, different contents be damned... This leads to a scenario where firing any gun becomes russian roulette, because you cannot be sure it will have a fitting caliber loaded. Profit!

Part 7: Tend to the AI
Reloading itself shouldn't be a problem to the AI, provided you kept their functions clean. Spawning guns and mags is, however.
AI guns are required to have a magazine (otherwise combat will be kinda dumb). Adjust the object creation functions accordingly - make sure they get one!
Some mags should be standard, others are more advanced and rare to diversify things. Use the first mag a gun can have as the standard for it.
Getting the AI to use different mags requires you altering the drop tables. As there will be more than 50 mags total, increase that table or come up with something smart. Random items might work here, but will likely still have to expand the table once the mods with fucktons of items get their hands on this.
This also requires you to fill the mags with ammo after creating them, so you need to do that too.
People will ask for the AI having less magazines and loading those magazines in combat. Simple.

You also need to come up with a way to get Bobby Ray and merchants working with this. Just have them sell mags as attachments and ammo as boxes - this won't be hard.

Part 8: Filling out xmls, creating items
After setting up the xmls, you will need to fill them with reasonable data. You will also need those magazines and bullet items, including all those pictures.
Create a post where you explain all this, and give a few examples on how to do this, and ask for volunteers to help you with this. Many people will like this. One or two will volunteer, but will vanish due to real-life issues.
Fill out the data yourself, and create the pictures yourself.
In the likely case that nobody comes forward with pictures for this stupid feature they requested, use placeholder pictures, I recommend dildos and pink unicorns.
After adding this to the game, people will complain about your values obviously being off. They will offer absurd alternative values (if at all) which you won't use.
People will not like your pictures. Tell them that these are only placeholders, and you will gladly replace them if they deliver better pictures. This will never happen, and those placeholders will stay in the stock data for the next 5 years.
The only way to get good item pictures is to get a modder interested in this. He will have loads of questions. Explain all this to him. He will draw quality pictures for his mod, which you can then steal for the trunk.

Part 9: Coding
For the love of the dark gods, develop this in a separate branch. NOT in the trunk!!!
Finished features can go into the trunk if they work and are tested.
The trunk is not a code dump.

While coding, comment your code. Explain why you are doing what. Explain the idea of a code bit.
After committing, explain in the pit what this is all about!!!

Part 10: Compatibility
Make this a gamestart option. Switching between old and new system in an ongoing game requires quite a lot of conversions. Not recommended.
You read that right. You cannot remove the old system, because the huge number of people who recognize this is nonsensical shit nobody needs (you and me among them) will protest if the old stuff is removed.

[Updated on: Sat, 11 August 2018 18:15]

Report message to a moderator

Captain

Re: [IDEA] New Magazine System[message #335781] Sun, 14 September 2014 21:53 Go to previous messageGo to next message
DepressivesBrot is currently offline DepressivesBrot

 
Messages:3658
Registered:July 2009
Flugente
Besides, we cannot look into a gun's bullet chamber, can we now?
Well, we would obviously need a tag for that since for example older SMGs shooting from an open bolt will plainly show you the next round to be fired ...
SCNR ROFL

Report message to a moderator

Captain

Re: [IDEA] New Magazine System[message #335798] Mon, 15 September 2014 18:17 Go to previous messageGo to next message
tais

 
Messages:656
Registered:February 2008
Location: NL
Just reading a compilation of the red texts is actually pretty entertaining

Report message to a moderator

First Sergeant

Re: [IDEA] New Magazine System[message #335882] Wed, 17 September 2014 23:02 Go to previous messageGo to next message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
Holy Crap Flugente, this could take me upwards of a week just to read Wink

This gives me a great place to start! Unfortunately I am /still/ the only one seemingly willing to work on this... so motivation to get started is a bit low. I will eventually soon, I promise though.

If anyone is willing to help out I would appreciate it.

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #341927 is a reply to message #335882] Sun, 02 August 2015 05:20 Go to previous messageGo to next message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
Sorry to kinda necro this thread, but I won't give up on this.

I have gained more experience coding (albeit in lua coding) so I feel more comfortable trying to code this. I have been perusing the SVN code for reloading and it am confident I can eventually mash enough code together to make this happen. However, I don't yet have experience with C++ coding. Is the JA 005 russian mod that had it implemented coded all in Russian? If not, can someone shoot me a link for a download (or a download to any scripts others have made). It would be incredible if I didn't have to reinvent the wheel.

If not, can someone point me in the direction of where OBJECTCLASS is defined so I can define the new magazine class?

Thanks!

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #341960 is a reply to message #341927] Tue, 04 August 2015 22:11 Go to previous messageGo to next message
Flugente

 
Messages:3509
Registered:April 2009
Location: Germany
I have no idea what the russian 005 mod is or what happened there, but there should be enough russians on this forum...

OBJECTTYPE is defined in Item Types.h. Be aware, however, that we don't do a lot of OO code. Also, due to the way we save and load data, creating a new class that inherits from OBJECTTYPE and adds new member variables will create a lot of new, messy problems.




I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.

Report message to a moderator

Captain

Re: [IDEA] New Magazine System[message #341966 is a reply to message #341927] Tue, 04 August 2015 22:47 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
You can find ja2'005 source here
All changes made by Bugmonster are commented.



Left this community.

Report message to a moderator

Lieutenant

Re: [IDEA] New Magazine System[message #341971 is a reply to message #341960] Wed, 05 August 2015 05:14 Go to previous messageGo to next message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
Flugente wrote on Tue, 04 August 2015 21:11
I have no idea what the russian 005 mod is or what happened there, but there should be enough russians on this forum...

OBJECTTYPE is defined in Item Types.h. Be aware, however, that we don't do a lot of OO code. Also, due to the way we save and load data, creating a new class that inherits from OBJECTTYPE and adds new member variables will create a lot of new, messy problems.



Hrm, well I can probably get away with using the base item class... I will see if I can do without.

@sevenfm

As always, you rock, thank you, I haven't looked into the file yet but I am sure it will really help out (though I will need to translate some Russian probably)

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #341981 is a reply to message #341971] Thu, 06 August 2015 05:53 Go to previous messageGo to next message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
Hey, while I am working on on the code (which will take me a while with my schedule) I had an idea for how to deal with custom loads of ammo using a table in each mag. Is this feasible? and if so, how do I create a table with C++ and subsequently add to said table? I know how to do it in LUA but not C++..

Thanks!

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #341983 is a reply to message #341981] Thu, 06 August 2015 11:34 Go to previous messageGo to next message
DepressivesBrot is currently offline DepressivesBrot

 
Messages:3658
Registered:July 2009
Taking a quick peek at the lua documentation, tables appear to be their universal, catch-all data structure. Ain't no such thing in C++, you'll have to figure out which functions you need out of your data structure and then pick a fitting one. Though Flug's vectors will probably work.


Chat with us!
#bearpit on IRC
Discord
Get your latest 1.13 Builds
(Pls don't use my forum PMs for general game queries)

Report message to a moderator

Captain

Re: [IDEA] New Magazine System[message #341999 is a reply to message #341983] Fri, 07 August 2015 07:08 Go to previous messageGo to next message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
DepressivesBrot wrote on Thu, 06 August 2015 10:34
Taking a quick peek at the lua documentation, tables appear to be their universal, catch-all data structure. Ain't no such thing in C++, you'll have to figure out which functions you need out of your data structure and then pick a fitting one. Though Flug's vectors will probably work.


So no array-like functions with c++? That is surprising...

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #342000 is a reply to message #341999] Fri, 07 August 2015 07:54 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
ormtnman wrote on Fri, 07 August 2015 09:08

So no array-like functions with c++? That is surprising...

Arrays in cpp



Left this community.

Report message to a moderator

Lieutenant

Re: [IDEA] New Magazine System[message #342002 is a reply to message #341999] Fri, 07 August 2015 11:57 Go to previous messageGo to next message
math3ws is currently offline math3ws

 
Messages:19
Registered:March 2013
Location: Czech Republic
Before I give you any advice, I want to say that I know pretty much nothing about JA2 code, I only have some C++ knowledge.

ormtnman wrote on Fri, 07 August 2015 06:08
DepressivesBrot wrote on Thu, 06 August 2015 10:34
Taking a quick peek at the lua documentation, tables appear to be their universal, catch-all data structure. Ain't no such thing in C++, you'll have to figure out which functions you need out of your data structure and then pick a fitting one. Though Flug's vectors will probably work.


So no array-like functions with c++? That is surprising...


First of all, they are not functions, functions perform a given task, data are stored in variables, that must have a data type defined. Just to make sure we are talking about the same thing, I don't mean to give you a hard time happy .

Second of all, that's not what DepressivesBrot said, he said there is no universal data structure, like tables in LUA. There are many data types that can store multiple values at once, each suitable for different purposes. sevenfm already pointed you to the basic one, and I advise you to familiarize yourself with standard template library. Now you have to decide, which data type suits your needs.

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #342006 is a reply to message #342002] Fri, 07 August 2015 15:54 Go to previous messageGo to next message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
Both of you are awesome.

Yeah, I am still stuck in the lua terminology. I did notice what is normally termed "function" under lua was called a boolean. So don't worry about giving me a hard time, I am still new and I am asking obvious questions I could probably google for myself ;)

I'll take a look at that but just to give you all a vague idea of what I am thinking of trying to do is:

Here is the magazine for say an M1911. It is empty. I load a standard ball roumd so now it has a .45ACP round stored as the first round in the mag. I then drop 3 AP rounds, now the mag has 4 stored values: 45ACP AP, 45ACP AP, 45ACP AP, 45ACP. (The left most round would be #1. If you decide to insert this mag into the 1911, it stores the magazine as inserted and copies the stored values for the rounds. However, as a mag fed gun, you need to rack the slide to chamber the round. That action removes the first stored value and moves it to the chamber value. So the chamber would equal 45ACP AP, this would determine the current stats of the gun. The mag now has 45ACP AP, 45ACP AP, 45AP. A round is fired, if it hits it will look at the current stats and deal the damage, then we remove the fired round from the chamber. Because this is auto-chambering when the round is ejected after firing the next in line is inserted. Chamber = 45ACP AP and the mag now has 45ACP AP and 45 ACP. And so on.

Other loading styles like revolvers or others would be handled slightly differently but similarly.

Does this make sense to you more experienced guys?

Report message to a moderator

Private
Re: [IDEA] New Magazine System[message #342007 is a reply to message #342006] Fri, 07 August 2015 16:09 Go to previous messageGo to next message
DepressivesBrot is currently offline DepressivesBrot

 
Messages:3658
Registered:July 2009
ormtnman wrote on Fri, 07 August 2015 14:54
Both of you are awesome.Yeah, I am still stuck in the lua terminology. I did notice what is normally termed "function" under lua was called a boolean. So don't worry about giving me a hard time, I am still new and I am asking obvious questions I could probably google for myself ;)
Uhm, no, functions are called functions. What you are talking about is defining a function in the code, for which C++ uses a slightly different syntax than Lua, owing to the fact that Lua is dynamically typed while in the C world you generally have to declare right away what data type a variable holds and which type a function returns.



Chat with us!
#bearpit on IRC
Discord
Get your latest 1.13 Builds
(Pls don't use my forum PMs for general game queries)

Report message to a moderator

Captain

Re: [IDEA] New Magazine System[message #342009 is a reply to message #342007] Fri, 07 August 2015 16:52 Go to previous message
ormtnman is currently offline ormtnman

 
Messages:19
Registered:October 2013
Location: Oregon, USA
DepressivesBrot wrote on Fri, 07 August 2015 15:09
ormtnman wrote on Fri, 07 August 2015 14:54
Both of you are awesome.Yeah, I am still stuck in the lua terminology. I did notice what is normally termed "function" under lua was called a boolean. So don't worry about giving me a hard time, I am still new and I am asking obvious questions I could probably google for myself ;)
Uhm, no, functions are called functions. What you are talking about is defining a function in the code, for which C++ uses a slightly different syntax than Lua, owing to the fact that Lua is dynamically typed while in the C world you generally have to declare right away what data type a variable holds and which type a function returns.


My words are being taken too literally... I understand how it operates. I'll just get to work now.

Report message to a moderator

Private
Previous Topic: (New) Common Attachment Framework (new title; was The NAS Receiver)
Next Topic: Path finding problems in 1.13
Goto Forum:
  


Current Time: Thu Mar 28 10:45:10 GMT+2 2024

Total time taken to generate the page: 0.02210 seconds