Add FPS-boosting 'state of decay' scripts
By Omniclasm. http://www.bay12forums.com/smf/index.php?topic=150782.msg6482346#msg6482346develop
parent
daf20c16bd
commit
94cadbf1ec
@ -0,0 +1,81 @@
|
||||
# Increase the rate at which clothes wear out
|
||||
=begin
|
||||
|
||||
deteriorateclothes
|
||||
==================
|
||||
Somewhere between a "mod" and a "fps booster", with a small impact on
|
||||
vanilla gameplay. All of those slightly worn wool shoes that dwarves
|
||||
scatter all over the place will deteriorate at a greatly increased rate,
|
||||
and eventually just crumble into nothing. As warm and fuzzy as a dining
|
||||
room full of used socks makes your dwarves feel, your FPS does not like it.
|
||||
|
||||
Usage: ``deteriorateclothes (start|stop)``
|
||||
|
||||
=end
|
||||
|
||||
class DeteriorateClothes
|
||||
|
||||
def initialize
|
||||
end
|
||||
|
||||
def process
|
||||
return false unless @running
|
||||
|
||||
items = [df.world.items.other[:GLOVES],
|
||||
df.world.items.other[:ARMOR],
|
||||
df.world.items.other[:SHOES],
|
||||
df.world.items.other[:PANTS],
|
||||
df.world.items.other[:HELM]]
|
||||
|
||||
items.each { |type|
|
||||
type.each { |i|
|
||||
if (i.subtype.armorlevel == 0 and i.flags.on_ground == true and i.wear > 0)
|
||||
i.wear_timer *= i.wear + 0.5
|
||||
if (i.wear > 2)
|
||||
i.flags.garbage_collect = true
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
|
||||
def start
|
||||
@onupdate = df.onupdate_register('deteriorateclothes', 1200, 1200) { process }
|
||||
@running = true
|
||||
|
||||
puts "Deterioration of old clothes commencing..."
|
||||
|
||||
end
|
||||
|
||||
def stop
|
||||
df.onupdate_unregister(@onupdate)
|
||||
@running = false
|
||||
end
|
||||
|
||||
def status
|
||||
@running ? 'Running.' : 'Stopped.'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
case $script_args[0]
|
||||
when 'start'
|
||||
if ($DeteriorateClothes)
|
||||
$DeteriorateClothes.stop
|
||||
end
|
||||
|
||||
$DeteriorateClothes = DeteriorateClothes.new
|
||||
$DeteriorateClothes.start
|
||||
|
||||
when 'end', 'stop'
|
||||
$DeteriorateClothes.stop
|
||||
|
||||
else
|
||||
if $DeteriorateClothes
|
||||
puts $DeteriorateClothes.status
|
||||
else
|
||||
puts 'Not loaded.'
|
||||
end
|
||||
end
|
@ -0,0 +1,106 @@
|
||||
# Make corpse parts decay and vanish over time
|
||||
=begin
|
||||
|
||||
deterioratecorpses
|
||||
==================
|
||||
Somewhere between a "mod" and a "fps booster", with a small impact on
|
||||
vanilla gameplay.
|
||||
|
||||
In long running forts, especially evil biomes, you end up with a lot
|
||||
of toes, teeth, fingers, and limbs scattered all over the place.
|
||||
Various corpses from various sieges, stray kitten corpses, probably
|
||||
some heads. Basically, your map will look like a giant pile of
|
||||
assorted body parts, all of which individually eat up a small part
|
||||
of your FPS, which collectively eat up quite a bit.
|
||||
|
||||
In addition, this script also targets various butchery byproducts.
|
||||
Enjoying your thriving animal industry? Your FPS does not. Those
|
||||
thousands of skulls, bones, hooves, and wool eat up precious FPS
|
||||
that could be used to kill goblins and elves. Whose corpses will
|
||||
also get destroyed by the script to kill more goblins and elves.
|
||||
|
||||
This script causes all of those to rot away into nothing after
|
||||
several months.
|
||||
|
||||
Usage: ``deterioratecorpses (start|stop)``
|
||||
|
||||
=end
|
||||
|
||||
class DeteriorateCorpses
|
||||
|
||||
def initialize
|
||||
end
|
||||
|
||||
def process
|
||||
return false unless @running
|
||||
|
||||
df.world.items.other[:ANY_CORPSE].each { |i|
|
||||
if (i.flags.dead_dwarf == false)
|
||||
i.wear_timer += 1
|
||||
if (i.wear_timer > 24 + rand(8))
|
||||
i.wear_timer = 0
|
||||
i.wear += 1
|
||||
end
|
||||
if (i.wear > 3)
|
||||
i.flags.garbage_collect = true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
}
|
||||
|
||||
df.world.items.other[:REMAINS].each { |i|
|
||||
if (i.flags.dead_dwarf == false)
|
||||
i.wear_timer += 1
|
||||
if (i.wear_timer > 6)
|
||||
i.wear_timer = 0
|
||||
i.wear += 1
|
||||
end
|
||||
if (i.wear > 3)
|
||||
i.flags.garbage_collect = true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
def start
|
||||
@onupdate = df.onupdate_register('deterioratecorpses', 1200, 1200) { process }
|
||||
@running = true
|
||||
|
||||
puts "Deterioration of body parts commencing..."
|
||||
|
||||
end
|
||||
|
||||
def stop
|
||||
df.onupdate_unregister(@onupdate)
|
||||
@running = false
|
||||
end
|
||||
|
||||
def status
|
||||
@running ? 'Running.' : 'Stopped.'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
case $script_args[0]
|
||||
when 'start'
|
||||
if ($DeteriorateCorpses)
|
||||
$DeteriorateCorpses.stop
|
||||
end
|
||||
|
||||
$DeteriorateCorpses = DeteriorateCorpses.new
|
||||
$DeteriorateCorpses.start
|
||||
|
||||
when 'end', 'stop'
|
||||
$DeteriorateCorpses.stop
|
||||
|
||||
else
|
||||
if $DeteriorateCorpses
|
||||
puts $DeteriorateCorpses.status
|
||||
else
|
||||
puts 'Not loaded.'
|
||||
end
|
||||
end
|
@ -0,0 +1,96 @@
|
||||
# Make food and plants decay, and vanish after a few months
|
||||
=begin
|
||||
|
||||
deterioratefood
|
||||
===============
|
||||
Somewhere between a "mod" and a "fps booster", with a small impact on
|
||||
vanilla gameplay.
|
||||
|
||||
With this script running, all food and plants wear out and disappear
|
||||
after several months. Barrels and stockpiles will keep them from
|
||||
rotting, but it won't keep them from decaying. No more sitting on a
|
||||
hundred years worth of food. No more keeping barrels of pig tails
|
||||
sitting around until you decide to use them. Either use it, eat it,
|
||||
or lose it. Seeds, are excluded from this, if you aren't planning on
|
||||
using your pig tails, hold onto the seeds for a rainy day.
|
||||
|
||||
This script is...pretty far reaching. However, almost all long
|
||||
running forts I've had end up sitting on thousands and thousands of
|
||||
food items. Several thousand cooked meals, three thousand plump
|
||||
helmets, just as many fish and meat. It gets pretty absurd. And your
|
||||
FPS doesn't like it.
|
||||
|
||||
Usage: ``deterioratefood (start|stop)``
|
||||
|
||||
=end
|
||||
|
||||
class DeteriorateFood
|
||||
|
||||
def initialize
|
||||
end
|
||||
|
||||
def process
|
||||
return false unless @running
|
||||
|
||||
items = [df.world.items.other[:FISH],
|
||||
df.world.items.other[:FISH_RAW],
|
||||
df.world.items.other[:EGG],
|
||||
df.world.items.other[:CHEESE],
|
||||
df.world.items.other[:PLANT],
|
||||
df.world.items.other[:PLANT_GROWTH],
|
||||
df.world.items.other[:FOOD]]
|
||||
|
||||
items.each { |type|
|
||||
type.each { |i|
|
||||
i.wear_timer += 1
|
||||
if (i.wear_timer > 24 + rand(8))
|
||||
i.wear_timer = 0
|
||||
i.wear += 1
|
||||
end
|
||||
if (i.wear > 3)
|
||||
i.flags.garbage_collect = true
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
|
||||
def start
|
||||
@onupdate = df.onupdate_register('deterioratefood', 1200, 1200) { process }
|
||||
@running = true
|
||||
|
||||
puts "Deterioration of food commencing..."
|
||||
|
||||
end
|
||||
|
||||
def stop
|
||||
df.onupdate_unregister(@onupdate)
|
||||
@running = false
|
||||
end
|
||||
|
||||
def status
|
||||
@running ? 'Running.' : 'Stopped.'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
case $script_args[0]
|
||||
when 'start'
|
||||
if ($DeteriorateFood)
|
||||
$DeteriorateFood.stop
|
||||
end
|
||||
|
||||
$DeteriorateFood = DeteriorateFood.new
|
||||
$DeteriorateFood.start
|
||||
|
||||
when 'end', 'stop'
|
||||
$DeteriorateFood.stop
|
||||
|
||||
else
|
||||
if $DeteriorateFood
|
||||
puts $DeteriorateFood.status
|
||||
else
|
||||
puts 'Not loaded.'
|
||||
end
|
||||
end
|
@ -0,0 +1,92 @@
|
||||
# Make undead units weaken after one month, and vanish after six
|
||||
=begin
|
||||
|
||||
starvingdead
|
||||
============
|
||||
Somewhere between a "mod" and a "fps booster", with a small impact on
|
||||
vanilla gameplay. It mostly helps prevent undead cascades in the caverns,
|
||||
where constant combat leads to hundreds of undead roaming the
|
||||
caverns and destroying your FPS.
|
||||
|
||||
With this script running, all undead that have been on the map for
|
||||
one month gradually decay, losing strength, speed, and toughness.
|
||||
After six months, they collapse upon themselves, never to be reanimated.
|
||||
|
||||
Usage: ``starvingdead (start|stop)``
|
||||
|
||||
=end
|
||||
|
||||
class StarvingDead
|
||||
|
||||
def initialize
|
||||
@threshold = 1
|
||||
@die_threshold = 6
|
||||
end
|
||||
|
||||
def process
|
||||
return false unless @running
|
||||
month_length = 67200
|
||||
if (@undead_count >= 25)
|
||||
month_length *= 25 / @undead_count
|
||||
end
|
||||
|
||||
@undead_count = 0
|
||||
df.world.units.active.each { |u|
|
||||
if (u.enemy.undead and not u.flags1.dead)
|
||||
@undead_count += 1
|
||||
if (u.curse.time_on_site > month_length * @threshold)
|
||||
u.body.physical_attrs.each { |att|
|
||||
att.value = att.value - (att.value * 0.02)
|
||||
}
|
||||
end
|
||||
|
||||
if (u.curse.time_on_site > month_length * @die_threshold)
|
||||
u.flags1.dead = true
|
||||
u.curse.rem_tags2.FIT_FOR_ANIMATION = true
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def start
|
||||
@onupdate = df.onupdate_register('starvingdead', 1200, 1200) { process }
|
||||
@running = true
|
||||
@undead_count = 0
|
||||
|
||||
if ($script_args[1] and $script_args[1].gsub(/[^0-9\.]/,'').to_f > 0)
|
||||
@threshold = $script_args[1].gsub(/[^0-9\.]/,'').to_f
|
||||
end
|
||||
|
||||
if ($script_args[2] and $script_args[2].gsub(/[^0-9\.]/,'').to_f > 0)
|
||||
@die_threshold = $script_args[2].gsub(/[^0-9\.]/,'').to_f
|
||||
end
|
||||
|
||||
puts "Starving Dead starting...weakness starts at #{@threshold} months, true death at #{@die_threshold} months"
|
||||
end
|
||||
|
||||
def stop
|
||||
df.onupdate_unregister(@onupdate)
|
||||
@running = false
|
||||
end
|
||||
def status
|
||||
@running ? 'Running.' : 'Stopped.'
|
||||
end
|
||||
end
|
||||
|
||||
case $script_args[0]
|
||||
when 'start'
|
||||
if ($StarvingDead)
|
||||
$StarvingDead.stop
|
||||
end
|
||||
$StarvingDead = StarvingDead.new
|
||||
$StarvingDead.start
|
||||
|
||||
when 'end', 'stop'
|
||||
$StarvingDead.stop
|
||||
else
|
||||
if $StarvingDead
|
||||
puts $StarvingDead.status
|
||||
else
|
||||
puts 'Not loaded.'
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue