Changeset 109 for trunk/src/bindings/scripts/include/sc_creature.cpp
- Timestamp:
- 11/19/08 13:36:49 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bindings/scripts/include/sc_creature.cpp
r106 r109 12 12 // Spell summary for ScriptedAI::SelectSpell 13 13 struct TSpellSummary { 14 uint8 Targets; // set of enum SelectTarget15 uint8 Effects; // set of enum SelectEffect14 uint8 Targets; // set of enum SelectTarget 15 uint8 Effects; // set of enum SelectEffect 16 16 } *SpellSummary; 17 17 … … 26 26 void ScriptedAI::MoveInLineOfSight(Unit *who) 27 27 { 28 if ( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature))28 if (!m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature)) 29 29 { 30 30 if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) … … 32 32 33 33 float attackRadius = m_creature->GetAttackDistance(who); 34 if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) 35 { 36 DoStartAttackAndMovement(who); 34 if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) 35 { 37 36 who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 38 39 if (!InCombat) 40 { 41 InCombat = true; 42 Aggro(who); 43 } 44 } 45 } 46 } 47 48 void ScriptedAI::AttackStart(Unit* who) 37 AttackStart(who); 38 } 39 } 40 } 41 42 void ScriptedAI::AttackStart(Unit* who, bool melee) 49 43 { 50 44 if (!who) 51 45 return; 52 46 53 if (who->isTargetableForAttack()) 54 { 55 //Begin attack 56 DoStartAttackAndMovement(who); 47 if (m_creature->Attack(who, melee)) 48 { 49 m_creature->AddThreat(who, 0.0f); 50 m_creature->SetInCombatWith(who); 51 who->SetInCombatWith(m_creature); 57 52 58 53 if (!InCombat) … … 61 56 Aggro(who); 62 57 } 58 59 if(melee) 60 DoStartMovement(who); 61 else 62 DoStartNoMovement(who); 63 } 64 } 65 66 void ScriptedAI::AttackStart(Unit* who) 67 { 68 if (!who) 69 return; 70 71 if (m_creature->Attack(who, true)) 72 { 73 m_creature->AddThreat(who, 0.0f); 74 m_creature->SetInCombatWith(who); 75 who->SetInCombatWith(m_creature); 76 77 if (!InCombat) 78 { 79 InCombat = true; 80 Aggro(who); 81 } 82 83 DoStartMovement(who); 63 84 } 64 85 } … … 67 88 { 68 89 //Check if we have a current target 69 if (m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim())70 { 71 if (m_creature->isAttackReady() )90 if (m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim()) 91 { 92 if (m_creature->isAttackReady() ) 72 93 { 73 94 //If we are within range melee the target 74 if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))95 if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) 75 96 { 76 97 m_creature->AttackerStateUpdate(m_creature->getVictim()); … … 89 110 m_creature->LoadCreaturesAddon(); 90 111 91 if ( m_creature->isAlive())112 if (m_creature->isAlive()) 92 113 m_creature->GetMotionMaster()->MoveTargetedHome(); 93 114 … … 104 125 } 105 126 106 void ScriptedAI::DoStart AttackAndMovement(Unit* victim, float distance, float angle)127 void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle) 107 128 { 108 129 if (!victim) 109 130 return; 110 131 111 if ( m_creature->Attack(victim, true) ) 112 { 113 m_creature->GetMotionMaster()->MoveChase(victim, distance, angle); 114 m_creature->AddThreat(victim, 0.0f); 115 } 116 } 117 118 void ScriptedAI::DoStartAttackNoMovement(Unit* victim) 132 m_creature->GetMotionMaster()->MoveChase(victim, distance, angle); 133 } 134 135 void ScriptedAI::DoStartNoMovement(Unit* victim) 119 136 { 120 137 if (!victim) 121 138 return; 122 139 123 if ( m_creature->Attack(victim, true) ) 124 { 125 m_creature->AddThreat(victim, 0.0f); 126 } 140 m_creature->GetMotionMaster()->MoveIdle(); 141 m_creature->StopMoving(); 127 142 } 128 143 … … 131 146 { 132 147 //Make sure our attack is ready and we aren't currently casting before checking distance 133 if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))148 if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) 134 149 { 135 150 //If we are within range melee the target 136 if ( m_creature->IsWithinCombatDist(m_creature->getVictim(), ATTACK_DISTANCE))151 if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) 137 152 { 138 153 m_creature->AttackerStateUpdate(m_creature->getVictim()); … … 144 159 void ScriptedAI::DoStopAttack() 145 160 { 146 if ( m_creature->getVictim() != NULL)161 if (m_creature->getVictim() != NULL) 147 162 { 148 163 m_creature->AttackStop(); … … 170 185 void ScriptedAI::DoSay(const char* text, uint32 language, Unit* target) 171 186 { 172 if (target) m_creature->Say(text, language, target->GetGUID());187 if (target) m_creature->Say(text, language, target->GetGUID()); 173 188 else m_creature->Say(text, language, 0); 174 189 } … … 176 191 void ScriptedAI::DoYell(const char* text, uint32 language, Unit* target) 177 192 { 178 if (target) m_creature->Yell(text, language, target->GetGUID());193 if (target) m_creature->Yell(text, language, target->GetGUID()); 179 194 else m_creature->Yell(text, language, 0); 180 195 } … … 182 197 void ScriptedAI::DoTextEmote(const char* text, Unit* target, bool IsBossEmote) 183 198 { 184 if (target) m_creature->TextEmote(text, target->GetGUID(), IsBossEmote);199 if (target) m_creature->TextEmote(text, target->GetGUID(), IsBossEmote); 185 200 else m_creature->TextEmote(text, 0, IsBossEmote); 186 201 } … … 205 220 } 206 221 207 unit->SendPlaySound(sound, false); 222 WorldPacket data(4); 223 data.SetOpcode(SMSG_PLAY_SOUND); 224 data << uint32(sound); 225 unit->SendMessageToSet(&data,false); 208 226 } 209 227 … … 462 480 { 463 481 error_log("SD2: DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); 482 464 483 return; 465 484 }*/ … … 580 599 if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) 581 600 { 582 DoStartAttackNoMovement(who);583 601 who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 584 585 if (!InCombat) 586 { 587 InCombat = true; 588 Aggro(who); 589 } 602 AttackStart(who); 590 603 } 591 604 } … … 597 610 return; 598 611 599 if (who->isTargetableForAttack()) 600 { 601 //Begin attack 602 DoStartAttackNoMovement(who); 612 if (m_creature->Attack(who, true)) 613 { 614 m_creature->AddThreat(who, 0.0f); 615 m_creature->SetInCombatWith(who); 616 who->SetInCombatWith(m_creature); 603 617 604 618 if (!InCombat) … … 607 621 Aggro(who); 608 622 } 609 } 610 } 623 624 DoStartNoMovement(who); 625 } 626 }