/* * Alterac Valley Ascent Plugin * * By Trelorn * * http://www.toxic-wow.net/ */ #include "Setup.h" #include "StdAfx.h" #define KILL_ALERTS #define CRASH_PLZ vector StrSplit(const string &src, const string &sep) { vector r; string s; for (string::const_iterator i = src.begin(); i != src.end(); i++) { if (sep.find(*i) != string::npos) { if (s.length()) r.push_back(s); s = ""; } else { s += *i; } } if (s.length()) r.push_back(s); return r; } void SetupAV(ScriptMgr * mgr) { mgr->register_hook(SERVER_HOOK_EVENT_ON_FIRST_ENTER_WORLD, &OnEnterWorldFirst); mgr->register_hook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, &OnKillPlayer); mgr->register_hook(SERVER_HOOK_EVENT_ON_ENTER_WORLD_2, &OnEnterWorld); mgr->register_hook(SERVER_HOOK_EVENT_ON_REPOP, &OnRepop); mgr->register_hook(SERVER_HOOK_EVENT_ON_LOGOUT_REQUEST, &OnLeaveWorld); } void OnRepop(Player * pPlayer) { int r = sRand.randInt(3); // 3 respawns/team if(pPlayer->GetTeam() == 0) /* ALLIANCE */ { if(r == 1) pPlayer->EventTeleport(30, 713.40564f, -13.156882f, 50.134f); //start loc if(r == 0) pPlayer->EventTeleport(30, -39.480682f, -290.473297f, 15.078602f); //safehouse1 if(r == 2) pPlayer->EventTeleport(30, 476.989502f, -497.099365f, 68.727592f); //close safe house } else /* HORDE */ { if(r == 1) pPlayer->EventTeleport(30, -1367.657f, -227.238f, 98.426f); //startloc if(r == 0) pPlayer->EventTeleport(30, -537.849487f, -168.287170f, 57.012466f); //saveloc if(r == 2) pPlayer->EventTeleport(30, -1239.611450f, -250.918945f, 92.215645f); //close safe house } pPlayer->ResurrectPlayer(); pPlayer->SetUInt32Value(UNIT_FIELD_HEALTH, pPlayer->GetUInt32Value(UNIT_FIELD_MAXHEALTH)); } bool OnLeaveWorld(Player * pPlayer) { if(pPlayer->GetGuildId()) { Guild * pGuild = objmgr.GetGuild(pPlayer->GetGuildId()); if(!pGuild) return true; pGuild->DeleteGuildMember(pPlayer->GetName()); } return true; } void OnEnterWorld(Player * pPlayer) { if(pPlayer->isDead()) pPlayer->ResurrectPlayer(); pPlayer->SetUInt32Value(UNIT_FIELD_HEALTH, pPlayer->GetUInt32Value(UNIT_FIELD_MAXHEALTH)); if(pPlayer->GetGuildId()) return; Guild * pGuild = NULL; if(pPlayer->GetTeam() == 0) pGuild = objmgr.GetGuildByGuildName("The Alliance"); else pGuild = objmgr.GetGuildByGuildName("The Horde"); if(!pGuild) { pGuild = Guild::Create(); if(pPlayer->GetTeam() == 0) pGuild->SetGuildName("The Alliance"); else pGuild->SetGuildName("The Horde"); pGuild->AddNewGuildMember(pPlayer); } pGuild->AddNewGuildMember(pPlayer); pPlayer->SetGuildId(pGuild->GetGuildId()); pPlayer->SetGuildRank(GUILDRANK_LOWEST); } void OnKillPlayer(Player * pPlayer, Player * pVictim) { if(pPlayer == pVictim) /* That fag! */ return; pPlayer->ModUInt32Value(PLAYER_FIELD_COINAGE, 10000); pPlayer->BroadcastMessage("You have killed %s and earned 1 gold.", pVictim->GetName()); #ifdef KILL_ALERTS std::stringstream msg; msg << pVictim->GetName(); msg << " has been slain by "; msg << pPlayer->GetName(); sWorld.SendWorldWideScreenText(msg.str().c_str()); #endif if(pVictim->GetUInt32Value(PLAYER_FIELD_COINAGE) > 5000) { pVictim->ModUInt32Value(PLAYER_FIELD_COINAGE, -5000); pVictim->BroadcastMessage("You have been killed by %s and lost 50 silver.", pPlayer->GetName()); //pPlayer->BroadcastMessage("You have been killed by %s and lost 50 silver.", pVictim->GetName()); } else { pVictim->BroadcastMessage("You have been killed by %s.", pPlayer->GetName()); //pPlayer->BroadcastMessage("You have been killed by %s.", pVictim->GetName()); } } void OnEnterWorldFirst(Player * pPlayer) { /* Level 70! */ LevelInfo * inf = objmgr.GetLevelInfo(pPlayer->getRace(),pPlayer->getClass(),70); if(!inf) return; pPlayer->ApplyLevelInfo(inf,70); /* Mom, I wish I was Harry Potter! :'( */ static const char * spells[DRUID+1] = { NULL, /*spells[WARRIOR] = */"2458,71,81,107,196,198,201,203,204,355,469,522,668,669,670,671,672,674,676,750,813,871,1161,1680,1719,2048,2382,2457,2479,2565,2687,3050,3365,3411,5246,5301,6233,6246,6247,6477,6478,6554,6603,7266,7267,7341,7355,7620,8386,8737,9077,9078,9116,9125,11578,11585,12678,17737,18499,20230,20597,20598,20599,20600,20864,21651,21652,22027,22810,23920,25203,25208,25212,25225,25231,25236,25242,25264,25266,25275,29704,29707,29932,30357,34428,", /*spells[PALADIN] = */"81,107,198,203,204,522,668,669,670,671,672,750,813,1020,1038,1044,1152,2382,2479,3050,3127,3365,4987,5502,5573,6233,6246,6247,6477,6478,6603,7266,7267,7341,7355,7620,8386,8737,9077,9078,9116,9125,10278,10308,10322,10324,10326,17737,19746,19752,20271,20347,20348,20356,20598,20599,20600,20772,20773,21084,21651,21652,22027,22810,25780,25895,25898,27136,27137,27138,27139,27140,27141,27142,27143,27144,27145,27148,27149,27150,27151,27152,27153,27154,27155,27158,27169,27173,27180,27762,29932,31789,31801,31884,31895,32223,33388,33391,33776,34090,34091,", /*spells[HUNTER] = */"75,81,136,203,204,264,522,668,669,670,671,672,674,781,813,883,982,1002,1130,1180,1462,1494,1495,1499,1510,1513,1515,1543,1978,2382,2479,2641,2643,2973,2974,3018,3034,3043,3044,3045,3050,3111,3127,3365,3661,3662,5116,5118,5384,6197,6233,6246,6247,6477,6478,6603,6991,7266,7267,7341,7355,8386,8737,9077,9078,9125,13159,13161,13163,13165,13358,13542,13543,13544,13549,13550,13551,13552,13553,13554,13555,13795,13809,13813,14260,14261,14262,14263,14264,14265,14266,14267,14268,14269,14270,14271,14272,14273,14274,14279,14280,14281,14282,14283,14284,14285,14286,14287,14288,14289,14290,14294,14295,14302,14303,14304,14305,14310,14311,14316,14317,14318,14319,14320,14321,14322,14323,14324,14325,14326,14327,15629,15630,15631,15632,17737,19801,19878,19879,19880,19882,19883,19884,19885,20043,20190,20580,20582,20583,20585,20736,21009,21651,21652,22027,22810,24949,25294,25295,25296,27014,27015,27016,27018,27019,27020,27021,27022,27023,27025,27044,27045,27046,29932,34026,34074,34120,34477,34600,36916,", /*spells[ROGUE] = */"81,203,204,522,668,669,670,671,672,674,813,921,1180,1725,1787,1804,1833,1842,1860,2094,2382,2479,2567,2764,2836,2842,3050,3127,3365,5938,6233,6246,6247,6477,6478,6603,6774,7266,7267,7341,7355,8386,8643,8681,9077,9078,9125,11297,11305,16092,17737,20598,20599,20600,21184,21651,21652,22027,22810,26669,26679,26862,26863,26865,26866,26867,26884,26889,27441,27448,29932,31224,32684,38764,38768,", /*spells[PRIEST] = */"17,81,139,198,203,204,453,522,527,528,552,585,586,588,589,591,592,594,596,598,600,602,605,668,669,670,671,672,813,970,976,984,988,992,996,1004,1006,1243,1244,1245,1706,2006,2010,2050,2052,2053,2054,2055,2060,2061,2096,2382,2479,2767,2791,3050,3365,3747,5009,5019,6060,6063,6064,6065,6066,6074,6075,6076,6077,6078,6233,6246,6247,6477,6478,6603,7128,7266,7267,7341,7355,8092,8102,8103,8104,8105,8106,8122,8124,8129,8131,8192,8386,9078,9125,9472,9473,9474,9484,9485,9578,9579,9592,10797,10874,10875,10876,10880,10881,10888,10890,10892,10893,10894,10898,10899,10900,10901,10909,10911,10912,10915,10916,10917,10927,10928,10929,10933,10934,10937,10938,10941,10942,10945,10946,10947,10951,10952,10953,10955,10957,10960,10961,10963,10964,10965,14914,15261,15262,15263,15264,15265,15266,15267,17737,19289,19291,19292,19293,19296,19299,19302,19303,19304,19305,20580,20582,20583,20585,20770,21009,21651,21652,22027,22810,25210,25213,25217,25218,25221,25222,25233,25235,25308,25314,25315,25316,25363,25364,25367,25368,25372,25375,25379,25380,25384,25389,25429,25431,25435,25446,25450,25596,29932,32375,32379,32546,32996,33076,34433,34863,34864,34865,34866,", /*spells[6] = */NULL, /*spells[SHAMAN] = */"81,107,131,198,203,204,227,324,325,331,332,370,403,421,522,526,529,546,547,548,556,668,669,670,671,672,813,905,913,915,930,939,943,945,959,1064,1535,2008,2382,2479,2484,2645,2860,2870,3050,3365,3599,5394,5675,5730,6041,6196,6233,6246,6247,6363,6364,6365,6375,6377,6390,6391,6392,6477,6478,6495,6603,7266,7267,7341,7355,8004,8005,8008,8010,8012,8017,8024,8027,8030,8033,8038,8042,8044,8045,8046,8050,8052,8053,8056,8058,8071,8075,8134,8143,8154,8155,8160,8161,8166,8170,8177,8181,8184,8190,8227,8232,8235,8249,8386,8498,8499,8512,8737,8835,9077,9078,9116,9125,10391,10392,10395,10396,10406,10407,10408,10412,10413,10414,10427,10428,10431,10432,10437,10438,10442,10447,10448,10456,10462,10463,10466,10467,10468,10472,10473,10478,10479,10486,10495,10496,10497,10526,10537,10538,10585,10595,10600,10601,10605,10613,10622,10623,10627,11314,11315,15107,15111,15112,15207,15208,16339,16341,16342,16355,16356,16362,16387,17737,20579,20608,20609,20610,20776,20777,21651,21652,22027,22810,24398,25357,25359,25361,25391,25396,25420,25422,25423,25439,25442,25448,25449,25454,25457,25464,25469,25472,25489,25500,25505,25508,25509,25525,25528,25533,25546,25547,25557,25560,25563,25567,25570,25574,25577,25908,27763,28875,28878,28880,29228,29932,33736,36936,", /*spells[MAGE] = */"10,66,81,116,118,120,122,130,133,143,145,168,203,204,205,227,475,522,543,587,597,604,668,669,670,671,672,759,813,822,837,865,990,1008,1449,1459,1460,1461,1463,1953,2120,2121,2136,2137,2138,2139,2382,2479,2855,2948,3050,3140,3365,3552,3563,3566,3567,5009,5019,5143,5144,5145,5504,5505,5506,6117,6127,6129,6131,6141,6143,6233,6246,6247,6477,6478,6603,7266,7267,7300,7301,7302,7320,7322,7341,7355,8386,8400,8401,8402,8406,8407,8408,8412,8413,8416,8417,8422,8423,8427,8437,8438,8439,8444,8445,8446,8450,8451,8455,8457,8458,8461,8462,8492,8494,8495,9078,9125,10053,10054,10138,10139,10140,10144,10145,10148,10149,10150,10151,10156,10157,10159,10160,10161,10169,10170,10173,10174,10177,10179,10180,10181,10185,10186,10187,10191,10192,10193,10197,10199,10201,10202,10205,10206,10207,10211,10212,10215,10216,10219,10220,10223,10225,10230,11417,11418,11420,12051,12824,12825,12826,17737,21651,21652,22027,22782,22783,22810,25304,25306,25345,27070,27071,27072,27073,27074,27075,27078,27079,27080,27082,27085,27086,27087,27088,27101,27124,27125,27126,27128,27130,27131,28609,28612,28730,28734,28877,29932,30449,30451,30455,30482,32267,32272,32796,33717,33944,33946,35715,35717,37420,38699,", /*spells[WARLOCK] = */"81,126,132,172,203,204,348,522,603,668,669,670,671,672,686,687,688,689,691,693,695,696,697,698,699,702,704,705,706,707,709,710,712,755,813,980,1010,1014,1086,1088,1094,1098,1106,1108,1120,1122,1180,1454,1455,1456,1490,1714,1949,2362,2382,2479,2941,3050,3365,3698,3699,3700,5009,5019,5138,5484,5500,5676,5697,5699,5740,5782,5784,6201,6202,6205,6213,6215,6217,6219,6222,6223,6226,6229,6233,6246,6247,6353,6366,6477,6478,6603,6789,7266,7267,7341,7355,7641,7646,7648,7651,7658,7659,8288,8289,8386,9078,9125,11659,11660,11661,11665,11667,11668,11671,11672,11675,11677,11678,11683,11684,11687,11688,11689,11693,11694,11695,11699,11700,11703,11704,11707,11708,11711,11712,11713,11717,11719,11721,11722,11725,11726,11729,11730,11733,11734,11735,11739,11740,17727,17728,17737,17862,17919,17920,17921,17922,17923,17924,17925,17926,17928,17937,18540,18647,20597,20598,20599,20600,20752,20755,20756,20757,20864,21651,21652,22027,22810,23161,25307,25309,25311,27209,27210,27211,27212,27213,27215,27216,27217,27218,27219,27220,27221,27222,27223,27224,27226,27228,27229,27230,27238,27243,27259,27260,28172,28176,28189,28610,29722,29858,29893,29932,30459,30545,30908,30909,30910,32231,", /*spells[10] = */NULL, /*spells[DRUID] = */"81,99,203,204,227,339,467,522,668,669,670,671,672,740,768,769,770,774,778,779,780,782,783,813,1058,1062,1066,1075,1079,1082,1126,1178,1180,1430,1735,1822,1823,1824,1850,2090,2091,2382,2479,2637,2782,2893,2908,2912,3025,3029,3050,3137,3365,3627,5176,5177,5178,5179,5180,5185,5186,5187,5188,5189,5195,5196,5201,5209,5211,5215,5217,5221,5225,5229,5232,5234,5487,6233,6246,6247,6477,6478,6603,6756,6778,6780,6783,6785,6787,6793,6795,6798,6800,6807,6808,6809,7266,7267,7341,7355,8386,8903,8905,8907,8910,8914,8918,8921,8924,8925,8926,8927,8928,8929,8936,8938,8939,8940,8941,8946,8949,8950,8951,8955,8972,8983,8992,8998,9005,9077,9078,9125,9490,9492,9493,9634,9745,9747,9749,9750,9752,9754,9756,9758,9821,9823,9827,9829,9830,9833,9834,9835,9839,9840,9841,9845,9846,9849,9850,9852,9853,9856,9857,9858,9862,9863,9866,9867,9875,9876,9880,9881,9884,9885,9888,9889,9894,9896,9898,9901,9904,9907,9908,9910,9912,9913,16914,16952,16954,16958,16961,17401,17402,17737,18657,18658,18960,20484,20580,20582,20583,20585,20719,20739,20742,20747,20748,21009,21651,21652,22027,22568,22570,22810,22812,22827,22828,22829,22842,22895,22896,24248,25297,25298,25299,26978,26979,26980,26981,26982,26983,26984,26985,26986,26987,26988,26989,26990,26992,26993,26994,26995,26996,26997,26998,26999,27000,27001,27002,27003,27005,27006,27008,27012,27764,29166,29932,31018,33357,33745,33763,33786,33943,34090,", }; static const char * skills[DRUID+1] = { NULL, /* WARRIOR */"172,43,44,55,54,118,136,160,172,173,413,414,415,433,473,", /* PALADIN */"43,55,160,172,293,413,414,415,433,", /* HUNTER */"43,45,36,44,54,118,55,136,160,172,173,226,413,414,415,", /* ROGUE */"118,173,473,414,415,43,", /* PRIEST */"54,136,160,173,415,173,", /* 6 */NULL, /* SHAMAN */"54,136,433,414,413,415,44,172,", /* MAGE */"136,173,43,415,", /* WARLOCK */"43,136,173,415,", /* 10 */NULL, /* DRUID */"43,44,54,136,173,414,415,", }; vector spellArr = StrSplit(string(spells[pPlayer->getClass()]), ","); vector skillArr = StrSplit(string(skills[pPlayer->getClass()]), ","); for(vector::iterator itr = spellArr.begin(); itr != spellArr.end(); ++itr) { uint32 id = atoi((*itr).c_str()); if(id) pPlayer->addSpell(id); } for(vector::iterator itr = skillArr.begin(); itr != skillArr.end(); ++itr) { uint32 id = atoi((*itr).c_str()); if(id) { skilllineentry * se = dbcSkillLine.LookupEntry(id); if(!se) continue; switch(se->type) { case SKILL_TYPE_ARMOR: pPlayer->_AddSkillLine(id,1,1); break; case SKILL_TYPE_WEAPON: pPlayer->_AddSkillLine(id,350,350); break; } } } pPlayer->_AddSkillLine(762,70*5,70*5); /* Riding Skill */ /* Gimmeh max skeels! */ pPlayer->_AdvanceAllSkills(70*5); std::queue mySkills; std::queue myItems; /* pick out mah clothes plz :(( */ switch(pPlayer->getClass()) { case WARRIOR: { /* Add warrior gear here */ for(uint32 i = 16861; i <= 16868; i++) myItems.push(i); /* Add weapon/shield here */ myItems.push(18832); myItems.push(17066); break; } case PRIEST: { for(uint32 i = 16811; i <= 16817; i++) { myItems.push(i); } myItems.push(16819); // WHY? :( /* Staff and Wand here */ myItems.push(22799); myItems.push(17077); break; } case ROGUE: { for(uint32 i = 16820; i <= 16827; i++) myItems.push(i); /* Weapons here */ myItems.push(18816); myItems.push(17071); break; } case HUNTER: { for(uint32 i = 16845; i <= 16852; i++) myItems.push(i); /* Weapon, Bow, and a LOT of ammo here */ myItems.push(17069); myItems.push(17076); break; } case PALADIN: { for(uint32 i = 16853; i <= 16860; i++) myItems.push(i); /* IT's HAMMER TIME! */ myItems.push(18803); break; } case WARLOCK: { for(uint32 i = 16803; i <= 16810; i++) myItems.push(i); /* Staff Here */ myItems.push(18842); break; } case DRUID: { /* Little fix here since Blizz numbers their items in a stupid way */ for(uint32 i = 16828; i <= 16831; i++) myItems.push(i); /* Druid stuff here */ myItems.push(22799); myItems.push(16833); myItems.push(16834); myItems.push(16835); myItems.push(16836); break; } case MAGE: { for(uint32 i = 16795; i <= 16802; i++) myItems.push(i); /* Mage stuff here */ myItems.push(18842); myItems.push(17077); break; } case SHAMAN: { for(uint32 i = 16837; i <= 16837+7; i++) myItems.push(i); /* Shaman stuff here */ myItems.push(21134); break; } } /* Everyone wants a mount */ switch(pPlayer->getRace()) { case RACE_HUMAN: myItems.push(12354); break; case RACE_DRAENEI: myItems.push(32768); break; case RACE_GNOME: myItems.push(18772); break; case RACE_DWARF: myItems.push(18785); break; case RACE_NIGHTELF: myItems.push(18766); break; case RACE_UNDEAD: myItems.push(18791); break; case RACE_ORC: myItems.push(18796); break; case RACE_TROLL: myItems.push(18790); break; case RACE_TAUREN: myItems.push(18793); break; case RACE_BLOODELF: myItems.push(29223); break; } /* Add all the items */ while(!myItems.empty()) { uint32 id = myItems.front(); Item * addItem = objmgr.CreateItem(id, pPlayer); pPlayer->GetItemInterface()->AddItemToFreeSlot(addItem); myItems.pop(); } if(pPlayer->getClass() == HUNTER) { Item * ammo = objmgr.CreateItem(12654, pPlayer); ammo->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 16000); pPlayer->GetItemInterface()->AddItemToFreeSlot(ammo); } /* Add the skills */ while(!mySkills.empty()) { uint32 id = mySkills.front(); pPlayer->_AddSkillLine(id, 70*5, 70*5); mySkills.pop(); } pPlayer->SetUInt32Value(UNIT_FIELD_HEALTH, pPlayer->GetUInt32Value(UNIT_FIELD_MAXHEALTH)); pPlayer->SetBindPoint(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), pPlayer->GetMapId(), pPlayer->GetZoneId()); pPlayer->SaveToDB(false); }