Index: scripts/npc/npcs_special.cpp =================================================================== --- scripts/npc/npcs_special.cpp (revision 679) +++ scripts/npc/npcs_special.cpp (working copy) @@ -825,6 +825,92 @@ return true; } +/*###### +## npc_bell +######*/ + +struct MANGOS_DLL_DECL npc_bellAI : public ScriptedAI +{ + npc_bellAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 delay; + uint32 dt; + uint32 min; + uint32 sound; + uint32 soundt; + + int n; + int count; + int hour; + int minute; + int second; + +void Reset() +{ + switch (m_creature->GetAreaId()) + { + case 1519: sound = 6594;dt = 2000;break; //BellTollAlliance +/* case : sound = 6595;break; //BellTollHorde + case : sound = 6674;break; //BellTollNightElf + case : sound = 6675;break; //BellTollTribal + case : sound = 7234;break; //BellTollDwarfGnome + case : sound = 9154;dt = 8000;break; //BellTollKharazhan +*/ + } + count = 0; + reset(); +} + +void reset() +{ + min = 45000; + GetTime(); + n = hour + 1; + if (n > 12) n -= 12; + delay = 1000*(3600 - ((60*minute+second) + (dt/1000)*(n+1))); + if (delay < dt*(n+1)) n = (60-second)/2; +} + +void GetTime() +{ + SYSTEMTIME time; + GetLocalTime( &time ); + hour = time.wHour; + if (hour > 12) hour -= 12; + minute = time.wMinute; + second = time.wSecond; +} + +void Aggro(Unit *who) {} + +void UpdateAI(const uint32 diff) +{ +// if ( sec < diff) +// { + if (count > 0) + { + delay = 3600000; + if (soundt < diff) + {DoPlaySoundToSet(m_creature,sound); + count -= 1;soundt = dt;} + else soundt -= diff; + } else { + if (min < diff) reset(); + else min -= diff; + if (delay < diff) count = n; + else delay -= diff; + } +// sec = 1000; +// } +// else sec -= diff; +} +}; + +CreatureAI* GetAI_npc_bell(Creature *_creature) +{ + return new npc_bellAI(_creature); +} + void AddSC_npcs_special() { Script *newscript; @@ -875,4 +961,10 @@ newscript->pGossipHello = &GossipHello_npc_sayge; newscript->pGossipSelect = &GossipSelect_npc_sayge; m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_bell"; + newscript->GetAI = GetAI_npc_bell; + m_scripts[nrscripts++] = newscript; } +