Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Rapid-fire weapons script?  (Read 862 times)

MaxTheFox

  • Bay Watcher
  • Лишь одна дорожка да на всей земле
    • View Profile
Rapid-fire weapons script?
« on: October 12, 2019, 04:32:04 am »

So I'm trying to mod in a machine gun, and I'm seeing there is no [FIRE_RATE] token. I guess I need a script? I found one, but it doesn't seem to work in adventure mode.
Code: [Select]
local eventful = require 'plugins.eventful'

print("rapidfire enabled")

eventful.onProjItemCheckMovement.rapidfire = function(projectile)
if projectile.distance_flown == 1 then
adjustFireRate(projectile)
end
end

function adjustFireRate(projectile)
local fireRate = nil
if projectile.firer == nil then --if the projectile wasn't shot by somebody, like a flying corpse
return
end
if projectile.item.subtype.id == "ITEM_AMMO_BULLET_LIGHT" then
fireRate = 20
elseif projectile.item.subtype.id == "ITEM_AMMO_BULLET_HEAVY" then
fireRate = 100
end
if fireRate ~= nil and projectile.firer.counters.think_counter > fireRate then
projectile.firer.counters.think_counter = fireRate
end
end

Help?
Logged
Woe to those who make unjust laws, to those who issue oppressive decrees, to deprive the poor of their rights and withhold justice from the oppressed of my people, making widows their prey and robbing the fatherless. What will you do on the day of reckoning, when disaster comes from afar?

TomiTapio

  • Bay Watcher
  • OldGenesis since 2012
    • View Profile
    • My Flickr animal photos
Re: Rapid-fire weapons script?
« Reply #1 on: October 12, 2019, 06:51:43 am »

nevermind
« Last Edit: October 12, 2019, 06:53:47 am by TomiTapio »
Logged
==OldGenesis mod== by Deon & TomiTapio. Five wood classes, four leather classes. Nine enemy civs. So much fine-tuning.
47.05e release: http://dffd.bay12games.com/who.php?id=1538
OldGenesis screenshots: https://twitter.com/hashtag/OldGenesis?src=hashtag_click&f=image
My Finnish language file: http://dffd.bay12games.com/file.php?id=14884

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: Rapid-fire weapons script?
« Reply #2 on: October 14, 2019, 04:22:05 am »

Are you using ammo of the provided types listed in the script? ITEM_AMMO_BULLET_LIGHT and/or ITEM_AMMO_BULLET_HEAVY. Otherwise, it could just be that some eventful stuff still isn't working outside of fortress mode. It's been like that for a while, which sucks because you could make some awesome stuff for adventure mode with what it provides.

MaxTheFox

  • Bay Watcher
  • Лишь одна дорожка да на всей земле
    • View Profile
Re: Rapid-fire weapons script?
« Reply #3 on: October 14, 2019, 04:25:41 am »

Are you using ammo of the provided types listed in the script? ITEM_AMMO_BULLET_LIGHT and/or ITEM_AMMO_BULLET_HEAVY. Otherwise, it could just be that some eventful stuff still isn't working outside of fortress mode. It's been like that for a while, which sucks because you could make some awesome stuff for adventure mode with what it provides.
1) Yes, I checked.
2) That's sad.
Logged
Woe to those who make unjust laws, to those who issue oppressive decrees, to deprive the poor of their rights and withhold justice from the oppressed of my people, making widows their prey and robbing the fatherless. What will you do on the day of reckoning, when disaster comes from afar?

MaxTheFox

  • Bay Watcher
  • Лишь одна дорожка да на всей земле
    • View Profile
Re: Rapid-fire weapons script?
« Reply #4 on: October 14, 2019, 08:26:32 am »

Nevermind, the script does work. The increased rate of fire makes firearms very powerful, but did you expect a swordsman to stand a chance against someone with a gun (in ranged combat)?
Logged
Woe to those who make unjust laws, to those who issue oppressive decrees, to deprive the poor of their rights and withhold justice from the oppressed of my people, making widows their prey and robbing the fatherless. What will you do on the day of reckoning, when disaster comes from afar?

kiwiphoenix

  • Bay Watcher
    • View Profile
Re: Rapid-fire weapons script?
« Reply #5 on: October 15, 2019, 08:52:32 am »

From my own experimentation with rapid fire weapons, thinking that the difference between fortress and adventure timescales (~72x?) also applies to reload times.

With a nice three-tick delay between shots in fort mode, adventure mode enemies were nearly able to close to melee after only a single shot.
Reducing the delay to 1/10 tick allowed several shots on a charging foe in adventure mode, but caused fortress mode shooters to vomit out all their ammo in under a second.
Ultimately just kept two different versions of the script, one for each mode.
Logged