forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deterioratecorpses.rb
108 lines (81 loc) · 2.58 KB
/
deterioratecorpses.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# 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