35 m_walkLockExpiration = 0;
37 m_skillsLevel.fill(-1);
38 m_skillsBaseLevel.fill(-1);
39 m_skillsLevelPercent.fill(-1);
50 m_magicLevelPercent = -1;
51 m_baseMagicLevel = -1;
55 m_regenerationTime = -1;
56 m_offlineTrainingTime = -1;
68 if(m_walkLockExpiration != 0 &&
g_clock.
millis() < m_walkLockExpiration)
83 if(!m_lastPrewalkDone && m_preWalking && !prewalkTimeouted)
99 m_secondPreWalk =
false;
100 m_lastPrewalkDone =
true;
102 if(newPos == m_lastPrewalkDestination) {
110 m_serverWalking =
true;
111 if(m_serverWalkEndEvent)
112 m_serverWalkEndEvent->
cancel();
124 m_secondPreWalk =
true;
130 if(m_serverWalkEndEvent)
131 m_serverWalkEndEvent->
cancel();
134 m_lastPrewalkDone =
false;
135 m_lastPrewalkDestination = newPos;
145 m_lastPrewalkDone =
true;
149 if(m_autoWalkDestination.
isValid()) {
152 if(m_autoWalkContinueEvent)
153 m_autoWalkContinueEvent->
cancel();
155 if(self->m_autoWalkDestination.isValid())
156 self->autoWalk(self->m_autoWalkDestination);
172 bool tryKnownPath =
false;
173 if(destination != m_autoWalkDestination) {
174 m_knownCompletePath =
false;
179 std::vector<Otc::Direction> limitedPath;
185 if(tryKnownPath || m_knownCompletePath) {
188 limitedPath = std::get<0>(result);
190 if(limitedPath.size() > 127)
191 limitedPath.resize(127);
192 m_knownCompletePath =
true;
197 if(limitedPath.empty()) {
206 for(
auto dir : std::get<0>(result)) {
211 limitedPath.push_back(dir);
215 m_autoWalkDestination = destination;
233 m_lastAutoWalkPosition =
Position();
234 m_knownCompletePath =
false;
236 if(m_autoWalkContinueEvent)
237 m_autoWalkContinueEvent->
cancel();
244 m_lastPrewalkDone =
true;
245 m_lastPrewalkDestination =
Position();
285 m_preWalking =
false;
286 m_secondPreWalk =
false;
291 if(m_serverWalking) {
292 if(m_serverWalkEndEvent)
293 m_serverWalkEndEvent->
cancel();
295 self->m_serverWalking =
false;
315 if(newPos == m_autoWalkDestination)
317 else if(m_autoWalkDestination.
isValid() && newPos == m_lastAutoWalkPosition)
323 if(m_states != states) {
324 int oldStates = m_states;
334 g_logger.traceError(
"invalid skill");
338 int oldLevel = m_skillsLevel[skill];
339 int oldLevelPercent = m_skillsLevelPercent[skill];
341 if(level != oldLevel || levelPercent != oldLevelPercent) {
342 m_skillsLevel[skill] = level;
343 m_skillsLevelPercent[skill] = levelPercent;
345 callLuaField(
"onSkillChange", skill, level, levelPercent, oldLevel, oldLevelPercent);
352 g_logger.traceError(
"invalid skill");
356 int oldBaseLevel = m_skillsBaseLevel[skill];
357 if(baseLevel != oldBaseLevel) {
358 m_skillsBaseLevel[skill] = baseLevel;
360 callLuaField(
"onBaseSkillChange", skill, baseLevel, oldBaseLevel);
366 if(m_health != health || m_maxHealth != maxHealth) {
367 double oldHealth = m_health;
368 double oldMaxHealth = m_maxHealth;
370 m_maxHealth = maxHealth;
372 callLuaField(
"onHealthChange", health, maxHealth, oldHealth, oldMaxHealth);
385 if(m_freeCapacity != freeCapacity) {
386 double oldFreeCapacity = m_freeCapacity;
387 m_freeCapacity = freeCapacity;
389 callLuaField(
"onFreeCapacityChange", freeCapacity, oldFreeCapacity);
395 if(m_totalCapacity != totalCapacity) {
396 double oldTotalCapacity = m_totalCapacity;
397 m_totalCapacity = totalCapacity;
399 callLuaField(
"onTotalCapacityChange", totalCapacity, oldTotalCapacity);
405 if(m_experience != experience) {
406 double oldExperience = m_experience;
407 m_experience = experience;
409 callLuaField(
"onExperienceChange", experience, oldExperience);
415 if(m_level != level || m_levelPercent != levelPercent) {
416 double oldLevel = m_level;
417 double oldLevelPercent = m_levelPercent;
419 m_levelPercent = levelPercent;
421 callLuaField(
"onLevelChange", level, levelPercent, oldLevel, oldLevelPercent);
427 if(m_mana != mana || m_maxMana != maxMana) {
428 double oldMana = m_mana;
433 callLuaField(
"onManaChange", mana, maxMana, oldMana, oldMaxMana);
439 if(m_magicLevel != magicLevel || m_magicLevelPercent != magicLevelPercent) {
440 double oldMagicLevel = m_magicLevel;
441 double oldMagicLevelPercent = m_magicLevelPercent;
442 m_magicLevel = magicLevel;
443 m_magicLevelPercent = magicLevelPercent;
445 callLuaField(
"onMagicLevelChange", magicLevel, magicLevelPercent, oldMagicLevel, oldMagicLevelPercent);
451 if(m_baseMagicLevel != baseMagicLevel) {
452 double oldBaseMagicLevel = m_baseMagicLevel;
453 m_baseMagicLevel = baseMagicLevel;
455 callLuaField(
"onBaseMagicLevelChange", baseMagicLevel, oldBaseMagicLevel);
462 double oldSoul = m_soul;
471 if(m_stamina != stamina) {
472 double oldStamina = m_stamina;
482 g_logger.traceError(
"invalid slot");
486 if(m_inventoryItems[inventory] != item) {
487 ItemPtr oldItem = m_inventoryItems[inventory];
488 m_inventoryItems[inventory] = item;
490 callLuaField(
"onInventoryChange", inventory, item, oldItem);
496 if(m_vocation != vocation) {
497 int oldVocation = m_vocation;
498 m_vocation = vocation;
500 callLuaField(
"onVocationChange", vocation, oldVocation);
506 if(m_premium != premium) {
515 if(m_regenerationTime != regenerationTime) {
516 double oldRegenerationTime = m_regenerationTime;
517 m_regenerationTime = regenerationTime;
519 callLuaField(
"onRegenerationChange", regenerationTime, oldRegenerationTime);
525 if(m_offlineTrainingTime != offlineTrainingTime) {
526 double oldOfflineTrainingTime = m_offlineTrainingTime;
527 m_offlineTrainingTime = offlineTrainingTime;
529 callLuaField(
"onOfflineTrainingChange", offlineTrainingTime, oldOfflineTrainingTime);
535 if(m_spells != spells) {
536 std::vector<int> oldSpells = m_spells;
545 if(blessings != m_blessings) {
546 int oldBlessings = m_blessings;
547 m_blessings = blessings;
549 callLuaField(
"onBlessingsChange", blessings, oldBlessings);