--HG--
branch : trunk
This commit is contained in:
QAston
2009-07-18 23:41:42 +02:00
15 changed files with 264 additions and 21 deletions
+1
View File
@@ -0,0 +1 @@
UPDATE `creature_template` SET `ScriptName`='mob_mojo' WHERE `entry`='24480';
+14
View File
@@ -0,0 +1,14 @@
-- ----------------------------
-- Table structure for channels
-- ----------------------------
DROP TABLE IF EXISTS `channels`;
CREATE TABLE `channels` (
`m_name` text NOT NULL,
`m_team` int(10) unsigned NOT NULL,
`m_ownerGUID` int(11) unsigned NOT NULL default '0',
`m_announce` tinyint(1) unsigned NOT NULL default '0',
`m_moderate` tinyint(1) unsigned NOT NULL default '0',
`m_password` text,
`BannedList` longtext,
PRIMARY KEY (`m_name`(10),`m_team`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Access Requirements';
@@ -1566,6 +1566,76 @@ CreatureAI* GetAI_npc_snake_trap_serpents(Creature *_Creature)
return new npc_snake_trap_serpentsAI(_Creature);
}
struct TRINITY_DLL_DECL mob_mojoAI : public ScriptedAI
{
mob_mojoAI(Creature *c) : ScriptedAI(c) {Reset();}
uint32 hearts;
uint64 victimGUID;
void Reset()
{
victimGUID = 0;
hearts = 15000;
Unit* own = m_creature->GetOwner();
if (own)
m_creature->GetMotionMaster()->MoveFollow(own,0,0);
}
void Aggro(Unit *who){}
void UpdateAI(const uint32 diff)
{
if(m_creature->HasAura(20372,0))
{
if(hearts<diff)
{
m_creature->RemoveAurasDueToSpell(20372);
hearts = 15000;
}hearts-=diff;
}
}
void ReceiveEmote(Player *player, uint32 emote)
{
m_creature->HandleEmoteCommand(emote);
Unit* own = m_creature->GetOwner();
if (own && ((Player*)own)->GetTeam() != player->GetTeam())
return;
if (emote == TEXTEMOTE_KISS)
{
std::string whisp = "";
switch (rand()%8)
{
case 0:whisp.append("Now that's what I call froggy-style!");break;
case 1:whisp.append("Your lily pad or mine?");break;
case 2:whisp.append("This won't take long, did it?");break;
case 3:whisp.append("I thought you'd never ask!");break;
case 4:whisp.append("I promise not to give you warts...");break;
case 5:whisp.append("Feelin' a little froggy, are ya?");break;
case 6:
whisp.append("Listen, ");
whisp.append(player->GetName());
whisp.append(", I know of a little swamp not too far from here....");
break;
case 7:whisp.append("There's just never enough Mojo to go around...");break;
}
m_creature->MonsterWhisper(whisp.c_str(),player->GetGUID());
if(victimGUID)
{
Player* victim = Unit::GetPlayer(victimGUID);
if(victim)
victim->RemoveAura(43906);//remove polymorph frog thing
}
m_creature->AddAura(43906,player);//add polymorph frog thing
victimGUID = player->GetGUID();
m_creature->CastSpell(m_creature,20372,true);//tag.hearts
m_creature->GetMotionMaster()->MoveFollow(player,0,0);
hearts = 15000;
}
}
};
CreatureAI* GetAI_mob_mojo(Creature *_Creature)
{
return new mob_mojoAI (_Creature);
}
void AddSC_npcs_special()
{
Script *newscript;
@@ -1656,5 +1726,10 @@ void AddSC_npcs_special()
newscript->Name="npc_snake_trap_serpents";
newscript->GetAI = &GetAI_npc_snake_trap_serpents;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name="mob_mojo";
newscript->GetAI = &GetAI_mob_mojo;
newscript->RegisterSelf();
}
@@ -58,8 +58,10 @@ struct TRINITY_DLL_DECL molten_flameAI : public NullCreatureAI
void InitializeAI()
{
float x, y, z;
me->GetNearPoint(me, x, y, z, 1, 50, M_PI*2*rand_norm());
me->GetNearPoint(me, x, y, z, 1, 100, M_PI*2*rand_norm());
me->GetMotionMaster()->MovePoint(0, x, y, z);
me->SetVisibility(VISIBILITY_OFF);
me->CastSpell(me,SPELL_MOLTEN_FLAME,true);
}
};
@@ -205,7 +207,8 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI
if(!target) target = m_creature->getVictim();
if(target)
{
DoCast(target, SPELL_VOLCANIC_SUMMON);
//DoCast(target, SPELL_VOLCANIC_SUMMON);//movement bugged
m_creature->SummonCreature(CREATURE_VOLCANO,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN,30000);
DoScriptText(EMOTE_GROUND_CRACK, m_creature);
events.DelayEvents(1500, GCD_CAST);
}
@@ -222,17 +225,19 @@ struct TRINITY_DLL_DECL boss_supremusAI : public ScriptedAI
}
};
struct TRINITY_DLL_DECL npc_volcanoAI : public ScriptedAI
struct TRINITY_DLL_DECL npc_volcanoAI : public Scripted_NoMovementAI
{
npc_volcanoAI(Creature *c) : ScriptedAI(c) {}
npc_volcanoAI(Creature *c) : Scripted_NoMovementAI(c) {}
void Reset()
{
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
DoCast(m_creature, SPELL_VOLCANIC_ERUPTION);
//DoCast(m_creature, SPELL_VOLCANIC_ERUPTION);
me->SetReactState(REACT_PASSIVE);
wait = 3000;
}
uint32 wait;
void EnterCombat(Unit *who) {}
@@ -243,7 +248,15 @@ struct TRINITY_DLL_DECL npc_volcanoAI : public ScriptedAI
m_creature->RemoveAura(SPELL_VOLCANIC_ERUPTION);
}
void UpdateAI(const uint32 diff) {}
void UpdateAI(const uint32 diff)
{
if(wait<=diff)//wait 3secs before casting
{
DoCast(m_creature, SPELL_VOLCANIC_ERUPTION);
wait = 60000;
}
else wait -= diff;
}
};
@@ -56,7 +56,7 @@ EndScriptData */
#define SPELL_ENRAGE 27680 //this spell need verification
#define SPELL_SUMMON_WATER_ELEMENT 36459 //not in use yet(in use ever?)
#define SPELL_ELEMENTAL_SPAWNIN 25035
#define SPELL_BLUE_BEAM /*40227*/40227 //channeled Hydross Beam Helper (not in use yet)
#define SPELL_BLUE_BEAM 40227 //channeled Hydross Beam Helper (not in use yet)
#define ENTRY_PURE_SPAWN 22035
#define ENTRY_TAINTED_SPAWN 22036
@@ -324,7 +324,7 @@ struct TRINITY_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI
//WaterTomb_Timer
if (WaterTomb_Timer < diff)
{
Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0);
Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
if (target)
DoCast(target, SPELL_WATER_TOMB);
@@ -365,7 +365,7 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
//Static Charge
//Used on random people (only 1 person at any given time) in Phases 1 and 3, it's a debuff doing 2775 to 3225 Nature damage to the target and everybody in about 5 yards around it, every 1 seconds for 30 seconds. It can be removed by Cloak of Shadows, Iceblock, Divine Shield, etc, but not by Cleanse or Dispel Magic.
Unit *target = NULL;
target = SelectUnit(SELECT_TARGET_RANDOM, 0);
target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200, true);
if(target && !target->HasAura(SPELL_STATIC_CHARGE_TRIGGER))
//cast Static Charge every 2 seconds for 20 seconds
@@ -111,10 +111,19 @@ struct TRINITY_DLL_DECL mob_inner_demonAI : public ScriptedAI
if (m_creature->getVictim()->GetGUID() != victimGUID)
{
DoModifyThreatPercent(m_creature->getVictim(), -100);
Unit* owner = Unit::GetUnit((*m_creature),victimGUID);
if (owner)
AttackStart(owner);
if (owner && owner->isAlive())
{
m_creature->AddThreat(owner,999999);
AttackStart(owner);
}else if(owner && owner->isDead())
{
m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
return;
}
}
if(Link_Timer < diff)
{
DoCast(m_creature->getVictim(), SPELL_SOUL_LINK, true);
@@ -433,6 +442,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
//Enrage_Timer ( 10 min )
if(Berserk_Timer < diff && !EnrageUsed)
{
m_creature->InterruptNonMeleeSpells(false);
DoCast(m_creature, SPELL_BERSERK);
EnrageUsed = true;
}else Berserk_Timer -= diff;
@@ -550,6 +560,8 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
if (!IsFinalForm && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 15)
{
//at this point he divides himself in two parts
CastConsumingMadness();
DespawnDemon();
Creature *Copy = NULL;
Copy = DoSpawnCreature(DEMON_FORM, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 6000);
if(Copy)
@@ -128,7 +128,7 @@ struct TRINITY_DLL_DECL boss_void_reaverAI : public ScriptedAI
target = *(target_list.begin()+rand()%target_list.size());
if (target)
m_creature->CastSpell(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), SPELL_ARCANE_ORB, false);
m_creature->CastSpell(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), SPELL_ARCANE_ORB, false, NULL, NULL, NULL, target);
ArcaneOrb_Timer = 3000;
}else ArcaneOrb_Timer -= diff;
+123 -3
View File
@@ -23,9 +23,10 @@
#include "SocialMgr.h"
#include "World.h"
Channel::Channel(const std::string& name, uint32 channel_id)
: m_announce(true), m_moderate(false), m_name(name), m_flags(0), m_channelId(channel_id), m_ownerGUID(0)
Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team)
: m_name(name), m_announce(true), m_moderate(false), m_channelId(channel_id), m_ownerGUID(0), m_password(""), m_flags(0)
{
m_Team = Team;
// set special flags if built-in channel
ChatChannelsEntry const* ch = GetChannelEntryFor(channel_id);
if(ch) // it's built-in channel
@@ -45,10 +46,54 @@ Channel::Channel(const std::string& name, uint32 channel_id)
m_flags |= CHANNEL_FLAG_LFG;
else // for all other channels
m_flags |= CHANNEL_FLAG_NOT_LFG;
m_IsSaved = false;
}
else // it's custom channel
{
m_flags |= CHANNEL_FLAG_CUSTOM;
//load not built in channel if saved
QueryResult *result = CharacterDatabase.PQuery("SELECT m_name, m_team, m_ownerGUID, m_announce, m_moderate, m_password, BannedList FROM channels WHERE m_name = '%s' AND m_team = '%u'", name.c_str(), m_Team);
if (result)//load
{
Field *fields = result->Fetch();
const char* db_name = fields[0].GetString();
uint32 db_team = fields[1].GetUInt32();
uint64 db_owner = fields[2].GetUInt64();
bool db_announce = fields[3].GetBool();
bool db_moderate = fields[4].GetBool();
const char* db_password = fields[5].GetString();
const char* db_BannedList = fields[6].GetString();
m_ownerGUID = db_owner;
m_announce = db_announce;
m_moderate = db_moderate;
m_password = db_password;
m_IsSaved = true;
if(db_BannedList)
{
Tokens tokens = StrSplit(db_BannedList, " ");
Tokens::iterator iter;
for (iter = tokens.begin();iter != tokens.end(); ++iter)
{
uint64 banned_guid = atol((*iter).c_str());
if(banned_guid)
{
sLog.outDebug("Channel(%s) loaded banned guid: %u",name.c_str(), banned_guid);
banned.insert(banned_guid);
}
}
}
}else{//save
std::ostringstream ss;
ss << "INSERT INTO channels (m_name,m_team,m_ownerGUID,m_announce,m_moderate,m_password) VALUES ('"
<< name.c_str() << "','" << m_Team << "','0','1','0','')";
if(CharacterDatabase.PExecuteLog( ss.str( ).c_str( ) ))
{
sLog.outDebug("New Channel(%s) saved", name.c_str());
m_IsSaved = true;
}
}
}
}
@@ -118,6 +163,10 @@ void Channel::Join(uint64 p, const char *pass)
// if no owner first logged will become
if(!IsConstant() && !m_ownerGUID)
{
SetOwner(p, (players.size() > 1 ? true : false));
players[p].SetModerator(true);
}else if(!IsConstant() && m_ownerGUID && plr && m_ownerGUID == plr->GetGUID())
{
SetOwner(p, (players.size() > 1 ? true : false));
players[p].SetModerator(true);
@@ -161,7 +210,7 @@ void Channel::Leave(uint64 p, bool send)
LeaveNotify(p);
if(changeowner)
if(changeowner && !m_IsSaved)
{
uint64 newowner = !players.empty() ? players.begin()->second.player : 0;
SetOwner(newowner);
@@ -213,6 +262,23 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban)
{
banned.insert(bad->GetGUID());
MakePlayerBanned(&data, bad->GetGUID(), good);
//save banlist
if(m_IsSaved)
{
std::ostringstream banlist;
BannedList::iterator iter;
for (iter = banned.begin();iter != banned.end(); ++iter)
{
banlist << (*iter) << " ";
}
std::ostringstream ss;
ss << "UPDATE channels SET BannedList = '" << banlist.str().c_str() << "' WHERE m_name = '"<<m_name.c_str()<<"' AND m_team = '"<<m_Team<<"'";
if(CharacterDatabase.PExecuteLog( ss.str( ).c_str( ) ))
{
sLog.outDebug("Channel(%s) BannedList saved", m_name.c_str());
}
}
}
else
MakePlayerKicked(&data, bad->GetGUID(), good);
@@ -265,6 +331,22 @@ void Channel::UnBan(uint64 good, const char *badname)
WorldPacket data;
MakePlayerUnbanned(&data, bad->GetGUID(), good);
SendToAll(&data);
//save banlist
if(m_IsSaved)
{
std::ostringstream banlist;
BannedList::iterator iter;
for (iter = banned.begin();iter != banned.end(); ++iter)
{
banlist << (*iter) << " ";
}
std::ostringstream ss;
ss << "UPDATE channels SET BannedList = '" << banlist.str().c_str() << "' WHERE m_name = '"<<m_name.c_str()<<"' AND m_team = '"<<m_Team<<"'";
if(CharacterDatabase.PExecuteLog( ss.str( ).c_str( ) ))
{
sLog.outDebug("Channel(%s) BannedList saved", m_name.c_str());
}
}
}
}
}
@@ -295,6 +377,15 @@ void Channel::Password(uint64 p, const char *pass)
WorldPacket data;
MakePasswordChanged(&data, p);
SendToAll(&data);
if(m_IsSaved)
{
std::ostringstream ss;
ss << "UPDATE channels SET m_password = '" << pass << "' WHERE m_name = '"<<m_name.c_str()<<"' AND m_team = '"<<m_Team<<"'";
if(CharacterDatabase.PExecuteLog( ss.str( ).c_str( ) ))
{
sLog.outDebug("Channel(%s) password saved", m_name.c_str());
}
}
}
}
@@ -500,6 +591,16 @@ void Channel::Announce(uint64 p)
else
MakeAnnouncementsOff(&data, p);
SendToAll(&data);
if(m_IsSaved)
{
std::ostringstream ss;
ss << "UPDATE channels SET m_announce = '" << m_announce << "' WHERE m_name = '"<<m_name.c_str()<<"' AND m_team = '"<<m_Team<<"'";
if(CharacterDatabase.PExecuteLog( ss.str( ).c_str( ) ))
{
sLog.outDebug("Channel(%s) announce saved", m_name.c_str());
}
}
}
}
@@ -532,6 +633,15 @@ void Channel::Moderate(uint64 p)
else
MakeModerationOff(&data, p);
SendToAll(&data);
if(m_IsSaved)
{
std::ostringstream ss;
ss << "UPDATE channels SET m_moderate = '" << m_moderate << "' WHERE m_name = '"<<m_name.c_str()<<"' AND m_team = '"<<m_Team<<"'";
if(CharacterDatabase.PExecuteLog( ss.str( ).c_str( ) ))
{
sLog.outDebug("Channel(%s) moderate saved", m_name.c_str());
}
}
}
}
@@ -659,6 +769,16 @@ void Channel::SetOwner(uint64 guid, bool exclaim)
MakeOwnerChanged(&data, m_ownerGUID);
SendToAll(&data);
}
if(m_IsSaved)
{
std::ostringstream ss;
ss << "UPDATE channels SET m_ownerGUID = '" << guid << "' WHERE m_name = '"<<m_name.c_str()<<"' AND m_team = '"<<m_Team<<"'";
if(CharacterDatabase.PExecuteLog( ss.str( ).c_str( ) ))
{
sLog.outDebug("Channel(%s) owner saved", m_name.c_str());
}
}
}
}
+3 -1
View File
@@ -158,6 +158,7 @@ class Channel
uint8 m_flags;
uint32 m_channelId;
uint64 m_ownerGUID;
bool m_IsSaved;
private:
// initial packet data (notify type and channel name)
@@ -243,7 +244,8 @@ class Channel
}
public:
Channel(const std::string& name, uint32 channel_id);
uint32 m_Team;
Channel(const std::string& name, uint32 channel_id, uint32 Team = 0);
std::string GetName() const { return m_name; }
uint32 GetChannelId() const { return m_channelId; }
bool IsConstant() const { return m_channelId != 0; }
+3
View File
@@ -48,8 +48,11 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
recvPacket >> pass;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
{
cMgr->team = _player->GetTeam();
if(Channel *chn = cMgr->GetJoinChannel(channelname, channel_id))
chn->Join(_player->GetGUID(), pass.c_str());
}
}
void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket)
+3 -2
View File
@@ -31,8 +31,9 @@
class ChannelMgr
{
public:
uint32 team;
typedef std::map<std::string,Channel *> ChannelMap;
ChannelMgr() {}
ChannelMgr() {team = 0;}
~ChannelMgr()
{
for(ChannelMap::const_iterator itr = channels.begin();itr!=channels.end(); ++itr)
@@ -43,7 +44,7 @@ class ChannelMgr
{
if (channels.find(name) == channels.end())
{
Channel *nchan = new Channel(name,channel_id);
Channel *nchan = new Channel(name,channel_id, team);
channels[name] = nchan;
}
return channels[name];
+1 -1
View File
@@ -255,7 +255,7 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
if(incremental)
{
// int32 *= float cause one point loss?
standing = floor((float)standing * sWorld.getRate(RATE_REPUTATION_GAIN) + 0.5f);
standing = (int32)((float)standing * sWorld.getRate(RATE_REPUTATION_GAIN) + 0.5f);
standing += itr->second.Standing + BaseRep;
}
+3 -1
View File
@@ -1183,7 +1183,7 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit*
}
// used for scripting
void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster)
void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster, Unit* OriginalVictim)
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );
@@ -1203,6 +1203,8 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered,
SpellCastTargets targets;
targets.setDestination(x, y, z);
if(OriginalVictim)
targets.setUnitTarget(OriginalVictim);
spell->m_CastItem = castItem;
spell->prepare(&targets, triggeredByAura);
}
+1 -1
View File
@@ -1306,7 +1306,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage);
void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
void CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0, Unit* originalVictim = 0);
void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* Victim = NULL, bool triggered = true, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim = NULL, bool triggered = true, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);