@@ -106,30 +106,99 @@ local function adjust_units(timeskip)
106
106
end
107
107
end
108
108
dfhack .units .subtractGroupActionTimers (unit , timeskip , df .unit_action_type_group .All )
109
+ local job = unit .job .current_job
109
110
local c2 = unit .counters2
111
+ if job and job .job_type == df .job_type .Rest then
112
+ c2 .sleepiness_timer = math.max (0 , c2 .sleepiness_timer - timeskip * 200 )
113
+ end
114
+ if not dfhack .units .isCitizen (unit , true ) then goto continue end
110
115
if not has_caste_flag (unit , ' NO_EAT' ) then
111
116
c2 .hunger_timer = c2 .hunger_timer + timeskip
112
117
end
113
118
if not has_caste_flag (unit , ' NO_DRINK' ) then
114
119
c2 .thirst_timer = c2 .thirst_timer + timeskip
115
120
end
116
- local job = unit .job .current_job
117
121
if not has_caste_flag (unit , ' NO_SLEEP' ) then
118
122
if job and job .job_type == df .job_type .Sleep then
119
123
c2 .sleepiness_timer = math.max (0 , c2 .sleepiness_timer - timeskip * 19 )
120
124
else
121
125
c2 .sleepiness_timer = c2 .sleepiness_timer + timeskip
122
126
end
123
127
end
124
- if job and job .job_type == df .job_type .Rest then
125
- c2 .sleepiness_timer = math.max (0 , c2 .sleepiness_timer - timeskip * 200 )
126
- end
128
+ -- TODO: c2.stomach_content, c2.stomach_food, and c2.stored_fat
129
+ -- TODO: needs
127
130
:: continue::
128
131
end
129
132
end
130
133
131
- local function adjust_armies (timeskip )
132
- -- TODO
134
+ local function increment_counter (ev , counter_name , timeskip )
135
+ if ev [counter_name ] <= 0 then return end
136
+ ev [counter_name ] = ev [counter_name ] + timeskip
137
+ end
138
+
139
+ local function decrement_counter (ev , counter_name , timeskip )
140
+ if ev [counter_name ] <= 0 then return end
141
+ ev [counter_name ] = math.max (1 , ev [counter_name ] - timeskip )
142
+ end
143
+
144
+ local function adjust_activities (timeskip )
145
+ for i , act in ipairs (df .global .world .activities .all ) do
146
+ for _ , ev in ipairs (act .events ) do
147
+ if df .activity_event_training_sessionst :is_instance (ev ) then
148
+ -- noop
149
+ elseif df .activity_event_combat_trainingst :is_instance (ev ) then
150
+ elseif df .activity_event_skill_demonstrationst :is_instance (ev ) then
151
+ -- can be negative or positive, but always counts towards 0
152
+ if ev .organize_counter < 0 then
153
+ ev .organize_counter = math.min (- 1 , ev .organize_counter + timeskip )
154
+ else
155
+ decrement_counter (ev , ' organize_counter' , timeskip )
156
+ end
157
+ decrement_counter (ev , ' train_countdown' , timeskip )
158
+ elseif df .activity_event_fill_service_orderst :is_instance (ev ) then
159
+ elseif df .activity_event_individual_skill_drillst :is_instance (ev ) then
160
+ -- only counts down on season ticks, nothing to do here
161
+ elseif df .activity_event_sparringst :is_instance (ev ) then
162
+ elseif df .activity_event_ranged_practicest :is_instance (ev ) then
163
+ decrement_counter (ev , ' countdown' , timeskip )
164
+ elseif df .activity_event_harassmentst :is_instance (ev ) then
165
+ elseif df .activity_event_encounterst :is_instance (ev ) then
166
+ elseif df .activity_event_reunionst :is_instance (ev ) then
167
+ elseif df .activity_event_conversationst :is_instance (ev ) then
168
+ increment_counter (ev , ' pause' , timeskip )
169
+ elseif df .activity_event_guardst :is_instance (ev ) then
170
+ elseif df .activity_event_conflictst :is_instance (ev ) then
171
+ increment_counter (ev , ' inactivity_timer' , timeskip )
172
+ increment_counter (ev , ' attack_inactivity_timer' , timeskip )
173
+ increment_counter (ev , ' stop_fort_fights_timer' , timeskip )
174
+ elseif df .activity_event_prayerst :is_instance (ev ) then
175
+ decrement_counter (ev , ' timer' , timeskip )
176
+ elseif df .activity_event_researchst :is_instance (ev ) then
177
+ -- noop
178
+ elseif df .activity_event_playst :is_instance (ev ) then
179
+ increment_counter (ev , ' down_time_counter' , timeskip )
180
+ elseif df .activity_event_worshipst :is_instance (ev ) then
181
+ increment_counter (ev , ' down_time_counter' , timeskip )
182
+ elseif df .activity_event_socializest :is_instance (ev ) then
183
+ increment_counter (ev , ' down_time_counter' , timeskip )
184
+ elseif df .activity_event_ponder_topicst :is_instance (ev ) then
185
+ elseif df .activity_event_discuss_topicst :is_instance (ev ) then
186
+ decrement_counter (ev , ' timer' , timeskip )
187
+ elseif df .activity_event_teach_topicst :is_instance (ev ) then
188
+ elseif df .activity_event_readst :is_instance (ev ) then
189
+ decrement_counter (ev , ' timer' , timeskip )
190
+ elseif df .activity_event_writest :is_instance (ev ) then
191
+ decrement_counter (ev , ' timer' , timeskip )
192
+ elseif df .activity_event_copy_written_contentst :is_instance (ev ) then
193
+ elseif df .activity_event_make_believest :is_instance (ev ) then
194
+ decrement_counter (ev , ' time_left' , timeskip )
195
+ elseif df .activity_event_play_with_toyst :is_instance (ev ) then
196
+ elseif df .activity_event_performancest :is_instance (ev ) then
197
+ increment_counter (ev , ' current_position' , timeskip )
198
+ elseif df .activity_event_store_objectst :is_instance (ev ) then
199
+ end
200
+ end
201
+ end
133
202
end
134
203
135
204
local function on_tick ()
@@ -166,7 +235,7 @@ local function on_tick()
166
235
df .global .cur_year_tick = df .global .cur_year_tick + calendar_timeskip
167
236
168
237
adjust_units (timeskip )
169
- adjust_armies (timeskip )
238
+ adjust_activities (timeskip )
170
239
end
171
240
172
241
---- --------------------------------
0 commit comments