Jump to content

Stormy

Member
  • Posts

    64
  • Joined

  • Last visited

Everything posted by Stormy

  1. I'm working on some stuff at the moment with fire. As soon as I figure out how to start it straight away I'll let you know. Btw, when the molotov smashes it that last number is 50... maybe that'll fix it.
  2. You did. And I very much appreciate it.
  3. 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.
  4. gridSquare:AddTileObject(IsoFire.new(gridSquare:getCell(), gridSquare, true, 2)) Not sure what that end number is for and the fire seems to spawn long after I call the function but that definitely does add a fire to a square.
  5. The shotgun already pumps on hardcore mode. Go into the options screen and scroll to the bottom. There's a little glitch for me that causes the pulldown to jump upwards when you click but if you find it and change the setting to Hardcore, you'll have to pump between each shot. And you'll need to use magazines with the pistol. May only work on new games. If there is a lot of requests for easy reloading with the pistol and hardcore with the shotgun I can add a few more difficulty levels. Can you expand or point me to the support thread? I've just uploaded a mod that updates the reloading and may fix your problems. You can find it here: http://theindiestone.com/forums/index.php/topic/3238-adding-more-guns/
  6. 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/
  7. I've seen two threads already and wanted to try and consolidate all the questions about this here. I've made some changes to the reloading scripts to make it easier to add extra weapons. Provided I can fix the remaining bugs, this should mean that the original lua scripts will not need tampering with in order to have additional weapons take advantage of the reloading scripts. Preparing the mod directory Find your zomboid mod directory, if you launch the game, click mods, you'll find the path at the bottom of the mod window. Mine is: C:\Users\Stormy\Zomboid\mods\ Where Stormy would be your windows user name. Next, extract the following zip to that directory: WARNING: It seems the files in the mod directory do not replace the original lua scripts perfectly. Override the files in the \Steam\steamapps\common\ProjectZomboid\media\lua\Reloading directory with those in the following archive: http://download1653.mediafire.com/62216je2q0wg/cue340cf05muivz/Reloading+-+moddable.zip And extract the following to the mod directory explained above. http://download856.mediafire.com/8x5fpe7hgqyg/tttr0ci0smpr924/moreguns.zip I've sorted out the mod structure for you, so you can continue building on the files inside. Once extracted, the file structure should resemble: C:\Users\Stormy\Zomboid\mods\moreguns C:\Users\Stormy\Zomboid\mods\moreguns\media C:\Users\Stormy\Zomboid\mods\moreguns\media\lua C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts The devs have been clever so that if you name the lua files the same in the mod directory, the game will replace the originals. Therefore, from now on, you can just modify these files to get the results you want. Remember, you'll have to enable the mod once upon starting the game and from then on it will use the mod until you disable it. Note this means REPLACE not MERGE. If a zomboid update changes the original files, the change will not be brought across to the custom files meaning potential bug fixes would be missed. Once I figure out the remaining bugs I ask for these versions to be made 'official'. Defining the items In the directory: C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts\Mods\MoreGuns there is an items.txt. This is where the majority of information about the item is found. module MoreGuns{ item Colt45 { item info here } item ColtClip { item info here }} I've defined the module name 'MoreGuns' which is the same as my mod name. This helps to reduce the difficulty of finding your particular items. Both the module name and the item name must contain no spaces or special characters. I won't go into details about the various fields in the item's information. I've copied mine directly from the existing pistol and changed only the display name. There is an important script that I noticed to do with languages which must have additional entries for each weapon you add for the mod to work. These are to do with language translations. It's not immediately obvious (I don't fully understand it) but goes something like this. In the C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Translate there is a file called Items_empty.txt. You need to create entries for your weapons in there. For your Colt where the weapon name is Colt .45 I've created the entry: DisplayNameColt_.45 = "", Replacing the space with an underscore. Same for the magazine DisplayNameColt_Magazine = "", Compare this with the items.txt in C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts\Mods\MoreGuns Here's the shorter entry (the magazine) as an example: item ColtClip{ CanStack = FALSE, Weight = 0.2, Type = Normal, DisplayName = Colt Magazine, Icon = BerettaClip,} You'll see the name in the Items_empty.txt corresponds to the DisplayName of the item in the items.txt. Updating the LUA files In the folder: C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Reloading You should be able to see the file ZMoreGuns.lua. It is named 'ZMoreGuns' rather than 'MoreGuns' because files are loaded in alphabetical order and I need it to load after storymysReload.lua Anyway, if you open the file, you should be able to see two entries. One for the magazine and one for the weapon. I've declared the magazine first. Here is the information broken down: local coltClip = { name = getItemText("Colt Magazine"), -- Make sure this is the same as the display name in items.txtmoduleName = 'MoreGuns',-- The module the weapon was defined under in items.txtreloadClass = 'ISReloadableMagazine', -- The type of reloading this item will follow (see below)clipType = 'ColtClip',-- The item type as defined in the items.txtammoType = 'Bullets9mm',-- The type of ammo this item takes. You can create a new ammo type in items.txtshootSound = 'none',-- The sound to play when this weapon firesclickSound = nil,-- The sound to play when this weapon dry firesejectSound = 'none',-- The sound to play when a magazine is ejectedinsertSound = 'stormyRevolverInsertRound',-- The sound to play when a round/magazine is insertedrackSound = 'stormyRevolverInsertRound',-- The sound to play when this weapon is rackedcontainsClip = 0,-- Whether the item contains a magazinemaxCapacity = 15,-- The maximum capacity of this itemreloadTime = 30,-- The time taken to insert one round/magazinerackTime = 10};-- The time taken to rack the item For the colt itself there is one extra value: clipData = coltClip This is just pointing to the local maagzine declared above it. Finally, the following statements are called: ReloadUtil:addWeaponType(colt)ReloadUtil:addMagazineType(coltClip) These add the weapon and its magazine to the list of weapons and magazines the reload utility is currently managing. Reload Types There are currently three reload types: ISReloadableMagazineISSemiAutoWeaponISShotgunWeapon A revolver type has not yet been implemented but would likely be restricted to a fixed number of chambers were I to implement it (for reasons to do with saving the reload data). Provided everything compiles there should be no extra steps required. I've left a debug key in the lua. The code for which can be found in the stormysReload.lua script. Press L and the game will give you the original Pistol, the new Colt, a magazine for each and some ammo. Both use the 9mm ammo type. (I may have commented out the important lines though, make sure you remove the dash that start of any line for which you want to create an item). There seems to be some glitches about the magazine appearing in your inventory. I need to look at these too. Hopefully though, there is enough here for you to make a start with.
  8. 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.
  9. Ok, First thing, I've noticed some bugs with this and I need some extra time to look into them. For example you seem to be able to put more ammo than you need to inside a magazine. There were also a few things that meant you were unable to add extra weapons. So, I fixed these problems and I've made the following mod for you which you can then use to expand upon. You mentioned that you were modifying the original zomboid files in the \Steam\steamapps\common\ProjectZomboid folder. First step, revert these. Whenever zomboid updates it will automatically do this so it's safer to use the mod folder. That way you won't lose any hard work. If you to need restore the steam version manually, right click on the game in steam and select properties, go to the local files tab and click verify local cache. Next step, find your zomboid mod directory, if you launch the game, click mods, you'll find the path at the bottom of the mod window. Mine is: C:\Users\Stormy\Zomboid\mods\ Where Stormy would be your windows user name. Next, extract the following zip to that directory: http://download846.mediafire.com/4fl0g3m6c3wg/tttr0ci0smpr924/moreguns.zip I've sorted out the mod structure for you, so you can continue building on the files inside. Once extracted, the file structure should resemble: C:\Users\Stormy\Zomboid\mods\moreguns C:\Users\Stormy\Zomboid\mods\moreguns\media C:\Users\Stormy\Zomboid\mods\moreguns\media\lua C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts The devs have been clever so that if you name the lua files the same in the mod directory, the game will replace the originals. Therefore, from now on, you can just modify these files to get the results you want. Remember, you'll have to enable the mod once upon starting the game and from then on it will use the mod until you disable it. There is an important script that I noticed to do with languages which must have additional entries for each weapon you add for the mod to work. These are to do with language translations. It's not immediately obvious (I don't fully understand it) but goes something like this. In the C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Translate there is a file called Items_empty.txt. You need to create entries for your weapons in there. For your Colt where the weapon name is Colt .45 I've created the entry: DisplayNameColt_.45 = "", Replacing the space with an underscore. Same for the magazine DisplayNameColt_Magazine = "", Compare this with the items.txt in C:\Users\Stormy\Zomboid\mods\moreguns\media\scripts\Mods\MoreGuns Here's the shorter entry (the magazine) as an example: item ColtClip{CanStack = FALSE,Weight = 0.2,Type = Normal,DisplayName = Colt Magazine,Icon = BerettaClip,} You'll see the name in the Items_empty.txt corresponds to the DisplayName of the item in the items.txt. I've made sure the item name (that follows the 'item' declaration above the '{' )doesn't have any spaces or unusual characters (like a period/full stop). The rest is essentially what you managed to do in the ISReloadUtil.lua now found in: C:\Users\Stormy\Zomboid\mods\moreguns\media\lua\Mods\Reloading I added the entries for the Colt and the Colt magazine and made sure they were added to the lua tables. I've left a debug line in for you as well. The code for which can be found in the stormysReload.lua script. Press L and the game will give you the original Pistol, the new Colt, a magazine for each and some ammo. Both use the 9mm ammo type. There seems to be some glitches about the magazine appearing in your inventory. I need to look at these too. Hopefully though, there is enough here for you to make a start with.
  10. Hey stayxstoned, I wrote the reloading mechanic and I will take a look (probably Monday at the earliest I'm afraid) to see if I can make it a little easier for you to do what you want. As a precursor, in your item declarations make sure you avoid spaces. e.g.: item 308 bullet{Type = Normal,DisplayName = .308 Bullets,Icon = 40calAmmoBox,Weight = 0.1,Count = 15} should be item 308bullet{Type = Normal,DisplayName = .308 Bullets,Icon = 40calAmmoBox,Weight = 0.1,Count = 15} The DisplayName can contain spaces but the item declaration can not. If the Colt 45 was the one you added, and it works, then most likely the others just need naming correctly.
  11. I'm fairly sure its a bug to be resolved. I had trouble launching in debug mode but I managed to do it a couple of builds ago. You have followed the instructions here (including those suggested in the other posts)? http://theindiestone.com/forums/index.php/topic/1033-lua-debugger/
  12. Run the game and from the main menu click mods There is small print at the bottom of the window that will tell you your path More info: http://theindiestone.com/forums/index.php/topic/61-robomats-modding-tutorials-updated-08112013/ http://theindiestone.com/forums/index.php/topic/2011-how-to-use-the-modloader/
  13. There's a public static class called IsoFireManager... you could try IsoFireManager:StartFire(IsoCell cell, IsoGridSquare gridSquare, boolean IgniteOnAny, int FireStartingEnergy) Can't remember the exact methods but I guess it would be something like: IsoFireManager:StartFire(getPlayer():getGridSquare():getCell(), getPlayer():getGridSquare(), true, 10)
  14. Until seasons are implemented in their entirety and you reach summer.
  15. Distribute freely, use at own risk If you do find problems, post them here and I'll try and fix them.
  16. Originally posted in this thread: http://theindiestone.com/forums/index.php/topic/1931-how-to-delay-processing-of-a-function/#entry29744 I've been needing something like this and thought it might be useful to other folks. Zomboid essentially runs a loop and updates the game world every cycle of the loop. Each cycle is commonly referred to as a 'Tick'. So on each 'tick', zomboid does things like detecting whether any keypresses have been made, calculates AI, draws the world, animates things etc etc. When you use the event hook onTick you are essentially adding an additional function to those that zomboid is already executing each tick. Some things, like detecting keypresses, are likely intended to stay in there indefinitely. However there are certain events that you may wish to fire once when a certain condition is met. Adding these to the onTIck mean that after that condition is met and the event fires, the check will continue to made afterwards, even if the conditions are never met again, or perhaps, the conditions are met again and the same event fires unintentionally. To counter this I've written these utility classes. By creating ScheduledEvents and adding them to the ScheduledEventsManager, you can have the events remove themselves from the onTick hook or chain events together. Instead of the adding functions to onTick and letting zomboid's loop handle the execution of events, you add them to the ScheduledEventsManager which will handle them in its own loop. Here's an explanation of how to work it: As an example mod that could be a treasure hunt, where the conditions check for the presence in the players inventory of an item. Upon finding the item, a new event is created that starts checking for the next item. The final item found then triggers a reward event or whatever. http://download1591.mediafire.com/tf9c84cj3jkg/lk48iyy5e178fhg/Scheduler.zip [url=http://theindiestone.com/forums/index.php/topic/2530-mod-permissions/#entry36476]
  17. I'm going to bundle this up into an object, but this will do nicely: local size = 0local table = {}function add(value) if(value ~= nil) then table[size+1] = value size = size + 1 endendfunction remove(index) if((index ~= nil) and (index < size) and (index > 0)) then for i=index, size do if(i+1 > size) then table[i] = nil else table[i] = table[i+1] end end size = size - 1 elseif(index == size) then table[index] = nil size = size - 1 endend
  18. I should point out that there is one major thing missing from this implementation. I haven't been bothered to look into this properly but the table in Lua is not an ideal collection. When a table is looped over the nil element identifies the end of the table. With a table consisting of {1, 2, nil, 3, 4} the loop ends when it hits the nil and doesn't go to elements 3, 4. Ideally the implementation above needs two things: 1. The ability to append an item to the end of the collection. Instead of calling EventManager.onTickTable[1] = newEvent, I should be calling an EventManager.addEvent(newEvent) which adds it on to the end of a table. A table resembling {event1, event2} before calling the method should look like {event1, event2, newEvent} afterwards. 2. To be able to remove items from the table and shuffle everything to the left when it happens. So when event2 executes, it is removed from the table and the table looks like: {event1, newEvent} rather than {event1, nil, newEvent}. I would have tried to do it but for some reason I couldn't define a function properly... I tried adding something like this: function ScheduledEventManager:append(newEvent) self.onTickTable[nextAvailableIndex] end but I was getting an error to do with the reference to self. I think I've dome something wrong with meta table. Maybe RJ or RoboMat can see it. Its probably really obvious. Essentially, because of these limitations, you can only have 1 series of scheduled events operating at a time. Oh well.
  19. Okay so here's a little program I've tested in zomboid: http://www.mediafire.com/download/lk48iyy5e178fhg/Scheduler.zip Essentially, the effects can largely be summed up from the temp.lua and you don't really need to pay much attention to the other two classes. The code there is as follows: local checkFunction = function(ticksAtCreation, ticks) print("ticksAtCreation"..ticksAtCreation) print("ticks"..ticks) return ticks - ticksAtCreation> 5endlocal performFunction = function() print("Action performed")endlocal postFunction = function() return nilendlocal newEvent = ScheduledEvent:new(ticks, checkFunction, performFunction, postFunction)EventManager.onTickTable[1] = newEventI create three local variables that each hold a function. The check function should return a boolean. It checks the conditions at any given moment and returns true or false. For example, in the above example it checks if 5 ticks have passed (this is a very short amount of time). The ScheduledEventManager is forced to pass those exact parameters to that function. However, if you could access a global variable (like the in-game date, or the player) you could have any type of condition here (e.g. the player has an item in their inventory or a certain date has been reached). The performFunction is the action that is performed when the condition is met. In this case, it just prints out to the console. The postFunction should return the next ScheduledEvent that you want to execute. After the performFunction executes, the postFunction is called and the value it returns replaces the 1 index in the onTickTable. A ScheduledEvent takes those functions in its constructor. So if you want a new function to execute after the current one you'd write three more functions, add them to a ScheduledEvent, have the postFunction of the first one return that object. If you don't want any more to execute, do as I do and return nil. The last step is adding the ScheduledEvent we wish to execute first to the EventManager's onTickTable. I've left some debug statements in there for assistance.
  20. Yeah loops won't work... For what we're talking about here we could do some sort of scheduler... The original program could be adapted. EDIT: See below.
  21. I fail to see what relevance the video posted has when its title is "World's Fastest Shotgun Load". Show me the video of "Person who's never used a gun before attempts to load a shotgun without instruction under stress in a combat situation" and I'll start paying attention.
  22. Depends what you mean by reoccurring. The method I proposed would be best suited to a strength potion for example. After x amount of time stop performing the function. But you could drink potions again. Adding the function to the table again and then removing it after x has passed. If you mean that the function always needs to keep doing something provided a condition is metthen adding something to OnTick where you check a condition first should be sufficient to avoid the overhead. For example, reloading is in the OnTick method. It constantly checks for r being pressed If r is pressed then it checks for ammo. That check for ammo involves looping through every item in the inventory (for semi-auto weapons anyway). I've never noticed a performance loss on it. The one thing I implemented that caused a massive overhead was a very nasty recursive loop when I did explosions a while back.
  23. EDIT: Answered my own question. Add a function to OnTick that executes functions in a table and checks first if the table is empty and doesn't do anything if it is. Add your desired function to that table and have it remove itself from the table once executed. Here is a short program that shows it working: print('Start')timesExecuted = 0onTickTable = {}local newFunction = function() print(timesExecuted) if(timesExecuted > 5) then return timesExecuted else return nil end endonTickTable[1] = newFunctionlocal checkTickTable = function() local removeIndex = 1 local functionToRemove = {} for i,method in ipairs(onTickTable) do if method ~= nil then local temp = method() if temp == nil then print('fail') else print('success') functionToRemove[removeIndex] = i removeIndex = removeIndex + 1 endend end for i=1, removeIndex-1 do onTickTable[functionToRemove[i]] = nil endend-- Mock OnTick functionwhile(timesExecuted < 10) do local temp = checkTickTable() -- Add this to OnTick timesExecuted = timesExecuted + 1endprint('Finish')Output: Start0fail1fail2fail3fail4fail5fail6successFinish After 6 is printed, the function is removed from the table and never executes again. Therefore no fear of overhead. The only overhead you have now comes from the checkTicksTable which effectively does nothing because the table is empty. Because of the way Lua uses nil to determine whether the end of an array has been met I'm not sure if this works if onTickTable look like {function1, function2, nil, function3}. But still, with only one function, you should be fine. In your function you'd be checking that the current ticks value is greater than 5secs + the ticks value at the time the function was created. This may take a little more work passing value around but I'm fairly sure it's all possible.
  24. Just to be clear: when you add your function to OnTick it causes a drag in performance or you are worried that it will cause a drag in performance? I'm not an expert but I've been under the impression that all games operate in a continual loop; doing the draw each 'tick', doing the logic, checking for button presses etc. If this is the case, presumably using an if control statement minimises the overhead, and whatever you are doing is presumably negligible next to LoS, AI, world drawing. I assumed the onTick was a way of hooking into the natural loop of the game. My question would be after I've added something to the OnTick, can I remove it (like removing listeners or observers).
×
×
  • Create New...