void tBiasSliderAction::Init(int biasRange, int bias, int defaultValue) { SetAppearance(Action::AutoAppearance); m_BiasRange = biasRange; NewDefaultValue( defaultValue ); SetSliderBias( bias ); SetOwnerControlMode(true); Connect( this, SIGNAL( AdjustValueRequest(int) ), this, SLOT( AdjustBias(int) ) ); Connect( this, SIGNAL( AbsoluteValueRequest(int) ), this, SLOT( SetSliderBiasByExplicitValue(int) ) ); }
void NPC::ResumeWandering() { // causes wandering to continue - overrides waypoint pause timer and PauseWandering() if(!IsNPC()) return; if (GetGrid() != 0) { if (GetGrid() < 0) { // we were paused by a quest AIwalking_timer->Disable(); SetGrid( 0 - GetGrid()); if (cur_wp==-1) { // got here by a MoveTo() cur_wp=save_wp; UpdateWaypoint(cur_wp); // have him head to last destination from here } Log.Out(Logs::Detail, Logs::Pathing, "Resume Wandering requested. Grid %d, wp %d", GetGrid(), cur_wp); } else if (AIwalking_timer->Enabled()) { // we are at a waypoint paused normally Log.Out(Logs::Detail, Logs::Pathing, "Resume Wandering on timed pause. Grid %d, wp %d", GetGrid(), cur_wp); AIwalking_timer->Trigger(); // disable timer to end pause now } else { Log.Out(Logs::General, Logs::Error, "NPC not paused - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); return; } if (m_CurrentWayPoint.x == GetX() && m_CurrentWayPoint.y == GetY()) { // are we we at a waypoint? if so, trigger event and start to next char temp[100]; itoa(cur_wp,temp,10); //do this before updating to next waypoint CalculateNewWaypoint(); SetAppearance(eaStanding, false); parse->EventNPC(EVENT_WAYPOINT_DEPART, this, nullptr, temp, 0); } // if not currently at a waypoint, we continue on to the one we were headed to before the stop } else { Log.Out(Logs::General, Logs::Error, "NPC not on grid - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); } return; }
bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, bool checkZ) { if(GetID()==0) return true; if(speed <= 0) { SetCurrentSpeed(0); return true; } if ((m_Position.x-x == 0) && (m_Position.y-y == 0)) {//spawn is at target coords if(m_Position.z-z != 0) { m_Position.z = z; Log.Out(Logs::Detail, Logs::AI, "Calc Position2 (%.3f, %.3f, %.3f): Jumping pure Z.", x, y, z); return true; } Log.Out(Logs::Detail, Logs::AI, "Calc Position2 (%.3f, %.3f, %.3f) inWater=%d: We are there.", x, y, z, inWater); return false; } else if ((std::abs(m_Position.x - x) < 0.1) && (std::abs(m_Position.y - y) < 0.1)) { Log.Out(Logs::Detail, Logs::AI, "Calc Position2 (%.3f, %.3f, %.3f): X/Y difference <0.1, Jumping to target.", x, y, z); if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } m_Position.x = x; m_Position.y = y; m_Position.z = z; return true; } bool send_update = false; int compare_steps = 20; if(tar_ndx < compare_steps && m_TargetLocation.x==x && m_TargetLocation.y==y) { float new_x = m_Position.x + m_TargetV.x*tar_vector; float new_y = m_Position.y + m_TargetV.y*tar_vector; float new_z = m_Position.z + m_TargetV.z*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } m_Position.x = new_x; m_Position.y = new_y; m_Position.z = new_z; Log.Out(Logs::Detail, Logs::AI, "Calculating new position2 to (%.3f, %.3f, %.3f), old vector (%.3f, %.3f, %.3f)", x, y, z, m_TargetV.x, m_TargetV.y, m_TargetV.z); uint8 NPCFlyMode = 0; if(IsNPC()) { if(CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) NPCFlyMode = 1; } //fix up pathing Z if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z); float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; Log.Out(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.x,m_Position.y,m_Position.z); if ((newz > -2000) && std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { if ((std::abs(x - m_Position.x) < 0.5) && (std::abs(y - m_Position.y) < 0.5)) { if (std::abs(z - m_Position.z) <= RuleR(Map, FixPathingZMaxDeltaMoving)) m_Position.z = z; else m_Position.z = newz + 1; } else m_Position.z = newz + 1; } } } tar_ndx++; return true; } if (tar_ndx>50) { tar_ndx--; } else { tar_ndx=0; } m_TargetLocation = glm::vec3(x, y, z); float nx = this->m_Position.x; float ny = this->m_Position.y; float nz = this->m_Position.z; // float nh = this->heading; m_TargetV.x = x - nx; m_TargetV.y = y - ny; m_TargetV.z = z - nz; SetCurrentSpeed((int8)speed); pRunAnimSpeed = speed; if(IsClient()) { animation = speed / 2; } //pRunAnimSpeed = (int8)(speed*NPC_RUNANIM_RATIO); //speed *= NPC_SPEED_MULTIPLIER; Log.Out(Logs::Detail, Logs::AI, "Calculating new position2 to (%.3f, %.3f, %.3f), new vector (%.3f, %.3f, %.3f) rate %.3f, RAS %d", x, y, z, m_TargetV.x, m_TargetV.y, m_TargetV.z, speed, pRunAnimSpeed); // -------------------------------------------------------------------------- // 2: get unit vector // -------------------------------------------------------------------------- float mag = sqrtf (m_TargetV.x*m_TargetV.x + m_TargetV.y*m_TargetV.y + m_TargetV.z*m_TargetV.z); tar_vector = (float)speed / mag; // mob move fix int numsteps = (int) ( mag * 16.0f / (float)speed + 0.5f); // mob move fix if (numsteps<20) { if (numsteps>1) { tar_vector=1.0f ; m_TargetV.x = m_TargetV.x/(float)numsteps; m_TargetV.y = m_TargetV.y/(float)numsteps; m_TargetV.z = m_TargetV.z/(float)numsteps; float new_x = m_Position.x + m_TargetV.x; float new_y = m_Position.y + m_TargetV.y; float new_z = m_Position.z + m_TargetV.z; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } m_Position.x = new_x; m_Position.y = new_y; m_Position.z = new_z; m_Position.w = CalculateHeadingToTarget(x, y); tar_ndx = 20 - numsteps; Log.Out(Logs::Detail, Logs::AI, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", m_Position.x, m_Position.y, m_Position.z, numsteps); } else { if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } m_Position.x = x; m_Position.y = y; m_Position.z = z; Log.Out(Logs::Detail, Logs::AI, "Only a single step to get there... jumping."); } } else { tar_vector/=16.0f; float dur = Timer::GetCurrentTime() - pLastChange; if(dur < 1.0f) { dur = 1.0f; } tar_vector = (tar_vector * AImovement_duration) / 100.0f; float new_x = m_Position.x + m_TargetV.x*tar_vector; float new_y = m_Position.y + m_TargetV.y*tar_vector; float new_z = m_Position.z + m_TargetV.z*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } m_Position.x = new_x; m_Position.y = new_y; m_Position.z = new_z; m_Position.w = CalculateHeadingToTarget(x, y); Log.Out(Logs::Detail, Logs::AI, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", m_Position.x, m_Position.y, m_Position.z, numsteps); } uint8 NPCFlyMode = 0; if(IsNPC()) { if(CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) NPCFlyMode = 1; } //fix up pathing Z if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z); float newz = zone->zonemap->FindBestZ(dest, nullptr); Log.Out(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.x, m_Position.y, m_Position.z); if ((newz > -2000) && std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { if (std::abs(x - m_Position.x) < 0.5 && std::abs(y - m_Position.y) < 0.5) { if (std::abs(z - m_Position.z) <= RuleR(Map, FixPathingZMaxDeltaMoving)) m_Position.z = z; else m_Position.z = newz + 1; } else m_Position.z = newz+1; } } } SetMoving(true); moved=true; m_Delta = glm::vec4(m_Position.x - nx, m_Position.y - ny, m_Position.z - nz, 0.0f); if (IsClient()) { SendPosUpdate(1); CastToClient()->ResetPositionTimer(); } else { SendPosUpdate(); SetAppearance(eaStanding, false); } pLastChange = Timer::GetCurrentTime(); return true; }
bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ, bool calcHeading) { if(GetID()==0) return true; float nx = m_Position.x; float ny = m_Position.y; float nz = m_Position.z; // if NPC is rooted if (speed == 0) { SetHeading(CalculateHeadingToTarget(x, y)); if(moved){ SetCurrentSpeed(0); moved=false; } Log.Out(Logs::Detail, Logs::AI, "Rooted while calculating new position to (%.3f, %.3f, %.3f)", x, y, z); return true; } float old_test_vector=test_vector; m_TargetV.x = x - nx; m_TargetV.y = y - ny; m_TargetV.z = z - nz; if (m_TargetV.x == 0 && m_TargetV.y == 0) return false; SetCurrentSpeed((int8)(speed)); //*NPC_RUNANIM_RATIO); //speed *= NPC_SPEED_MULTIPLIER; Log.Out(Logs::Detail, Logs::AI, "Calculating new position to (%.3f, %.3f, %.3f) vector (%.3f, %.3f, %.3f) rate %.3f RAS %d", x, y, z, m_TargetV.x, m_TargetV.y, m_TargetV.z, speed, pRunAnimSpeed); // -------------------------------------------------------------------------- // 2: get unit vector // -------------------------------------------------------------------------- test_vector=sqrtf (x*x + y*y + z*z); tar_vector = speed / sqrtf (m_TargetV.x*m_TargetV.x + m_TargetV.y*m_TargetV.y + m_TargetV.z*m_TargetV.z); m_Position.w = CalculateHeadingToTarget(x, y); if (tar_vector >= 1.0) { if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } m_Position.x = x; m_Position.y = y; m_Position.z = z; Log.Out(Logs::Detail, Logs::AI, "Close enough, jumping to waypoint"); } else { float new_x = m_Position.x + m_TargetV.x*tar_vector; float new_y = m_Position.y + m_TargetV.y*tar_vector; float new_z = m_Position.z + m_TargetV.z*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } m_Position.x = new_x; m_Position.y = new_y; m_Position.z = new_z; Log.Out(Logs::Detail, Logs::AI, "Next position (%.3f, %.3f, %.3f)", m_Position.x, m_Position.y, m_Position.z); } uint8 NPCFlyMode = 0; if(IsNPC()) { if(CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) NPCFlyMode = 1; } //fix up pathing Z if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z); float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; Log.Out(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.x,m_Position.y,m_Position.z); if ((newz > -2000) && std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { if (std::abs(x - m_Position.x) < 0.5 && std::abs(y - m_Position.y) < 0.5) { if (std::abs(z - m_Position.z) <= RuleR(Map, FixPathingZMaxDeltaMoving)) m_Position.z = z; else m_Position.z = newz + 1; } else m_Position.z = newz+1; } } } //OP_MobUpdate if((old_test_vector!=test_vector) || tar_ndx>20){ //send update tar_ndx=0; this->SetMoving(true); moved=true; m_Delta = glm::vec4(m_Position.x - nx, m_Position.y - ny, m_Position.z - nz, 0.0f); SendPosUpdate(); } tar_ndx++; // now get new heading SetAppearance(eaStanding, false); // make sure they're standing pLastChange = Timer::GetCurrentTime(); return true; }
void Client::ActivateAlternateAdvancementAbility(int rank_id, int target_id) { AA::Rank *rank = zone->GetAlternateAdvancementRank(rank_id); if(!rank) { return; } AA::Ability *ability = rank->base_ability; if(!ability) { return; } if(!IsValidSpell(rank->spell)) { return; } if(!CanUseAlternateAdvancementRank(rank)) { return; } //make sure it is not a passive if(!rank->effects.empty()) { return; } uint32 charges = 0; // We don't have the AA if (!GetAA(rank_id, &charges)) return; //if expendable make sure we have charges if(ability->charges > 0 && charges < 1) return; //check cooldown if(!p_timers.Expired(&database, rank->spell_type + pTimerAAStart, false)) { uint32 aaremain = p_timers.GetRemainingTime(rank->spell_type + pTimerAAStart); uint32 aaremain_hr = aaremain / (60 * 60); uint32 aaremain_min = (aaremain / 60) % 60; uint32 aaremain_sec = aaremain % 60; if(aaremain_hr >= 1) { Message(13, "You can use this ability again in %u hour(s) %u minute(s) %u seconds", aaremain_hr, aaremain_min, aaremain_sec); } else { Message(13, "You can use this ability again in %u minute(s) %u seconds", aaremain_min, aaremain_sec); } return; } //calculate cooldown int cooldown = rank->recast_time - GetAlternateAdvancementCooldownReduction(rank); if(cooldown < 0) { cooldown = 0; } if (!IsCastWhileInvis(rank->spell)) CommonBreakInvisible(); if (spells[rank->spell].sneak && (!hidden || (hidden && (Timer::GetCurrentTime() - tmHidden) < 4000))) { Message_StringID(MT_SpellFailure, SNEAK_RESTRICT); return; } // // Modern clients don't require pet targeted for AA casts that are ST_Pet if (spells[rank->spell].targettype == ST_Pet || spells[rank->spell].targettype == ST_SummonedPet) target_id = GetPetID(); // extra handling for cast_not_standing spells if (!spells[rank->spell].cast_not_standing) { if (GetAppearance() == eaSitting) // we need to stand! SetAppearance(eaStanding, false); if (GetAppearance() != eaStanding) { Message_StringID(MT_SpellFailure, STAND_TO_CAST); return; } } // Bards can cast instant cast AAs while they are casting another song if(spells[rank->spell].cast_time == 0 && GetClass() == BARD && IsBardSong(casting_spell_id)) { if(!SpellFinished(rank->spell, entity_list.GetMob(target_id), EQEmu::spells::CastingSlot::AltAbility, spells[rank->spell].mana, -1, spells[rank->spell].ResistDiff, false)) { return; } ExpendAlternateAdvancementCharge(ability->id); } else { if(!CastSpell(rank->spell, target_id, EQEmu::spells::CastingSlot::AltAbility, -1, -1, 0, -1, rank->spell_type + pTimerAAStart, cooldown, nullptr, rank->id)) { return; } } CastToClient()->GetPTimers().Start(rank->spell_type + pTimerAAStart, cooldown); SendAlternateAdvancementTimer(rank->spell_type, 0, 0); }
void CMultiSelTreeCtrl::OnLButtonDown(UINT nFlags, CPoint point) { // update shift and control flags m_CtrlDown= nFlags & MK_CONTROL ? TRUE : FALSE; m_ShiftDown= nFlags & MK_SHIFT ? TRUE : FALSE; // find out what was hit TV_HITTESTINFO ht; ht.pt=point; m_LastLButtonDown=HitTest( &ht ); if(m_LastLButtonDown==NULL) return; BOOL success; m_PendingDeselect=FALSE; if(m_LastLButtonDown != TVI_ROOT && (ht.flags & TVHT_ONITEM )) { // Select nothing so there is no focus rect SelectItem(NULL); // Add the item to the selection set if(nFlags & MK_CONTROL) { // Make sure its a valid selection if( !OKToAddSelection( m_LastLButtonDown ) ) return; // If not in set, add it if(!IsSelected(m_LastLButtonDown)) success=SetSelectState(m_LastLButtonDown, TRUE); else // removing from set, or possibly re-clicking for drag success=m_PendingDeselect=TRUE; } else if(nFlags & MK_SHIFT) { success=RangeSelect(m_LastLButtonDown); } else { if(!IsSelected(m_LastLButtonDown)) { UnselectAll(); success=SetSelectState(m_LastLButtonDown, TRUE); ASSERT(GetSelectedCount()); } else { success= TRUE; m_PendingDeselect= TRUE; } } // wait at least 20 secs before autopolling for updates MainFrame()->WaitAWhileToPoll(); if(!success) return; // Store the clicked item m_DragFromItem=m_LastLButtonDown; // Force the stinking item to repaint, because new select atts seem to // be lost in commctl32.dll occasionally SetAppearance(FALSE, TRUE, FALSE); GetItemRect(m_LastLButtonDown, &m_DragSourceRect, TRUE); RedrawWindow( m_DragSourceRect, NULL, RDW_UPDATENOW ); // Then create a suitably small drag rect around the cursor CPoint pt= point; ClientToScreen(&pt); m_DragSourceRect.SetRect( max(0, pt.x - 2), max(0, pt.y - 2), max(0, pt.x + 2), max(0, pt.y + 2) ); // The drag drop attempt will clear m_PendingDeselect if a drag is attempted TryDragDrop( m_LastLButtonDown ); if( m_PendingDeselect ) { if( nFlags & MK_CONTROL ) SetSelectState(m_LastLButtonDown, FALSE); else { UnselectAll(); success=SetSelectState(m_LastLButtonDown, TRUE); } } // Make sure selection set is properly displayed SetAppearance(FALSE, TRUE, FALSE); } else { if(ht.flags & TVHT_ONITEM && (nFlags & MK_CONTROL || nFlags & MK_SHIFT) ) return; else { if (ht.flags & TVHT_ONITEM && m_ViewIsActive ) { // Select just the one item UnselectAll(); SetSelectState(m_LastLButtonDown, TRUE); } // Clicked on something other than a bimap or item text, so just call // the default hanlder and make sure nothing gets selected CTreeCtrl::OnLButtonDown(nFlags, point); SelectItem( NULL); } } }
bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool checkZ) { if(GetID()==0) return true; float nx = x_pos; float ny = y_pos; float nz = z_pos; // if NPC is rooted if (speed == 0.0) { SetHeading(CalculateHeadingToTarget(x, y)); if(moved){ SendPosition(); SetMoving(false); moved=false; } SetRunAnimSpeed(0); mlog(AI__WAYPOINTS, "Rooted while calculating new position to (%.3f, %.3f, %.3f)", x, y, z); return true; } float old_test_vector=test_vector; tar_vx = x - nx; tar_vy = y - ny; tar_vz = z - nz; if (tar_vx == 0 && tar_vy == 0) return false; pRunAnimSpeed = (uint8)(speed*NPC_RUNANIM_RATIO); speed *= NPC_SPEED_MULTIPLIER; mlog(AI__WAYPOINTS, "Calculating new position to (%.3f, %.3f, %.3f) vector (%.3f, %.3f, %.3f) rate %.3f RAS %d", x, y, z, tar_vx, tar_vy, tar_vz, speed, pRunAnimSpeed); // -------------------------------------------------------------------------- // 2: get unit vector // -------------------------------------------------------------------------- test_vector=sqrtf (x*x + y*y + z*z); tar_vector = speed / sqrtf (tar_vx*tar_vx + tar_vy*tar_vy + tar_vz*tar_vz); heading = CalculateHeadingToTarget(x, y); if (tar_vector >= 1.0) { if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } x_pos = x; y_pos = y; z_pos = z; mlog(AI__WAYPOINTS, "Close enough, jumping to waypoint"); } else { float new_x = x_pos + tar_vx*tar_vector; float new_y = y_pos + tar_vy*tar_vector; float new_z = z_pos + tar_vz*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } x_pos = new_x; y_pos = new_y; z_pos = new_z; mlog(AI__WAYPOINTS, "Next position (%.3f, %.3f, %.3f)", x_pos, y_pos, z_pos); } uint8 NPCFlyMode = 0; if(IsNPC()) { if(CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) NPCFlyMode = 1; } //fix up pathing Z if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) { Map::Vertex dest(x_pos, y_pos, z_pos); float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { if(ABS(x - x_pos) < 0.5 && ABS(y - y_pos) < 0.5) { if(ABS(z - z_pos) <= RuleR(Map, FixPathingZMaxDeltaMoving)) z_pos = z; else z_pos = newz + 1; } else z_pos = newz+1; } } } //OP_MobUpdate if((old_test_vector!=test_vector) || tar_ndx>20){ //send update tar_ndx=0; this->SetMoving(true); moved=true; delta_x=(x_pos-nx); delta_y=(y_pos-ny); delta_z=(z_pos-nz); delta_heading=0;//(heading-nh)*8; SendPosUpdate(); } tar_ndx++; // now get new heading SetAppearance(eaStanding, false); // make sure they're standing pLastChange = Timer::GetCurrentTime(); return true; }
bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, bool checkZ) { if(GetID()==0) return true; if ((x_pos-x == 0) && (y_pos-y == 0)) {//spawn is at target coords if(z_pos-z != 0) { z_pos = z; mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f): Jumping pure Z.", x, y, z); return true; } mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f) inWater=%d: We are there.", x, y, z, inWater); return false; } else if ((ABS(x_pos - x) < 0.1) && (ABS(y_pos - y) < 0.1)) { mlog(AI__WAYPOINTS, "Calc Position2 (%.3f, %.3f, %.3f): X/Y difference <0.1, Jumping to target.", x, y, z); if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } x_pos = x; y_pos = y; z_pos = z; return true; } int compare_steps = IsBoat() ? 1 : 20; if(tar_ndx < compare_steps && tarx==x && tary==y) { float new_x = x_pos + tar_vx*tar_vector; float new_y = y_pos + tar_vy*tar_vector; float new_z = z_pos + tar_vz*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } x_pos = new_x; y_pos = new_y; z_pos = new_z; mlog(AI__WAYPOINTS, "Calculating new position2 to (%.3f, %.3f, %.3f), old vector (%.3f, %.3f, %.3f)", x, y, z, tar_vx, tar_vy, tar_vz); uint8 NPCFlyMode = 0; if(IsNPC()) { if(CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) NPCFlyMode = 1; } //fix up pathing Z if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) { Map::Vertex dest(x_pos, y_pos, z_pos); float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { if((ABS(x - x_pos) < 0.5) && (ABS(y - y_pos) < 0.5)) { if(ABS(z-z_pos) <= RuleR(Map, FixPathingZMaxDeltaMoving)) z_pos = z; else z_pos = newz + 1; } else z_pos = newz + 1; } } } tar_ndx++; return true; } if (tar_ndx>50) { tar_ndx--; } else { tar_ndx=0; } tarx=x; tary=y; tarz=z; float nx = this->x_pos; float ny = this->y_pos; float nz = this->z_pos; // float nh = this->heading; tar_vx = x - nx; tar_vy = y - ny; tar_vz = z - nz; //pRunAnimSpeed = (int8)(speed*NPC_RUNANIM_RATIO); //speed *= NPC_SPEED_MULTIPLIER; mlog(AI__WAYPOINTS, "Calculating new position2 to (%.3f, %.3f, %.3f), new vector (%.3f, %.3f, %.3f) rate %.3f, RAS %d", x, y, z, tar_vx, tar_vy, tar_vz, speed, pRunAnimSpeed); // -------------------------------------------------------------------------- // 2: get unit vector // -------------------------------------------------------------------------- float mag = sqrtf (tar_vx*tar_vx + tar_vy*tar_vy + tar_vz*tar_vz); tar_vector = speed / mag; // mob move fix int numsteps = (int) ( mag * 20 / speed) + 1; // mob move fix if (numsteps<20) { if (numsteps>1) { tar_vector=1.0f ; tar_vx = tar_vx/numsteps; tar_vy = tar_vy/numsteps; tar_vz = tar_vz/numsteps; float new_x = x_pos + tar_vx; float new_y = y_pos + tar_vy; float new_z = z_pos + tar_vz; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } x_pos = new_x; y_pos = new_y; z_pos = new_z; tar_ndx=22-numsteps; heading = CalculateHeadingToTarget(x, y); mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", x_pos, y_pos, z_pos, numsteps); } else { if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } x_pos = x; y_pos = y; z_pos = z; mlog(AI__WAYPOINTS, "Only a single step to get there... jumping."); } } else { tar_vector/=20; float new_x = x_pos + tar_vx*tar_vector; float new_y = y_pos + tar_vy*tar_vector; float new_z = z_pos + tar_vz*tar_vector; if(IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } x_pos = new_x; y_pos = new_y; z_pos = new_z; heading = CalculateHeadingToTarget(x, y); mlog(AI__WAYPOINTS, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", x_pos, y_pos, z_pos, numsteps); } uint8 NPCFlyMode = 0; if(IsNPC()) { if(CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) NPCFlyMode = 1; } //fix up pathing Z if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(x_pos, y_pos, z_pos))) { Map::Vertex dest(x_pos, y_pos, z_pos); float newz = zone->zonemap->FindBestZ(dest, nullptr); + 2.0f; mlog(AI__WAYPOINTS, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,x_pos,y_pos,z_pos); if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { if(ABS(x - x_pos) < 0.5 && ABS(y - y_pos) < 0.5) { if(ABS(z - z_pos) <= RuleR(Map, FixPathingZMaxDeltaMoving)) z_pos = z; else z_pos = newz + 1; } else z_pos = newz+1; } } } SetMoving(true); moved=true; delta_x=x_pos-nx; delta_y=y_pos-ny; delta_z=z_pos-nz; delta_heading=0; if (IsClient()) SendPosUpdate(1); else SendPosUpdate(); SetAppearance(eaStanding, false); pLastChange = Timer::GetCurrentTime(); return true; }
CXTPTabPaintManager::CXTPTabPaintManager() { m_bUseStandardFont = TRUE; m_pColorSet = NULL; m_pAppearanceSet = NULL; SetAppearance(xtpTabAppearancePropertyPage); m_bHotTracking = FALSE; m_bBoldNormal = m_bBoldSelected = FALSE; m_bShowIcons = TRUE; m_bSelectOnButtonDown = TRUE; m_bDisableLunaColors = FALSE; m_bOneNoteColors = FALSE; m_tabPosition = xtpTabPositionTop; m_tabLayout = xtpTabLayoutAutoSize; m_clientFrame = xtpTabFrameBorder; m_bStaticFrame = FALSE; m_bInvertGradient = FALSE; m_bFillBackground = TRUE; m_bDrawFocusRect = TRUE; m_rcClientMargin.SetRect(0, 0, 0, 0); m_rcControlMargin.SetRect(0, 0, 0, 0); m_rcButtonMargin.SetRect(0, 0, 0, 0); m_nButtonExtraLength = 0; m_szIcon = CSize(16, 16); m_nFixedTabWidth = 70; m_nMinTabWidth = m_nMaxTabWidth = 0; m_bDrawTextEndEllipsis = TRUE; m_bDrawTextPathEllipsis = FALSE; m_bDrawTextNoPrefix = TRUE; m_bDrawTextHidePrefix = FALSE; m_bMultiRowFixedSelection = FALSE; m_bMultiRowJustified = TRUE; m_toolBehaviour = xtpTabToolTipShrinkedOnly; m_bSelectOnDragOver = 2; m_nItemColor = 0; m_bClearTypeTextQuality = FALSE; m_bRotateImageOnVerticalDraw = FALSE; m_rcButtonTextPadding.SetRect(6, 0, 6, 0); m_bClipHeader = TRUE; m_nDrawTextFormat = DT_LEFT | DT_VCENTER; m_szNavigateButton = CSize(14, 15); m_bShowTabs = TRUE; EnableAutomation(); RefreshMetrics(); }