bool OnGossipHello(Player* player, Creature* creature) { if(!isLandOwner(player->GetGUID())) { ChatHandler(player->GetSession()).PSendSysMessage("You do not own any land!"); player->PlayerTalkClass->SendCloseGossip(); return false; } char gprice [50]; char npcprice [50]; npcb = getNPCBonus(player->GetGUID()); if(npcb > 0){ if(npcb >= 200) npcb = 200; else npcb = npcb+10; } else { npcb = 10; } gob = getGoBonus(player->GetGUID()); if(gob > 0){ if(gob >= 200) gob = 200; else gob = gob+5; } else { gob = 10; } sprintf (npcprice, "+10 NPC Spawn Limit!(%i Tokens)", npcb); sprintf (gprice, "+10 GameObject Spawn Limit!(%i Tokens)", gob); player->PlayerTalkClass->ClearMenus(); uint32 accID = player->GetGUIDLow(); if(!hasPackage(accID, 1) || !hasPackage(accID, 2) || !hasPackage(accID, 3) || !hasPackage(accID, 4)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Buy Spawn Packages!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Buy More Land!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, npcprice, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, gprice, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); player->PlayerTalkClass->SendGossipMenu(11111, creature->GetGUID()); return true; }
void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor, bool cancelOther) { if (actor == getPlayer()) throw std::runtime_error("Can't add AI packages to player"); // Stop combat when a non-combat AI package is added if (isActualAiPackage(package.getTypeId())) stopCombat(); // We should return a wandering actor back after combat, casting or pursuit. // The same thing for actors without AI packages. // Also there is no point to stack return packages. int currentTypeId = getTypeId(); int newTypeId = package.getTypeId(); if (currentTypeId <= MWMechanics::AiPackage::TypeIdWander && !hasPackage(MWMechanics::AiPackage::TypeIdInternalTravel) && (newTypeId <= MWMechanics::AiPackage::TypeIdCombat || newTypeId == MWMechanics::AiPackage::TypeIdPursue || newTypeId == MWMechanics::AiPackage::TypeIdCast)) { osg::Vec3f dest; if (currentTypeId == MWMechanics::AiPackage::TypeIdWander) { AiPackage* activePackage = getActivePackage(); dest = activePackage->getDestination(actor); } else { dest = actor.getRefData().getPosition().asVec3(); } MWMechanics::AiTravel travelPackage(dest.x(), dest.y(), dest.z(), true); stack(travelPackage, actor, false); } // remove previous packages if required if (cancelOther && package.shouldCancelPreviousAi()) { for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end();) { if((*it)->canCancel()) { delete *it; it = mPackages.erase(it); } else ++it; } mRepeat=false; } // insert new package in correct place depending on priority for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end(); ++it) { // We should keep current AiCast package, if we try to add a new one. if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdCast && package.getTypeId() == MWMechanics::AiPackage::TypeIdCast) { continue; } if((*it)->getPriority() <= package.getPriority()) { mPackages.insert(it,package.clone()); return; } } mPackages.push_back (package.clone()); // Make sure that temporary storage is empty if (cancelOther) { mAiState.moveIn(new AiCombatStorage()); mAiState.moveIn(new AiFollowStorage()); mAiState.moveIn(new AiWanderStorage()); } }
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction) { uint32 AccID = player->GetGUIDLow(); switch(uiAction) { //BUY PACKAGE case GOSSIP_ACTION_INFO_DEF+1: player->PlayerTalkClass->ClearMenus(); if(!hasPackage(AccID, 1)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, PACKAGE_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10); if(!hasPackage(AccID, 2)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, PACKAGE_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+11); if(!hasPackage(AccID, 3)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, PACKAGE_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+12); if(!hasPackage(AccID, 4)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, PACKAGE_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+130); player->SaveRecallPosition(); player->PlayerTalkClass->SendGossipMenu(11111, creature->GetGUID()); break; //BUY NPC PACKAGE case GOSSIP_ACTION_INFO_DEF+2: ChatHandler(player->GetSession()).PSendSysMessage("This feature is not available yet!"); player->PlayerTalkClass->SendCloseGossip(); break; //+10 NPC SPAWN case GOSSIP_ACTION_INFO_DEF+3: if(player->HasItemCount(HOUSE_TOKEN, npcb, true)){ player->DestroyItemCount(HOUSE_TOKEN, npcb, true); CharacterDatabase.PExecute("UPDATE player_house SET npcs_bonus = npcs_bonus + 10 WHERE player_guid=%u", player->GetGUID()); ChatHandler(player->GetSession()).PSendSysMessage("You can now add 10 more NPC's!"); } else { ChatHandler(player->GetSession()).PSendSysMessage("You do not have enough House Tokens to purchase this package!"); } player->PlayerTalkClass->SendCloseGossip(); break; //+10 GO SPAWN case GOSSIP_ACTION_INFO_DEF+4: if(player->HasItemCount(HOUSE_TOKEN, gob, true)){ player->DestroyItemCount(HOUSE_TOKEN, gob, true); CharacterDatabase.PExecute("UPDATE player_house SET items_bonus = items_bonus + 10 WHERE player_guid=%u", player->GetGUID()); ChatHandler(player->GetSession()).PSendSysMessage("You can now add 10 more GameObjects!!"); } else { ChatHandler(player->GetSession()).PSendSysMessage("You do not have enough House Tokens to purchase this package!"); } player->PlayerTalkClass->SendCloseGossip(); break; case GOSSIP_ACTION_INFO_DEF+10: player->PlayerTalkClass->ClearMenus(); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Buy Package #1 (15 Tokens)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+13); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Preview Package #1", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+16); player->PlayerTalkClass->SendGossipMenu(11111, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+11: player->PlayerTalkClass->ClearMenus(); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Buy Package #2 (15 Tokens)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+14); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Preview Package #2", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+17); player->PlayerTalkClass->SendGossipMenu(11111, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+12: player->PlayerTalkClass->ClearMenus(); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Buy Package #3 (15 Tokens)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+15); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Preview Package #3", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+18); player->PlayerTalkClass->SendGossipMenu(11111, creature->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+130: player->PlayerTalkClass->ClearMenus(); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Buy Package #4 (15 Tokens)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+150); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Preview Package #4", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+180); player->PlayerTalkClass->SendGossipMenu(11111, creature->GetGUID()); break; //buy packages case GOSSIP_ACTION_INFO_DEF+13: if(player->HasItemCount(HOUSE_TOKEN, 15, true)) { player->PlayerTalkClass->SendCloseGossip(); player->DestroyItemCount(HOUSE_TOKEN, PRICE_FOR_P1, true); updatePlayerPackage(player->GetGUIDLow(), 1); ChatHandler(player->GetSession()).PSendSysMessage("Package #1 bought! A new option will show up on your Land Manager."); }else { ChatHandler(player->GetSession()).PSendSysMessage("You do not have enough House Tokens to purchase this package!"); } break; case GOSSIP_ACTION_INFO_DEF+14: if(player->HasItemCount(HOUSE_TOKEN, 15, true)) { player->PlayerTalkClass->SendCloseGossip(); player->DestroyItemCount(HOUSE_TOKEN, PRICE_FOR_P2, true); updatePlayerPackage(player->GetGUIDLow(), 2); ChatHandler(player->GetSession()).PSendSysMessage("Package #2 bought! A new option will show up on your Land Manager."); }else { ChatHandler(player->GetSession()).PSendSysMessage("You do not have enough House Tokens to purchase this package!"); } break; case GOSSIP_ACTION_INFO_DEF+15: if(player->HasItemCount(HOUSE_TOKEN, 15, true)) { player->PlayerTalkClass->SendCloseGossip(); player->DestroyItemCount(HOUSE_TOKEN, PRICE_FOR_P3, true); updatePlayerPackage(player->GetGUIDLow(), 3); ChatHandler(player->GetSession()).PSendSysMessage("Package #3 bought! A new option will show up on your Land Manager."); } else { ChatHandler(player->GetSession()).PSendSysMessage("You do not have enough House Tokens to purchase this package!"); } break; case GOSSIP_ACTION_INFO_DEF+150: if(player->HasItemCount(HOUSE_TOKEN, 15, true)) { player->PlayerTalkClass->SendCloseGossip(); player->DestroyItemCount(HOUSE_TOKEN, PRICE_FOR_P4, true); updatePlayerPackage(player->GetGUIDLow(), 4); ChatHandler(player->GetSession()).PSendSysMessage("Package #4 bought! A new option will show up on your Land Manager."); } else { ChatHandler(player->GetSession()).PSendSysMessage("You do not have enough House Tokens to purchase this package!"); } break; //preview packages case GOSSIP_ACTION_INFO_DEF+16: if (player->isInCombat()) return false; player->TeleportTo(530, -1881.034668f, 5631.024902f, 127.382050f, 4.603881f); break; case GOSSIP_ACTION_INFO_DEF+17: if (player->isInCombat()) return false; player->TeleportTo(530, -1729.365845f, 5612.726562f, 127.946556f, 4.764105f); break; case GOSSIP_ACTION_INFO_DEF+18: if (player->isInCombat()) return false; player->TeleportTo(530, -2003.780518f, 5566.025391f, 53.307026f, 6.0363144f); break; case GOSSIP_ACTION_INFO_DEF+180: if (player->isInCombat()) return false; player->TeleportTo(530, -2213.622070f, 5547.188477f, 112.163513f, 2.822561f); break; } return true; }