Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Long description
Long description
New Items:
Basic Ammo Box: Contains the same contents as 100 basic ammo magazines, stacks to 100.
Piercing Ammo Box: Contains the same contents as 100 piercing ammo magazines, stacks to 100.
Gun Turret Mk2: Has a range of 25, does 2x base damage as regular gun turret, has a logistic slot & can request items from storage network
New Techs:
Ammo Box: Requires Military 3, unlocks basic and piercing ammo boxes
Turrets 2: Requires Military 3, turrets, unlocks Gun Turret Mk2
Pictures
Pictures Gun Turret Mk2
Gun Turret Mk2 w/ Ammo Boxes
Version history
Version history v0.3.0 (30-1-2016):
Compatibility with mods like Dytech that add their own gun-turrets 2 technology.
Minor Performance Improvements
v0.2.1 (2-12-2015):
Fix missing locale text for gun turret 2 in tech description
v0.2.0 (1-11-2015):
Add compressed flamethrower ammo
Holds 100x magazine size of standard flame thrower ammo
Has 2x attack distance of regular flamethrower ammo
Requires Flamethrowers 2 tech to unlock
Added flamethrower 2 tech to unlock compressed flamethrower ammo
v0.1.4 (26-10-2015):
Work around Factorio serialization issues
Rescan map for untracked gun turrets on initial load
v0.1.3 (16-10-2015):
Updated to support mod api changes in Factorio 0.12.11+
v0.1.2 (26-8-2015):
Bugfix: Allow damaged mk2 gun turrets to be repaired correctly
v0.1.1 (24-8-2015):
Update gun turret mk2 to split selection boxes, allows seeing Gun Turret Mk2 stats (Thanks to Aldi!)
Made the gun turret mk2 inventory to update every 20 ticks instead of every tick (Performance)
Speaking of which on_robot_built_entity handler is bugged as it lacks the line 7 from on_built_entity.
Both tooltips can be made accessible by changing selection boxes of entities. Say logistic container might have selection_box = {{-1, -1 }, {0, 1}}, and the gun - {{0,1 }, {1, 1}}.
Same goes to collision boxes. In a fact I'd make the gun non-colliding at all, by setting collision_mask={}.
And probably make chest invincible while gun lives instead of constantly updating its health.
As a continuation of previous, I'd say that this tandem creation should be initiated by placing the logistic container rather than by placing gun turret. That way blueprints would preserve requester conditions (but all item tooltips would not provide gun-power info).
Alternatively, requester might be made into standalone module that can be placed over turret (like my unloader mods).
Also, is it really necessary to sync every turret-chest pair sixty times a second?
Re: [MOD 0.12.x] AmmoBox
Posted: Mon Aug 24, 2015 4:56 pm
by Afforess
Adil wrote:Good job.
I wanted to do that too.
Can we have a discussion?
Absolutely! No reason you can't contribute to the project on github, btw. I try not to be one of those people who think their code is some work of art that shouldn't be modified or criticized by others. Code is code, and plenty of mine is not so great.
Adil wrote:
I didn't know create_entity can spawn colliding entities together, probably that will get fixed someday.
I agree, it is a bit of a hack. No idea if they will fix it, but it works for now.
Adil wrote:
You can group events with same handlers together like this:
Nice, I did not know that. I am not super-familiar with lua, or the factorio API.
Adil wrote:Speaking of which on_robot_built_entity handler is bugged as it lacks the line 7 from on_built_entity.
Ouch, yes. It shouldn't be player.force... I need to check the API to see what it should be. entity.force?
Adil wrote:Both tooltips can be made accessible by changing selection boxes of entities. Say logistic container might have selection_box = {{-1, -1 }, {0, 1}}, and the gun - {{0,1 }, {1, 1}}.
Oh, very good. That solves one of my primary issues.
Adil wrote:Same goes to collision boxes. In a fact I'd make the gun non-colliding at all, by setting collision_mask={}.
And probably make chest invincible while gun lives instead of constantly updating its health.
Yeah. Both are good suggestions, I will test an implementation later tonight.
Adil wrote:As a continuation of previous, I'd say that this tandem creation should be initiated by placing the logistic container rather than by placing gun turret. That way blueprints would preserve requester conditions (but all item tooltips would not provide gun-power info).
Alternatively, requester might be made into standalone module that can be placed over turret (like my unloader mods).
That is a really good point. The reason I had the gun turret placed first was so you could access the requester inventory, as that entity was on top. But if changing the selection boxes and collision boxes makes it possible to hide the gun while showing it's tooltip, then there will be no reason to have the gun turret placed first anymore.
Adil wrote:Also, is it really necessary to sync every turret-chest pair sixty times a second?
I really didn't want to do that, but I'm not aware of any events that fire when health or inventory changes. I did my best to try to minimize the per-tick impact, but obviously it could be better. If I made it update only update every 5 or 10 ticks, then I would run into the possibility that health or ammo would become out of sync enough that the turret could die, or ammo run out.
Re: [MOD 0.12.x] AmmoBox
Posted: Mon Aug 24, 2015 5:09 pm
by Xterminator
Really cool idea! Having a turret with a built in Logistic request slot is brilliant, and surprised it hasn't been done yet. The ammo boxes are pretty awesome too, especially for turrets.
Mind if I do a mod spotlight on this in the near future?
Re: [MOD 0.12.x] AmmoBox
Posted: Mon Aug 24, 2015 6:13 pm
by Adil
Afforess wrote:
Absolutely! No reason you can't contribute to the project on github, btw.
Yeah, one day I will get around registering there.
Afforess wrote:
hide the gun while showing it's tooltip, then there will be no reason to have the gun turret placed first anymore.
Tooltip is shown when you select entity. I doubt you can get it from completely hidden object. Suggested selection boxes would just allow you to select chest when hovering cursor over the left side of entity, and gun when over right.
Afforess wrote:
If I made it update only update every 5 or 10 ticks, then I would run into the possibility that health or ammo would become out of sync enough that the turret could die,
There is on_entity died event for that.
Afforess wrote:
or ammo run out.
Not that I'd see that as a problem (provided it is not happenning each time turret shoots).
Turret shoots 10 bullets/second, that's 1 clip/second, updates hardly need to happen more often than that, though then it'll need to load more than a single clip per check. With bullet speed upgrades it wastes 2 clips/sec but it's not far-fetched assumption that by the time ammoboxes would be used. (Though I myself am usually against such items.)
By the way, your turrets are not affected by the gun-turret upgrades and thus vanilla overpower them after all upgrades.
The following would put them in upgrades.
require 'util'
for _,tech in pairs(data.raw.technology) do
if tech.effects then
for _,effect in pairs(effects) do
if effect.turret_id and effect.turret_id=='gun-turret' then
local neweff=table.deepcopy(effect)--defined in util
neweff.turret_id='gun-turret-2'
table.insert(effects,neweff)
end
end
end
end
Re: [MOD 0.12.x] AmmoBox
Posted: Mon Aug 24, 2015 6:33 pm
by Afforess
Xterminator wrote:Really cool idea! Having a turret with a built in Logistic request slot is brilliant, and surprised it hasn't been done yet. The ammo boxes are pretty awesome too, especially for turrets.
Mind if I do a mod spotlight on this in the near future?
Sure. You might want to hold off a day or two until I can fix the bugs Adil has mentioned, but absolutely.
Adil wrote:
Afforess wrote:
Absolutely! No reason you can't contribute to the project on github, btw.
Yeah, one day I will get around registering there.
Afforess wrote:
hide the gun while showing it's tooltip, then there will be no reason to have the gun turret placed first anymore.
Tooltip is shown when you select entity. I doubt you can get it from completely hidden object. Suggested selection boxes would just allow you to select chest when hovering cursor over the left side of entity, and gun when over right.
Ahh... I see.
Adil wrote:
Not that I'd see that as a problem (provided it is not happenning each time turret shoots).
Turret shoots 10 bullets/second, that's 1 clip/second, updates hardly need to happen more often than that, though then it'll need to load more than a single clip per check. With bullet speed upgrades it wastes 2 clips/sec but it's not far-fetched assumption that by the time ammoboxes would be used. (Though I myself am usually against such items.)
So basically, I could update the turrets every 30 ticks instead of every tick? Sounds like a good idea.
Adil wrote:
By the way, your turrets are not affected by the gun-turret upgrades and thus vanilla overpower them after all upgrades.
The following would put them in upgrades.
require 'util'
for _,tech in pairs(data.raw.technology) do
if tech.effects then
for _,effect in pairs(effects) do
if effect.turret_id and effect.turret_id=='gun-turret' then
local neweff=table.deepcopy(effect)--defined in util
neweff.turret_id='gun-turret-2'
table.insert(effects,neweff)
end
end
end
end
Very helpful! With all your suggestions, I might just have to cite you as a contributor,
Adil wrote: but it's not far-fetched assumption that by the time ammoboxes would be used. (Though I myself am usually against such items.)
I can definitely see the argument both ways, and I do worry it could be unbalanced. I tried to make the ammo boxes expensive, but I realize that never fully makes up for the extra ammo. I just think this particular case is an exception because Gun Turrets / Regular Ammo are already so underpowered, that a bit of a boost does not hurt.
Re: [MOD 0.12.x] AmmoBox
Posted: Tue Aug 25, 2015 1:37 am
by Afforess
Xterminator wrote:Really cool idea! Having a turret with a built in Logistic request slot is brilliant, and surprised it hasn't been done yet. The ammo boxes are pretty awesome too, especially for turrets.
Mind if I do a mod spotlight on this in the near future?
Issues should be fixed now, feel free to spotlight this whenever you have time.
Many thanks to Aldi for the suggestions & improvements.
Re: [MOD 0.12.x] AmmoBox
Posted: Fri Oct 16, 2015 6:07 pm
by capthavic
Update today broke the mod. Any chance of getting an patch for it?
Re: [MOD 0.12.x] AmmoBox
Posted: Fri Oct 16, 2015 6:50 pm
by Afforess
capthavic wrote:Update today broke the mod. Any chance of getting an patch for it?
I will take a look in a few hours.
Re: [MOD 0.12.x] AmmoBox 0.1.3
Posted: Sat Oct 17, 2015 1:39 am
by Afforess
AmmoBox 0.1.3 is released, fixing the issues introduced in Factorio 0.12.11. For users of previous versions of Factorio, I have added a link to previous releases.
Error while running the event handler: __AmmoBox__/control.lua:133: petroleum-generator doesn't have an inventory with index(1)
A new "Game Breaking Bug", with 12.14
As long as you are on AmmoBox 0.1.4 and Factorio 0.12.15, you shouldn't see this. If you do, provide a save & zip of mods.
Re: [MOD 0.12.x] AmmoBox 0.2.0
Posted: Sun Nov 01, 2015 10:18 pm
by Afforess
AmmoBox 0.2.0 released. Changes:
v0.2.0 (1-11-2015):
Add compressed flamethrower ammo
Holds 100x magazine size of standard flame thrower ammo
Has 2x attack distance of regular flamethrower ammo
Requires Flamethrowers 2 tech to unlock
Added flamethrower 2 tech to unlock compressed flamethrower ammo
Re: [MOD 0.12.x] AmmoBox 0.2.1
Posted: Wed Dec 02, 2015 10:54 pm
by Afforess
Minor patch release 0.2.1. Fixed some missing locale text for gun turret 2 in the tech description.
Re: [MOD 0.12.x] AmmoBox 0.2.1
Posted: Mon Jan 18, 2016 5:49 am
by callmewoof
I appreciate the mod! I was wondering though after looking at the files, is there a reason it needs to be so complicated? Like, what's with the logger stuff? Isn't the principal of requesters built into the base game? I know it isn't literally that simple, but in the end an object is just saying "hey I have 1 requester slot, FYI". I hope that doesn't sound rude, I mean the mod works and again thanks, but what's the hurdle from it being much simpler? I'm sure I'm missing something, probably obvious, so I appreciate if you/anyone can answer. Thanks!