@@ -1136,29 +1136,38 @@ public void imprison(short playerId) {
1136
1136
@ Override
1137
1137
public boolean isStateTimeExceeded () {
1138
1138
double timeSpent = gameTimer .getGameTime () - entityData .getComponent (entityId , CreatureAi .class ).stateStartTime ;
1139
+ double stateTargetTime ;
1139
1140
1140
1141
switch (stateMachine .getCurrentState ()) {
1141
- case STUNNED : {
1142
+ case STUNNED -> {
1142
1143
// Hmm, this might actually be the level variable, the stun seems to be the time fallen when dropped
1143
- return timeSpent > = entityData .getComponent (entityId , CreatureComponent .class ).stunDuration ;
1144
+ stateTargetTime = entityData .getComponent (entityId , CreatureComponent .class ).stunDuration ;
1144
1145
}
1145
- case FALLEN : {
1146
- return timeSpent > = entityData .getComponent (entityId , CreatureComponent .class ).stunDuration ;
1146
+ case FALLEN -> {
1147
+ stateTargetTime = entityData .getComponent (entityId , CreatureComponent .class ).stunDuration ;
1147
1148
}
1148
- case GETTING_UP : {
1149
- return timeSpent > = getAnimationTime (creature , Creature .AnimationType .GET_UP );
1149
+ case GETTING_UP -> {
1150
+ stateTargetTime = getAnimationTime (creature , Creature .AnimationType .GET_UP );
1150
1151
}
1151
- case ENTERING_DUNGEON : {
1152
- return timeSpent > = getAnimationTime (creature , Creature .AnimationType .ENTRANCE );
1152
+ case ENTERING_DUNGEON -> {
1153
+ stateTargetTime = getAnimationTime (creature , Creature .AnimationType .ENTRANCE );
1153
1154
}
1154
- case MELEE_ATTACK : {
1155
- return timeSpent > = getAnimationTime (creature , Creature .AnimationType .MELEE_ATTACK );
1155
+ case MELEE_ATTACK -> {
1156
+ stateTargetTime = getAnimationTime (creature , Creature .AnimationType .MELEE_ATTACK );
1156
1157
}
1157
- case EATING : {
1158
- return timeSpent >= getAnimationTime (creature , Creature .AnimationType .EATING );
1158
+ case EATING -> {
1159
+ stateTargetTime = getAnimationTime (creature , Creature .AnimationType .EATING );
1160
+ }
1161
+ case FLEE -> {
1162
+ // I couldn't find a variable for this, so lets use this for now
1163
+ stateTargetTime = gameSettings .get (Variable .MiscVariable .MiscType .IMP_IDLE_DELAY_BEFORE_REEVALUATION_SECONDS ).getValue ();
1164
+ }
1165
+ default -> {
1166
+ stateTargetTime = Double .MAX_VALUE ;
1159
1167
}
1160
1168
}
1161
- return false ;
1169
+
1170
+ return stateTargetTime < timeSpent ;
1162
1171
}
1163
1172
1164
1173
private static double getAnimationTime (Creature creature , Creature .AnimationType animation ) {
0 commit comments