Jump to content

tommysticks

Recommended Posts

Hello Everyone.

 

Let me start off by saying I'm really bad at understanding any programming language, but I'm pretty good at piecing together/slightly modding other people's work to get what I need done.

 

That being said, I have a question and some ramblings.

 

I think the we need more guns mod is an awesome idea, but it isn't very stable. I play on steam, originally downloaded from Desura, so I don't know if everyone is having this problem, but when I shoot any weapon without having the appropriate ammo in my inventory the game crashes. I also noticed that none of the weapons require reloading, instead there is a short script that reduces the ammo count by 1 with each shot.

 

I was poking around the game's reloading Lua files, and it seems like it should be pretty simple (to someone who knows what their doing) to make custom weapons require reloading using the programmer's original scripting.

 

I attempted this, as it seemed like it should be fairly logical if I mirrored the style of the reloading Lua, however, I ended up wasting about 6 hours getting jack shit accomplished. There are even little notes in the reloading Lua that try to assist with coding, but I got lost in the sauce.

 

From the time I spent messing around with this code I ran into something that boggled my mind for about 60 minutes: I could not figure out why the in-game Pistol reloaded 12 rounds every time rather than 10 - which is the number associated with Bullets 9mm. Then I found a little piece of coding that eluded me earlier: the item PistolMagazine, which has a count of 12.

 

After finding the PistolMagazine piece, I can't find any bit of coding that associates PistolMagazine with the in-game Pistol. It is no where to be found in any of the reloading Lua, and I can't find it anywhere else. I assume it has something to do with the more difficult reloading settings, however I believe this is a feature that is not accessible in the beta.

 

A few conclusions that I have made are these:

 

Under Items, AmmoType is associated with the type of magazine the weapon accepts. The ammo and amount of ammo that goes into the magazine is somehow associated with the magazine as well, most likely through reloading Lua. So it sort of looks like this:

 

Item - Pistol > AmmoType = BerettaClip > PistolMagazine > Bullets9mm

 

It also seems that the reloading Lua is somehow associated with what sprite has been identified on the item list.

 

If this makes any sense to anyone, can you verify what I'm talking about or provide clarity?

 

TL;DR

Is there a way to make custom weapons require reloading using the game's reloading Lua?

 

 

Link to comment
Share on other sites

Hey,

I made a start trying to explain how to add more weapons over in another thread here:

http://theindiestone.com/forums/index.php/topic/3078-need-help-with-spritesicons-and-much-more-to-come/

I'm not home now and trying to reply on a mobile. I think the discrepancy you found between the amount of ammo the gun can hold and the magazine can hold is a bug. I also apologise for the complexity of the code. I had originally written the code to take advantage of inheritance and it caused problems trying to save, so it now is a bit of a Frankenstein.

When I get some time this afternoon I will try and get a tutorial up.

Link to comment
Share on other sites

Regarding the different amounts being reloaded I'm still looking into this. On easy mode, one value is being used and on hardcore another. Furthermore, firing off rounds uses two rounds at a time. I'm looking into the causes of both of these. They should both be using the lua code to determine the capacity.

 

The magazine is used to determine the ammo being used by the pistol in both easy and hardcore. The difficulty setting can be changed from the options screen (must be done each time the game loads).

 

See here for more info:

 

http://theindiestone.com/forums/index.php/topic/3238-adding-more-guns/

Link to comment
Share on other sites

Awesome, I'm glad you were able to understand my ramblings.

I haven't had a chance to look at your coding yet, because I am now on a mobile but I was having the same problem with two bullets being fired when I was attempting to piece the reloading Luas together for my own purposes.

I figured out it was because I copied the entire reloading folder into my mod, so the reloading Lua was running twice it seemed. It stopped happening when I took one of the files out, it may have been the ISSemiAutoWeapon Lua. I can verify that later when I get to my comp.

Link to comment
Share on other sites

I figured out it was because I copied the entire reloading folder into my mod, so the reloading Lua was running twice it seemed. It stopped happening when I took one of the files out, it may have been the ISSemiAutoWeapon Lua. 

 

Confirmed. I was sure that the files in the mod directory should replace the originals and therefore stop that from happening. If I can fix the easy vs reload ammo count problem I'll consolidate the changes I've made and ask to get this into a release.

 

In the meantime, replace the files in the zomboid actual directory.

Link to comment
Share on other sites

lol that just made my day.

 

I just remembered that I did find somewhere a line of code that seemed like it influenced the number of Bullets 9mm to be reloaded into the Pistol.... lemme see if I can find it again.

 

Alright it is under ISSemAutoWeapon:

 

 

--************************************************************************----** ISSemiAutoWeapon:reloadPerform--**--** Function that should be performed upon successful completion of the--** timed action. Considers the difficulty and performs the corresponding--** reload action--**--** @param char - the character performing the action. Must not be nil--** @param square - not used--** @param difficulty - the difficulty level--**--************************************************************************--function ISSemiAutoWeapon:reloadPerform(char, square, difficulty, weapon)if(difficulty == 1) thenself:reloadPerformEasy(char, square, weapon)elseself:reloadPerformNormal(char, square, weapon)endendfunction ISSemiAutoWeapon:reloadPerformEasy(char, square, weapon)-- Does find and return give an abilty to determine size of stack?local amountToRemove = 12 - self.currentCapacity;local inventoryAmmoCount = 0;local amountRemoved = 0;while((char:getInventory():FindAndReturn(ReloadUtil:getClipData().ammoType) ~= nil)

 

The bit about removing 12 bullets...

 

That is the only line that I could find that relates to the amount of bullets going into the gun.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...