diff options
author | maximius <none@none> | 2009-10-27 22:58:35 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-27 22:58:35 -0700 |
commit | b243cf3228ddbbd15fe2bb8f5434bd45ce7c303e (patch) | |
tree | 931be496e21df4098f3e2fd296db9d4fe197a12c /src | |
parent | d2fe03dda7e12c11048a58163b934e860f2c6e46 (diff) |
*Hallow's End Innkeeper, by WarHead
*Some Confused Movement Generator fixes, thanks Proofzor
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/include/precompiled.h | 1 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/world/npc_innkeeper.cpp | 134 | ||||
-rw-r--r-- | src/bindings/scripts/system/ScriptLoader.cpp | 2 | ||||
-rw-r--r-- | src/game/ConfusedMovementGenerator.cpp | 21 |
4 files changed, 74 insertions, 84 deletions
diff --git a/src/bindings/scripts/include/precompiled.h b/src/bindings/scripts/include/precompiled.h index 3f5bc7e7265..c533aade45f 100644 --- a/src/bindings/scripts/include/precompiled.h +++ b/src/bindings/scripts/include/precompiled.h @@ -8,6 +8,7 @@ #include "../ScriptMgr.h" #include "Cell.h" #include "CellImpl.h" +#include "GameEventMgr.cpp" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "Unit.h" diff --git a/src/bindings/scripts/scripts/world/npc_innkeeper.cpp b/src/bindings/scripts/scripts/world/npc_innkeeper.cpp index da124eeb720..43ba02b79df 100644 --- a/src/bindings/scripts/scripts/world/npc_innkeeper.cpp +++ b/src/bindings/scripts/scripts/world/npc_innkeeper.cpp @@ -1,4 +1,6 @@ -/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> +/* + * Copyright (C) 2008 - 2009 Trinity <http://www.trinitycore.org/> + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -16,8 +18,9 @@ /* ScriptData SDName: Npc_Innkeeper -SD%Complete: 50 -SDComment: This script are currently not in use. EventSystem cannot be used on Windows build of SD2 +SDAuthor: WarHead +SD%Complete: 99% - SendBindPoint(pCreature); needs question if you really want to bind before the real bind is done (don't know how atm) +SDComment: Complete SDCategory: NPCs EndScriptData */ @@ -32,48 +35,39 @@ EndScriptData */ #define LOCALE_TRICK_OR_TREAT_3 "Süßes oder Saures!" #define LOCALE_TRICK_OR_TREAT_6 "¡Truco o trato!" -bool isEventActive() +#define LOCALE_INNKEEPER_0 "Make this inn my home." +#define LOCALE_INNKEEPER_3 "Ich möchte dieses Gasthaus zu meinem Heimatort machen." + +bool GossipHello_npc_innkeeper(Player *pPlayer, Creature *pCreature) { - /* - const GameEvent::ActiveEvents *ActiveEventsList = gameeventmgr.GetActiveEventList(); - GameEvent::ActiveEvents::const_iterator itr; - for (itr = ActiveEventsList->begin(); itr != ActiveEventsList->end(); ++itr) - { - if (*itr==HALLOWEEN_EVENTID) - { - return true; - } - }*/ - return false; -} + if (gameeventmgr.IsActiveEvent(HALLOWEEN_EVENTID) && !pPlayer->HasAura(SPELL_TRICK_OR_TREATED)) + { + char* localizedEntry; + switch (pPlayer->GetSession()->GetSessionDbcLocale()) + { + case LOCALE_frFR: localizedEntry = LOCALE_TRICK_OR_TREAT_2; break; + case LOCALE_deDE: localizedEntry = LOCALE_TRICK_OR_TREAT_3; break; + case LOCALE_esES: localizedEntry = LOCALE_TRICK_OR_TREAT_6; break; + case LOCALE_enUS: default: localizedEntry = LOCALE_TRICK_OR_TREAT_0; + } + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, localizedEntry, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID); + } -bool GossipHello_npc_innkeeper(Player* pPlayer, Creature* pCreature) -{ if (pCreature->isQuestGiver()) pPlayer->PrepareQuestMenu(pCreature->GetGUID()); - if (isEventActive()&& !pPlayer->GetAura(SPELL_TRICK_OR_TREATED, pPlayer->GetGUID())) + if (pCreature->isVendor()) + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + + if (pCreature->isInnkeeper()) { char* localizedEntry; - switch (pPlayer->GetSession()->GetSessionDbLocaleIndex()) + switch (pPlayer->GetSession()->GetSessionDbcLocale()) { - case 0: - localizedEntry=LOCALE_TRICK_OR_TREAT_0; - break; - case 2: - localizedEntry=LOCALE_TRICK_OR_TREAT_2; - break; - case 3: - localizedEntry=LOCALE_TRICK_OR_TREAT_3; - break; - case 6: - localizedEntry=LOCALE_TRICK_OR_TREAT_6; - break; - default: - localizedEntry=LOCALE_TRICK_OR_TREAT_0; + case LOCALE_deDE: localizedEntry = LOCALE_INNKEEPER_3; break; + case LOCALE_enUS: default: localizedEntry = LOCALE_INNKEEPER_0; } - - pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, localizedEntry, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID); + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, localizedEntry, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INN); } pPlayer->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID()); @@ -83,54 +77,46 @@ bool GossipHello_npc_innkeeper(Player* pPlayer, Creature* pCreature) bool GossipSelect_npc_innkeeper(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction) { - if (uiAction == GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID && isEventActive() && !pPlayer->GetAura(SPELL_TRICK_OR_TREATED, pPlayer->GetGUID())) + if (uiAction == GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID && gameeventmgr.IsActiveEvent(HALLOWEEN_EVENTID) && !pPlayer->HasAura(SPELL_TRICK_OR_TREATED)) { - pPlayer->CLOSE_GOSSIP_MENU(); pPlayer->CastSpell(pPlayer, SPELL_TRICK_OR_TREATED, true); - - // either trick or treat, 50% chance - if (rand()%2) - { + + if (urand(0, 1)) pPlayer->CastSpell(pPlayer, SPELL_TREAT, true); - } else { - int32 trickspell=0; - switch (rand()%9) // note that female characters can get male costumes and vice versa + uint32 trickspell = 0; + switch (urand(0, 13)) { - case 0: - trickspell=24753; // cannot cast, random 30sec - break; - case 1: - trickspell=24713; // lepper gnome costume - break; - case 2: - trickspell=24735; // male ghost costume - break; - case 3: - trickspell=24736; // female ghostcostume - break; - case 4: - trickspell=24710; // male ninja costume - break; - case 5: - trickspell=24711; // female ninja costume - break; - case 6: - trickspell=24708; // male pirate costume - break; - case 7: - trickspell=24709; // female pirate costume - break; - case 8: - trickspell=24723; // skeleton costume - break; + case 0: trickspell = 24753; break; // cannot cast, random 30sec + case 1: trickspell = 24713; break; // lepper gnome costume + case 2: trickspell = 24735; break; // male ghost costume + case 3: trickspell = 24736; break; // female ghostcostume + case 4: trickspell = 24710; break; // male ninja costume + case 5: trickspell = 24711; break; // female ninja costume + case 6: trickspell = 24708; break; // male pirate costume + case 7: trickspell = 24709; break; // female pirate costume + case 8: trickspell = 24723; break; // skeleton costume + case 9: trickspell = 24753; break; // Trick + case 10: trickspell = 24924; break; // Hallow's End Candy + case 11: trickspell = 24925; break; // Hallow's End Candy + case 12: trickspell = 24926; break; // Hallow's End Candy + case 13: trickspell = 24927; break; // Hallow's End Candy } pPlayer->CastSpell(pPlayer, trickspell, true); } - return true; // prevent Trinity core handling + pPlayer->CLOSE_GOSSIP_MENU(); + return true; } - return false; // the player didn't select "trick or treat" or cheated, normal core handling + + pPlayer->CLOSE_GOSSIP_MENU(); + + switch (uiAction) + { + case GOSSIP_ACTION_TRADE: pPlayer->SEND_VENDORLIST(pCreature->GetGUID()); break; + case GOSSIP_ACTION_INN: pPlayer->GetSession()->SendBindPoint(pCreature); break; + } + return true; } void AddSC_npc_innkeeper() diff --git a/src/bindings/scripts/system/ScriptLoader.cpp b/src/bindings/scripts/system/ScriptLoader.cpp index cd3e1d8dc80..02ee9cdf5bc 100644 --- a/src/bindings/scripts/system/ScriptLoader.cpp +++ b/src/bindings/scripts/system/ScriptLoader.cpp @@ -22,6 +22,7 @@ extern void AddSC_go_scripts(); extern void AddSC_guards(); extern void AddSC_item_scripts(); extern void AddSC_npc_professions(); +extern void AddSC_npc_innkeeper(); extern void AddSC_npcs_special(); extern void AddSC_npc_taxi(); @@ -465,6 +466,7 @@ void AddScripts() AddSC_guards(); AddSC_item_scripts(); AddSC_npc_professions(); + AddSC_npc_innkeeper(); AddSC_npcs_special(); AddSC_npc_taxi(); diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp index 24308dd6c36..9d07d0986ef 100644 --- a/src/game/ConfusedMovementGenerator.cpp +++ b/src/game/ConfusedMovementGenerator.cpp @@ -34,7 +34,7 @@ template<class T> void ConfusedMovementGenerator<T>::Initialize(T &unit) { - const float wander_distance=11; + const float wander_distance = 11; float x,y,z; x = unit.GetPositionX(); y = unit.GetPositionY(); @@ -49,21 +49,22 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) VMAP::IVMapManager *vMaps = VMAP::VMapFactory::createOrGetVMapManager(); - for (unsigned int idx=0; idx < MAX_CONF_WAYPOINTS+1; ++idx) + for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx) { - const float wanderX=wander_distance*rand_norm() - wander_distance/2; - const float wanderY=wander_distance*rand_norm() - wander_distance/2; - const bool isInLoS = vMaps->isInLineOfSight(unit.GetMapId(), x, y, z + 2.0f, i_waypoints[idx][0], i_waypoints[idx][1], z + 2.0f); - if (!isInLoS) + if (isInLoS) + { + const float wanderX = wander_distance*rand_norm() - wander_distance/2; + const float wanderY = wander_distance*rand_norm() - wander_distance/2; + i_waypoints[idx][0] = x + wanderX; + i_waypoints[idx][1] = y + wanderY; + } + else { i_waypoints[idx][0] = x; i_waypoints[idx][1] = y; } - i_waypoints[idx][0] = x + wanderX; - i_waypoints[idx][1] = y + wanderY; - // prevent invalid coordinates generation Trinity::NormalizeMapCoord(i_waypoints[idx][0]); Trinity::NormalizeMapCoord(i_waypoints[idx][1]); @@ -77,7 +78,7 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) } unit.UpdateGroundPositionZ(i_waypoints[idx][0],i_waypoints[idx][1],z); - i_waypoints[idx][2] = z; + i_waypoints[idx][2] = z; } unit.SetUInt64Value(UNIT_FIELD_TARGET, 0); |