Show
Ignore:
Timestamp:
11/19/08 13:36:49 (17 years ago)
Author:
yumileroy
Message:

[svn] Update trinityscript to SD2 rev 700. Source: scriptdev2. Patch provided by SLG.

Original author: megamage
Date: 2008-10-25 11:40:10-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/bindings/scripts/include/sc_creature.cpp

    r106 r109  
    1212// Spell summary for ScriptedAI::SelectSpell 
    1313struct TSpellSummary { 
    14     uint8 Targets;    // set of enum SelectTarget 
    15     uint8 Effects;    // set of enum SelectEffect 
     14    uint8 Targets;                                          // set of enum SelectTarget 
     15    uint8 Effects;                                          // set of enum SelectEffect 
    1616} *SpellSummary; 
    1717 
     
    2626void ScriptedAI::MoveInLineOfSight(Unit *who) 
    2727{ 
    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)) 
    2929    { 
    3030        if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) 
     
    3232 
    3333        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        { 
    3736            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 
     42void ScriptedAI::AttackStart(Unit* who, bool melee) 
    4943{ 
    5044    if (!who) 
    5145        return; 
    5246 
    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); 
    5752 
    5853        if (!InCombat) 
     
    6156            Aggro(who); 
    6257        } 
     58 
     59        if(melee) 
     60            DoStartMovement(who); 
     61        else 
     62            DoStartNoMovement(who); 
     63    } 
     64} 
     65 
     66void 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); 
    6384    } 
    6485} 
     
    6788{ 
    6889    //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() ) 
    7293        { 
    7394            //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)) 
    7596            { 
    7697                m_creature->AttackerStateUpdate(m_creature->getVictim()); 
     
    89110    m_creature->LoadCreaturesAddon(); 
    90111 
    91     if( m_creature->isAlive() ) 
     112    if (m_creature->isAlive()) 
    92113        m_creature->GetMotionMaster()->MoveTargetedHome(); 
    93114 
     
    104125} 
    105126 
    106 void ScriptedAI::DoStartAttackAndMovement(Unit* victim, float distance, float angle) 
     127void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle) 
    107128{ 
    108129    if (!victim) 
    109130        return; 
    110131 
    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 
     135void ScriptedAI::DoStartNoMovement(Unit* victim) 
    119136{ 
    120137    if (!victim) 
    121138        return; 
    122139 
    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(); 
    127142} 
    128143 
     
    131146{ 
    132147    //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)) 
    134149    { 
    135150        //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)) 
    137152        { 
    138153            m_creature->AttackerStateUpdate(m_creature->getVictim()); 
     
    144159void ScriptedAI::DoStopAttack() 
    145160{ 
    146     if( m_creature->getVictim() != NULL ) 
     161    if (m_creature->getVictim() != NULL) 
    147162    { 
    148163        m_creature->AttackStop(); 
     
    170185void ScriptedAI::DoSay(const char* text, uint32 language, Unit* target) 
    171186{ 
    172     if (target)m_creature->Say(text, language, target->GetGUID()); 
     187    if (target) m_creature->Say(text, language, target->GetGUID()); 
    173188    else m_creature->Say(text, language, 0); 
    174189} 
     
    176191void ScriptedAI::DoYell(const char* text, uint32 language, Unit* target) 
    177192{ 
    178     if (target)m_creature->Yell(text, language, target->GetGUID()); 
     193    if (target) m_creature->Yell(text, language, target->GetGUID()); 
    179194    else m_creature->Yell(text, language, 0); 
    180195} 
     
    182197void ScriptedAI::DoTextEmote(const char* text, Unit* target, bool IsBossEmote) 
    183198{ 
    184     if (target)m_creature->TextEmote(text, target->GetGUID(), IsBossEmote); 
     199    if (target) m_creature->TextEmote(text, target->GetGUID(), IsBossEmote); 
    185200    else m_creature->TextEmote(text, 0, IsBossEmote); 
    186201} 
     
    205220    } 
    206221 
    207     unit->SendPlaySound(sound, false); 
     222    WorldPacket data(4); 
     223    data.SetOpcode(SMSG_PLAY_SOUND); 
     224    data << uint32(sound); 
     225    unit->SendMessageToSet(&data,false); 
    208226} 
    209227 
     
    462480    { 
    463481        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 
    464483        return; 
    465484    }*/ 
     
    580599        if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) 
    581600        { 
    582             DoStartAttackNoMovement(who); 
    583601            who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 
    584  
    585             if (!InCombat) 
    586             { 
    587                 InCombat = true; 
    588                 Aggro(who); 
    589             } 
     602            AttackStart(who); 
    590603        } 
    591604    } 
     
    597610        return; 
    598611 
    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); 
    603617 
    604618        if (!InCombat) 
     
    607621            Aggro(who); 
    608622        } 
    609     } 
    610 } 
     623 
     624        DoStartNoMovement(who); 
     625    } 
     626}