@@ -220,15 +220,42 @@ void Creature::onCreatureWalk() {
220
220
}
221
221
222
222
void Creature::onWalk (Direction &dir) {
223
- if (hasCondition (CONDITION_DRUNK)) {
224
- uint32_t r = uniform_random (0 , 60 );
225
- if (r <= DIRECTION_DIAGONAL_MASK) {
226
- if (r < DIRECTION_DIAGONAL_MASK) {
227
- dir = static_cast <Direction>(r);
223
+ int32_t highestDrunkSubId = -1 ;
224
+ if (!isSuppress (CONDITION_DRUNK, false )) {
225
+ for (const auto &condition : conditions) {
226
+ if (condition->getType () != CONDITION_DRUNK) {
227
+ continue ;
228
+ }
229
+
230
+ int32_t subId = condition->getSubId ();
231
+ if ((!condition->getEndTime () || condition->getEndTime () >= OTSYS_TIME ()) && subId > highestDrunkSubId) {
232
+ highestDrunkSubId = subId;
228
233
}
229
- g_game ().internalCreatureSay (static_self_cast<Creature>(), TALKTYPE_MONSTER_SAY, " Hicks!" , false );
230
234
}
231
235
}
236
+
237
+ if (highestDrunkSubId < 0 ) {
238
+ return ;
239
+ }
240
+
241
+ highestDrunkSubId += 25 ;
242
+ int32_t randomValue = normal_random (1 , 100 );
243
+ if (randomValue > highestDrunkSubId) {
244
+ return ;
245
+ }
246
+
247
+ int32_t threshold = highestDrunkSubId / 5 ;
248
+ if (randomValue <= threshold) {
249
+ dir = DIRECTION_NORTH;
250
+ } else if (randomValue <= (threshold * 2 )) {
251
+ dir = DIRECTION_WEST;
252
+ } else if (randomValue <= (threshold * 3 )) {
253
+ dir = DIRECTION_SOUTH;
254
+ } else if (randomValue <= (threshold * 4 )) {
255
+ dir = DIRECTION_EAST;
256
+ }
257
+
258
+ g_game ().internalCreatureSay (static_self_cast<Creature>(), TALKTYPE_MONSTER_SAY, " Hicks!" , false );
232
259
}
233
260
234
261
void Creature::resetMovementState () {
0 commit comments