Bay 12 Games Forum

Dwarf Fortress => DF Modding => Mod Releases => Topic started by: zaporozhets on August 14, 2018, 08:29:07 pm

Title: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: zaporozhets on August 14, 2018, 08:29:07 pm
Musket-Mod v0.5c

(https://i.imgur.com/DdyovFy.gif)

Adds a choice of muskets and pistols (and bayonetted versions), blunderbusses and blunderbuss "dragon" pistols, hand mortars, rocket launchers, cannons (with normal cannon balls, explosive shells and chemical cannisters), rapid-fire automuskets and lightning guns to the human civilization, which are all conveniently craftable at your fortress.
It's a WIP, so I'd appreciate it if you let me know what you think or if you find any bugs (I've not done too much testing, but everything seemed to work properly).

(https://i.imgur.com/OK9iO5w.png)
Each weapon category can be enabled or disabled ingame with a menu run from DFhack.

(https://i.imgur.com/m3dBeLF.png)

Muskets

(https://i.imgur.com/W06MDMH.gif)

      Crafting
         To make a musket or a pistol at the gunsmith's workshop, you will need a steel bar, a log, any mechanism and fuel.
         Pistols aren't as good as muskets, but are one handed so can be used with a shield.
      Ammunition
         The bullets themselves are crafted at the gunsmith's workshop in lots of 50 using 1 potash and any type of metal bar.
         This means you must be careful about which stockpiles your ammunition forges take from, but allows you to experiment
         with different types of metal as ammunition or get rid of all that excess zinc and lead. REMEMBER TO SPECIFY THOSE STOCKPILES.
      Bayonets
         Bayonets simply require a steel bar and are both crafted and attached at the gunsmith's workshop. FIX BAYONETS!

Blunderbusses and Dragon Pistols

(https://i.imgur.com/NxduuMC.gif)

      Crafting
         Blunderbusses and their miniature equivalents, dragon pistols, are produced in exactly the same manner as the normal musket and pistol.
      Ammunition
         Both of these weapons take ammunition referred to ingame as 'cartridges', with the reactions taking the same reagents as bullets,
         but producing only half as many rounds. The round will split into 4 pellets of shot upon firing, which will spread out in a haphazard manner.

Rocket Launchers

(https://i.imgur.com/EB5Gr5r.gif)

Rocket launchers now have WIP constructed wall and tree destruction:
(https://i.imgur.com/c5pJyZj.gif)
f*ck nature!

      Crafting
         Launchers are the same as muskets, but no wood and twice the steel and mechanisms, which must be made out of steel.
      Ammunition
         Rockets are much the same as bullets, but can only be made out of steel, need steel mechanism for the fuze and take 3 bars of potash
         to produce only 1 rocket (because they're stupidly OP). Using these will start fires if your map is grassy, be careful!

Hand Mortars

pic coming soon

      Crafting
         Mortars are halfway between muskets and launchers in both effect and construction, requiring two steel bars, a log and any one mechanism.
         Credits to MottledPetrel for the idea.
      Ammunition
         Grenades use a steel bar and mechanism, along with 2 bars of potash, to produce 5 grenades. They're much less powerful than rockets, but
         will still start forest fires if used in a grassy area.

Cannons

(https://i.imgur.com/txESPu6.gif)
They're not quite custom siege engines, but they do the job. Pulpy!
cannons have been much improved since this gif, they're now mostly instantly deadly

      Crafting
         Cannons require blocks and a pipe section.
      Ammunition
         Cannons are workshops that can fire any trap components (spiked balls, serrated discs and so on), but have 3 new types of ammunition: solid cannon balls,
         exploding shells and gas cannisters. Whatever you fire out a cannon, you'll need a bar of potash to make it shoot.
         Cannon balls simply require metal bars of any type.
         Explosive shells require steel bars, a mechanism for the fuze and a bar of potash for the explosion. Will start forest fires!
         Gas cannisters have been temporarily removed due to native venoms not being inhalable, making them useless. Currently being reworked.

Automuskets

(https://i.imgur.com/VB3eQVZ.gif)
this kills the crab

      Crafting
         Same as a musket, but twice the amount of steel and mechanisms.
      Ammunition
         Fires normal musket bullets, but will chew threw them very quickly and with less accuracy than a musket.

Lightning Guns

(https://i.imgur.com/KhBwT3S.gif)
UNLIMITED POWER!

      Crafting
         Lightning guns are experimental weapons that are extremely deadly but can sometimes injure the user with little chance of recovery.
         Made out of a blunderbuss, 2 mechanisms and a copper bar at the Alchemist's Laboratory.
      Ammunition
         Each lightning bolt consumes 1 voltaic cell, also produced at the Laboratory from a copper bar and a zinc bar in lots of 50.


Credits (in alphabetical order, let me know if I've missed you out):
 expwnent
 Fleeting Frames
 Lethosor
 Michael_Almeida
 MottledPetrel
 PeridexisErrant
 Putnam
 Roses
 sponge
 squamous
 thefriendlyhacker
 Warmist
whose works and/or guidance served as a valuable reference.

big thanks to:
 Grimlocke
for many brilliant improvements and suggestions
 Jake
this mod is based on his excellent (and far more realistic) mod BPFA
 John Acar of juniorgeneral.org
 meph
 Vordak
for the use of their sprites.

special thanks to:
 toady
for creating DF

Link:
http://dffd.bay12games.com/file.php?id=13964
This mod is heavily WIP, test at your own peril.

Changelog:
0.5c fixed blunderbuss errors and added WIP rocket launcher wall breaching
0.5b fixed some raw errors (thanks to DWARFFRAWD and Sver)
0.5  updated for Meph tileset V4.2
     added Alchemist's Laboratory and reimplemented chemical weapons
     added lightning gun
     added new ammo sprites and retouched weapon sprites
     improved cannon reactions (firer will now wait for target and fire at will), fixed targetting distance error and made rotation compatible with other mods with much assistance from Grimlocke
     merged weapon scripts preventing them tripping up over each other
     tweaked automusket to use regular bullets, lowered smoke amount and slightly increased accuracy
     increased number of blunderbuss pellets from 4 to 6
     slightly increased rocket explosion size and made flight path become unpredictable after 30 tiles of flight
0.4i updated for Meph tileset V.4
0.4h made cannonball more effective (thanks to Grimlocke)
     fixed automusket listener name error
0.4g tweaked cannon pathing algorithm to be more accurate
     rolled back settings manager changes due to arena mode scripts not firing
0.4f added automusket
     tweaked settings manager to try and lower overhead whilst retaining arena mode functionality
0.4d added cannon rotation, separate fire and load reactions at Grimlocke's suggestion, also native-like announcements
     added Vordak's cannon sprites
     added cave-in dust concussion effect to hand mortar grenades
     fixed blunderbuss ammo name error
     attempted to make normal cannonballs more deadly by increasing velocity & velocity multiplier
0.4c added blunderbuss and dragon pistol
0.4b moved reactions into appropriate workshop categories
0.4  added ingame customization menu letting users select which weapons appear in fortress mode
     added Vordak's weapon sprites
     added Gunsmith's workshop (sprite by Meph) so as to not gum up the metalsmith's menu with reactions.
     added flintlock pistols and bayonets
     added notification when cannon user cannot find valid target
     added new reaction to cannon to allow targetting of helpless domestic animals for test-firing
0.3c added gun carriage to cannon sprites and changed skill used by firearms to blowgun, as per Vordak's advice
0.3b added hand mortars at the request of MottledPetrel
0.3  initial release
Title: Re: Musket-Mod v0.3
Post by: MottledPetrel on August 14, 2018, 10:04:35 pm
Please, make a hand mortar, it's my favorite black powder fire arm.
Title: Re: Musket-Mod v0.3
Post by: zaporozhets on August 15, 2018, 04:32:35 am
Please, make a hand mortar, it's my favorite black powder fire arm.

Added it.
This is the best I could do for the graphic, I'm no pixel artist by any means:
(https://i.imgur.com/CdmRyBC.png)

I'll update the OP with a gif and info at some point in the near future, I've made it a sort of intermediate between the musket and the launcher.
It has the muzzle smoke of the musket and a smaller impact explosion than the launcher, but grenades can be produced faster and with less cost than rockets. Still causes fires though.
Let me know what you think, I'm guessing there may be bugs due to me rushing it out because of a mistake in the readme I wanted gone.
Title: Re: [44.12] Musket-Mod v0.3b
Post by: Vordak on August 15, 2018, 06:07:29 am
I think that for gunpowder and any new ranged weapons need to use the skill BLOWGUN - this will allow to draw graphics for rifledwarves, it will allow a clear distinction between different types of ranged military. Besides, dwarves (players) do not use blowguns.

Upd.
(https://i.imgur.com/Cqs9oVZ.png)
Title: Re: [44.12] Musket-Mod v0.3b
Post by: SpeardwarfErith on August 15, 2018, 09:51:38 am
This is ridiculously cool. I am especially impressed by the rocket launcher and the smoke effects.
Title: Re: [44.12] Musket-Mod v0.3b
Post by: zaporozhets on August 15, 2018, 12:10:07 pm
I think that for gunpowder and any new ranged weapons need to use the skill BLOWGUN - this will allow to draw graphics for rifledwarves, it will allow a clear distinction between different types of ranged military. Besides, dwarves (players) do not use blowguns.
Upd.

You make a good point, changed the skill used by handheld weapons to blowgun.
Your rifledwarf sprite is impressive, I don't suppose you have any musket item sprites you don't mind me using?
I'd be sure to credit you. Would be much better looking than me just mashing together stuff from metal slug.

This is ridiculously cool. I am especially impressed by the rocket launcher and the smoke effects.

I'm glad you like it! The handheld weapons use very simple scripts, I was surprised I hadn't seen anyone do it before.
The cannon was much more difficult for me to make, but everyone seems to like the rocket launcher the most. Oh well. ¯\_(ツ)_/¯
Title: Re: [44.12] Musket-Mod v0.3b
Post by: SpeardwarfErith on August 15, 2018, 12:53:22 pm
I'm glad you like it! The handheld weapons use very simple scripts, I was surprised I hadn't seen anyone do it before.
The cannon was much more difficult for me to make, but everyone seems to like the rocket launcher the most. Oh well. ¯\_(ツ)_/¯

Heh, I just haven't had a chance to try the cannon out yet. I think the reason people haven't done this sort of thing before is because using a script adds more overhead to the mod, though imo the extra possibilities are definitely worth the complexity.
Title: Re: [44.12] Musket-Mod v0.3c
Post by: Vordak on August 15, 2018, 01:12:30 pm
Your rifledwarf sprite is impressive, I don't suppose you have any musket item sprites you don't mind me using?
I'd be sure to credit you. Would be much better looking than me just mashing together stuff from metal slug.
(https://i.imgur.com/FJ2u2iY.png)
It's just the sprite of your gun rotated by 45 degrees. Use if necessary, credit do not need.

I think portable rocket launchers are too much - in my opinion it is better to make it as a siege weapon - it's just a wish. Better it would be something like mortars.
Title: Re: [44.12] Musket-Mod v0.3c
Post by: Meph on August 15, 2018, 01:22:25 pm
Why not a flamethrower?  Adding firebreath to the wielder shouldn't be too hard.
Title: Re: [44.12] Musket-Mod v0.3c
Post by: SpeardwarfErith on August 15, 2018, 03:15:34 pm
Why not a flamethrower?  Adding firebreath to the wielder shouldn't be too hard.

The rocket launcher is everything you could ever hope for in a flamethrower, and more.
Title: Re: [44.12] Musket-Mod v0.3c
Post by: Grimlocke on August 15, 2018, 07:21:59 pm
Oooh, interesting. Especially like how you added smoke. I might try and adapt these scripts to my own mod in the future.
Title: Re: [44.12] Musket-Mod v0.3c
Post by: zaporozhets on August 16, 2018, 05:53:34 am
It's just the sprite of your gun rotated by 45 degrees. Use if necessary, credit do not need.

I think portable rocket launchers are too much - in my opinion it is better to make it as a siege weapon - it's just a wish. Better it would be something like mortars.

They're wonderful! Thank you.

You're right about the rocket launchers, I thought many times about making them fixed like the cannons. They were initially just made as an experiment, but when I expressed apprehension to the people I showed it to they were citing Congreve rockets and Chinese fire arrow launchers as to why they should stay in.

I couldn't show people that gif and then deny it to them, when I myself have been annoyed at other mod makers teasing and then never delivering.
If it makes people happy, I can ignore my feelings of wanting to maintain balance, plus the expense of each rocket, forest fires, melted goblinite and occasional friendly fire are at least some downsides to using it.

Eventually, I plan on making an installer with Rubble or mod-manager or something to let users choose what gets put ingame.

Why not a flamethrower?  Adding firebreath to the wielder shouldn't be too hard.

I did consider adding a flammenwerfer as a ranged weapon, but thought it would be impossible to ensure they get in range before firing it and scrapped the idea. I hadn't even considered using firebreath, I'll have a mess around and see. Thanks for the idea.

Oooh, interesting. Especially like how you added smoke. I might try and adapt these scripts to my own mod in the future.

I look forward to seeing what you get up to with them if you do. If you plan on using the cannon and have any difficulties with ripping chemical and explosive rounds out of the code, or whatever really, don't hesitate to ask. I didn't add many comments, you see.
Title: Re: [44.12] Musket-Mod v0.3c
Post by: Meph on August 16, 2018, 06:16:15 am
You could make the distinctions i made in MasterworkDF: pistol, one handed, musket, two handed. Both in normal and in a bayonetted version.
Title: Re: [44.12] Musket-Mod v0.3c
Post by: zaporozhets on August 16, 2018, 11:34:40 am
You could make the distinctions i made in MasterworkDF: pistol, one handed, musket, two handed. Both in normal and in a bayonetted version.

Yeah, I really like playing as the human civ in Masterwork, that's part of what made me want muzzle smoke in the first place.

The only reason I haven't added stuff like that yet is that the mod just adds all the reactions to the root of the metalsmith's forge menu for now (owing to my inability to make a satisfactory custom gunsmith workshop) and I was worried about cluttering it up with too many different-but-similar weapons. Same reason the musket reaction insists on steel rather than having separate reactions for each capable metal like in Masterwork.

I eventually hope to make it so barrels are made at the forge, stocks made at either the carpenter's or bowyer's and assembly done at the gunsmith's, where I'll have lots of room for different weapons (maybe in different categories if it's possible) and affixing bayonets and stuff. Make them much more labour-intensive to produce than crossbows.
Title: Re: [44.12] Musket-Mod v0.3c
Post by: Meph on August 16, 2018, 02:35:00 pm
Well, well, a custom gunsmith you say?  8)

(https://i.imgur.com/Z2jHbKo.jpg)
Title: Re: [44.12] Musket-Mod v0.3c
Post by: zaporozhets on August 21, 2018, 12:19:52 am
Well, well, a custom gunsmith you say?  8)

Added it along with some other fixes, thanks again.
Still struggling with a native-like custom sidebar for different categories and metals like the metalsmith's, so I figured I'd just lump everything into it for now whilst I work on it.

Edit:
Just figured out reaction categories are now a thing, I'm an idiot. I'll add reactions for metals other than steel when I'm able.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: Meph on August 22, 2018, 08:48:44 am
Will you ever do grenades or landmines?
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: MottledPetrel on August 22, 2018, 02:50:36 pm
What are some of those sprites on the original post that aren't yet in the mod? That harpoon with an (what I assume to be) explosive charge looks interesting.

And for more suggestions, how about a nock gun? I have no idea if you can script a gun that fires seven shots at once, but it would be pretty cool. And if you manage to figure that out, making a duck's foot pistol wouldn't be that different. A blunderbuss could be made in similar effect, albeit much more inaccurate, short ranged, and devastating. To a similar effect, a grapeshot charge would be good for cannons when your target isn't an elephant. For the elephants an elephant gun for excessive caliber needs. A double barrelled turn over pistol could be used for two quick shots followed by an extended reload time. A french knife pistol could be exactly what it says on the tin, a well crafted knife with a usable pistol built into it. But at the very least, I would STRONGLY recommend the German axe pistol.

Having little prior knowledge of scripting, I don't know how many of these can actually be done or are practical to do, but I just thought I'd give some ideas. All suggestions are based off of real fire arms from the 1800's or prior.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: zaporozhets on August 22, 2018, 04:12:09 pm
Will you ever do grenades or landmines?

My understanding of traps is that they use the trap weapon as a very short range projectile when triggered, if that is correct, an explosive shell used in a trap should be picked up by the cannon script and trigger an explosion.

I can't think of a fast way of testing this, however. I'll use some shells in my traps, wait for a siege and let you know when I get a result either way.

As for grenades, the hand mortar already fires 'grenades' (though I'm not happy with how they currently perform and am experimenting with a cave-in dust concussion effect to replace or go alongside the current bang), but I could add a 'grenade bag' ranged weapon so they could be 'thrown' in fortress mode. I'd have to think through a way to balance it against the mortar and make it distinct enough before adding it.

One possible way would be to remove the original grenade projectile after firing and replace it with a clone that is less accurate and has less range (but that could mean dwarves throwing grenades at too distant targets).
I'm trying to do something similar with the WIP blunderbuss where I need to replace a 'cartridge' with multiple weaker 'pellet' projectiles that can't be re-used.

I've been thinking about the flamethrower you asked about previously, too. Looking at the spellcrafts mod it seems possible to add firebreath to a dwarf when a (secretly melee weapon) flamethrower is in their inventory, but the overhead might be high as the script would perform the check whenever anybody changed anything in their inventory. Not sure if I'll get round to doing this one given the drawback but it's on the to-do list nevertheless.



What are some of those sprites on the original post that aren't yet in the mod? That harpoon with an (what I assume to be) explosive charge looks interesting.

That's the ammo for the rocket launcher, I'm afraid. It looked like a Congreve rocket to me, so I used it for that. All the sprites on that pic are ingame, unless I've made a horrible mistake. ;D

And for more suggestions, how about a nock gun? I have no idea if you can script a gun that fires seven shots at once, but it would be pretty cool. And if you manage to figure that out, making a duck's foot pistol wouldn't be that different. A blunderbuss could be made in similar effect, albeit much more inaccurate, short ranged, and devastating.

As fascinating as the nock gun is (I'd never heard of it although there is something that looks similar in a Mount and Blade mod) I probably wouldn't want too many similar weapons as I'm already working on a blunderbuss, as I mentioned in my reply to Meph. It's firing multiple shots well enough, but currently acts as an infinite ammo generator.
I hadn't considered a blunderbuss pistol but it's so effing metal that I'll have to add it once I work the bugs out of the blunderbuss, might call it a 'dragon pistol' to keep the name concise, what do you think?

To a similar effect, a grapeshot charge would be good for cannons when your target isn't an elephant. For the elephants an elephant gun for excessive caliber needs. A double barrelled turn over pistol could be used for two quick shots followed by an extended reload time. A french knife pistol could be exactly what it says on the tin, a well crafted knife with a usable pistol built into it. But at the very least, I would STRONGLY recommend the German axe pistol.

Grapeshot shells for cannons is a great idea, I'll put it on my to-do list. I'm slightly angry at myself it didn't dawn on me at all when messing about with the blunderbuss. What a brilliant suggestion!
Not sure about the elephant gun and turn-over pistol as I don't know how to balance them against normal muskets and pistols, I wouldn't know how to change reload times beyond deleting every other shot and re-adding it to the firers inventory.
They're also quite similar to the existing weapons, as is the knife pistol, and it bothers me somewhat to have almost-duplicate weapons.
I hope that doesn't disappoint you too much. An axe pistol is very cool and distinct and could be included with the bayonets, added it to my list. Thanks.

Having little prior knowledge of scripting, I don't know how many of these can actually be done or are practical to do, but I just thought I'd give some ideas. All suggestions are based off of real fire arms from the 1800's or prior.

I appreciate your ideas, all these obscure firearms you know about are a great inspiration. I forgot to add you to the actual credits when I added the hand mortar (but credited you in the readme), my apologies, I'll do so with the next version.
I do hope my feelings of wanting to retain simplicity and abstraction in terms of the weapon categories don't disappoint you (or Meph) too much.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: Meph on August 22, 2018, 04:36:56 pm
Maybe make the flamethrower like the cannon?  Triggers dragonfirebreath in a cardinal direction when used?

Your understanding of traps is correct. I did bombs in masterwork like that using the projectile-trigger script. The other Form of landmine was a creature using a short range interaction. That gave invaders the Chance to disable them with ranged weapons, but also enabled wonderful murder holes just like in RL.

Make gate, inner gate, trap invaders in between. One zlvl above, pit/pasture the landmine down a hatch into the room below. :-)
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: zaporozhets on August 22, 2018, 05:56:20 pm
Maybe make the flamethrower like the cannon?  Triggers dragonfirebreath in a cardinal direction when used?

The problems with using dfhack.maps.spawnFlow are: I don't know how to make directed jets (like firebreath or webs) or trailing flows (might be useful for gas cannisters). Even if I did, if used with a 'melee' flamethrower the flow wouldn't trigger unless the opponent was adjacent to the wielder, and a 'bow' flamethrower would have to much range and dwarves would just sit there impotently spraying fire.
That's why I discounted the idea of a flammenwerfer originally and very much liked your suggestion of temporarily imparting a breath attack to the wielder.

Edit:
Wait, did you mean making the flamethrower a pseudo siege engine like the cannon?

Your understanding of traps is correct. I did bombs in masterwork like that using the projectile-trigger script. The other Form of landmine was a creature using a short range interaction. That gave invaders the Chance to disable them with ranged weapons, but also enabled wonderful murder holes just like in RL.

Make gate, inner gate, trap invaders in between. One zlvl above, pit/pasture the landmine down a hatch into the room below. :-)

If it's already possible to create landmines using the existing exploding shells, would you want an explicit landmine trapcomp even if it was just a copy of the shell? Duplicating an existing weapon goes against my sensibilities personally and I like the idea of leaving it to the ingenuity of the player, but I'd be more than happy to add it in if it makes things nicer for you. That's why I added the settings menu.

Solved the blunderbuss infinite ammo bug by making the pellets a new ammo subtype that can't be fired by anything if they survive impact.
Just trying to decide on the number of pellets to be fired, whether they should be deleted or remain to be melted into new ammo (potentially taking up ammo stockpile space) and whether the spread should be videogame-esque with a very wide shot pattern or more realistic, tighter and deadlier (might be OP).
Anyone have any opinons?

Edit:
This is 4 pellets with a spread of '20' for reference.
(https://i.imgur.com/T0XKocH.gif)
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: MottledPetrel on August 22, 2018, 06:23:05 pm
In real life the nock gun and the blunderbuss aren't that similar. The nock gun is intended to allow a single gunner to fire a musket volley that would normally take 7 men, and then it turned into a weapon for taking out men in hallways when boarding a ship. The blunderbuss on the other hand is more apt to just create a giant cloud of shrapnel that destroys anything in close range, obviously depending on whether you use actual ball ammo or just fill it with nails or other random metal, which you can do with little problem. In DF though, I would agree that they are probably going to have to be pretty similar. Blunderbuss pistols are a thing that exist, and they're just called blunderbuss pistols. The closest thing you're going to find to a dragon pistol are the old smooth bores that they used to make, which they loved to put dragon heads on the end of when they could afford it. The japanese were a little late to pick up gunpowder as a weapon, so they didn't make much before moving to more modern designs. Or, you could go all the way back to the chinese who were the first to use gunpowder for weaponry. After they discovered they could use fireworks as artillery, they made the first prototype cannons, which often had dragons heads on them. Their clashes with the western world eventually introduced these prototype cannons to the Europeans, who perfected it and eventually made smaller hand held versions that became muskets. Most of that probably won't help you, but it's interesting trivia. You might be able to make some kind of custom 'siege engine' called a missile launch ground, and have it fire some old style chinese artillery fireworks though.

I would think that the elephant gun would just be a much heavier, more unwieldy, but much more powerful version of the musket. I was under the assumption that you could change reload time and shot frequency with dfhack, but if you can't then there is probably little you can do for the turnover pistol. For the French knife gun, I was just thinking a standard knife with the ability to shoot a very light shot for the stealthy types. It's fine if you don't want it, I'm just trying to suggest some more unique fire arms so that it doesn't end up being 50 rifles that are slightly different from each other, which is mostly how gunsmithing of that time went.

For future suggestions, I'm assuming you don't want me to go beyond the invention of percussion caps, right? Some of them still used loose gunpowder and a separate ball shot, but that tends to mark the point between old style fire arms and the newer stuff.

I'd also say maybe go for a revolver rifle, but if you can't edit firing speed and reload time there isn't much of a point.

Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: SpeardwarfErith on August 22, 2018, 06:37:37 pm
The problems with using dfhack.maps.spawnFlow are: I don't know how to make directed jets (like firebreath or webs) or trailing flows (might be useful for gas cannisters).

My time to shine!

I have spent the last several days messing around with flows, first in an attempt to spawn webs for barbed wire (a partial success, but only with the help of 2 different scripts and it isn't effective enough to matter) and then in an attempt to make a 1-tile creature look like a sandworm (works really well, but since it fires every 5 ticks regardless of whether there's a worm or not it adds too much overhead to be practical).

Anyways, I have had the displeasure of getting to know the internal workings of flows better than I would like to. You can create aimed flows by spawning the flow, and then setting the destination of that flow to whatever you want while it's still only 1 tile big. This doesn't work with everything- I know that it works with dragonfire and webs, but not with MaterialGas. I don't know about the other flows, but I suspect you can find out what how to do trailing flows by examining the flows that come out of creatures that have that interaction

EDIT:
also, if MottledPetrel is correct when he says that
you could change reload time and shot frequency with dfhack
I would be interested in knowing how. I've spent more hours than I'd like to admit going through the data structures, trying to find some cooldown variable.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: zaporozhets on August 22, 2018, 07:07:36 pm
It is interesting trivia, I'm lucky to have someone so knowledgeable on the subject to help me.
Any time period is fine, really, I'm not going for real-world historical accuracy at all and I wouldn't expect technological progression to follow our world anyway, so percussion cap stuff is good too.
For player ease-of-use and my own compulsions everything is quite abstract which hopefully allows people to imagine the level and style of tech they're happy with for their world. In my headcanon the 'muskets' use jacketed bullets filled with the potash "gunpowder" for example (I know it's stupid  ;)).

I saw a blunderbuss pistol on wikipedia found at a battlefield in Mexico referred to as a dragon, that's the only reason I suggested it, it does conjure up more oriental-oriented visions than I was intending.
I just needed a more concise name as it gets abbreviated on the menus, which I don't like. Probably going to change 'flintlock pistol' to simply 'pistol' for the same reason. I googled 'shot-pistol' but apparently that refers to derringers. Not sure what to call them.

I have spent the last several days messing around with flows, first in an attempt to spawn webs for barbed wire (a partial success, but only with the help of 2 different scripts and it isn't effective enough to matter) and then in an attempt to make a 1-tile creature look like a sandworm (works really well, but since it fires every 5 ticks regardless of whether there's a worm or not it adds too much overhead to be practical).
I'd be interested to see the sandworm script, I was messing about with multi-tile giant snakes by chaining the positions of multiple creatures which worked well but fired every tick and would need seperate raw definitions for the different bits so the snake didn't have multiples of every organ. Your method sounds much better! Are you working on a Dune mod?

Anyways, I have had the displeasure of getting to know the internal workings of flows better than I would like to. You can create aimed flows by spawning the flow, and then setting the destination of that flow to whatever you want while it's still only 1 tile big. This doesn't work with everything- I know that it works with dragonfire and webs, but not with MaterialGas. I don't know about the other flows, but I suspect you can find out what how to do trailing flows by examining the flows that come out of creatures that have that interaction

Ah, interesting! Does maps.spawnflow return the flow then? I've never even checked.
Edit:
It does!
Do you know if the size of the flow matters with regards to maximum range?
I guess I just need to have a play around with it. Thanks for your help.

I would be interested in knowing how. I've spent more hours than I'd like to admit going through the data structures, trying to find some cooldown variable.

I did find something when looking at how squamous made different mechs have different fire rates in his mod Mechanized Warfare, the mechs are creatures and have tags in the raws like [CDI:WAIT_PERIOD:30] I think are being used to control the rate. I don't know if you could change the dwarfs raws on an individual basis though, I'm not experienced enough with dfhack.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: SpeardwarfErith on August 22, 2018, 08:33:56 pm

On mobile so I gave up formatting quotes.

Sandworm: I don't have the script immediately available atm, but I got out the easy way using this script- Sandworms are burrowing creatures, and only ever leave their head exposed above the sand. The worm itself is a simple (albeit massive) creature, but it spawns a long wormsign behind it that looks really cool as it moves. The wormsign is just a bunch of gas flows that are immediately altered to not expand, and their density is constantly multiplied by a factor that controls how long the wormsign is. Note that the wormsign is usually much longer than it is in the picture now, probably 15-25 blocks. The wormsign is sadly only visible when the worm moves, though you can change that very easily by storing the individual flows that make it up in an array and giving them a constant density. I'm not working on a full-blown dune mod, mostly just the sandworms. Because sandworms are cool. 
(https://i.imgur.com/b2QB1Vj_d.jpg?maxwidth=640&shape=thumb&fidelity=high)

Range of flows: I don't actually know that much about how the spawnflow function works so idk exactly what size does. I know density of the flow controls range, but returns very much diminish. I suggest constantly multiplying the density to make it go down slower since it doesn't decrease linearly.

As for the mechs, I'm not that well versed in raws but I'm pretty sure that's an interaction token, so it isn't actually relevant for bow/gun firing rate (though you can simulate a machinegun or whatever by just giving the creature an interaction)
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: zaporozhets on August 22, 2018, 09:31:28 pm
I'm not working on a full-blown dune mod, mostly just the sandworms. Because sandworms are cool.

Yes they are. I can't lie that I'm not disappointed, it would be amazing to play Dune Fortress. I have visions of assigning collection zones over a spice patch.
I'd think about doing it myself but raw editing has been a pain even for the limited stuff I've managed to do for the guns, I'm not capable of something as complex as a full overhaul.
Your approach to the Shai-Hulud is very clever, thanks for sharing.

Range of flows: I don't actually know that much about how the spawnflow function works so idk exactly what size does. I know density of the flow controls range, but returns very much diminish. I suggest constantly multiplying the density to make it go down slower since it doesn't decrease linearly.

You're clearly are more informed than myself on the subject, I'm thinking of changing the muzzle smoke to use directed flows if it works like I think it does. My current system of spawning undirected flows of increasing-size is so primitive in comparison. Edit: Doesn't seem like I can direct smoke but with what you've told me, I can make chemical cannisters for the cannon more effective (and more importantly, cooler-looking). Again, thanks for the help.

As for the mechs, I'm not that well versed in raws but I'm pretty sure that's an interaction token, so it isn't actually relevant for bow/gun firing rate (though you can simulate a machinegun or whatever by just giving the creature an interaction)

I see. I vaguely remember reading a certain skill might have a bearing on fire rate, whatever it was could be temporarily manipulated to modulate the rate to the desired amount.
Failing that, you could take the naive approach and use something similar to the blunderbuss script I'm working on to increase the rate by having multiple projectiles be created (but with a delay between each one), or lower it by deleting every other (or every third and so on) and adding ammo back into the inventory.
Sorry I couldn't be more helpful to return the favour.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: scourge728 on August 22, 2018, 09:54:01 pm
Very Interesting...
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: zaporozhets on August 23, 2018, 12:41:00 am
I'm an idiot, I didn't realize gas cannister liquids had to have the [SYN_CONTACT[ or [SYN_INHALED] tags for them to have any effect. Makes chemical weapons pretty useless when used with almost all of the native liquids.

I guess I'll eventually have to try and add some raws for new ones and a maybe a laboratory to make them in. There are plenty of effects to choose from, but deciding on names and reagents will be difficult.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: Prismaa on August 23, 2018, 01:38:13 am
I take it this works with Meph's launcher thingy?
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: Meph on August 23, 2018, 02:10:02 am
Oh god.

DF. Dune Fortress.

Dont give me ideas.

(yes, i meant like a siege engine flamethrower, maybe triggered by a lever or pressure plate)
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: zaporozhets on August 23, 2018, 07:54:00 am
I take it this works with Meph's launcher thingy?

Should do. If you have any problems let me know.

Oh god.
DF. Dune Fortress.
Dont give me ideas.
(yes, i meant like a siege engine flamethrower, maybe triggered by a lever or pressure plate)

I know right. Fortress, Sietch, what's the difference really?

That might be best for a flamethrower actually, would stop most of the accidents with forest fires & immolation of friendlies if the "splash zone" was a controlled environment as well as side-stepping the range bugs and problems with inventory checking.
Cool (or very hot) idea, makes me think of the tunnel flamethrower in Metro 2033.

Not sure how feasible it is to implement support for levers and pressure plates, however.
It seems possible (looking at scripts/lever.rb) to poll the levers to see if they're pulled (and thus presumably plates) every 100 ticks to sort of achieve a native-like effect, but I don't yet know how I would go about linking the thing to one lever specifically without doing something silly like making the flammenwerfer a door.
Something hacky might have to be done like make it spawn a gear assembly building upon a "prepare for linkage" reaction, linking the lever to the assembly, if possible transferring its mechanism link to the 'siege engine', storing the lever id in a table for manual polling) and then removing the assembly it to allow native lever linking behaviour.

Hopefully someone smarter than myself can think of a better way before I bungle it.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: Meph on August 23, 2018, 10:45:48 am
Ask warmist. He made something like that looong ago, but it was never really released.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: thefriendlyhacker on August 23, 2018, 11:45:21 am
...
also, if MottledPetrel is correct when he says that
you could change reload time and shot frequency with dfhack
I would be interested in knowing how. I've spent more hours than I'd like to admit going through the data structures, trying to find some cooldown variable.
...
As for the mechs, I'm not that well versed in raws but I'm pretty sure that's an interaction token, so it isn't actually relevant for bow/gun firing rate (though you can simulate a machinegun or whatever by just giving the creature an interaction)
I see. I vaguely remember reading a certain skill might have a bearing on fire rate, whatever it was could be temporarily manipulated to modulate the rate to the desired amount.
...
Sorry I couldn't be more helpful to return the favour.
Ooh, ooh, ask me, ask me, I know things!

The variable (Firing Unit).counters.think_counter is set whenever a ranged weapon is fired.  The variable is set to a number that is related to a creature's weapon skill (agility and ranged combat don't appear to do anything, haven't checked any other attributes), and will lie somewhere between 80 (dabbling) and 40 (an obscenely high legendary rating), with 48 being the practical limit for legendary weapon users.   Once set, the variable ticks down until it reaches 0, at which point the creature can fire again that tick.  Adjusting the think_counter variable of a creature with dfhack will directly adjust the time until the creature fires again.
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: SpeardwarfErith on August 23, 2018, 11:57:40 am
Ooh, ooh, ask me, ask me, I know things!

The variable (Firing Unit).counters.think_counter is set whenever a ranged weapon is fired.  The variable is set to a number that is related to a creature's weapon skill (agility and ranged combat don't appear to do anything, haven't checked any other attributes), and will lie somewhere between 80 (dabbling) and 40 (an obscenely high legendary rating), with 48 being the practical limit for legendary weapon users.   Once set, the variable ticks down until it reaches 0, at which point the creature can fire again that tick.  Adjusting the think_counter variable of a creature with dfhack will directly adjust the time until the creature fires again.

holy crap, I remember looking at that counter. I never even bothered considering messing with it, I immediately assumed it was related to how long until the creature can get another thought. You, sir, are a life saver. This opens up so many possibilities...
Title: Re: [44.12] Musket-Mod v0.4b (Now with ingame customization menu!)
Post by: Meph on August 23, 2018, 01:33:30 pm
...

Miniguns.

Quick-fire crossbows.

Differences between bow types.

Awesome!
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 23, 2018, 06:21:49 pm
Added blunderbuss and blunderbuss pistol (I'm still confused as to whether calling it a dragon is correct or not but hey-ho).
Feedback would be appreciated, not sure if I got the feel right with only 4 pellets. Was thinking about balance and performance.

Thanks for the info about Unit.counters.think_counter, thefriendlyhacker. So much potential for new weapons!
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: MottledPetrel on August 23, 2018, 07:23:27 pm
You can call it a dragon pistol, an in-game name doesn't have to be accurate to a pinpoint. Also, for people who aren't familiar with fire arms it would probably be like naming a standard flintlock pistol a 'musket pistol'.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: thefriendlyhacker on August 23, 2018, 08:53:50 pm
...
Thanks for the info about Unit.counters.think_counter, thefriendlyhacker. So much potential for new weapons!
I was planning on writing a rate of fire script myself at some stage, when I wasn't busy with other stuff.  But if you want to beat me to it (and let me "borrow" it), I will not be complaining.
...

Miniguns.

Quick-fire crossbows.

Differences between bow types.

Awesome!
Not only that, but if the script kept track of when/how many times a creature fired recently, it would be possible to have burst weapons.  You could also combine it with the multi-projectile shot script zaporozhets has for fun things like quad barrel or mag fed automatic shotguns with appropriate reload delays.

If you wanted a work around for limited ammo capacity on high ROF weapons like miniguns that would burn through the ~50 round capacity of a quiver rather quickly, you could likewise use the multi-projectile shot script to turn an "ammo belt" projectile into multiple normal projectiles.  Combine with a hypothetical ROF script to taste.  Yes, I have put a bit of thought into this.

While I am posting, here is a question.  Would it work if you created more projectiles on a projectile weapon's impact to simulate a fragmentation explosive?  That was an idea I came up with a while back, but I never got around to looking into the implementation details seriously.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 23, 2018, 11:42:06 pm
I was planning on writing a rate of fire script myself at some stage, when I wasn't busy with other stuff.  But if you want to beat me to it (and let me "borrow" it), I will not be complaining.

I'm quite eager to get started on implementing inhalable chemicals to use in gas cannisters and adding directed flows, I wasn't really planning on going further with fire rates right now.
The way I thought of doing it was just setting the think_counter when projectile.distance_flown == 0 (after an ammo type check ofc). Should be super simple once appropriate values are figured out.
I made an automusket just for fun though. www.pastebin.com/cXPpTvjL

(https://i.imgur.com/iAWQg7F.gif)
makes me long for a dieselpunk industrial warfare mod set in the future of the DF universe

I'd like to see what other people come up with really, I'm quite inexperienced so more things to reference would be great. Just general scripting practices, you know. I could see where I've done silly things.

While I am posting, here is a question.  Would it work if you created more projectiles on a projectile weapon's impact to simulate a fragmentation explosive?  That was an idea I came up with a while back, but I never got around to looking into the implementation details seriously.

I can't see why it wouldn't, but my foresight usually leaves much to be desired.
Would look and read great with some flow effects and a custom ammo for it "urist is caught in a burst of boiling iron" then "the iron fragment strikes urist in the lower body, tearing the guts!"
Just create a bunch of projectiles with a loop like the blunderbuss does (but onProjItemCheckImpact like the rocket launcher explosion) and use the rng to set their target_pos. And thanks again for sharing, it's one of those things that people have always said is impossible.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Grimlocke on August 24, 2018, 01:27:57 am
Ooh, someone's finally gone and done this.

thefriendlyhacker's info should also let me reduce firing rate of the handcannons and arquebusses I have laying around from way back which is arguably less exciting than making machine guns but will actually let me fit them in with armor and crossbows balance-wise. Soooo, cool!

I've been tinkering with the cannon, and I think it should be feasible to make a gun that just shoots solid cannonballs and grapeshot as well as an (also stationary) organ gun. (something something check the input item type and loop the projectile function a bunch of times)
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 04:03:04 am
thefriendlyhacker's info should also let me reduce firing rate of the handcannons and arquebusses I have laying around from way back which is arguably less exciting than making machine guns but will actually let me fit them in with armor and crossbows balance-wise. Soooo, cool!

My first thoughts were along the same lines; finally being able to balance modded ranged weapons with native ones is just as important a part of thefriendlyhacker's discovery, I'd be interested to see your decision on the bolts-to-bullets fired ratio.
I do hope to see people making UZIs and other crazy things, too.

I've been tinkering with the cannon, and I think it should be feasible to make a gun that just shoots solid cannonballs and grapeshot as well as an (also stationary) organ gun. (something something check the input item type and loop the projectile function a bunch of times)

Have you had any problems with it? I've not had anyone report bugs which is quite strange.
I know they sometimes try and fire through closed doors if the nearest enemy is behind (they don't yet check for buildings on a tile) but I want to know if I should make the make the pathing function parameter dynamic, so as to be more reliable in choosing a clear path (at the expense of more overhead).
Has it worked well enough for you?

I agree with your thoughts, seems very feasible! Were you thinking of making it fire item_ammo (item_ammos?), or use a different method of stopping trapcomp fire altogether?
A static organ gun is a rad idea, much better than the affront to native balance I posted above.
I'd like to do something similar but with a lower fire rate than an organ gun firing weak rockets that veer away and oscillate at random to make a katyusha/nebelwerfer/hwacha thingy as a more sane version of the rocket launcher.

I said it before, but I look forward to seeing the fruits of your tinkering.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Meph on August 24, 2018, 04:16:30 am
Have you thought about less RL weapons and more in the line of magic weapons? 

Staff of fireball = rocket launcher alternative that fits df.

Or spelltome of rock barrage = shotgun-like effect.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 06:08:47 am
Have you thought about less RL weapons and more in the line of magic weapons? 

Staff of fireball = rocket launcher alternative that fits df.

Or spelltome of rock barrage = shotgun-like effect.

It's not something that's popped into my head really, I'm afraid. Magic just doesn't seem too dwarfy to me is the only reason I can think of as to why that is. In my headcanon they're more like the gnomes out of Masterwork (without the nature stuff), all clockwork and industry. I just wanted them to have guns with muzzle smoke and the other stuff was a natural extension of that.

Some of the scripts might make interesting magic, the comparison has been made to me before when I showed the launcher to some people before release, but when the magic update drops and we get the real thing to play with, all this stuff will hopefully look like a cheap imitation.
I like the idea of moving towards the industrial and then having it clash with the native magic.

Plus I dread to think of the compromises that would have to be made in the raws and naming different types of 'power crystal' ammo and things like that.
I'm struggling with chemical weapon names as it is: "blistering gas", "choking gas", "sleeping gas", "nerve gas" etc. Just terrible. I wanted cool names but I'm so bad at it. ;D

Magic weapons would open up lots of possibilities for strange and exotic things, though, but I'll probably leave it to someone with more of a love for the magic stuff unless I come up with something I can't not make. I don't really see me converting this into a full-blown sorcery mod.

I'm sorry if that disappoints you, I know putting rocket launchers in DF is stupid as hell but I just couldn't help myself. I'm sure it'd be easy enough for you to convert things to your liking given you made Masterwork, but if you had any difficulties you could always ask here or shoot (npi) me a pm and I'd be more than willing to help.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Grimlocke on August 24, 2018, 06:44:25 am
Have you had any problems with it? I've not had anyone report bugs which is quite strange.
I know they sometimes try and fire through closed doors if the nearest enemy is behind (they don't yet check for buildings on a tile) but I want to know if I should make the make the pathing function parameter dynamic, so as to be more reliable in choosing a clear path (at the expense of more overhead).
Has it worked well enough for you?

I agree with your thoughts, seems very feasible! Were you thinking of making it fire item_ammo (item_ammos?), or use a different method of stopping trapcomp fire altogether?
A static organ gun is a rad idea, much better than the affront to native balance I posted above.
I'd like to do something similar but with a lower fire rate than an organ gun firing weak rockets that veer away and oscillate at random to make a katyusha/nebelwerfer/hwacha thingy as a more sane version of the rocket launcher.

I said it before, but I look forward to seeing the fruits of your tinkering.

The cannon so far worked without outright bugs (I hadn't come across any situation where buildings were in the way yet). The only oddity I had was my gunner persistently shooting to the bottom right with nothing there for some time but I suspect that was due to me sabotaging the hostility check (I didn't feel like waiting for a nicely grouped bunch of goblins to show up, so my own dwarves and some bards volunteered for projectile testing) perhaps causing it to target something it shouldn't be.

Some features I do miss is targeting being restricted to cannon orientation. My planning was to make a heavier, fixed bombard on a 3x3 building plot that would only rotate on manual command (using a building transform script), and a light 1x1 swivel-mounted gun that could fire in any direction. Having large guns be mostly fixed, defensive things you would generally place along a shooting gallery welcoming entrance, the building collision issue might only be problematic with raised bridges.

I'd say that if targeting being blocked by buildings and orientation-restriction are both impossible with the current targeting implementation, it might be worth going with something with more overhead. Its not like the targeting script it run that frequently.

One other feature I would appreciate is a separate load and fire command, which I could probably implement myself once I figure out how to make very short-duration reactions. Being able to have accurate commands at when and where guns fire would help a lot in keeping down the number of hilarious friendly fire incidents.

Also yes, I was planning on using the ammo item time for projectiles, mostly for storage sake and to make cannonballs and grapeshot cartridges not show up in the item list for trap construction. From what I've tested they behave mostly the same as projectiles and while firing sawblades is inarguably cool, the mod I'm working with has a historic accuracy/realism premise to it so I can't exactly do that. I will have to console myself with adding edged damage to cannonballs to make sure they get the proper amount of dismemberment going.

Speaking of historic accuracy, shotguns are actually contemporary to vanilla DFs time period (late 1300/early 1400), if we interpret 'shotgun' to mean any gun loaded with shot instead of ball ammunition. Loading handcannons and artillery with a bunch of small projectiles instead of one big one was apparently not a huge leap in logic.

Edit: I'm not sure what to make of these two lines in the cannon script:

output_items[0].skill_used = input_items[0].mat_type
output_items[0].sharpness = input_items[0].mat_index

Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 09:50:37 am
The cannon so far worked without outright bugs (I hadn't come across any situation where buildings were in the way yet). The only oddity I had was my gunner persistently shooting to the bottom right with nothing there for some time but I suspect that was due to me sabotaging the hostility check (I didn't feel like waiting for a nicely grouped bunch of goblins to show up, so my own dwarves and some bards volunteered for projectile testing) perhaps causing it to target something it shouldn't be.

Hopefully that is just your tinkering, the current version has a test fire reaction for firing on domestic animals that circumvents some or all of the hostility check.

Some features I do miss is targeting being restricted to cannon orientation. My planning was to make a heavier, fixed bombard on a 3x3 building plot that would only rotate on manual command (using a building transform script), and a light 1x1 swivel-mounted gun that could fire in any direction. Having large guns be mostly fixed, defensive things you would generally place along a shooting gallery welcoming entrance, the building collision issue might only be problematic with raised bridges.

Good suggestions, I'm looking into it. Rotating the building by setting its x1/y1 and x2/y2 fields isn't working out for me, have you cracked it?
I think I'd have to make the building delete itself and create another in the new direction due to how twbt works with the sprites anyway but I'd be interested to know how if you managed it.

I'd say that if targeting being blocked by buildings and orientation-restriction are both impossible with the current targeting implementation, it might be worth going with something with more overhead. Its not like the targeting script it run that frequently.

Yeah, orientation restriction should be easy and cheap, it's more the pathing check that checks a line of tiles between the cannon and every possible target that could be heavy if I increased the sample rate of tiles to make building checks worthwhile. The rate would have to be dynamic otherwise it would check the same tiles multiple times at close range and skip some at long range.

One other feature I would appreciate is a separate load and fire command, which I could probably implement myself once I figure out how to make very short-duration reactions. Being able to have accurate commands at when and where guns fire would help a lot in keeping down the number of hilarious friendly fire incidents.

This seems easy enough to implement too, I'll do it after I get 'rotation' working. Not sure about reaction duration, armoks-blessing makes firing the cannon much quicker so I'd look at what that's doing. Might be as simple as the level of the skill used.

Edit: I'm not sure what to make of these two lines in the cannon script:

output_items[0].skill_used = input_items[0].mat_type
output_items[0].sharpness = input_items[0].mat_index

You can ignore/remove them, it's a hacky way of storing the venom type for gas cannisters in unused fields. Will be removed when I add new chemicals that can be inhaled, I'll be making the shells out of the new materials directly. I tried doing that with venom, they instantly melted, I wrote a script to permafreeze the cannisters made out of venom, they wouldn't go into stockpiles. ¯\_(ツ)_/¯
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Meph on August 24, 2018, 10:04:58 am
Roses building-subtype-change script enables rotating your workshop. Its a bit complicated, because you'd need to make 4 separate workshops, but it works well.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 10:35:27 am
Roses building-subtype-change script enables rotating your workshop. Its a bit complicated, because you'd need to make 4 separate workshops, but it works well.

Thanks for the info!
It's a good thing I was lazy with the rotation previously and just made 4 workshops. Works okay just setting building.custom_type rather than using Roses script but gets messed up a little I think due to it being a 1x2 workshop. A 3x3 should work perfect.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Meph on August 24, 2018, 10:42:33 am
Yeah, if you rotate, use square designs. Sneaking of which, any sprites needed for those?
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 10:57:48 am
Yeah, if you rotate, use square designs. Sneaking of which, any sprites needed for those?

I was just going to use the floor of the gunsmith's (the mottled dark gray looks like exactly like my browser theme default background) and slap the existing cannon on top.
If you have something better that would be great, it would be nice for everything to match, but I have become somewhat attached to the cannon as it is and I wouldn't want to have wasted your time if I didn't like your efforts.
What sort of thing did you have in mind?

Edit:
Okay, my efforts look quite bad. Yes please, if you could be bothered!
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Grimlocke on August 24, 2018, 11:06:52 am
Roses building-subtype-change script enables rotating your workshop. Its a bit complicated, because you'd need to make 4 separate workshops, but it works well.

This is what I was going to refer to yes.

As for the test fire, didn't notice your updated script has it. Certainly more graceful than swapping true and false around on the hostility check (Yes, the thought of a cannon that only shoots friendlies amuses me :)
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Meph on August 24, 2018, 11:08:14 am
I just read grimlocks Post about swivel guns, etc and thought you had more workshops / fake siege engines coming up.

So... You just need the cannon, right?
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Vordak on August 24, 2018, 11:10:54 am
Cannon tubes.
(https://i.imgur.com/NuLiZod.png)
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 11:16:55 am
Cannon tubes.
(https://i.imgur.com/NuLiZod.png)

большое спасибо, красиво!
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 11:24:55 am
I just read grimlocks Post about swivel guns, etc and thought you had more workshops / fake siege engines coming up.

So... You just need the cannon, right?

If you wouldn't mind, that would be great. I'm quite partial to Vordak's third tube down. What do you think?
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Meph on August 24, 2018, 11:37:49 am
I think I let Vordak do his thing.  ;)
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Vordak on August 24, 2018, 11:48:59 am
I actually did not plan drawing anything except tubes, but ok, I do it. It is planned to leave cannons in size 1x2 tiles?
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 11:54:32 am
I actually did not plan drawing anything except tubes, but ok, I do it. It is planned to leave cannons in size 1x2 tiles?

The cannon tube should be 1x2 or 1x3, but overall the workshop needs to be 3x3 so it can be rotated ingame.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Meph on August 24, 2018, 12:04:07 pm
Yeah, but the workshop sprites can be transparent, doesnt have to look like a square.

I would have made a circle, with tracks on it, and a cannon positioned on them. I think it would look quite striking in comparison to otherwise rectangular workshops.

Vordak, if you only want to make the barrel, thats fine. :-)
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 12:11:09 pm
Yeah, but the workshop sprites can be transparent, doesnt have to look like a square.

I would have made a circle, with tracks on it, and a cannon positioned on them. I think it would look quite striking in comparison to otherwise rectangular workshops.

That's a shame, I'd like to have seen that.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Vordak on August 24, 2018, 12:18:30 pm
(https://i.imgur.com/f8vNVDE.png)
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Meph on August 24, 2018, 12:30:39 pm
Perfect. :-)

Mind if I do the rest?
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Vordak on August 24, 2018, 12:37:51 pm
Perfect. :-)

Mind if I do the rest?
No problem.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 12:46:32 pm
(https://i.imgur.com/f8vNVDE.png)

Великолепная пушка, у вас есть моя благодарность. Извините за обязательство.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Meph on August 24, 2018, 01:04:36 pm
I present: The VoMeZa-Cannon!

(https://i.imgur.com/YMFeFky.png)

What do you think? It's mostly Vordaks sprites, even the tracks are his. ^^ He improved the ones I had in my tileset once.

With TWBTnext you have transparency, so the workshop appears round, the corners will look like the floor below it.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Vordak on August 24, 2018, 01:11:17 pm
Great idea.
But track stops maybe can make narrower? So that it does not stand out against the background of the gun's nose.
And add for example a blue tint to the metal of cannon for better contrast.

In general, on such a floor does not look contrasted - everything merges.
(https://i.imgur.com/TVB3Wdx.png)

Upd. Perhaps it is worth to divide into two types:
1) My, stationary.
2) by Meph - the same cannon, only with a swivel device, costs more materials
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: thefriendlyhacker on August 24, 2018, 01:29:44 pm
I present: The VoMeZa-Cannon!

(https://i.imgur.com/YMFeFky.png)

What do you think? It's mostly Vordaks sprites, even the tracks are his. ^^ He improved the ones I had in my tileset once.

With TWBTnext you have transparency, so the workshop appears round, the corners will look like the floor below it.
When you said a circle with tracks on it, I thought you were going to do a little railway loop with the gun facing outwards and perpendicular to the tracks, so rotating the gun would just be a matter of pushing the rail cart through 90 deg of track, and the firer would stand in the center of the rail loop while firing the gun. I just figured I would bring it up as an alternative design you could try if you wanted.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Meph on August 24, 2018, 01:50:31 pm
(https://i.imgur.com/NxmYPvS.png)

More contrast. Blue hue on the gun, and smaller track-stops.

afriendlyhacker: That sounds more logical, but when was logic ever the strong suit of dwarves? :D Won't make a second design now. ^^
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Vordak on August 24, 2018, 01:54:34 pm
(https://i.imgur.com/fR6uElt.png)(https://i.imgur.com/sg5lLvs.png)
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 24, 2018, 03:22:38 pm
(https://i.imgur.com/fR6uElt.png)(https://i.imgur.com/sg5lLvs.png)

That was impressive to watch, like a collaborative argument between artists.
I probably won't add both types in at once as separate cannons to make the scripting easier on myself, but to respect Vordak's wish and to give players a choice of which they prefer, I'll include both in separate install folders.
Thanks, guys. I'm very lucky to have your assistance.

Edit:
I could just be suffering from sleep deprivation but the 'swivel' one doesn't appear to be centered. Is it a problem with creating a circle with so few pixels or a mishap?
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: Vordak on August 24, 2018, 05:00:35 pm
I could just be suffering from sleep deprivation but the 'swivel' one doesn't appear to be centered. Is it a problem with creating a circle with so few pixels or a mishap?
I corrected the offset.
(https://i.imgur.com/sg5lLvs.png)(https://i.imgur.com/k3vCaVH.png)

That was impressive to watch, like a collaborative argument between artists.
I probably won't add both types in at once as separate cannons to make the scripting easier on myself, but to respect Vordak's wish and to give players a choice of which they prefer, I'll include both in separate install folders.
Do not be so tense - choose one at your discretion.
Title: Re: [44.12] Musket-Mod v0.4c (Now with ingame customization menu!)
Post by: zaporozhets on August 25, 2018, 06:37:21 am
I corrected the offset.

Do not be so tense - choose one at your discretion.

Appreciate it.
I can't help being tense. I don't want to upset anyone, especially if they are doing me a favour.

Just rewriting the cannon to work with the new separate load and fire reactions now. Reactions don't seem to register as completing unless they have a product, so I'm just changing it to work on job completion instead.
Going to take chemical weapons out for now, I'm changing how they work so I can't write the cannon script to accommodate them until I'm completely set on how I'm doing that and it's done to test. I'd rather just get the updated cannon out so I can work on the chemical stuff with no pressure.

Does anyone know if there is a proper way of getting items out of buildings? Not too keen on having to clone and delete them like I've done previously. Tried items.moveToGround() and setting Item.pos manually with no luck.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: Grimlocke on August 26, 2018, 06:59:07 pm
Nice work on the cannon improvements!

Here's where I'm at with my own efforts with the handheld firearms, which kind of sprawled into a script to modify any projectile: https://pastebin.com/j07S30Nb

Right now it modifies accuracy, velocity, firing rate, hit rate (to account for shot weapons that should be harder to dodge), chance of breaking on impact (needed that for a thrown weapon), whether it pierces through stuff or not and how many extra projectiles it spawns of which item subtype.

A few lingering issues I'm still having and could use some advice on are that I can't quite think of a way around: I'm trying to have it do stuff based on the weapon used, so that I can slow down firing rate for heavier crossbow (using the same ammunition). The projectile data structure has a 'bow_id' value, which is a number starting at 0 and increasing as more items are spawned in the map. It clearly corresponds to the specific ranged weapon used, but its not an item ID and I can't get any of the item functions to do anything useful with it. I suspect there's some obvious way of using that that I'm missing.

Also I've been trying to change the item type of projectiles, which is easy enough for the subtype (using item.setSubtype), but setType doesn't exist. Is there some other way of doing this or do I just have to delete the original and spawn a new projectile?

I'm also somewhat of a noob at lua, so if anyone spots screwups or points of improvement, I'd be much obliged if you point them out.

And as an aside, I've noticed that the 'piercing' flag behaves weirdly and causes a single projectile to hit the same target numerous times, sometimes killing them dead instantly, before passing through. Might be useful to simulate explosives? Change the material to something with huge shear value and give the projectile plenty of contact area/surface and it should make giblets easily enough.

Edit: Just found that the shot projectiles can only hit one target one time, even though a single shot can hit multiple enemies at once. Even at close range the a single enemy only gets hit by one projectile while the rest merrily goes on its way.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: SpeardwarfErith on August 26, 2018, 08:07:09 pm
Could I include the rocket launchers in the dune mod I'm creating? They really are amazing, and proper credit would obviously be given.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: zaporozhets on August 26, 2018, 10:45:39 pm
Here's where I'm at with my own efforts with the handheld firearms, which kind of sprawled into a script to modify any projectile: https://pastebin.com/j07S30Nb

Right now it modifies accuracy, velocity, firing rate, hit rate (to account for shot weapons that should be harder to dodge), chance of breaking on impact (needed that for a thrown weapon), whether it pierces through stuff or not and how many extra projectiles it spawns of which item subtype.

Very impressed after a cursory reading. As a fellow noob to lua, I did not know you could set table keys like that.
I did notice you set multiProjectile.distance_flown to 6 to avoid smoke, I initially did something similar on the blunderbuss before I noticed it seemed to be teleporting the projectiles forward. It's not a problem really unless the target is nearly adjacent.
Making a general purpose projectile script is a brilliant idea.

A few lingering issues I'm still having and could use some advice on are that I can't quite think of a way around: I'm trying to have it do stuff based on the weapon used, so that I can slow down firing rate for heavier crossbow (using the same ammunition). The projectile data structure has a 'bow_id' value, which is a number starting at 0 and increasing as more items are spawned in the map. It clearly corresponds to the specific ranged weapon used, but its not an item ID and I can't get any of the item functions to do anything useful with it. I suspect there's some obvious way of using that that I'm missing.

I've had this issue too and just sidestepped it by giving the weapon a new ammo, the only way I could think of using the same ammo was iterating through the firers inventory on distance_flown == 0, getting projectile.firer.inventory[indx].item.subtype.id and checking against the weapon name (or checking subtype.subtype, but I like strings for readability), but it was for the automusket and I was worried about the overhead and so didn't go any further with it. Hope that works for you.

Also I've been trying to change the item type of projectiles, which is easy enough for the subtype (using item.setSubtype), but setType doesn't exist. Is there some other way of doing this or do I just have to delete the original and spawn a new projectile?

I don't know of any other way of doing it, I don't think I was even aware of setSubtype until just now (will come in handy, thanks).
The next best thing would be creating a new item and changing the original projectiles .item to the new item, but my experience with trying to do stuff like that is it crashes the game. I've tried changing the general/specific_refs too but it just doesn't like it. I don't think I was trying to do that specifically though, maybe you would have better luck than myself.

And as an aside, I've noticed that the 'piercing' flag behaves weirdly and causes a single projectile to hit the same target numerous times, sometimes killing them dead instantly, before passing through. Might be useful to simulate explosives? Change the material to something with huge shear value and give the projectile plenty of contact area/surface and it should make giblets easily enough.

Edit: Just found that the shot projectiles can only hit one target one time, even though a single shot can hit multiple enemies at once. Even at close range the a single enemy only gets hit by one projectile while the rest merrily goes on its way.

Interesting stuff. I'll need have to have more of a mess around with the projectile flags, I have no idea what I'm doing with them. I just copied them in from Roses projectile script and I keep getting a weird bug on the cannon where it only causes light bruising, setting the piercing flag seemed to fix it but now I'm not so sure it did what I thought given what you've said. Maybe I should just make the cannonball use an edge attack. Has anything like that happened to you?

Could I include the rocket launchers in the dune mod I'm creating? They really are amazing, and proper credit would obviously be given.

It's lovely of you to ask, of course you can! I've been messing about with a lasgun that makes an instant beam of 'laser' and one that has a more simple 'blaster' trail as well, but I'm not happy with the results are so far (fire rate is just to make testing easier):

(https://i.imgur.com/ESrlavR.gif) (https://i.imgur.com/HX1DHJz.gif)

Your thread seems to indicate you also have a preliminary version of it as well, I'd love to see it. I want to try my hand at the beam-shield interaction.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: thefriendlyhacker on August 27, 2018, 04:36:45 am
...
I've had this issue too and just sidestepped it by giving the weapon a new ammo, the only way I could think of using the same ammo was iterating through the firers inventory on distance_flown == 0, getting projectile.firer.inventory[indx].item.subtype.id and checking against the weapon name (or checking subtype.subtype, but I like strings for readability), but it was for the automusket and I was worried about the overhead and so didn't go any further with it. Hope that works for you.
...
I wouldn't be so concerned with overhead if I was you.  If you are doing checks that only happen during combat, then any overhead caused by those checks will be hidden by the massive slowdown caused by combat.  No sane amount of searching through memory is going to compare to the herculean task of writing "The goblin lasher dodges the steel bolt" to hard drive.  Unless you are doing something that iterates through lists multiple times on a constant near tick by tick basis, don't even bother worrying about performance, because your dinky little script's overhead will be lost in the sea of RAM sundering computation cycles that is Dwarf Fortress.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: zaporozhets on August 27, 2018, 06:12:45 am
I wouldn't be so concerned with overhead if I was you.  If you are doing checks that only happen during combat, then any overhead caused by those checks will be hidden by the massive slowdown caused by combat.  No sane amount of searching through memory is going to compare to the herculean task of writing "The goblin lasher dodges the steel bolt" to hard drive.  Unless you are doing something that iterates through lists multiple times on a constant near tick by tick basis, don't even bother worrying about performance, because your dinky little script's overhead will be lost in the sea of RAM sundering computation cycles that is Dwarf Fortress.

It's a very salient point, I just see that hit of a few frames in arena mode and wonder if there's a lighter way of doing whatever it is I'm trying to do. I'll keep this in mind.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: SpeardwarfErith on August 27, 2018, 08:38:40 am

It's lovely of you to ask, of course you can! I've been messing about with a lasgun that makes an instant beam of 'laser' and one that has a more simple 'blaster' trail as well, but I'm not happy with the results are so far (fire rate is just to make testing easier):

(https://i.imgur.com/ESrlavR.gif) (https://i.imgur.com/HX1DHJz.gif)

Your thread seems to indicate you also have a preliminary version of it as well, I'd love to see it. I want to try my hand at the beam-shield interaction.

Wow, I don't know what you are unhappy with. That's impressive, especially the first one. How did you get the beam to work? It can't just be flows spawned on the bullet because it's moving faster than a tile a tick.

To clarify, I don't actually have any real code written (aside from the samdworm prototype), just a bit of pseudocode. I've been forcing myself to do the raws first, because that's the harder part for me and also the more important one for the mod. A beam-shield interaction should be pretty simple, something along the lines of
Code: [Select]
onProjectileHit:
    if projectile.type == beam and projectile.target.isShielded() then
        spawnflow(a fuckton of dragonfire, maybe some smoke, cave in dust, at target.pos and shooter.pos)
    end
end
Title: Re: [44.12] Musket-Mod v0.4f
Post by: Grimlocke on August 27, 2018, 09:24:38 am
Very impressed after a cursory reading. As a fellow noob to lua, I did not know you could set table keys like that.
I did notice you set multiProjectile.distance_flown to 6 to avoid smoke, I initially did something similar on the blunderbuss before I noticed it seemed to be teleporting the projectiles forward. It's not a problem really unless the target is nearly adjacent.
Making a general purpose projectile script is a brilliant idea.

Ah... I hadn't noticed, but this sure explains the issue of shot projectiles not hitting stuff. Thanks, I'll have to come up with something else for that. I've also manually carried over the firer ID to the multiProjectile since the one in makeProjectile didn't seem to work; shot projectile hit combat reports weren't showing as coming from the player character in adventurer mods.

I've had this issue too and just sidestepped it by giving the weapon a new ammo, the only way I could think of using the same ammo was iterating through the firers inventory on distance_flown == 0, getting projectile.firer.inventory[indx].item.subtype.id and checking against the weapon name (or checking subtype.subtype, but I like strings for readability), but it was for the automusket and I was worried about the overhead and so didn't go any further with it. Hope that works for you.

Hmm yeah, I considered something like that but I had hoped I could circumvent it by using the bow_id. It does seem to correspond to whatever ranged weapon is being used, but I can't figure how to use it. Anyhow, thefriendlyhacker probably had a point, I'll give your idea a try.

Interesting stuff. I'll need have to have more of a mess around with the projectile flags, I have no idea what I'm doing with them. I just copied them in from Roses projectile script and I keep getting a weird bug on the cannon where it only causes light bruising, setting the piercing flag seemed to fix it but now I'm not so sure it did what I thought given what you've said. Maybe I should just make the cannonball use an edge attack. Has anything like that happened to you?

Some blunt objects seem to have that effect, I've set cannonballs to be edged since they pretty much behave that way judging by historic records. Piercing is appropriate for cannonballs too, since they tended to tear through lines with fairly little regard for how many soldiers were in the way.


Edit: Alright, got weapon properties to work. Seems projectile.bow_id is the item.id of the weapon used to fire the projectile, so that let me avoid the issue of not being able to figure out which weapon was used to do the shooting, avoiding cases like 'Urist is holding a machinepistol and a shotgun, his shotgun is now a machineshotgun'.

There is uh... probably a more graceful way to do this, but I couldn't find how to match item.id directly so here's what I ended up with:
Spoiler (click to show/hide)

Also I forgot to mention: That laser gun looks pretty cool, and if you should find a way to remove projectiles after they've hit (to prevent a bunch of 'laser beams' laying on the floor) that'd be pretty useful too.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: zaporozhets on August 27, 2018, 11:11:24 am
Wow, I don't know what you are unhappy with. That's impressive, especially the first one. How did you get the beam to work? It can't just be flows spawned on the bullet because it's moving faster than a tile a tick.

To clarify, I don't actually have any real code written (aside from the samdworm prototype), just a bit of pseudocode. I've been forcing myself to do the raws first, because that's the harder part for me and also the more important one for the mod. A beam-shield interaction should be pretty simple, something along the lines of
Code: [Select]
onProjectileHit:
    if projectile.type == beam and projectile.target.isShielded() then
        spawnflow(a fuckton of dragonfire, maybe some smoke, cave in dust, at target.pos and shooter.pos)
    end
end

A bunch of stuff is not great with them.

The beam works by deleting the "energy cartridge" projectile fired, getting the parametric form of the line between the firer and the projectile target (sort of like how the cannon checks a path is viable, but more dynamic (I need to update the cannon with it)), drawing the "laser" gas flow in tile-by-tile along the line whilst checking the tile for passibility and units (though maybe I should let it fire through walls and units), and if a unit is found, spawning a "beam" projectile made of "laser" somewhere close (on the line so as to be hidden by the flow) aimed at the unit.

The problems I have are: when the beam projectile misses it looks stupid flying out of the flow (I've considered firing it top down at the risk of surplus headshots), the broken laser arrows everywhere (could be easily fixed by making them not be destroyable and manually deleting them on impact) and the beam projectile is ineffective (because I'm terrible with raws).

Ah... I hadn't noticed, but this sure explains the issue of shot projectiles not hitting stuff. Thanks, I'll have to come up with something else for that. I've also manually carried over the firer ID to the multiProjectile since the one in makeProjectile didn't seem to work; shot projectile hit combat reports weren't showing as coming from the player character in adventurer mods.

Hmm yeah, I considered something like that but I had hoped I could circumvent it by using the bow_id. It does seem to correspond to whatever ranged weapon is being used, but I can't figure how to use it. Anyhow, thefriendlyhacker probably had a point, I'll give your idea a try.

You could also check to see if the projectile had any fields set differently when fired from the heavy crossbow, then check projectile type and the field and assume the weapon type from that, if you've not already tried.
I don't really play in adventure mode but I'll try and remember to update the blunderbuss with that, thanks for the info.
I'd like to make a way to create items manually without createItem() eventually, I don't like that loading the cannon changes the quality of the trapcomp.
It could just be set back and any announcements about how Urist transmogrified a crude cannonball into a masterwork by loading it into a cannon be somehow suppressed I suppose.

Some blunt objects seem to have that effect, I've set cannonballs to be edged since they pretty much behave that way judging by historic records. Piercing is appropriate for cannonballs too, since they tended to tear through lines with fairly little regard for how many soldiers were in the way.

I'll have to do that too. Could I be very rude and lazy and ask for the values you've given them, that I might just copy them in? I'd of course credit you for the improvements. I'm not too clear on appropriate raw values despite reading the relevant wiki pages a bunch of times.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: scourge728 on August 27, 2018, 11:24:15 am
May I also have access to the laser lua stuff, for an animorphs mod I'm working on?
Title: Re: [44.12] Musket-Mod v0.4f
Post by: Grimlocke on August 27, 2018, 11:28:38 am
Heh, I edited my previous post just before you responded, see that for a followup on the weapon properties thing.

Here's what I have for raws right now: https://pastebin.com/NcNidFzE of course, use whatever you like; I don't think anyone here is particularly possessive of their work and would much rather it see use in whatever way. Its really a very pleasant community we've got here.

Anyhow, what makes the cannonballs do hurt is: weight, velocity and a moderate contact area with a large penetration area (the attack token is [ATTACK:EDGED/BLUNT:contact area:penetration depth:blah:blahs:what you blah with:velocity], velocity on ammunition is only used when you use it as a melee weapon). Impact is divided by contact area (though capped by bodysize I think), so lower contact areas generally mean more impact. If you want to make a laser, you may want give the material really high shear values.

Title: Re: [44.12] Musket-Mod v0.4g
Post by: Koumakan on August 27, 2018, 02:45:48 pm
Oh my god.
Title: Re: [44.12] Musket-Mod v0.4g
Post by: thefriendlyhacker on August 27, 2018, 02:53:50 pm
Oh my god.
It is all pretty cool, isn't it?
Title: Re: [44.12] Musket-Mod v0.4f
Post by: zaporozhets on August 27, 2018, 03:11:33 pm
May I also have access to the laser lua stuff, for an animorphs mod I'm working on?

Yeah, sorry for not posting it before, I was just worried about treading on SpeardwarfErith's toes.
It's nowhere near finished and pretty much a complete mess, just an experiment really.
I've tried to fix it up a little and add some comments for you, but do ask if you're unsure of anything and please let me know where I've made foolish mistakes.

http://dffd.bay12games.com/file.php?id=13983

Here's what I have for raws right now: https://pastebin.com/NcNidFzE of course, use whatever you like; I don't think anyone here is particularly possessive of their work and would much rather it see use in whatever way. Its really a very pleasant community we've got here.

Good find on the bow_id thing, going to try and make use of it. Thanks for the raw stuff too, I appreciate it and your attitude. Everyone does seem really nice.
I'm just used to seeing modders in other communities be the usual selfish artistic types, throwing tantrums and deleting all their stuff and so on.
On that note I hope everyone here who wants it grabs all this stuff before I get into a really bad mood.  ;)

Edit:
I put a thing in the lasgun script that removes the lasers after they've hit, just needs them to be made no_impact_destroy = false. Out of interest did you plan on doing anything in particular with it?
Title: Re: [44.12] Musket-Mod v0.4g
Post by: SpeardwarfErith on August 27, 2018, 04:45:27 pm
Thanks for the consideration about the toes, but honestly don't worry about it. I looked over the laser code, it looks good. The functions flow pretty well, the implementation is elegant, and the only part that really bothers me about it is when you copy the entire projectile variable by variable- It seems easier to just change the existing cartridge projectile's type into a laser beam.

idk if I'll actually use your laser, I'm not at that point yet and I'm planning for some complex artificial AI to be involved (the whole mindgame of "do I risk firing in case he has a shield?" and "should I use a shield and risk angering the worms?"). It all depends on how the code is going to end up structuring itself.

This thread has been an amazing goldmine of really dramatic advances in the modding field (especially thefriendlyhacker's think_counter discovery), and I've been thinking more and more of writing a couple advanced modding guides on the wiki, that would describe various lua functions and such, and specifically some useful aspects of the data structure. I don't have time for that right now what with all my other projects, but it's a thought worth considering.

On that note I hope everyone here who wants it grabs all this stuff before I get into a really bad mood.
zaporozhets looses a roaring laughter, fell and terrible!
Musket-Mod has been missing for a week.
zaporozhets has created An Explanation of the Musket-Mod Drama, a mod bone post! It menaces with walls of text and rantings about due credit. He claims it as personal treasure.

Jokes aside, the df community is honestly the best one I've seen yet, and I can prove it. During reddit's circles of trust thing, most circles were composed of closed cliques, while the only requirement to enter the dwarf fortress circle was proof that you play df. We were among the largest circles, twice, before being betrayed by people that I'm pretty sure aren't actual df players. My theory is that it's the learning cliff that scares off most low-quality players, and the ones willing to put in the time to get past it tend to be good people.
Title: Re: [44.12] Musket-Mod v0.4g
Post by: zaporozhets on August 27, 2018, 06:01:28 pm
Thanks for the consideration about the toes, but honestly don't worry about it. I looked over the laser code, it looks good. The functions flow pretty well, the implementation is elegant, and the only part that really bothers me about it is when you copy the entire projectile variable by variable- It seems easier to just change the existing cartridge projectile's type into a laser beam.

idk if I'll actually use your laser, I'm not at that point yet and I'm planning for some complex artificial AI to be involved (the whole mindgame of "do I risk firing in case he has a shield?" and "should I use a shield and risk angering the worms?"). It all depends on how the code is going to end up structuring itself.

I appreciate the praise. You're right about the ammo cloning, I just didn't know about setSubtype() until recently. I don't think it's documented on the DFHack wiki. I'll have to remember it exists for next time I need to do something like that.

Your ideas for Fremen Fortress sound incredible, I can't wait to play it. I sincerely hope you don't use that laser under any circumstances, unless you change it enough to no longer be able to be considered mine, it's bloody useless. I'm looking forward to poring through the scripts as a learning exercise, too.

This thread has been an amazing goldmine of really dramatic advances in the modding field (especially thefriendlyhacker's think_counter discovery), and I've been thinking more and more of writing a couple advanced modding guides on the wiki, that would describe various lua functions and such, and specifically some useful aspects of the data structure. I don't have time for that right now what with all my other projects, but it's a thought worth considering.

It is a lofty and noble idea. DFHack has so many features and functionalities, but people don't seem to be exploiting them to the full.
It seems like there is a way to do everything imaginable without the compromises necessary with raw editing alone, but the built-in modtools are complex to use (for a simpleton like me anyway) and not really adequate for more advanced stuff. A set of tutorials written by someone competent would be great and could bring in a golden age of DF mods.

zaporozhets looses a roaring laughter, fell and terrible!
Musket-Mod has been missing for a week.
zaporozhets has created An Explanation of the Musket-Mod Drama, a mod bone post! It menaces with walls of text and rantings about due credit. He claims it as personal treasure.

Jokes aside, the df community is honestly the best one I've seen yet, and I can prove it. During reddit's circles of trust thing, most circles were composed of closed cliques, while the only requirement to enter the dwarf fortress circle was proof that you play df. We were among the largest circles, twice, before being betrayed by people that I'm pretty sure aren't actual df players. My theory is that it's the learning cliff that scares off most low-quality players, and the ones willing to put in the time to get past it tend to be good people.

That made me laugh a lot, especially the due credit part.
Your theory makes a lot of sense, not to sound judgemental but I've tried explaining Dwarf Fortress to friends who I love dearly, but are by all accounts 'low-quality players' (of phone games and the like), and they just don't seem to grasp the sheer magnitude and unparalleled scope of it or take any interest.
Using a tileset just made it worse, with them fixating on a flashing icon of a horse. ::)
Title: Re: [44.12] Musket-Mod v0.4f
Post by: Grimlocke on August 27, 2018, 06:29:15 pm
Heh I guess it takes a special sort of character to make sense of and enjoy DF, all the more so to also go rooting around in its bowels.

Its endlessly more pleasant than certain other modding communities cough skyrim, minecraft cough, although the audience is also couple orders of magnitude smaller I find it perfectly worthwhile. Not that other modding communities don't have their share of perfectly agreeable folks, its just they also have a share of self-obsessed 'donut steal' sorts and all sorts of generally unpleasant characters. Especially the Minecraft one... that's the community that decided to hide their work behind virus and ad riddled click monetization websites.

That sort of stuff simply would not fly here, and thats pretty cool. Anyhow, back to the subject at hand.

I put a thing in the lasgun script that removes the lasers after they've hit, just needs them to be made no_impact_destroy = false. Out of interest did you plan on doing anything in particular with it?

Thanks, seems to work! I'll be using it mostly just for cleanup of shot projectiles; things get really messy once a couple gunners start shooting at flying targets (@*!#^! keas) which has the shot drop to the floor un-destroyed, regardless of the impact_destroy flag. Same thing if they hit a wall that is above the ground. It would also be weird for bullets to be re-usable without needing more gunpowder so I've just had it delete anything starting with ITEM_AMMO_GUN.

I've also gotten the smoke to work again by hijacking projectile.unk21 to store a 'smokiness' value and having each smoke instance reduce it by 1.

The setSubtype thing I found by rooting around in the data structure XMLs, which I found a pretty useful thing to do overall.

Also +1 for an intermediate level modding guide. Just using the dfhack modtools isn't tremendously complex and you can still do plenty neat stuff with them, but nothing about dfhack docs even made it clear where to put the file for the script commands. Figuring all this out by taking apart other people's mods was (and is) a fun journey but really took a lot longer and would see a lot more people drop out than needed.

Your theory makes a lot of sense, not to sound judgemental but I've tried explaining Dwarf Fortress to friends who I love dearly, but are by all accounts 'low-quality players' (of phone games and the like), and they just don't seem to grasp the sheer magnitude and unparalleled scope of it or take any interest.
Using a tileset just made it worse, with them fixating on a flashing icon of a horse. ::)

Heh I'm sure we've all felt this. I have some friends who are pretty into gaming and even modding too but only one who got anywhere with DF, and he too lost interest after not too long.
Title: Re: [44.12] Musket-Mod v0.4g
Post by: Splint on August 27, 2018, 07:20:00 pm
For once, I might actually need to get a mod that adds guns. Assuming they can kill reliably.

Cause this looks amazing.
Title: Re: [44.12] Musket-Mod v0.4h
Post by: Grimlocke on August 28, 2018, 10:37:10 pm
Some things I was pondering while going over the cannon script: The subtype increment/decrement thing used to rotate it is clever, but its going to cause weirdness if any other mods add a custom building in an alphabetically higher raw file. I'm somewhat stuck on thinking of anything better though, since I can't see to get dfhack to read the damned custom building subtype name. Theres a workaround involving making a separate pair of reactions for the North > West and West > North rotation, but it seems... somewhat ungraceful? I also don't know how it will handle the building subtype changing with reactions still queued, possibly it will keep the old reaction jobs and turn itself into a screw press. It'd be nicer if it could just use the same too jobs and do a check for 'does my subtype name end in '_N' or not'.

I also noticed the blunderbuss-missile spawner doesn't copy over ammunition quality, pelletProjectile.item.quality = projectile.item.quality should cure that.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: zaporozhets on August 29, 2018, 06:09:14 am
Thanks, seems to work! I'll be using it mostly just for cleanup of shot projectiles; things get really messy once a couple gunners start shooting at flying targets (@*!#^! keas) which has the shot drop to the floor un-destroyed, regardless of the impact_destroy flag. Same thing if they hit a wall that is above the ground. It would also be weird for bullets to be re-usable without needing more gunpowder so I've just had it delete anything starting with ITEM_AMMO_GUN.

It is weird, I think I'll have to do the same because it's bothering me now that you've mentioned it. ;D

For once, I might actually need to get a mod that adds guns. Assuming they can kill reliably.

I've not found them to be lacking, I've had many battles in the arena with no survivors, but if you try it and you're not happy let me know.

Some things I was pondering while going over the cannon script: The subtype increment/decrement thing used to rotate it is clever, but its going to cause weirdness if any other mods add a custom building in an alphabetically higher raw file. I'm somewhat stuck on thinking of anything better though, since I can't see to get dfhack to read the damned custom building subtype name. Theres a workaround involving making a separate pair of reactions for the North > West and West > North rotation, but it seems... somewhat ungraceful? I also don't know how it will handle the building subtype changing with reactions still queued, possibly it will keep the old reaction jobs and turn itself into a screw press. It'd be nicer if it could just use the same too jobs and do a check for 'does my subtype name end in '_N' or not'.

Don't know if it counts as graceful but the way I would do it would be upon fortress load, iterating through df.global.world.raws.buildings.workshops[] checking .code until it finds CANNON_N, then have the script set the index of that to a variable 'cannonSubtype' used in place of where I've clumsily stuffed a '3' and just changing '6' to 'cannonSubtype + 3'.

Mostly so I could just plug it into what's already there and not have to think too much, but you could easily use workshops[custom_type].code == foo to do a check.
Not sure what you're planning if it doesn't find it though, maybe I'm just not clear on what you intend to do with the check. I'm more excited than I ought to be to find out.

Edit:
Like this:
Code: [Select]
local cannonSubtype

dfhack.onStateChange.cannon = function(state)
if state == SC_WORLD_LOADED then
for indx, building in pairs(df.global.world.raws.buildings.all) do --not sure whether to use .all or .workshops
if building.code == "CANNON_N" then
cannonSubtype = indx
end
end
end
end


I also noticed the blunderbuss-missile spawner doesn't copy over ammunition quality, pelletProjectile.item.quality = projectile.item.quality should cure that.

Ah, I'm an idiot. Thanks for the tip, I'm very lucky to have someone noticing these things, I've put it on my list along with the same-ammo-different-weapon stuff for the automusket. I hope it doesn't spam the announcements too much when a masterwork cartridge is fired.

On a related note (to ammo quality preservation, announcement spams and me being an idiot), I've been thinking of improving the cannon loading with [PRESERVE_REAGENT] rather than cloning everything like a damned fool, but I've not tried it yet as I've been trying to focus on getting chemical weapons back in:

(https://i.imgur.com/kopawjF.png)
My partner helped me whip up a laboratory with an eroge spritesheet (that slime has done awful, awful things) but I'm a little worried it's too 'busy' for DF.
Title: Re: [44.12] Musket-Mod v0.4h
Post by: Splint on August 29, 2018, 06:25:31 am
My concern is just on how well they do.

Marksdwarves for me in vanilla have just never been worth the material investment (they piss through ammo at a constant rate, necessitating dedicating at least two or three people just to making ammo for them with just a single full squad,) and lacking killing power, since unless a major artery or the brain is hit, it usually takes forever to kill anything with them. Hell, more than half the time hunters can't kill anything besides small game reliably.

These weapons obviously (and understandably) have an even greater material investment, so I'm a bit leery. But I'll give it a shot.
Title: Re: [44.12] Musket-Mod v0.4h
Post by: zaporozhets on August 29, 2018, 07:45:00 am
My concern is just on how well they do.

Marksdwarves for me in vanilla have just never been worth the material investment (they piss through ammo at a constant rate, necessitating dedicating at least two or three people just to making ammo for them with just a single full squad,) and lacking killing power, since unless a major artery or the brain is hit, it usually takes forever to kill anything with them. Hell, more than half the time hunters can't kill anything besides small game reliably.

These weapons obviously (and understandably) have an even greater material investment, so I'm a bit leery. But I'll give it a shot.

I didn't want them to be golden guns, but someone did complain they were too weak early on in development so I doubled the power and I've not heard any complaints since.
I'd have a play with them in arena mode on a fresh install you can just delete before you decide. Do let me know how you find them, it'd be a great help to get your opinion.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: Grimlocke on August 29, 2018, 11:59:48 am
About the cannons, I've been considering using [PRESERVE_REAGENT] as well as making the barrel used to build the building a container tool item. All I'd have to do to make be 'loaded' is move reagents to the barrel 'container' until there are no empty barrels (relevant for organ guns), and when firing check for any containers with use_mode == 2 (item used as building item) and spew it out until there is no more left.

I actually considered the thing you suggested for indexing the custom workshop subtypes, but found it shouldn't even be needed. All I need to do when turning clockwise is have the workshop check 'Does my name end in _N, _E or _S? then add 1 to subtype' and 'else, substract 3 from subtype'. Basically the same thing you did except it doesn't check against its own subtype but against a string match in the name. Only problem with that is, I've not been able to read anything from the building raws from the building objects (which seem to be different data structures altogether). I'm probably missing something simple...

I might use that index code snippet at some point though, thanks :)

Also I hadn't considered masterwork announcement spam. Gah. Does it also announce masterwork if its an existing item changing quality later I wonder?

Edit: dfhack.items.moveToContainer isn't moving to container. No error output either. Is it picky about the sort of container used or does it not like me editing the container property in an existing item? I'll try adding some of the tool use tags and risk dwarves storing plump helmets in gun barrels.

Edit yet again: I recall you asking how to move items to the ground, item:moveToGround(cannon.centerx,cannon.centery,cannon.z) seems to do the trick.
Title: Re: [44.12] Musket-Mod v0.4f
Post by: zaporozhets on August 29, 2018, 03:00:38 pm
About the cannons, I've been considering using [PRESERVE_REAGENT] as well as making the barrel used to build the building a container tool item. All I'd have to do to make be 'loaded' is move reagents to the barrel 'container' until there are no empty barrels (relevant for organ guns), and when firing check for any containers with use_mode == 2 (item used as building item) and spew it out until there is no more left.

I like the idea of putting the stuff in the actual barrel, probably won't change it for this given it'd be functionally the same for a normal cannon but for an organ gun it makes tons of sense for being able to load different barrels.

I actually considered the thing you suggested for indexing the custom workshop subtypes, but found it shouldn't even be needed. All I need to do when turning clockwise is have the workshop check 'Does my name end in _N, _E or _S? then add 1 to subtype' and 'else, substract 3 from subtype'. Basically the same thing you did except it doesn't check against its own subtype but against a string match in the name. Only problem with that is, I've not been able to read anything from the building raws from the building objects (which seem to be different data structures altogether). I'm probably missing something simple...

I might use that index code snippet at some point though, thanks :)

Ah, that's a much better way. You mean something like:
Code: [Select]
local cannonDirection = string.sub(df.global.world.raws.buildings.all[cannon.custom_type].code, -2)
if job.reaction_name == "ROTATE_CANNON_R" then
if cannonDirection == "_N" or cannonDirection == "_E" or cannonDirection == "_S" then
cannon.custom_type = cannon.custom_type + 1
else
cannon.custom_type = cannon.custom_type - 3
end
else
if cannonDirection == "_E" or cannonDirection == "_S" or cannonDirection == "_W" then
cannon.custom_type = cannon.custom_type - 1
else
cannon.custom_type = cannon.custom_type + 3
end
end
right?

Also I hadn't considered masterwork announcement spam. Gah. Does it also announce masterwork if its an existing item changing quality later I wonder?

Edit: dfhack.items.moveToContainer isn't moving to container. No error output either. Is it picky about the sort of container used or does it not like me editing the container property in an existing item? I'll try adding some of the tool use tags and risk dwarves storing plump helmets in gun barrels.

I don't really know about either of these things, first one would be a good way of suppressing the announcement. Never done anything with containers but I can imagine it is picky, give me a progress update if you manage it. Can't see how I'd use it personally, but I'd be interested to know.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: thefriendlyhacker on August 30, 2018, 07:17:19 pm
I have been playing around with something lately, and I have just gotten it to a basically functional point (although I will revisit it later and add/tweak a few things).  I figured that in the meantime you might like to have it for some double barrel muskets or something.
Code: [Select]
----changes the cooldown between each time a creature fires a projectile weapon----
--author thefriendlyhacker
--based on work by Roses, expwnent, zaporozhets and Putnam.

local usage = [====[

ranged/ranged-rof
===========================
This triggers when a unit fires a projectile, and changes the delay (in ticks) until the unit's
next attack.

The new delay is set according to the following formula:
    New Delay = Base Delay + Old Delay * Delay Multiplier
Base delay is set by -delayBase, and Delay Multiplier by -delayMult

For reference, dabbling firers have a normal delay of 80 ticks, legendary +5 firers 48 ticks, and legendary +100 firers 40 ticks.

Several arguments can be added to restrict a particular command to select weapons/ammo (see below)

A set of values can be passed through -delayBase and/or -delayMult.  When only one of the args is multi-value, the other is treated as an equal sized set of identical values.  If both are multi-value sets, they must be of equal length.

The script steps through the set of values when a unit fires a projectile weapon, and keeps track of
the unit's position in the set on a per command, per weapon basis. Beginning at the first
number in the set, the script iterates through the entire pair of sets, using each pair of numbers
to calculate the delay for a single firing event.  Effectively, this allows for variable delay
times.  This can simulate, for example, burst fire weapons, multi-barreled firearms, or autoloading
weapons with a reload time.

After a delay (calculated using -resetBase and -resetMult similar to the equation above), the position in a unit's firing delay set is reset to the first position.

Data does not persist across saves, which will mean that loading saves made in the middle of combat will influence that combat when using variable delays.  Outside of combat, this shouldn't matter.

Usage::
    -name str
        name of the command.  Not optional.
    -clear name (not implemented atm)
        unregisters a named command. If arg is used with no name, unregisters every command
    -reset name (not implemented atm)
        clears all persistant data associated with the named command. If used with no name, clears all data
    -reqProjType subtype or [ subtype1 subtype2 ... ]
        only runs command if the projectile is one of the appropriate subtypes
        example: ITEM_AMMO_BOLTS
    -reqWeaponType subtype or [ subtype1 subtype2 ... ]
        only runs command if the weapon is of one of the appropriate subtypes
        example: ITEM_WEAPON_CROSSBOW
    -reqProjMat mat or [ mat1 mat2 ... ]
        only runs command if the projectile is one of the appropriate material(s)
        examples: INORGANIC:IRON, CREATURE_MAT:DWARF:BRAIN
    -reqWeaponMat mat or [ mat1 mat2 ... ]
        only runs command if the weapon is one of the appropriate material(s)
        same format as -reqProjMat
    -timeBase nbr or [ nbr1 nbr2 ... ] (default 0)
    -timeMult nbr or [ nbr1 nbr2 ... ](default 0)
        timeBase and timeMult are used to set the time until the next attack
        at least one must be set, and the number can be negative or non-integer
        if they are both multi-element tables, they must be of equal length
        -timeBase is a flat number of ticks
        -timeMulti is a multiplier of the base firing delay of the unit
        see above for details
    -neverReset
        never resets position in a loop
    -resetBase nbr (default 0)
    -resetMult nbr (default 5)
      determines how long until a unit's position in the command's firing delay set is reset
      works similarly to timeBase and timeMult, see above for details
]====]
eventful = require 'plugins.eventful'
utils = require 'utils'

--holds individual commands as anon functions
rangedTriggers=rangedTriggers or {}

--3 dimension sparse table for command/creature/firing weapon combos,
--holds the position of a unit in a command's delay set, on a per weapon basis
rangedArrayPos=rangedArrayPos or {}

--
rangedResetTimeouts=rangedResetTimeouts or {}

eventful.enableEvent(eventful.eventType.UNLOAD,1)
eventful.onUnload.rangedTriggerModule = function()
 rangedTriggers = {}
 rangedArrayPos = {}
 rangedResetTimeouts = {}
end

function eventfulFunc(projectile)
  if projectile.distance_flown~=0 then return end
  for funcName,func in pairs(rangedTriggers) do
    if func(projectile,funcName) then return end
  end
 end
eventful.onProjItemCheckMovement.rangedTriggerModule = eventfulFunc

function getCommandFunc(reqProjMats,reqProjTypes,reqWeaponMats,reqWeaponTypes, timeBase, timeMult, resetBase, resetMult, neverReset)
  return function (proj,funcName)
    if not proj.firer then return false end
    local weapon=df.item.find(proj.bow_id)
   
    --dismembered limbs require this
   
    if not weapon then return false end

    --first off,checks to see if this conforms to the command requirements

    local found=false
    for _,mat in ipairs(reqProjMats) do
      if mat==dfhack.matinfo.decode(proj.item):getToken() then found=true end
    end
    if #reqProjMats>0 and not found then return false end
   
    found=false
    for _,mat in ipairs(reqWeaponMats) do
      if mat==dfhack.matinfo.decode(weapon):getToken() then found=true end
    end
    if #reqWeaponMats>0 and not found then return false end
   
    found=false
    if #reqProjTypes>0 and proj.item:getSubtype() ~= -1 then
      for _,itype in ipairs(reqProjTypes) do
        if  dfhack.items.getSubtypeDef(proj.item:getType(),proj.item:getSubtype()).id == itype then
          found=true
        end
      end
    end
    if #reqProjTypes>0 and not found then return false end
   
   
    found=false
    if #reqWeaponTypes>0 and weapon:getSubtype() ~= -1 then
      for _,itype in ipairs(reqWeaponTypes) do
        if  dfhack.items.getSubtypeDef(weapon:getType(),weapon:getSubtype()).id == itype then
          found=true
        end
      end
    end
    if #reqWeaponTypes>0 and not found then return false end
   
    --now, do internal stuff, initialize any rangedArrayPos data when necessary and set/reset the delay trigger 
    local oldThinkCounter=proj.firer.counters.think_counter
    if #timeBase>1 then
      if not rangedArrayPos[funcName][proj.firer.id] then rangedArrayPos[funcName][proj.firer.id]={} end
      if not rangedArrayPos[funcName][proj.firer.id][proj.bow_id] then rangedArrayPos[funcName][proj.firer.id][proj.bow_id]=1 end
      if not neverReset then
        local delayTime=math.max(1,math.floor(oldThinkCounter*resetMult+resetBase))
        if not rangedResetTimeouts[funcName][proj.firer.id] then rangedResetTimeouts[funcName][proj.firer.id]={} end
        if rangedResetTimeouts[funcName][proj.firer.id][proj.bow_id] and dfhack.timeout_active(rangedResetTimeouts[funcName][proj.firer.id][proj.bow_id]) then
          dfhack.timeout_active(rangedResetTimeouts[funcName][proj.firer.id][proj.bow_id],nil)
        end
        --these get used later when the projectile has probably been deleted
        --hence the need to store locally so we don't have dangling references causing segfaults
        local pid=proj.firer.id
        local bowid=proj.bow_id
        rangedResetTimeouts[funcName][pid][bowid]=dfhack.timeout(delayTime,'ticks',function() rangedArrayPos[funcName][pid][bowid]=1 end)
      end
    end
   
    --now the meaty bit - calculate and set the new think_counter time
    if #timeBase>1 then
      proj.firer.counters.think_counter=math.max(1,math.floor(oldThinkCounter*timeMult[rangedArrayPos[funcName][proj.firer.id][proj.bow_id]]+timeBase[rangedArrayPos[funcName][proj.firer.id][proj.bow_id]]))
    else
      proj.firer.counters.think_counter=math.max(1,math.floor(oldThinkCounter*timeMult[1]+timeBase[1]))
    end
    --iterate through the array of times
    if #timeBase>1 then
      rangedArrayPos[funcName][proj.firer.id][proj.bow_id]=rangedArrayPos[funcName][proj.firer.id][proj.bow_id]+1
      if rangedArrayPos[funcName][proj.firer.id][proj.bow_id]>#timeBase then
        rangedArrayPos[funcName][proj.firer.id][proj.bow_id]=1
      end
    end
    return true
   
  end
 
end
 
local validArgs = utils.invert({
 'help',
 'clear',
 'reset',
 'name',
 'reqProjMat',
 'reqProjType',
 'reqWeaponMat',
 'reqWeaponType',
 'timeBase',
 'timeMult',
 'neverReset',
 'delayBase',
 'delayMult'
})

if moduleMode then return end

local args = utils.processArgs({...}, validArgs)

if args.help then
 print(usage)
 return
end

if args.clear then
  return --todo, code below won't work
  --rangedTriggers[args.clear]=nil
  --rangedArrayPos[args.clear]=nil
  --if dfhack.timeoutActive(rangedDelayedReset[args.clear]) then
   -- dfhack.timeoutActive(rangedDelayedReset[args.clear],nil)
  --end
end

if args.reset then
  return --todo
end

local reqProjMats={}
local reqProjTypes={}
local reqWeaponMats={}
local reqWeaponTypes={}
local timeBase={0}
local timeMult={0}
local resetBase=0
local resetMult=5
local neverReset=false

if type(args.reqProjMat)=='string' then
  reqProjMats={args.reqProjMat}
elseif type(args.reqProjMat)=='table' then
  reqProjMats=args.reqProjMat
end
if type(args.reqProjType)=='string' then
  reqProjTypes={args.reqProjType}
elseif type(args.reqProjType)=='table' then
  reqProjTypes=args.reqProjType
end
if type(args.reqWeaponMat)=='string' then
  reqWeaponMats={args.reqWeaponMat}
elseif type(args.reqWeaponMat)=='table' then
  reqWeaponMats=args.reqWeaponsMat
end
if type(args.reqWeaponType)=='string' then
  reqWeaponTypes={args.reqWeaponType}
elseif type(args.reqWeaponType)=='table' then
  reqWeaponTypes=args.reqWeaponType
end


if not args.timeBase and not args.timeMult then
  error("-timeBase or -timeMult must be defined")
end

if args.timeBase and type(args.timeBase)=='string' then
  timeBase={args.timeBase}
elseif args.timeBase then
  timeBase=args.timeBase
end

if args.timeMult and type(args.timeMult)=='string' then
  timeMult={args.timeMult}
elseif args.timeMult then
  timeMult=args.timeMult 
end


for i,numb in ipairs(timeBase) do
  timeBase[i]=tonumber(numb)
  if not timeBase[i] then
    error("all elements of timeBase must be numbers")
  end
end

for i,numb in ipairs(timeMult) do
  timeMult[i]=tonumber(numb)
  if not timeMult[i] then
    error("all elements of timeMult must be numbers")
  end
end

if #timeBase>1 and #timeMult>1 and #timeBase~=#timeMult then
  error("-timeBase and -timeMult must be the same length when they are both tables")
end

if #timeBase>1 and #timeMult==1 then
  for i=#timeMult+1,#timeBase do
    timeMult[i]=timeMult[1]
  end
end

if #timeMult>1 and #timeBase==1 then
  for i=#timeBase+1,#timeMult do
    timeBase[i]=timeBase[1]
  end
end

if args.resetBase then
  resetBase=tonumber(args.resetBase)
  if not resetBase then error("resetBase must be a number") end
end

if args.resetMult then
  resetMult=tonumber(args.resetMult)
  if not resetMult then error("resetMult must be a number") end
end

if args.neverReset then
  neverReset=true
end

if not args.name then error("-name must be specified") end

rangedTriggers[args.name]=getCommandFunc(reqProjMats,reqProjTypes,reqWeaponMats,reqWeaponTypes, timeBase, timeMult, resetBase, resetMult, neverReset)
rangedArrayPos[args.name]={}
rangedResetTimeouts[args.name]={}
I *think* it works without any issues, but I wouldn't be surprised if I screwed something up somewhere, so test it and tell me how it goes. Also tell me if the documentation is understandable - my technical writing skills are mediocre at best.

Of course, anyone else is welcome to use it as well if they want to.

EDIT:I missed a couple of bugs - only the last script call would actually function correctly, and passing tables to both timeMult and timeBase would throw an error.  Those are now fixed.  Also, now it uses the built in item find(id) function instead of my own home rolled one.  Code has been updated above.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on August 30, 2018, 08:59:17 pm
I have been playing around with something lately, and I have just gotten it to a basically functional point (although I will revisit it later and add/tweak a few things).  I figured that in the meantime you might like to have it for some double barrel muskets or something.
Code: [Select]
I *think* it works without any issues, but I wouldn't be surprised if I screwed something up somewhere, so test it and tell me how it goes. Also tell me if the documentation is understandable - my technical writing skills are mediocre at best.

Of course, anyone else is welcome to use it as well if they want to.

Bloody hell mate! I'm both impressed and shamed.
All I can contribute is df.item.find(item_id) and you can get persistence by hijacking a (hopefully) unused field in the bow if there is one. I think you just made a lot of modders very happy.
Definitely get it included as one of the built-in modtools when it's finished.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: thefriendlyhacker on August 30, 2018, 10:34:16 pm
...
All I can contribute is df.item.find(item_id)...
Ah, so I was blind.  Good to know.
Quote
...and you can get persistence by hijacking a (hopefully) unused field in the bow if there is one.
...
Ehhh, I don't particularly like the idea of sticking data in random bits of apparently currently hopefully unused memory. It just reeks of "this will bite me in the ass later in excitingly exotic ways".  Not to mention the fact that I have several bits of data I need to keep track of, and I would need to change the script logic to remove the "each weapon+firer+command combo has it's own data" stuff (and deal with a bunch of edge cases I avoided by using the current logic), and I intend to add some other scripts of a similar nature at a later date, so I am going to need to hijack a lot of unused memory.

With all that, it is probably easier in the long run to take the rather weird data structures provided by dfhack's existing persistent storage lua interface (read:paper thin wrapper over some internal DF data structure that dfhack commandeered), write a wrapper that treats each entry as a linked list element with a flag for type, and then go swap out the current table based implementation with a persistent linked list version that is virtually identical logic wise besides some code to restart lost timeout calls, and maybe deleting unneeded tables/linked lists when calling the delayed reset function to minimize the potential accumulation of several megabytes of memory/hard disk overhead in a long running fort.  The only serious piece of coding I would need to do is the wrapper itself, and the difficulty in that will stem from me being fairly unfamiliar with Lua more than anything else.

All this will come later, though.  For the moment, I am going to stress test what I have already by adding script calls for most of Fallout Equestria's firearms, mod in a reaction to create SMGs, and maybe mod in another reaction to duct tape two SMGs to a chainsaw glaive for funsies and maximum firepower (I shall call it a storm glaive, and it shall be glorious).
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on August 31, 2018, 01:29:58 am
Ehhh, I don't particularly like the idea of sticking data in random bits of apparently currently hopefully unused memory. It just reeks of "this will bite me in the ass later in excitingly exotic ways".  Not to mention the fact that I have several bits of data I need to keep track of, and I would need to change the script logic to remove the "each weapon+firer+command combo has it's own data" stuff (and deal with a bunch of edge cases I avoided by using the current logic), and I intend to add some other scripts of a similar nature at a later date, so I am going to need to hijack a lot of unused memory.

With all that, it is probably easier in the long run to take the rather weird data structures provided by dfhack's existing persistent storage lua interface (read:paper thin wrapper over some internal DF data structure that dfhack commandeered), write a wrapper that treats each entry as a linked list element with a flag for type, and then go swap out the current table based implementation with a persistent linked list version that is virtually identical logic wise besides some code to restart lost timeout calls, and maybe deleting unneeded tables/linked lists when calling the delayed reset function to minimize the potential accumulation of several megabytes of memory/hard disk overhead in a long running fort.  The only serious piece of coding I would need to do is the wrapper itself, and the difficulty in that will stem from me being fairly unfamiliar with Lua more than anything else.

Probably a good shout on the 'unused' memory, I considered using the built-in persistent storage to store venom types for chemical shells, but my lack of experience and the warning about significant overhead scared me off.
Forgive me if this is a completely asinine question, but mightn't it be easier and more lightweight to simply hold the necessary stuff in memory until the player saves and then write to an external file, with a game state listener to load it in again with the save? Might be more lightweight than storing it in histfigs (if the persistent tables still are) and you'd get finer control over the whole process.

All this will come later, though.  For the moment, I am going to stress test what I have already by adding script calls for most of Fallout Equestria's firearms, mod in a reaction to create SMGs, and maybe mod in another reaction to duct tape two SMGs to a chainsaw glaive for funsies and maximum firepower (I shall call it a storm glaive, and it shall be glorious).

A sturmglaive does indeed sound a glorious weapon.
I couldn't help but notice the postponed energy weapons in Equestria and wondered if you saw the rubbishy attempt at a lasgun posted earlier. I've been having some fun with trying to turn it into a tesla rifle using hot syndrome gas (that causes paralysis and blisters on contact and can melt bodyparts) rather than spawning in a projectile when the beam hits and I think something vaguely like that (without the paralysis and shoddy attempt at curving/branching) would make good fallout-esque laser weapons:

(https://i.imgur.com/KbVgzIa.gif)
Title: Re: [44.12] Musket-Mod v0.4i
Post by: Meph on August 31, 2018, 08:38:54 am
Seeing that gif: could I please have randomized lightning strikes when it rains ingame, pretty please? ;)
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on August 31, 2018, 03:31:05 pm
Seeing that gif: could I please have randomized lightning strikes when it rains ingame, pretty please? ;)

I had a quick look and found df.weather_type[dfhack.world.ReadCurrentWeather()] so it should be possible to check that every n ticks for rain and use an rng to control the chances of lightning spawns. Not too experienced with timeout loops so it would be quite rough, but functional. Some more data on weather duration and so on would be helpful but I was unable to find any.

After having a play today, I need to get an inorganic gas 'lightning' that is more reliable in melting limbs and such, doesn't seem to transfer its heat as well as I previously thought. Making it hotter didn't work so I'll have to try more dense and failing that, spawning a couple of tiles of flow when the beam touches a unit. Would be nice for weather if the gas interacted with the world more too.

Edit: Both increasing the density and number of individual flows spawned when a unit is detected made it reliably deadly, but also occasionally melts parts of the user. A fight between an automusket wielding dwarf and one with a lightning gun lead to them both dying of bodily disintegration. Needs more work.

I'd also need to rewrite it to make up a path from the top of the skybox to the ground rather than get one from a projectile, not sure if the top z-level is hardcoded or related to the altitude of the embark. Edit: Found some stuff related to map dimensions in 'df.global.world.map'.

There are also a few console errors related to branching that need to be ironed out (due to always doing this stuff when tired).

Once that's all figured out it should be straightforward but the player would usually only see one tile of lightning anyway which could be more easily achieved by:
https://github.com/Pheosics/v24-r3_Scripts/blob/master/hack/scripts/flow/customweather.lua

Edit:
Okay, it's done. I'm having to release this with a disclaimer though: I put the check frequency waayy too high whilst I was writing it and my PC had a seizure and crashed. I had a bunch of stuff open, hadn't freshly booted in weeks, was watching a stream and listening to music and was running the script every tick. Might have been a thermal shutdown as it was on my laptop.
I've changed much about how it works and it's not happened again but I wanted to give people fair warning.

I put a bunch of variables at the top to tweak it to your liking. Only tested it in arena mode.

http://dffd.bay12games.com/file.php?id=13997
Title: Re: [44.12] Musket-Mod v0.4i
Post by: cltail on September 05, 2018, 11:19:06 am
I was looking into the possibility of making a civ that would use these weapons, but it seems like right now if i gave them the weapons they would make them out of whatever materials they wanted (including wood, I think.) unless I only gave them steel for everything, which i really don't want to do. I know for a fact that the guns work perfectly fine as any material, all the reactions and scripts are already fine with anything.

I'm not worried about balance issues, a copper musket will be much less effective in caving in someone's head than a steel one would, and the steel musket's bayonet would be considerably sharper. I just don't want there to be a situation where the player would go "Why can they make guns out of anything, and I can't?"

Ideally i would just let the player make anything to compensate for the fact I have no control over what other civs make their guns out of. I would have just done that myself instead of complaining here if I knew of any way to have the custom workshop allow any metal in a reasonable way that doesn't involve making a custom reaction for every single metal, or letting dwarves pick whatever metal they want - forcing the player to mess with stockpiles to force a specific material.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on September 05, 2018, 12:27:16 pm
I was looking into the possibility of making a civ that would use these weapons, but it seems like right now if i gave them the weapons they would make them out of whatever materials they wanted (including wood, I think.) unless I only gave them steel for everything, which i really don't want to do. I know for a fact that the guns work perfectly fine as any material, all the reactions and scripts are already fine with anything.

I'm not worried about balance issues, a copper musket will be much less effective in caving in someone's head than a steel one would, and the steel musket's bayonet would be considerably sharper. I just don't want there to be a situation where the player would go "Why can they make guns out of anything, and I can't?"

Ideally i would just let the player make anything to compensate for the fact I have no control over what other civs make their guns out of. I would have just done that myself instead of complaining here if I knew of any way to have the custom workshop allow any metal in a reasonable way that doesn't involve making a custom reaction for every single metal, or letting dwarves pick whatever metal they want - forcing the player to mess with stockpiles to force a specific material.

I know how you feel, this bothers me too.
It wouldn't be a problem to allow only metals (of all types), like the bullet reaction does, but it would be nicer to allow firearms to use only weapons grade metals without the tedium of a separate reaction for each metal for each weapon.

I think the trick would be making use of a tag like [METAL_WEAPON_MAT] or [ITEMS_WEAPON] where the metal reagent is specified but I know next to nothing about raw modding and have no idea how to use these tags.

Failing that, another way of doing it would be having the barrels made as a tool at the metalsmith's forge so as to make use of the native metal choice menu, and requiring the barrel in the musket reaction in place of the current steel bars.
Might be too micromanage-y for some players, though.

I'm hoping Grim or thefriendlyhacker or Meph another competent person comes along to help you and I out with this. I'm just finishing up with the re-implemented chemical weapons and then a bunch of nearly-finished other stuff on the to-do list like the lightning gun, but I'll be sure to devote some more time to this in future once I get this update out.
Until then, you might have problems with cannon rotation if you put it in your mod ATM, it's currently dependent on custom workshop load order because I'm an idiot.

Keep me posted if you have any breakthroughs.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: thefriendlyhacker on September 05, 2018, 06:24:48 pm
I was looking into the possibility of making a civ that would use these weapons, but it seems like right now if i gave them the weapons they would make them out of whatever materials they wanted (including wood, I think.) unless I only gave them steel for everything, which i really don't want to do. I know for a fact that the guns work perfectly fine as any material, all the reactions and scripts are already fine with anything.

I'm not worried about balance issues, a copper musket will be much less effective in caving in someone's head than a steel one would, and the steel musket's bayonet would be considerably sharper. I just don't want there to be a situation where the player would go "Why can they make guns out of anything, and I can't?"

Ideally i would just let the player make anything to compensate for the fact I have no control over what other civs make their guns out of. I would have just done that myself instead of complaining here if I knew of any way to have the custom workshop allow any metal in a reasonable way that doesn't involve making a custom reaction for every single metal, or letting dwarves pick whatever metal they want - forcing the player to mess with stockpiles to force a specific material.
Here is an idea you could try that is a little hacky but that gets the job done.  Add a tool called a "firearm components" or whatever, and another called a "heavy firearm components".  Make six custom reactions (copper,bronze, bismuth bronze, iron, steel, candy) per component, with 1 bar for normal components and two bars for heavy parts, and then use one of those components in the making of each firearm, taking the component item's metal as the product weapon's metal.  That will let the player use whatever weapon metal materials they want without bloating workshop menus with dozens of custom reactions.

Oh, and afaik most civs only use ranged weapons made of weapon metals. Unless you are giving guns to an elf type civ that uses wood, I don't think wooden firearms are a problem.  Barring a civ that uses wooden weapons, the only time you will see wood guns is artifacts.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: Grimlocke on September 05, 2018, 07:30:39 pm
Civs will have ranged weapon made only from metals with the [ITEMS_WEAPON_RANGED], removing this from bronze and iron really makes sense in general. Only if they are treehuggers, they will use wood instead, but the ability to make a wooden musket will still show up in the bowyers workshop in fortress mode and I think there are some instances where wooden ranged weapons turn up in adventurer mode, so perfect it is not.

Best solution is usually to just not add the special ranged weapons to your own civ and make them with reactions instead, since you have to do some really unsubtle dfhack things to get rid of the automatically spawned weapon production jobs. I personally only added iron and bronze for one type and steel and bronze for the other type of firearm I added, lead and rock for small arms ammunition and iron and rock for cannons. The number of reactions is a dozen or so, including some weapons that are made in two stages. Since material doesn't factor much or at all into how ranged weapons perform there isn't a whole lot of a point out of making them out of high-grade stuff.

There is also the really radical solution of adding a dfhack item trigger that magically transforms dumb things like wooden bullets into lead bullets. I might actually have to look into that if I don't find another way to tinker with melee combat balance; dfhack eventful's onUnitAttack event listener seems to run after attacks hit and is thus not really useful at all for tinkering with melee balance.

More on topic, I've added damage falloff, dfhack command line weapon/ammo property population and various other stuffs to the ranged weapon script and gave up on trying to get items in a workshop into a container that is a building item in that workshop and just went went 'delete them and spawn a new one'. It's simple not possible to get the !@#&^!( things out of the workshop through any of the stock DFhack or vmethod functions, best I managed to do was weirdly making them exist both in the workshop and on the floor at the same time which didn't help. Dropping them from a height worked but I'd have to do some weird timeout thing and get it to be smart about finding a place to drop from aaand... none of that is any more graceful than just duping the items, copying the itemquality and deleting the obstinate buggers in the workshop.

Job/reaction triggers also have the same problem as onUnitAttack in that they run just after or before the thing I want to modify exists. (job time in this case, I want to make firing the cannon not take forever).
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on September 08, 2018, 07:42:06 pm

Thanks for the help guys. Might be necessary to make something to write the reactions for me and hide them away behind reaction categories like the metalsmith's does.

More on topic, I've added damage falloff, dfhack command line weapon/ammo property population and various other stuffs to the ranged weapon script and gave up on trying to get items in a workshop into a container that is a building item in that workshop and just went went 'delete them and spawn a new one'. It's simple not possible to get the !@#&^!( things out of the workshop through any of the stock DFhack or vmethod functions, best I managed to do was weirdly making them exist both in the workshop and on the floor at the same time which didn't help. Dropping them from a height worked but I'd have to do some weird timeout thing and get it to be smart about finding a place to drop from aaand... none of that is any more graceful than just duping the items, copying the itemquality and deleting the obstinate buggers in the workshop.

Job/reaction triggers also have the same problem as onUnitAttack in that they run just after or before the thing I want to modify exists. (job time in this case, I want to make firing the cannon not take forever).

Interesting, does the damage falloff modulate sharpness or something using distance_flown?

I want to spend some more time with trying to get items out of buildings, what you've said about dropping from a height could be useful.
If the ammo can't be moved through changing fields (though I still hope it can be), you could maybe teleport it to {0, 0, map.z_count} and then instantly moveToGround() it to the position of the muzzle given by checkDirection(cannon, nil, 2) in the cannon script.
Janky as hell, but no-one would know.

I'm worried a reaction with no product (and no createItem()) wouldn't train the siege operation skill of the firer, though, so it would need to be increased manually if this is the case.

As for reaction speed, did you do some tests with firer skill?
Using armoks-blessing during testing increases the reaction speed significantly, you would just need to increment the units SIEGEOPERATE skill +=20 onJobInitiated() and decrement -=20 onJobCompleted(), if it doesn't bother you that cancelling the job might permabuff the firer.
Could add a timeout debuff rather than onJobCompleted() and have a skill level check before applying the buff (preventing double buffing) to avoid that I guess.

I've been thinking about adding something similar for rotate and fire, but my hands are full ATM working on next version, twbt is a pain and I'm battling brain fog.
Had to merge the weapons scripts (hope you don't think I'm aping you too much with that, Grim) as they were beginning to trip up over one-another due to explosions destroying items before they could be removed on impact and causing many other weirdnesses like "floaty ricochets" where the projectile would serenely drift around the map after hitting something. Think that one was the distance_flown counter resetting on impact and triggering the accuracy modifier.
Unified existence checks are much easier to manage and I won't keep accidentally overwriting event listeners like an idiot now.

Edit: On a similar note to the skill buff thing, I noticed your post mentioning cannon operator fear in the History & Realism Mod thread, I'm very curious how you've managed to avoid that. The only way I can think of doing it is onJobInitiated() applying a temporary syndrome that adds the NOFEAR tag to the firer.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: Grimlocke on September 10, 2018, 02:06:17 pm
The damage falloff right now just modifies velocity every 4 tiles of distance flown by something below 1 (or above 1 if your making a rocket or something). Its a bit crude and I might replace that with table that stores per-projectile properties (also handy for smoke, on-impact effects and preventing dumb stuff like smoke being triggered on bullets dropping after they ran out of reach), but it does work nicely for making gunpowder smallarms only go through armor at closer ranges, which was what they were known to do in the middle ages.

Dropping items from a height would in theory work and tried what your suggested, but the item only gets removed from the building holder list once it starts dropping, which is at least 1 tick so you would have to teleport it, use a timeout to wait for it to actually start dropping and then teleport it where you need it. Small bonus might be that it will already be a projectile at that point, so you might only have to change origin/target positions. Its... both kinda janky, so take your preferred pick :)

I should mention that moveToGround and then immediately moving it to container worked at some point when I set the move coords to 5,5,5 but it only worked on one map and I havn't been able to reproduce that. It was weird.

The thing about operator skill is a good point... if product-less reactions don't train them I'll have to add the skill manually since firing the cannon also doens't yield any product.

The way I'm having the reactions go faster now is by adding every initiated artillery job to a table, checking job.completion_timer every 50 ticks, doing nothing if its -1 (default state if no dwarf is working the job yet), to 80 if no target is found and to 0 if one is found as well as dropping the job from the table. Using completion_timer seems to have no downsides and doesn't have issues like gunners gaining skill from having commands cancelled, dwarves finding no targets will just wait for something to blast until the job is cancelled or presumably until the dwarf gets sick of it due to starvation/etc. The only issue I'm having is that the script seems to have trouble identifying a firer every now and then.

The trick I'm using right now for artillery dwarves getting spooked and running off is kinda dumb to be honest, I just make the front facing workshop tiles non-passable. It makes some amount of sense for medieval guns which were often placed behind wooden barricades, what with them often being set up in range of crossbows and other small weapons. I've not really tested it extensively though, my reserve solution was making the operator blind. Can't be spooked by things you can't see and blind dwarves don't really seem impeded in doing jobs. NOFEAR might work too, though it might result in typical dwarf behaviour of leaving the gun to charge and hit them with a sock.

I should also add that onJobInitiated triggers once the player orders up the job, immediately checking for a firer to modify results in the script borking because it doesn't have a firer yet.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on September 10, 2018, 07:05:37 pm
The damage falloff right now just modifies velocity every 4 tiles of distance flown by something below 1 (or above 1 if your making a rocket or something). Its a bit crude and I might replace that with table that stores per-projectile properties (also handy for smoke, on-impact effects and preventing dumb stuff like smoke being triggered on bullets dropping after they ran out of reach), but it does work nicely for making gunpowder smallarms only go through armor at closer ranges, which was what they were known to do in the middle ages.

I'm actually putting in a table using your example ATM to store different smoke amounts, I haven't put the unique effects in yet, as I was worried about too many table lookups. It looks messier just doing weapon-type checks for weapon-specific function calls in onProjItemCheckMovement, but I think it might be nicer on performance. I'm using the weaponProperties table with indexes to avoid slower string hash lookups too, but again, messier.

Have you noticed any impact on performance storing more stuff in tables? I might just have to bite the bullet (npi), listen to thefriendlyhacker's reminder about writing to disk and get everything into a table if I'm able.

Dropping items from a height would in theory work and tried what your suggested, but the item only gets removed from the building holder list once it starts dropping, which is at least 1 tick so you would have to teleport it, use a timeout to wait for it to actually start dropping and then teleport it where you need it. Small bonus might be that it will already be a projectile at that point, so you might only have to change origin/target positions. Its... both kinda janky, so take your preferred pick :)

I should mention that moveToGround and then immediately moving it to container worked at some point when I set the move coords to 5,5,5 but it only worked on one map and I havn't been able to reproduce that. It was weird.

Damn. That's disappointing. I'll have to keep messing about, I'll be sure to let you know if I come across anything.

The way I'm having the reactions go faster now is by adding every initiated artillery job to a table, checking job.completion_timer every 50 ticks, doing nothing if its -1 (default state if no dwarf is working the job yet), to 80 if no target is found and to 0 if one is found as well as dropping the job from the table. Using completion_timer seems to have no downsides and doesn't have issues like gunners gaining skill from having commands cancelled, dwarves finding no targets will just wait for something to blast until the job is cancelled or presumably until the dwarf gets sick of it due to starvation/etc. The only issue I'm having is that the script seems to have trouble identifying a firer every now and then.

I should also add that onJobInitiated triggers once the player orders up the job, immediately checking for a firer to modify results in the script borking because it doesn't have a firer yet.

Doy, of course there is a counter for it.  :-[
It's nice that the unit stands ready too, would make the idea of a fixed machine gun possible. Could set the timer to a given point above zero (accounting for normal tick-down) corresponding to ammo remaining in the gun and decrement the counter for each bullet fired so the unit doesn't complete the reaction until the gun is empty (or he gets hungry as you say). Looking forward to getting my meathooks on your code and seeing your implementation, I like how thoroughly you think through these things.

I also have had some strangeness with missing firers, it can usually just be checked for and ignored for infantry weapon projectiles (as I'm sure you know), but it's definitely more of an issue for cannon reactions.
The only thing I can offer to help is upon failing to find a firer with the usual check, maybe grab all units in the workshop with dfhack.getUnitsInBox() when the timer starts (assuming the timer stays at -1 until the work actually starts) and checking their profession to ensure you have got the firer and not a kitty, might not be too useful if you need the firer straight away, though.

If that timer works as I think it does, it could give a much-needed modicum of control between a job starting and finishing. Thanks for sharing and being so open, I really owe you one.

The trick I'm using right now for artillery dwarves getting spooked and running off is kinda dumb to be honest, I just make the front facing workshop tiles non-passable. It makes some amount of sense for medieval guns which were often placed behind wooden barricades, what with them often being set up in range of crossbows and other small weapons. I've not really tested it extensively though, my reserve solution was making the operator blind. Can't be spooked by things you can't see and blind dwarves don't really seem impeded in doing jobs. NOFEAR might work too, though it might result in typical dwarf behaviour of leaving the gun to charge and hit them with a sock.

I did consider that method when I read your post, I'm guessing from what you say it causes no problems for the projectile. I'd also be concerned about loading under fire though, I think I'll have to test out some syndromes.
Removing sight is a fine idea, you might have to employ a timeout eyeball de-pluck for abandoned job cases, mind. That's the strangest sentence I've written today.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: Grimlocke on September 11, 2018, 01:40:43 pm
I'm having some issues with the tables still, I'll post it when everything is behaving as desired. Right now it works as long as there are a few guns all neatly completing their reactions, but it breaks once you spam a bunch of reactions (table becomes too large and complains about running out of memory) and when reactions are cancelled (the table entry will linger), I'll have to find a better way to check whether jobs are dead than just completion_timer being 0 and not store the entire job and building entry in the table (just the IDs instead and only looking up the actual job/building/units once the job is under way). I havn't noticed any effect on performance, but I've only let the timeout check the table every 50 ticks so it only does a single check on the job timer per job per 50 ticks, which isn't really a massive burden as long as the table doesn't become polluted with lingering rubbish.

I'm currently in the process of moving though so the next few days will be somewhat less productive for me.

Also yes, that last sentence would make an interesting out of context quote :)
Title: Re: [44.12] Musket-Mod v0.4i
Post by: Splint on September 11, 2018, 01:53:40 pm
Really quick question, would copy-pasting the override stuff into a separate download of Meph's tileset break anything? I have absolutely no idea how graphic-related stuff works beyond some very bare-bones work I've started, and I'd love to have my engineering sector have just a bit more bite to it than a siegeworks and a couple mechanic workshops, and I don't wanna go just copy-pasting the override.txt into a fresh install of the tileset.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on September 11, 2018, 04:33:17 pm
I'm having some issues with the tables still, I'll post it when everything is behaving as desired. Right now it works as long as there are a few guns all neatly completing their reactions, but it breaks once you spam a bunch of reactions (table becomes too large and complains about running out of memory) and when reactions are cancelled (the table entry will linger), I'll have to find a better way to check whether jobs are dead than just completion_timer being 0 and not store the entire job and building entry in the table (just the IDs instead and only looking up the actual job/building/units once the job is under way). I havn't noticed any effect on performance, but I've only let the timeout check the table every 50 ticks so it only does a single check on the job timer per job per 50 ticks, which isn't really a massive burden as long as the table doesn't become polluted with lingering rubbish.

I'm currently in the process of moving though so the next few days will be somewhat less productive for me.

Also yes, that last sentence would make an interesting out of context quote :)

No worries, man. I'll have a bash at something using what you've told me about the timer (thanks again for that) and you can have a good laugh at my bumbling attempts.
I've put in the cannon 'wall' and after finding adding anonymous syndromes and curses would be harder than I thought, I'll have to use vision_impaired until they get into the workshop. It's either that or define a NOFEAR syndrome in an 'adrenaline' inorganic and I'm not too happy about doing that, I was really hoping I could just insert a syndrome synthesized with DFHack.
Hope the move goes well for you and you get settled nicely.

Really quick question, would copy-pasting the override stuff into a separate download of Meph's tileset break anything? I have absolutely no idea how graphic-related stuff works beyond some very bare-bones work I've started, and I'd love to have my engineering sector have just a bit more bite to it than a siegeworks and a couple mechanic workshops, and I don't wanna go just copy-pasting the override.txt into a fresh install of the tileset.

It shouldn't do as long as you only paste in the tileset declaration:
Code: [Select]
[TILESET:musketmod.png:musketmod.png:musketmod_overrides]
as well as the block starting with:
Code: [Select]
[OVERRIDE:228:I:TRAPCOMP:TRAPCOMP:0:musketmod_overrides:83] - cannonball
over the block containing the vanilla trapcomps (so as to update the indexes) into the new overrides.txt.

I'm quite curious as to why you want to add the overrides into a new file rather than copying it, is it due to the new release of Meph's tileset, a mod or something else?
If it's the new Meph tileset, I do apologize for not updating it sooner, I'm nearly done with the next version which will support it.

BTW, did you find everything to be deadly enough for your tastes and to justify the material investment?
Title: Re: [44.12] Musket-Mod v0.4i
Post by: Splint on September 11, 2018, 04:52:14 pm
It is indeed due to updates to the main tileset (of which I suspect another might be coming soon, but I'd have to ask Meph to confirm.) He asked me to show off the tileset, and I figured I'd go ahead and add a few other mods mainly to spice things up, since just a boring old building fort isn't really my style - I'm a war-mongering jackass after all, and I figure I can use it as an opportunity to tell a good story and use the tileset to make a fort that looks damned good while doing it.  ;D

Besides, tell me that copper set isn't begging to be a building for a gunsmith.

I haven't actually used it yet though, unfortunately. Been fiddling around with a whole bunch of other stuff, both mods and not, as well as chipping away at graphics for ZM5's cavern and biome mods, which is... Well, even if I weren't drawing for money or playing games alongside everything else, it's still gonna be a herculean task just in terms of number of things. But I'm genning up a world with the musket mod right now, mainly to see it in action alongside bug-testing stuff of my own.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on September 11, 2018, 05:57:37 pm
It is indeed due to updates to the main tileset (of which I suspect another might be coming soon, but I'd have to ask Meph to confirm.) He asked me to show off the tileset, and I figured I'd go ahead and add a few other mods mainly to spice things up, since just a boring old building fort isn't really my style - I'm a war-mongering jackass after all, and I figure I can use it as an opportunity to tell a good story and use the tileset to make a fort that looks damned good while doing it.  ;D

Besides, tell me that copper set isn't begging to be a building for a gunsmith.

I haven't actually used it yet though, unfortunately. Been fiddling around with a whole bunch of other stuff, both mods and not, as well as chipping away at graphics for ZM5's cavern and biome mods, which is... Well, even if I weren't drawing for money or playing games alongside everything else, it's still gonna be a herculean task just in terms of number of things. But I'm genning up a world with the musket mod right now, mainly to see it in action alongside bug-testing stuff of my own.

Ah, I am sorry for dropping the ball on that one and not getting this out sooner. The blame rests squarely on man flu for that.
It's a damned shame you won't get to gas/zap/flamethrow some gobbos/unspeakable horrors for your readers. I'm even retouching the sprites despite my limited ability:

(https://i.imgur.com/wutK1eY.png)

I'm really digging the tesla-esque stuff, I've tried to incorporate material graphics into the workshops (copper cannon barrels and whatnot) but not yet found a way to make it work.

Let me know if you're unhappy with any of the weapons, and watch out for the explosive weapons causing massive fires if you embark in a forested or grassy area (unless a landscape ravaged by war and industry is what you're going for).

I really don't envy you taking that on, I had a look at your announcement and I'm impressed, those things look f*cking twisted (in the nicest possible way) but it seems like a lot of work, be careful not to burn yourself out. I especially like the Flesh Harvester, it's a cutie!
Title: Re: [44.12] Musket-Mod v0.4i
Post by: Splint on September 11, 2018, 06:43:18 pm
Believe it or not, if I can manage to make the place look like a blasted hellscape without  having to pumpstack up magma, whichr equires learning how to even do that, I'll consider it a win. I'll just need to be careful to not use rockets and the like while the infantry are beyond the defenses.  ;)

I also dunno why, but I'm digging the automusket's look.

Quote
I really don't envy you taking that on, I had a look at your announcement and I'm impressed, those things look f*cking twisted (in the nicest possible way) but it seems like a lot of work, be careful not to burn yourself out. I especially like the Flesh Harvester, it's a cutie!

Yeah, well, I figure since I can't really afford to pay someone and happen to have some drawing ability, might as well make them more accessible by including graphics, right? And that'd be on ZM5, he's the one who gave them purple-ish skin. :P
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on September 12, 2018, 10:08:36 pm
Believe it or not, if I can manage to make the place look like a blasted hellscape without  having to pumpstack up magma, whichr equires learning how to even do that, I'll consider it a win. I'll just need to be careful to not use rockets and the like while the infantry are beyond the defenses.  ;)

No, I completely understand. I've given some early thought to terrain and construction damage from explosions for that very reason, it'd take a lot of work if it's even possible but it would be fun to have a cratered and decimated landscape and would allow for Helm's Deep-esque wall breaches (albeit accidental ones) and a drilling and blasting workshop for mining too.
Friendly fire is going to be even more of a problem with chemical weapons leaving residue on goblinite.
Decontamination chambers and making fully covering uniforms should help. I don't really want to add in an explicit hazmat suit or anything. Doesn't seem right, more fun to let players design their own.

Yeah, well, I figure since I can't really afford to pay someone and happen to have some drawing ability, might as well make them more accessible by including graphics, right? And that'd be on ZM5, he's the one who gave them purple-ish skin. :P

Completely, I love the ascii look (especially wanderlust with the pastel colour scheme) but tilesets make playing so much easier on my atrophied brain. As a non-artist the amount of creatures just seems daunting. More power to you for taking those abhorrent f*ckers on.


Grim, I had a go at eye-plucking the firer and making them wait for a target, very slapdash, but seems to work if it's of any use to you: https://pastebin.com/5P1cZL5H
(hope I've credited you enough)

Note the addition of a killed check in isHostile() you may want to add, could explain the firing-at-seemingly-nothing bug you were having.
Only noticed the problem after repeated test firings at the corpse of an unfortunate wayward kitty. Foolish!
Title: Re: [44.12] Musket-Mod v0.4i
Post by: Grimlocke on September 14, 2018, 03:23:55 pm
Neat, the eye-poker will come of use for sure. I've found out what was causing my memory issues, namely not a memory issue; it just says that when it tried to check a job that no longer exists. Consequence of using a jobs table I guess, it should be faster but also a hassle to properly remove finished/canceled jobs.

Also hah, good catch on the hostility check. I wouldn't have figured dead things would still count as a unit, but I guess that is used for necromancers and such.

I should have this working once I figure out how to properly make a check identify job being dead (no luck in the short bit of time I've had, the only job property that is only present on canceled jobs is general_refs[0] instead of general_refs[1], these change numbers throughout for some reason but nuking any job with
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on September 14, 2018, 08:20:42 pm

Sounds like it should do, but I'm wondering if you're removing the actual jobs through setting the completion timer to 0 or through deleting them from the linked list. If you're doing the latter, did you catch the discussion on the current DFHack thread on page 97 where Fleeting Frames was attempting the same and expressed concern about memory leakage? Might be pertinent.
I'm personally hoping that completing the job with timer modification is triggering the GC and that nothing more needs to be done, though I have no way of checking (that I know of) without creating a reference to the job and impeding collection.

Also discovered a bug with the old targetDistance algorithm you might not have noticed whereby the target being at certain positions away from the cannon can result in the tile passability check being off by one either way.
As best I can tell it's due to them having to use differing methods of obtaining distances and me rejecting Pythagoras' theorem like the idiot I am. I've learned my lesson.

Changed waitForTarget(), canPathTo(), findDistance() and added tilePassable() and with many dead sheep bits in a refuse pile next to my cannon I'm confident it's fixed (thank f*ck).
Hope you've not made it too difficult on yourself to implement the fixed stuff with your modifications (more like improvements) but it should be easy enough to run a diff against the last version I posted and go from there (text-compare.com comes in handy if you don't have something in your environment), as always don't hesitate to ask.

https://pastebin.com/V8YPeiet

Edit: As a follow-up to expressing interest in terrain damage, I've done some really early tests and it seems easy enough to have wall-breaching explosives at the very least:
(https://i.imgur.com/UbixTQT.gif)
Title: Re: [44.12] Musket-Mod v0.5: Tesla Guns and Chemical Warfare
Post by: DWARFFRAWD on September 16, 2018, 03:05:39 am
I found mismatch.
tesla gun's token names are not same.


in reaction.txt ,
[PRODUCT:100:1:WEAPON:ITEM_WEAPON_GUN_LIGHTNINGGUN:GET_MATERIAL_FROM_REAGENT:B:NONE]

in weapon.txt ,
[ITEM_WEAPON:ITEM_WEAPON_GUN_TESLAGUN]
   
Title: Re: [44.12] Musket-Mod v0.5: Tesla Guns and Chemical Warfare
Post by: Sver on September 16, 2018, 09:43:40 am
Hey, nice work on the firearms! Would you mind if I make a compatibility patch between your mod and mine?

Also, in [REACTION:CANNONBALL], a closing bracket is missing in the line [CATEGORY_PARENT:FORGE_AMMO
Nothing cruicial, but the workshop category will probably not work properly.
Title: Re: [44.12] Musket-Mod v0.5: Tesla Guns and Chemical Warfare
Post by: zaporozhets on September 16, 2018, 11:58:39 am
I found mismatch.
tesla gun's token names are not same.


in reaction.txt ,
[PRODUCT:100:1:WEAPON:ITEM_WEAPON_GUN_LIGHTNINGGUN:GET_MATERIAL_FROM_REAGENT:B:NONE]

in weapon.txt ,
[ITEM_WEAPON:ITEM_WEAPON_GUN_TESLAGUN]

Hey, nice work on the firearms! Would you mind if I make a compatibility patch between your mod and mine?

Also, in [REACTION:CANNONBALL], a closing bracket is missing in the line [CATEGORY_PARENT:FORGE_AMMO
Nothing cruicial, but the workshop category will probably not work properly.

Thanks guys, I'm an idiot!
Hope it didn't cause you any trouble.

Sver, of course you can.
Can I be straightforward and ask if you're simply being lovely in asking or are genuinely unsure, a few people have asked and I'm worried I've not made it clear enough in the OP that I'm happy for this stuff to be used for whatever. Maybe everyone is just being nice and polite.
Title: Re: [44.12] Musket-Mod v0.5: Tesla Guns and Chemical Warfare
Post by: Sver on September 16, 2018, 12:31:23 pm
Sver, of course you can.
Can I be straightforward and ask if you're simply being lovely in asking or are genuinely unsure, a few people have asked and I'm worried I've not made it clear enough in the OP that I'm happy for this stuff to be used for whatever. Maybe everyone is just being nice and polite.

Oh, well, it's just that the head post talks specifically about scripts (which will not conflict with my mod in any way - I'm only modifying the raws), and I'm generally wary of straightaway including a huge chunk of someone else's work into my own upload, even with some changes applied.
I mean, it probably wouldn't hurt to specify that the raws are ok to use/modify too - if that's what you want. Then, some people may still be wary or just polite, but wha' can do about it :)
Title: Re: [44.12] Musket-Mod v0.5b: Tesla Guns and Chemical Warfare
Post by: Splint on September 16, 2018, 12:35:39 pm
Oh god, does this mean I could end up accidentally knocking down trees and walls if I get careless? I mean, if so, that's grand, just because you proved it was doable.
Title: Re: [44.12] Musket-Mod v0.5: Tesla Guns and Chemical Warfare
Post by: zaporozhets on September 16, 2018, 02:18:24 pm
Oh, well, it's just that the head post talks specifically about scripts (which will not conflict with my mod in any way - I'm only modifying the raws), and I'm generally wary of straightaway including a huge chunk of someone else's work into my own upload, even with some changes applied.
I mean, it probably wouldn't hurt to specify that the raws are ok to use/modify too - if that's what you want. Then, some people may still be wary or just polite, but wha' can do about it :)

Ah, I see. Probably should have been more clear on that, I'll get it changed. It's nice of you to ask anyway, I'm looking forward to seeing what you get up to with them.

Oh god, does this mean I could end up accidentally knocking down trees and walls if I get careless? I mean, if so, that's grand, just because you proved it was doable.

That's what I'm hoping for. I need to get it to trigger cave-ins first, only figured out it didn't do a support check after posting the gif  :-[ (hoping a DFHack guru can help me if I don't figure it out for myself).
Accidentally flooding the testing arena was a lot of fun, but I just couldn't live with floating floors.
Need to check for material strength too (so metal walls are stronger etc).
The plan is to give the basic firearms and the rocket launcher to the gobbos to eliminate turtling as an unbeatable strategy, not sure where that will leave the elves as they don't seem very firearm-y to me.

Edit: Figured out cave-ins, but the cave-in itself is creating a small amount of magma which is bizarre. I'll keep trying. This is just going to lead to AoE2 style multi-walls, isn't it?
Not sure whether to suppress surface collapse announcements or not.
Title: Re: [44.12] Musket-Mod v0.5b: Tesla Guns and Chemical Warfare
Post by: Sver on September 17, 2018, 10:00:28 am
Could you clarify a bit on the exact mechanics of the blunderbuss and the dragon pistol? Do the split shots retain the force and velocity of the weapon or is it uncertain?
Title: Re: [44.12] Musket-Mod v0.5b: Tesla Guns and Chemical Warfare
Post by: thefriendlyhacker on September 17, 2018, 11:36:24 am
Could you clarify a bit on the exact mechanics of the blunderbuss and the dragon pistol? Do the split shots retain the force and velocity of the weapon or is it uncertain?
I took a gander at the code, and if I understand correctly the code just changes the fired projectile to a pellet, creates duplicates of the projectile a few times, makes a projectile out of each of the duplicates, copies the projectile properties over and adds a random factor to the origin and destination tiles.  As such, the velocity and material of each pellet will be identical to the fired projectile.
Title: Re: [44.12] Musket-Mod v0.5b: Tesla Guns and Chemical Warfare
Post by: Sver on September 17, 2018, 12:20:57 pm
I took a gander at the code, and if I understand correctly the code just changes the fired projectile to a pellet, creates duplicates of the projectile a few times, makes a projectile out of each of the duplicates, copies the projectile properties over and adds a random factor to the origin and destination tiles.  As such, the velocity and material of each pellet will be identical to the fired projectile.

Thanks!
Title: Re: [44.12] Musket-Mod v0.4i
Post by: Grimlocke on September 17, 2018, 09:39:54 pm

Previously, I was plinking completed jobs from the linked list along with setting the timer to 0 in the case of firing jobs, but that did not cover cases where the job was not completed but still expired like the player canceling or the operator/building meeting some untimely demise. In that case the job would linger in the linked list and eventually return bogus values before giving a memory error. This prompted me to try and write a check to see if a job went gone on its own, but nothing I've found really works to that effect.

So, instead I'll just not use a link table and store only the job id, look for it on each iteration and drop the job id  if its not found. Least, that's the plan. My new place is short on internet connection which makes it somewhat of a pain to check general lua docs, forums, etc.

If that also fails I might just have to rip off your job checker and not store jobs anywhere at all :)

Anyhow, nice going on the other improvements and fixes! Hadn't noticed the bork in the targeting, I was mostly just testing the cannon by shooting it at my own dwarves with a firer added to the cannon projectile, which prevents any kind of friendly fire (boring, but convenient for testing. Also a temporary requirement of my projectile modding script, should have that fixed soon).

Also

Spoiler (click to show/hide)

... Cool!

If only the AI could bring guns and use them intelligently, could make turtling fortress a suicidal tactic.
Title: Re: [44.12] Musket-Mod v0.4i
Post by: zaporozhets on September 17, 2018, 10:45:45 pm
Previously, I was plinking completed jobs from the linked list along with setting the timer to 0 in the case of firing jobs, but that did not cover cases where the job was not completed but still expired like the player canceling or the operator/building meeting some untimely demise. In that case the job would linger in the linked list and eventually return bogus values before giving a memory error. This prompted me to try and write a check to see if a job went gone on its own, but nothing I've found really works to that effect.

So, instead I'll just not use a link table and store only the job id, look for it on each iteration and drop the job id  if its not found. Least, that's the plan. My new place is short on internet connection which makes it somewhat of a pain to check general lua docs, forums, etc.

Those cases are the ones that were worrying me (and I wasn't even attempting my own list), but after messing about with synthesized fake jobs I'm a little more reassured (but still apprehensive) they're being deleted properly from the built-in job list given they're real jobs that should just be handled normally.
Annoying the list didn't work out for you, I don't really know what to suggest.

As a side note, when linking lua-created jobs into the world and assigning a worker, the job in unit.job.current_job didn't carry the same name as the one in the built-in list but dfhack.job.is_equal() reported them as being the same. Some strangeness going on there.

I'd be interested to know an average job list size after some (ingame) years of play, could end up getting expensive searching through.

If that also fails I might just have to rip off your job checker and not store jobs anywhere at all :)

Rip away, my dude. It was your idea!

Anyhow, nice going on the other improvements and fixes! Hadn't noticed the bork in the targeting, I was mostly just testing the cannon by shooting it at my own dwarves with a firer added to the cannon projectile, which prevents any kind of friendly fire (boring, but convenient for testing. Also a temporary requirement of my projectile modding script, should have that fixed soon).

If only the AI could bring guns and use them intelligently, could make turtling fortress a suicidal tactic.

Thanks, I hope they work and I credited you enough.
You're kidding me that the cloned projectiles don't have a firer ATM, right?

Just checked, crap. Also errors, double crap. Thanks for the heads up, I'll get on that now...

Edit: I remember I've tried adding it before and setting pelletProjectile.firer = projectile.firer just crashes. What am I doing wrong?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Grimlocke on September 21, 2018, 03:09:30 am
You need to point the firer to the unit working the job first, else it'll try and copy a nothing. I thought not having a firer was intentional though, since it creates hilarious friendly fire incidents :)
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: zaporozhets on September 21, 2018, 03:36:05 pm
You need to point the firer to the unit working the job first, else it'll try and copy a nothing. I thought not having a firer was intentional though, since it creates hilarious friendly fire incidents :)

Oh, I meant for the blunderbuss not the cannon. Nope, not intentional, just being typically thoughtless.  ;D

If anyone is interested in rocket launcher progress, I found a quicker way of accessing construction materials that doesn't require the linear search through all constructions (~88000 table elements in the testing arena, performing the search 9 times for a 3x3 "explosion" was too slow) by reindexing the entries into a new table using map pos as the key rather than build order making direct lookup possible.

It now checks for wall strength and produces appropriate debris:

(https://i.imgur.com/VBMV7Zd.gif)

Just got to set it up to insert new constructions after load, or the explosion will produce gems and beds and all sorts of other random stuff. Oh, and destroy buildings.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Splint on September 21, 2018, 03:37:57 pm
Those testers had to be some of the worst shots in dwarven history.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: zaporozhets on September 21, 2018, 04:41:25 pm
Those testers had to be some of the worst shots in dwarven history.

Grand master dodgers and nothing else, they ended up getting swept along by the current to the lower part of the arena still fighting amongst the burning logs and steam. Great fun to watch.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Vordak on September 23, 2018, 06:45:40 am
Appreciated your new tile-destructive rocket launcher - to impressive, although I find that such weapons are not hand-carried.
You could not add something like thunderflash or dinamite, which was activated by a lever and also destroys tiles? - solely for engineering tasks).
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Splint on September 24, 2018, 05:29:51 pm
Appreciated your new tile-destructive rocket launcher - to impressive, although I find that such weapons are not hand-carried.
You could not add something like thunderflash or dinamite, which was activated by a lever and also destroys tiles? - solely for engineering tasks).


It'd be more correct to say reusable ones aren't hand carried - stuff like bazookas and Panzerschrecks usually being closer to a crew-served weapon (I think one guy is doable, but massively inefficient when it comes to loading stuff like that.) Stuff like LAWs and Panzerfausts can be carried in bunches by individual soldiers, but are single-use. But that's a massive digression. :P

These are probably more like early Chinese rockets, albeit with a bit more bang than expected since I assume they can hurt solid stone walls.

I do like the idea of lever activated explosives though if doable. Short on miners? Have an engineer clear the space with a couple charges and some mechanisms. Need to deal with a particularly nasty critter? Lure it into a room filled with satchel charges and hit the lever. Need to burn stuff off above or below ground? Rig up a fire bomb to start a fire and away you go at the flip of a lever, suddenly free of all that tangled greenery (or even use such a thing to incinerate corpses without magma.)
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: thefriendlyhacker on September 24, 2018, 05:36:52 pm
So you want something along the lines of a support constructed from an explosive material that runs a script when it triggers eventful's onBuildingDestroyed?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Vordak on September 24, 2018, 05:42:48 pm
I do like the idea of lever activated explosives though if doable. Short on miners? Have an engineer clear the space with a couple charges and some mechanisms. Need to deal with a particularly nasty critter? Lure it into a room filled with satchel charges and hit the lever. Need to burn stuff off above or below ground? Rig up a fire bomb to start a fire and away you go at the flip of a lever, suddenly free of all that tangled greenery (or even use such a thing to incinerate corpses without magma.)

In general developing the idea - need three kinds of charges.
First, that work only in one z-level and low power (small radius)
Second - same as the first, but with directional (NSWE) action and cost much more materials.
Third - high power with multi-z-level effect.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Kraiger on September 25, 2018, 03:21:32 pm
Is there a convenient entity file lying around?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Meph on September 26, 2018, 06:31:50 am
Hey, I just realized that overrides work for ammo in flight too. Dragondeplatino mentioned it.

So, you can have bullets and cannonballs flying around, instead of arrows, if you want to.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: zaporozhets on September 27, 2018, 09:04:55 pm
Sorry for being inactive for a bit, personal circumstances led to a temporary progress halt and my laptop has been down for the count too. Also been waylaid by a nautical side project.
Blast mining is indeed being considered, though I'm leaning ATM towards it being a workshop that can be loaded with varying levels of explosive as I've no experience with levers (but thefriendlyhacker's explosive support is intriguing and ingenious).
Destruction function now has z-level support and variable explosive size (though not yet in a circle) so Vordak's ideas will be possible, could be similar to cannon rotation whereby it can be set to explode radially or directionally with a reaction.
Appreciate all the idea discussion, it's a great help.

Is there a convenient entity file lying around?

I'm afraid not, the mod has injected the appropriate entity stuff into the existing entity file(s) for a while now so people who didn't have any experience with modding could disable weapons they didn't like.
All the stuff is in text files in scripts/musket/entity/ and would need to be manually cobbled together. You could also use musket-settings to modify the existing entity file(s) and copy out the stuff you need.
I'm curious and I'd like to be of more help, what did you need it for?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Grimlocke on September 30, 2018, 06:57:21 am
Alright, I got something presentable at last for both the ranged weapon script and the artillery script. Both are working as intended, I even got the organ gun to work satisfying. I ended up snubbing the job completion trigger entirely and just faking work completion timers with a timeout command, which lets me do some neat stuff like leading each organ gun barrel one by one with only one job set to repeat. It fetches some fairly basic properties per artillery type now, like rate of fire for multibarrel guns and reload times. It bases hitrate and reload rate on firer skill, a shoot force property the works exactly the same as vanilla ranged weapons and lets ranged-mod handle the remaining stuff like smoke and piercing effects. I still want to expand it a bit more to let me load them with stacks of ammunition rather than single items and add let the repeat jobs increase experience properly (and let botched job like a fire command that finds no ammo to fire NOT generate experience), but right now both scripts work well enough to let me finally update my main mod.

Pasties for ranged-mod and arty-mod respectively, more details in their -usage sections: https://pastebin.com/VZ0M5F6T https://pastebin.com/bq9kutS9

And a topic in the utils subforum: http://www.bay12forums.com/smf/index.php?topic=172239
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Fleeting Frames on September 30, 2018, 09:52:51 am
*looks around*

*sees this quite impressive thing*

Impressive!

The talk on explosive mining reminds me of dwarven power mining bug with sky support.
I'm an idiot, I didn't realize gas cannister liquids had to have the [SYN_CONTACT[ or [SYN_INHALED] tags for them to have any effect. Makes chemical weapons pretty useless when used with almost all of the native liquids.

I guess I'll eventually have to try and add some raws for new ones and a maybe a laboratory to make them in. There are plenty of effects to choose from, but deciding on names and reagents will be difficult.
About this...Since modding stone boiling points post-embark works, I wonder whether temporarily tagging the syndromes with that in df.global.world.raws on explosion would work.

Though one may consider it undesirable.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: zaporozhets on October 01, 2018, 09:41:32 pm
Alright, I got something presentable at last for both the ranged weapon script and the artillery script. Both are working as intended, I even got the organ gun to work satisfying. I ended up snubbing the job completion trigger entirely and just faking work completion timers with a timeout command, which lets me do some neat stuff like leading each organ gun barrel one by one with only one job set to repeat. It fetches some fairly basic properties per artillery type now, like rate of fire for multibarrel guns and reload times. It bases hitrate and reload rate on firer skill, a shoot force property the works exactly the same as vanilla ranged weapons and lets ranged-mod handle the remaining stuff like smoke and piercing effects. I still want to expand it a bit more to let me load them with stacks of ammunition rather than single items and add let the repeat jobs increase experience properly (and let botched job like a fire command that finds no ammo to fire NOT generate experience), but right now both scripts work well enough to let me finally update my main mod.

Pasties for ranged-mod and arty-mod respectively, more details in their -usage sections: https://pastebin.com/VZ0M5F6T https://pastebin.com/bq9kutS9

And a topic in the utils subforum: http://www.bay12forums.com/smf/index.php?topic=172239

I had a quick look when it released and was very impressed with all the stuff you added (I'll need to take another look for the pseudo-completion timer stuff which I missed).
Wish I had the intelligence to make (or even use) modtool-style scripts but I find them very confusing to work with.
Not had much time to play with it in game yet though which is a shame, looking forward to seeing the organ gun in action.

Stack-loading will be really useful for a fixed MG, was thinking of using a preservable magazine item but straight-up stack loading sounds better.
Not sure what to suggest for failed fire skill gain.
Do you know about setting job.expire_timer = 20 and job.flags.store_item = true to make the job expire rather than complete?
Just seemed like something that might be useful to you.

About this...Since modding stone boiling points post-embark works, I wonder whether temporarily tagging the syndromes with that in df.global.world.raws on explosion would work.

Though one may consider it undesirable.

Thanks, I just hope better modders than I continue to run with it. DF needs guns!
Tried a few things regarding venom: flipping syndrome contact bits (did nothing afaict), attempted to insert the needed line into the raws (crashed), couldn't get anything to work. Must have just been inexperience.
In the end I just used the mods settings menu to backup all creature raws and then edit any venoms it finds to work on contact. Not a great solution, but it was all I could do at the time.

Don't suppose you have an example of how you changed boiling points to hand? NP if not.
Your way would be far superior, not sure why one might consider it undesirable given it could presumably be changed back after the bang, you might have to explain your thinking on that one.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: thefriendlyhacker on October 01, 2018, 11:16:37 pm
Alright, I got something presentable at last for both the ranged weapon script and the artillery script.
...
I had a quick look when it released and was very impressed with all the stuff you added (I'll need to take another look for the pseudo-completion timer stuff which I missed).
Wish I had the intelligence to make (or even use) modtool-style scripts but I find them very confusing to work with.
Not had much time to play with it in game yet though which is a shame, looking forward to seeing the organ gun in action.
Heh, fun fact. I am also in the progress of writing a general purpose set of ranged scripts.  They have a shared back end that controls their ordering and passes tags between them so the individual scripts can communicate to each other.   It is still a WIP, but at the moment I have implemented variable rates of fire for hand-held projectile weapons (and it is done in a way that can mimic magazine fed weapons) and multi-shot projectiles.  All I have to do is write a third script that alters velocity (which should be easy) and I can replace all the glob projectile interaction based weapons in my mod with real bullets.
About this...Since modding stone boiling points post-embark works, I wonder whether temporarily tagging the syndromes with that in df.global.world.raws on explosion would work.

Though one may consider it undesirable.
...
Your way would be far superior, not sure why one might consider it undesirable given it could presumably be changed back after the bang, you might have to explain your thinking on that one.
I can probably answer that one.

Changing it's contact/inhale properties is only safe if Dwarf Fortress handles checks concerning contact/inhaled syndrome bearing mats in a stateless way.  If it does keep any sort of state, you run a serious risk of blundering into the programmer's equivalent of !!fun!!, undefined behavior.

Let me give an illustrative example. Lets say that the game mimics the effects of breathing without having to track it explicitly by keeping an array of counters and IDs for contact/inhale syndrome bearing materials that each creature is has recently been exposed to, and when a counter runs out the code for handling that syndrome is run again if the creature is still being exposed appropriately to that material.  Lets say you change a mat's syn to be inhaled, and expose a creature to it.  That creature now has a counter+ID for your mat.  Between it's initial exposure and the counter running out, you change it back to not inhaled.  When the counter runs out, the code that handles inhaled or contact syndrome bearing mats runs on something that has neither a contact or inhaled syn.  What happens? Well, it could assume anything passed to it is one or the other and check with a simple if (syn.inhaled==1) statement, thus treating your mat as contact and breaking any inhaled poisons you do this trick with some of the time.  It could check both types, return the default value of 0/null/false, which could result in correct behavior if 0/null/false is what the code returns if the syndrome isn't supposed to be applied any more...or it could crash the game on the spot by dereferencing a null pointer if it is always meant to return an object.  And of course the checks for if it is contact/inhaled at all could be within the code that gets executed when the counter runs out, meaning it is completely safe to pass that code whatever the hell you want.  Nobody but Toady knows.

This is why when reasonably possible you should try to change DF's memory such that the variables you are altering describe the in-game behavior you are trying to alter in its entirety.  That way, all you have to do is change the set of variables from one valid in-game state to another, and the game will continue to run with the new valid state.  Changing syndrome properties is not the sort of thing you should do when alternatives are possible, because creatures have a lot of data in them about what syndromes affect them, and you have to understand all of it to ensure that you aren't breaking the game in some weird to diagnose manner by changing the materials to something which conflicts with data that may be held within the data structure of individual creatures (or data held somewhere else, for that matter).
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Fleeting Frames on October 02, 2018, 03:27:33 am
If it doesn't work, it doesn't work. Gotta use more complex options (such as tagging people caught in geographical location of the cloud with modtools/add-syndrome; note that DF creatures don't breathe all the time so deadly fog isn't guaranteed to hit the whole squad).

Beyond what thefriendlyhacker said (I find if I change something I shouldn't it almost always crashes, but I haven't written any mods) and more in line with editing the raws before worldgen, there's also that by making the syndromes contact ones changes their behaviour everywhere outside the gunshells (i.e. GCS venom pools become legitimate weapons) and such approach not getting other mods a player might use for venom-loading.

Changing stone boiling points is an old practice - here (http://www.bay12forums.com/smf/index.php?topic=51457.msg1102184#msg1102184) is a reference. I've seen it in mid-action on some dfma maps.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: zilpin on October 14, 2018, 03:02:19 pm

Wall destruction is impressive.

I'll be watching this.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Grimlocke on October 17, 2018, 11:35:28 am
I just updated my own mod with some fixes including updated targeting that you might find to be of some use. The old one didn't account for floors existing when shooting up/down, and didn't consider fortifications as something it could shoot through. I also used dfhack.units.getUnitsInBox to get only units in potential range rather than iterating through every single unit on the map and sorted them by distance from the gun before checking other conditions.


I set the targeting bounding box in checkDirection to prevent it from having to recalculate that on every shot:
   gunTable[gun.id].muzzlePos = xyz2pos(gun.centerx, gun.centery - 1, gun.z)
   gunTable[gun.id].targetBox1 = xyz2pos(math.ceil(gun.centerx + range[2] * 0.82), gun.centery - 1, gun.z + range[2])
   gunTable[gun.id].targetBox2 = xyz2pos(math.ceil(gun.centerx - range[2] * 0.82), gun.centery - range[2], gun.z - range[2])

Hope some of that is of some use.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Forwe on October 17, 2018, 12:22:33 pm
Hey, excuse me for a possibly stupid question, but does this mod work nicely with Adventure Mode? I mean, will Blunderbusses shoot in a cone and Machine Guns have short reload times, etc?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: DWARFFRAWD on October 23, 2018, 12:01:12 am
Can you add tilesets that work properly with this mod?

Or, can you teach how to make tileset to support this mod?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: zaporozhets on October 24, 2018, 06:37:54 pm
Hey, excuse me for a possibly stupid question, but does this mod work nicely with Adventure Mode? I mean, will Blunderbusses shoot in a cone and Machine Guns have short reload times, etc?

No such thing as a stupid question, nothing was made with adventure mode in mind and so there are many oddities, but as best I can tell all the weapons still function properly they just don't look nearly as cool.
For example the lightning gun is one of the most script heavy weapons and whilst it works, you'll only see the lightning briefly if at all due to the differences in timescale between fortress and adventure modes.
I'd only recommend it if you really really want guns, your mileage may vary.

Can you add tilesets that work properly with this mod?

Or, can you teach how to make tileset to support this mod?

Sure, what tileset did you want me to add?

If you want to make a tileset work yourself, you'll want to navigate to "Dwarf Fortress/data/init/overrides.txt" and add:
Spoiler (click to show/hide)
after the other tileset definitions (lines beginning with [TILESET:).

Then you'll want to add:
Spoiler (click to show/hide)
Somewhere with the other overrides (not sure it matters where).
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: DWARFFRAWD on October 24, 2018, 07:19:21 pm
Hey, excuse me for a possibly stupid question, but does this mod work nicely with Adventure Mode? I mean, will Blunderbusses shoot in a cone and Machine Guns have short reload times, etc?

No such thing as a stupid question, nothing was made with adventure mode in mind and so there are many oddities, but as best I can tell all the weapons still function properly they just don't look nearly as cool.
For example the lightning gun is one of the most script heavy weapons and whilst it works, you'll only see the lightning briefly if at all due to the differences in timescale between fortress and adventure modes.
I'd only recommend it if you really really want guns, your mileage may vary.

Can you add tilesets that work properly with this mod?

Or, can you teach how to make tileset to support this mod?

Sure, what tileset did you want me to add?

If you want to make a tileset work yourself, you'll want to navigate to "Dwarf Fortress/data/init/overrides.txt" and add:
Spoiler (click to show/hide)
after the other tileset definitions (lines beginning with [TILESET:).

Then you'll want to add:
Spoiler (click to show/hide)
Somewhere with the other overrides (not sure it matters where).


Oh, thanks for kind instruction. :D
Sorry for my insufficient explanation.
 
But i mean,
In readme file, it said this mod works only in ascii or meph graphic set.

Can i make it change to works with other graphic set?

I had played in ascii version but now i want to change graphic to spacefox.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: zaporozhets on October 26, 2018, 06:47:21 pm
Oh, thanks for kind instruction. :D
Sorry for my insufficient explanation.
 
But i mean,
In readme file, it said this mod works only in ascii or meph graphic set.

Can i make it change to works with other graphic set?

I had played in ascii version but now i want to change graphic to spacefox.

The problem is that the tileset included with the mod is at 32x32 resolution, whereas spacefox is 16x16.
You could try simply halving the resolution, but I had a quick go in GIMP and it looks pretty bad without retouching everything.
Ideally new graphics would need to be drawn for everything at that resolution, but I'm no artist and I'm finding free time a little hard to come by ATM to even make something as paltry as my ability would allow.
Sorry I can't be more help, I do want to add compatibility for smaller tilesets at some point.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: thefriendlyhacker on October 27, 2018, 03:16:32 pm
Hey zaporozhets, I found a bug in my multishot script, and I believe you have the same problem.

To demonstrate, load up arena and spawn two winged animal people in the air equipped with multishot weapons (e.g. the blunderbuss).  You should get a null variable error from the "pelletProjectile" variable.

Here is my fix.  I changed the variable names from what my script uses to what your 0.5b script uses.  Double check that I didn't screw anything up, then stick it just after you try to make a projectile out of a created pellet.
Code: [Select]
  --if pellet is created midair then dfhack "helpfully" makes it a falling projectile
  --this prevents the above call from creating a projectile, so we need to "borrow" the one dfhack made
  if pelletProjectile==nil then
    local projLink=df.global.world.proj_list
    repeat
      projLink=projLink.next
      if projLink~=nil then
        if projLink.item.item==pellet then
          pelletProjectile=projLink.item
        end
      else error("error - cannot create projectile from new item for unknown reason") end
    until pelletProjectile
  end
I noticed that you don't manually init every part of the created projectile, so you may want to go through and check that there isn't anything weird left over from the old falling projectile your code is overwriting.  Otherwise, the above snippet should fix the bug.

While I am here, I might as well make a suggestion.  At the moment you are using eventful.onProjItemCheckMovement to run your script.  If you do it this way, there is one tick in which the player can see the fired projectiles before your script runs.  If you instead iterate through the projectile list (like I did above) every tick using dfhack.timeout then the player won't see the seam between df's internal logic and your dfhack powered hack job and it will all look silky smooth.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Brody on November 06, 2018, 04:19:27 pm
Oh, thanks for kind instruction. :D
Sorry for my insufficient explanation.
 
But i mean,
In readme file, it said this mod works only in ascii or meph graphic set.

Can i make it change to works with other graphic set?

I had played in ascii version but now i want to change graphic to spacefox.

The problem is that the tileset included with the mod is at 32x32 resolution, whereas spacefox is 16x16.
You could try simply halving the resolution, but I had a quick go in GIMP and it looks pretty bad without retouching everything.
Ideally new graphics would need to be drawn for everything at that resolution, but I'm no artist and I'm finding free time a little hard to come by ATM to even make something as paltry as my ability would allow.
Sorry I can't be more help, I do want to add compatibility for smaller tilesets at some point.

Is there a way to use another tileset, and then just get this mod to pull in ASCII tiles? I'm wondering if thats the cause of the problem I'm having, which is I installed my tileset, and then brought in some of this stuff and tried to cut in the overrides, but all I can build is the Gunsmith shop, muskets, and flintlocks. I set most things as buildable, and I can assign them as military equipment, but it doesn't give me the option to build.

Edit: Now I've gone and fucked something up. What do I need to do to get the game to recognize the additions to the objects folder?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Metaltooth on November 10, 2018, 04:05:40 pm
Ive installed the mod and enabled everything via DF hack but I cant get the weapons to spawn in the item test area. In fact i cant seem to find any guns or way to make a gunsmith in fortress mode.
Ive done as your instructions said and installed the mod and enabled it, generated a new world but i cant find guns or a way to build them. any ideas?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Meph on March 06, 2019, 06:08:21 am
Bump, because I'd really like to see a v1 version of this.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: zaporozhets on March 20, 2019, 06:36:18 pm
Bump, because I'd really like to see a v1 version of this.
I appreciate it.
Recently started working on this again after a leave of absence. Currently completely redoing the wall-breaching/destruction system; explosions now have better z-level support, they are now spherical rather than squared, and can be of any size/height. They now use raycasting rather than instantaneously coming into existence in their entirety, meaning that if a wall withstands a blast, anything behind the wall will survive it.

On a more technical note, some methods are finally being moved to a shared-functionality utility module, meaning less code repetition and easier to read scripts for modders.

Proper blast mining is next on the table, but I've also been thinking a lot about changing the way weapons are constructed, requiring additional tool components (maybe something like 'small mechanisms' or just 'barrels'), but ultimately allowing them to be made of either wood or metal, as thefriendlyhacker suggested back in September. This will solve the current material problems with allowing the other civs access to the guns.

Got some future features planned, but I want to keep them under wraps until I figure out if I can actually manage it, it'll also be necessary to have an easier way for people to disable the parts of the mod they don't like or don't think fit the setting of their game.

Edit:
Making progress on terrain destruction. Had some problems with the explosion algorithm when the terrain destruction parameter was set, with there being 5 seconds per explosion where the game would be frozen, but I've been working on optimizing it where I'm able.
The whole thing is now taking between ~0.01 and ~0.06 seconds for a small 3*3*3 explosion and between ~0.09 and ~0.12 seconds for a larger 5*5*7 one.

(https://i.imgur.com/IIhGg1i.gif)
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Dragonslayerelf on June 05, 2020, 12:45:37 am
Bump - are the current raws/scripts compatible with 47.04? I know not much changed between the two, but checking anyway.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Kraiger on June 16, 2020, 06:22:43 pm
Aside from the bugs listed by others, it does appear to work in 47.04.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Luckyowl on November 13, 2020, 05:55:49 pm
Hey, looking to see if anyone can help me out on installing this script.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Iä! RIAKTOR! on November 26, 2020, 08:39:01 am
How it looks in ASCII? Whats about making weapons from all bronze-grade metals/alloys?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Tachytaenius on April 24, 2022, 05:14:57 am
Bump, because I'd really like to see a v1 version of this.
I appreciate it.
Recently started working on this again after a leave of absence. Currently completely redoing the wall-breaching/destruction system; explosions now have better z-level support, they are now spherical rather than squared, and can be of any size/height. They now use raycasting rather than instantaneously coming into existence in their entirety, meaning that if a wall withstands a blast, anything behind the wall will survive it.

On a more technical note, some methods are finally being moved to a shared-functionality utility module, meaning less code repetition and easier to read scripts for modders.

Proper blast mining is next on the table, but I've also been thinking a lot about changing the way weapons are constructed, requiring additional tool components (maybe something like 'small mechanisms' or just 'barrels'), but ultimately allowing them to be made of either wood or metal, as thefriendlyhacker suggested back in September. This will solve the current material problems with allowing the other civs access to the guns.

Got some future features planned, but I want to keep them under wraps until I figure out if I can actually manage it, it'll also be necessary to have an easier way for people to disable the parts of the mod they don't like or don't think fit the setting of their game.

Edit:
Making progress on terrain destruction. Had some problems with the explosion algorithm when the terrain destruction parameter was set, with there being 5 seconds per explosion where the game would be frozen, but I've been working on optimizing it where I'm able.
The whole thing is now taking between ~0.01 and ~0.06 seconds for a small 3*3*3 explosion and between ~0.09 and ~0.12 seconds for a larger 5*5*7 one.

(https://i.imgur.com/IIhGg1i.gif)
This looks wonderful!
Have you considered making a general explosion script/function as a contribution to DFHack? "modtools/explode" would be wonderful. I was thinking of doing it but shouldn't reinvent the wheel.
Something like
Code: [Select]
local utils = require("utils")

local function explode(pos, intensity, incendiary)
-- what you have been working on
end

if #{...} == 0 then return explode end
local validArgs = utils.invert({
"position", -- DF position
"intensity", -- float
"incendiary" -- bool
})
local args = utils.processArgs({...}, validArgs)
if not args.position then
qerror("Position not specified!")
end
local pos = {x = tonumber(args.position[1]), y = tonumber(args.position[2]), z = tonumber(args.position[3])}
if not dfhack.maps.isValidTilePos(pos) then
qerror("Invalid position!")
end
if not args.intensity then
qerror("Explosion intensity not specified!")
end
explode(pos, args.intensity, args.incendiary)
which is based on "modtools/create-unit"
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Deon on April 24, 2022, 06:04:33 am
How did I miss this... The firearms mod... It is fantastic!

The lack of proper ranged weapons is what made it hard for me to develop the "Fallout" total conversion mod in the past. This looks just fantastic, I will definitely look into it.

One simple question: what is your opinion on taking your mod, changing gun values and using them in a separate mod/total conversion? With full credit given.
I had thoughts about bringing DF Fallout back for a while now. Would you allow that?
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: FantasticDorf on April 24, 2022, 08:02:04 am
How did I miss this... The firearms mod... It is fantastic!

The lack of proper ranged weapons is what made it hard for me to develop the "Fallout" total conversion mod in the past. This looks just fantastic, I will definitely look into it.

One simple question: what is your opinion on taking your mod, changing gun values and using them in a separate mod/total conversion? With full credit given.
I had thoughts about bringing DF Fallout back for a while now. Would you allow that?

Bit of a necro since the creator hasn't been online since the beginning of the global pandemic (2020) mind you, but this thread really is great. Im sure they'd probably impart their blessing if you were responsible with it, in any case there are supplimentary credits on the OP you could add commented out in any sort of personal published adjustment.

I especially like normal period or fantasy weapons with the smoke as a really well thought out touch to make the modded experience more novel. Or the idea that putting your spotter dogs over your walls might leave them open to grenadiers inadventently blowing apart your structures meaning you have to replace it with metal out of practicality. Its been on my list of things to poke at, but i struggle with finding niches to stick it in then sticking to seeing it through to the end.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Deon on April 24, 2022, 09:38:50 am
Thank you for the comment. I do remember the open source spirit of most utilities here, but I like to ask permission nonetheless, to demonstrate my goodwill.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Tachytaenius on April 24, 2022, 12:08:44 pm
How did I miss this... The firearms mod... It is fantastic!

The lack of proper ranged weapons is what made it hard for me to develop the "Fallout" total conversion mod in the past. This looks just fantastic, I will definitely look into it.

One simple question: what is your opinion on taking your mod, changing gun values and using them in a separate mod/total conversion? With full credit given.
I had thoughts about bringing DF Fallout back for a while now. Would you allow that?

Bit of a necro since the creator hasn't been online since the beginning of the global pandemic (2020) mind you, but this thread really is great. Im sure they'd probably impart their blessing if you were responsible with it, in any case there are supplimentary credits on the OP you could add commented out in any sort of personal published adjustment.

I especially like normal period or fantasy weapons with the smoke as a really well thought out touch to make the modded experience more novel. Or the idea that putting your spotter dogs over your walls might leave them open to grenadiers inadventently blowing apart your structures meaning you have to replace it with metal out of practicality. Its been on my list of things to poke at, but i struggle with finding niches to stick it in then sticking to seeing it through to the end.

The necro was mine actually :P
I'm making a gun mod too and though I'm fully reinventing the wheel for most of it I wanted to see if the explosions code would be releasable and if they'd want to contribute it to DFHack where I'm sure it'd be welcome.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Deon on April 24, 2022, 12:46:22 pm
Do you make it in free time whenever, or do you have an approximate ETA when you plan to release it?

I won't rush the mod I am working on, so it will take a while. If you are around with more ideas/extensions to the system, I could use either if you also give a permission.
I'm back at it, and currently I foresee hours of trying to balance "a pistol" vs "a rifle" vs "a typical armor" :D.

The best part of THIS mod is ability to change the shooting rate of guns. It is something that always made melee better.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Tachytaenius on April 24, 2022, 01:48:42 pm
Do you make it in free time whenever, or do you have an approximate ETA when you plan to release it?

I won't rush the mod I am working on, so it will take a while. If you are around with more ideas/extensions to the system, I could use either if you also give a permission.
I'm back at it, and currently I foresee hours of trying to balance "a pistol" vs "a rifle" vs "a typical armor" :D.

The best part of THIS mod is ability to change the shooting rate of guns. It is something that always made melee better.

If you meant me, I'm doing it whenever. It's on my github. https://github.com/wolfboyft/guns. Figured all this out myself. Mine has custom firing speed too. (It's currently relying on a pull request to dfhack that isn't actually in dfhack yet but if you pm me i can talk to you about installing and stuff.) If you didn't mean me, oops, how embarrassing.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Deon on April 24, 2022, 02:46:51 pm
I did mean you. I will wait for the pull requests to be accepted, there's no rush :). It will take me ages to port plants, animals and entities over with new ideas I have, so guns won't be the first thing. Thanks for the link to the github.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Deon on April 24, 2022, 03:23:32 pm
I didn't realise that blunderbuss code calls for the "next" ammo type when shooting multiple shots.

So I just made my own shotgun shells for shotguns. And put them just before mini-grenades. Imagine my surprise when I practiced on a squirrel and exploded the whole room.

P.S. I am having SO MUCH fun here already with all the explosive bullets and multi-shot guns, this is better than sliced bread. Thank you for making my day/night.
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Deon on April 27, 2022, 04:47:06 pm
This is PERFECT for my Fallout mod.

The rockets, the shotguns and the assault rifles change the game to what I wanted it to be back when I had to simulate guns with fancy named crossbows.
Thank you SO MUCH for making this possible.

(https://i.imgur.com/PabBiPy.png)

(https://i.imgur.com/kuTrcRw.png)
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: Deon on April 29, 2022, 06:17:19 pm
I've decided to implement it in the following way:
- Each non-heavy gun fires the same type of ammo - very lightweight so you could carry a lot of it. It greatly reduces micromanagement in squad ammo assignment.
- When the ammo leaves the gun, it becomes a special kind of ammo (pistol, rifle, shotgun pellet etc), thus making weapons unique

I do notice an issue though. no matter how I torture Evenful, the lodged in bullets do not disappear, and they are pulled out and dropped on the floor.

I tried to explicitly specify projectile types, and yet they get stuck in people.
Spoiler (click to show/hide)
Title: Re: [44.12] Musket-Mod v0.5c: Experimental Wall Breaching
Post by: FantasticDorf on May 01, 2022, 06:48:21 pm
I do notice an issue though. no matter how I torture Evenful, the lodged in bullets do not disappear, and they are pulled out and dropped on the floor.
Shucks.

If this was a little bit more of a historical mod, then that would be perhaps appropriate like your grandpappy telling you about the bullet that nearly killed him in the US civil war. In the meantime trying to find out anything about this subject it seems like Hugo was trying out [ROTS] type metals for ammo (http://www.bay12forums.com/smf/index.php?topic=111008.msg3391788;topicseen#msg3391788) and found out the item type itself is near indestructable in that way, even going as far to create rotting steak made out of pure lead.

Maybe look towards scripts that apply thorough eventful on contact?

Im no script-writer but the gnomish cage-gun script from MW seems to have a already set up proc and 'projectile.flags.to_be_deleted=true' seem relevant with how they handle applying and removing the projectile without getting nets stuck in people (and importantly creating a cage of the creature on the spot per impact)