-
Notifications
You must be signed in to change notification settings - Fork 198
/
starvingdead.rb
92 lines (76 loc) · 2.47 KB
/
starvingdead.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
# Weaken and eventually destroy undead over time
=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