本文整理汇总了C++中Datapad::requestNewWaypoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Datapad::requestNewWaypoint方法的具体用法?C++ Datapad::requestNewWaypoint怎么用?C++ Datapad::requestNewWaypoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Datapad
的用法示例。
在下文中一共展示了Datapad::requestNewWaypoint方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _handleFindFriendDBReply
void ObjectController::_handleFindFriendDBReply(uint64 retCode,string friendName)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
friendName.convert(BSTRType_Unicode16);
if(retCode == 0)
{
gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed_noname","","",L"",0,"","",friendName.getUnicode16());
return;
}
PlayerObject* searchObject = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(retCode));
if(!searchObject)
{
gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed","","",L"",0,"","",friendName.getUnicode16());
return;
}
//are we on our targets friendlist???
if(!searchObject->checkFriendList(player->getFirstName().getCrc()))
{
gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed","","",L"",0,"","",friendName.getUnicode16());
return;
}
Datapad* thePad = dynamic_cast<Datapad*>(searchObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
if(thePad && thePad->getCapacity())
{
//the datapad automatically checks for waypoint caspacity and gives the relevant error messages
thePad->requestNewWaypoint(searchObject->getFirstName().getAnsi(),searchObject->mPosition,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
}
}
示例2: _handleRequestWaypointAtPosition
void ObjectController::_handleRequestWaypointAtPosition(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
Datapad* datapad = player->getDataPad();
//if(!datapad->getCapacity())
//{
// gMessageLib->sendSystemMessage(player,L"","base_player","too_many_waypoints");
// return;
//}
BStringVector dataElements;
BString dataStr;
std::string nameStr;
message->getStringUnicode16(dataStr);
// Have to convert BEFORE using split, since the conversion done there is removed It will assert().. evil grin...
// Either do the conversion HERE, or better fix the split so it handles unicoe also.
dataStr.convert(BSTRType_ANSI);
uint32 elementCount = dataStr.split(dataElements,' ');
if(elementCount < 5)
{
if(elementCount < 4)
{
return;
}
else
{
nameStr = gWorldManager->getPlanetNameThis();
std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), &tolower);
}
}
else
{
for(uint i = 4; i < elementCount; i++)
{
nameStr.append(dataElements[i].getAnsi());
if(i + 1 < elementCount)
nameStr.append(" ");
}
}
BString planetStr = dataElements[0].getAnsi();
//gLogger->log(LogManager::DEBUG,"ObjController::handleCreateWaypointAtPosition: planet %s",planetStr.getAnsi());
float x = static_cast<float>(atof(dataElements[1].getAnsi()));
float y = static_cast<float>(atof(dataElements[2].getAnsi()));
float z = static_cast<float>(atof(dataElements[3].getAnsi()));
int32 planetId = gWorldManager->getPlanetIdByName(planetStr);
if(planetId == -1)
{
return;
}
datapad->requestNewWaypoint(nameStr.c_str(), glm::vec3(x,y,z),static_cast<uint16>(planetId),Waypoint_blue);
}
示例3: _handleWaypoint
void ObjectController::_handleWaypoint(uint64 targetId, Message* message, ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
Datapad* datapad = player->getDataPad();
BString waypoint_data;
glm::vec3 waypoint_position;
// Before anything else verify the datapad can hold another waypoint.
if(! datapad->getCapacity()) {
gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "too_many_waypoints"), player);
return;
}
// Read in any waypoint data that may have been sent:
// [SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>
message->getStringUnicode16(waypoint_data);
// Check and see if any parameters were passed to the /waypoint command. For
// immediate purposes the length can be used to tell if anything or nothing was passed.
if (waypoint_data.getLength()) {
int count = swscanf(waypoint_data.getUnicode16(), L"%f %f %f", &waypoint_position.x, &waypoint_position.y, &waypoint_position.z);
// If there are an invalid number of items then disregard and notify the player of the correct
// format for the /waypoint command.
if (count < 2 || count > 3) {
gMessageLib->SendSystemMessage(L"[SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>", player);
return;
}
// If the item count is 2 it means no y value was set in the /waypoint command so
// update the waypoint_position data values accordingly.
if (count == 2) {
waypoint_position.z = waypoint_position.y;
waypoint_position.y = 0;
}
// Validate the position values.
if (waypoint_position.x < -8192 || waypoint_position.x > 8192 ||
waypoint_position.y < -500 || waypoint_position.y > 500 ||
waypoint_position.z < -8192 || waypoint_position.z > 8192) {
gMessageLib->SendSystemMessage( L"[SYNTAX] Invalid range for /waypoint. x = -8192/8192 y = -500/500 z = -8192/8192", player);
return;
}
} else {
// If no parameters were passed to the /waypoint command use the current world position.
waypoint_position = player->getWorldPosition();
}
datapad->requestNewWaypoint("Waypoint", waypoint_position, static_cast<uint16>(gWorldManager->getZoneId()), Waypoint_blue);
}
示例4: surveyEvent
////=============================================================================
////
//// survey event
////
//
void ArtisanManager::surveyEvent(PlayerObject* player, CurrentResource* resource, SurveyTool* tool)
{
if(tool && resource && player->isConnected())
{
Datapad* datapad = player->getDataPad();
ResourceLocation highestDist = gMessageLib->sendSurveyMessage(tool->getInternalAttribute<uint16>("survey_range"),tool->getInternalAttribute<uint16>("survey_points"),resource,player);
// this is 0, if resource is not located
if(highestDist.position.y == 5.0)
{
std::string name("Resource Survey");
std::u16string name_u16(name.begin(), name.end());
std::shared_ptr<WaypointObject> waypoint = datapad->getWaypointByName(name_u16);
// remove the old one
if(waypoint)
{
datapad->updateWaypoint(waypoint->getId(), waypoint->getName(), glm::vec3(highestDist.position.x,0.0f,highestDist.position.z),
static_cast<uint16>(gWorldManager->getZoneId()), player->getId(), WAYPOINT_ACTIVE);
}
else
{
// create a new one
if(datapad->getCapacity())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "survey_waypoint"), player);
//gMessageLib->sendSystemMessage(this,L"","survey","survey_waypoint");
}
//the datapad automatically checks if there is room and gives the relevant error message
std::string name("Resource Survey");
std::u16string name_u16(name.begin(), name.end());
datapad->requestNewWaypoint(name_u16, glm::vec3(highestDist.position.x,0.0f,highestDist.position.z),static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
}
gMissionManager->checkSurveyMission(player,resource,highestDist);
}
}
player->getSampleData()->mPendingSurvey = false;
}
示例5: sendGroupMissionUpdate
void GroupManager::sendGroupMissionUpdate(GroupObject* group)
{
// this procedure ensures, that in case of a change in the mission pool of the group
// all players get updated Mission waypoints
// it concerns all players of the group on the zone, but not on other zones
//get us the mission nearest to the most players on the Zone
MissionObject* mission = getZoneGroupMission(group->getPlayerList());
if(!mission)
return;
//now set the GroupWaypoint for all onZone groupmembers
Uint64List::iterator playerListIt = group->getPlayerList()->begin();
while(playerListIt != group->getPlayerList()->end())
{
PlayerObject* player = dynamic_cast<PlayerObject*> (gWorldManager->getObjectById((*playerListIt)));
Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
WaypointObject* waypoint = datapad->getWaypointByName("@group:groupwaypoint");
// remove the old one
if(waypoint)
{
gMessageLib->sendUpdateWaypoint(waypoint,ObjectUpdateAdd,player);
datapad->removeWaypoint(waypoint);
gObjectFactory->deleteObjectFromDB(waypoint);
}
else
// create a new one
if(datapad->getCapacity())
{
datapad->requestNewWaypoint("@group:groupwaypoint",mission->getDestination().Coordinates,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
gMessageLib->sendSystemMessage(player,L"","group","groupwaypoint");
}
playerListIt++;
}
}
示例6: handleDatabaseJobComplete
void ObjectFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
OFAsyncContainer* asyncContainer = reinterpret_cast<OFAsyncContainer*>(ref);
switch(asyncContainer->query)
{
case OFQuery_House:
{
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
if(!result->getRowCount())
{
gLogger->logMsg("ObjFactory::handleDatabaseJobComplete : create house failed : no result");
break;
}
uint64 requestId = 0;
DataBinding* binding = mDatabase->CreateDataBinding(1);
binding->addField(DFT_uint64,0,8);
result->GetNextRow(binding,&requestId);
mDatabase->DestroyDataBinding(binding);
if(!requestId)
{
gLogger->logMsg("ObjFactory::handleDatabaseJobComplete : create house failed : result is 0");
}
mHouseFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);
//now we need to update the Owners Lots
//cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
if(player)
{
gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
//destroy it in the client
gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
//delete it out of the inventory
inventory->deleteObject(deed);
Datapad* thePad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
thePad->requestNewWaypoint("Player House",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);
}
// now we need to link the deed to the factory in the db and remove it out of the inventory in the db
int8 sql[250];
sprintf(sql,"UPDATE items SET parent_id = %I64u WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
mDatabase->ExecuteSqlAsync(NULL,NULL,sql);
}
break;
case OFQuery_Factory:
{
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
if(!result->getRowCount())
{
gLogger->logMsg("ObjFactory::handleDatabaseJobComplete : create Factory failed : no result");
break;
}
uint64 requestId = 0;
DataBinding* binding = mDatabase->CreateDataBinding(1);
binding->addField(DFT_uint64,0,8);
result->GetNextRow(binding,&requestId);
mDatabase->DestroyDataBinding(binding);
if(!requestId)
{
gLogger->logMsg("ObjFactory::handleDatabaseJobComplete : create Factory failed : result is 0");
}
mFactoryFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);
//now we need to update the Owners Lots
//cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
if(player)
{
gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
//destroy it in the client
gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
//delete it out of the inventory
inventory->deleteObject(deed);
Datapad* thePad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
thePad->requestNewWaypoint("Player Factory",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);
}
// now we need to link the deed to the factory in the db and remove it out of the inventory in the db
int8 sql[250];
sprintf(sql,"UPDATE items SET parent_id = %I64u WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
mDatabase->ExecuteSqlAsync(NULL,NULL,sql);
}
//.........这里部分代码省略.........
示例7: handleDatabaseJobComplete
void ObjectFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
OFAsyncContainer* asyncContainer = reinterpret_cast<OFAsyncContainer*>(ref);
switch(asyncContainer->query)
{
case OFQuery_House:
{
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
if(!result->getRowCount())
{
LOG(ERROR) << "create house failed : no result";
break;
}
uint64 requestId = 0;
DataBinding* binding = mDatabase->createDataBinding(1);
binding->addField(DFT_uint64,0,8);
result->getNextRow(binding,&requestId);
mDatabase->destroyDataBinding(binding);
if(!requestId)
{
LOG(ERROR) << "Create house failed : result is 0";
}
mHouseFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);
//now we need to update the Owners Lots
//cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
if(player)
{
gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
ObjectContainer* tO = dynamic_cast<ObjectContainer*>(gWorldManager->getObjectById(deed->getParentId()));
//destroy it in the client
gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
//delete it out of the inventory
tO->deleteObject(deed);
Datapad* datapad = player->getDataPad();
datapad->requestNewWaypoint("Player House",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);
}
// now we need to link the deed to the factory in the db and remove it out of the inventory in the db
int8 sql[250];
sprintf(sql,"UPDATE items SET parent_id = %"PRIu64" WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
mDatabase->executeSqlAsync(NULL,NULL,sql);
}
break;
case OFQuery_Factory:
{
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
if(!result->getRowCount())
{
LOG(ERROR) << "Create factory failed : no result";
break;
}
uint64 requestId = 0;
DataBinding* binding = mDatabase->createDataBinding(1);
binding->addField(DFT_uint64,0,8);
result->getNextRow(binding,&requestId);
mDatabase->destroyDataBinding(binding);
if(!requestId)
{
LOG(ERROR) << "Create factor failed : result is 0";
}
mFactoryFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);
//now we need to update the Owners Lots
//cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
if(player)
{
gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
//destroy it in the client
gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
//delete it out of the container
ObjectContainer* tO = dynamic_cast<ObjectContainer*>(gWorldManager->getObjectById(deed->getParentId()));
tO->deleteObject(deed);
Datapad* datapad = player->getDataPad();
datapad->requestNewWaypoint("Player Factory",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);
}
// now we need to link the deed to the factory in the db and remove it out of the inventory in the db
int8 sql[250];
sprintf(sql,"UPDATE items SET parent_id = %"PRIu64" WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
mDatabase->executeSqlAsync(NULL,NULL,sql);
//.........这里部分代码省略.........
示例8: handleDatabaseJobComplete
void Tutorial::handleDatabaseJobComplete(void* ref,swganh::database::DatabaseResult* result)
{
TutorialQueryContainer* asyncContainer = reinterpret_cast<TutorialQueryContainer*>(ref);
switch(asyncContainer->mQueryType)
{
case TutorialQuery_MainData:
{
swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(3);
binding->addField(swganh::database::DFT_uint32,offsetof(Tutorial,mState),4,0);
binding->addField(swganh::database::DFT_int32,offsetof(Tutorial,mSubState),4,1);
binding->addField(swganh::database::DFT_bstring,offsetof(Tutorial,mStartingProfession),64,2);
uint64 count = result->getRowCount();
if (count == 1)
{
result->getNextRow(binding,this);
}
else if (count == 0)
{
// First time, no tutorial data saved.
mSubState = 1;
mState = 1;
// Save the state.
(gWorldManager->getKernel()->GetDatabase())->executeSqlAsync(0,0,"INSERT INTO %s.character_tutorial VALUES (%"PRIu64",%u,%u)",gWorldManager->getKernel()->GetDatabase()->galaxy(),asyncContainer->mId,mState, mSubState);
}
gWorldManager->getKernel()->GetDatabase()->destroyDataBinding(binding);
// Here we go...
this->startScript();
}
break;
case TutorialQuery_PlanetLocation:
{
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->mId));
if (player)
{
swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(4);
TutorialStartingLocation startingLocation;
binding->addField(swganh::database::DFT_uint32, offsetof(TutorialStartingLocation, destinationPlanet), 4, 0);
binding->addField(swganh::database::DFT_float, offsetof(TutorialStartingLocation, destX), 4, 1);
binding->addField(swganh::database::DFT_float, offsetof(TutorialStartingLocation, destY), 4, 2);
binding->addField(swganh::database::DFT_float, offsetof(TutorialStartingLocation, destZ), 4, 3);
result->getNextRow(binding, &startingLocation);
startingLocation.destX += (gRandom->getRand()%5 - 2);
startingLocation.destZ += (gRandom->getRand()%5 - 2);
gMessageLib->sendClusterZoneTransferRequestByPosition(player,
glm::vec3(startingLocation.destX, startingLocation.destY, startingLocation.destZ),
startingLocation.destinationPlanet);
// create waypoint at starting location.
glm::vec3 position;
position.x = startingLocation.destX;
position.z = startingLocation.destZ;
Datapad* datapad = player->getDataPad();
std::string name("@ui:cpt_avatar_location");
std::u16string name_u16(name.begin(), name.end());
std::shared_ptr<WaypointObject> wp = datapad->getWaypointByName(name_u16);
if(wp)
{
datapad->RemoveWaypoint(wp->getId());
}
datapad->requestNewWaypoint(name_u16, position, startingLocation.destinationPlanet, Waypoint_blue);
//send starting emails
sendStartingMails();
}
else
{
}
}
break;
default:
{
}
break;
}
delete asyncContainer;
}
示例9: handleDatabaseJobComplete
void Tutorial::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
TutorialQueryContainer* asyncContainer = reinterpret_cast<TutorialQueryContainer*>(ref);
switch(asyncContainer->mQueryType)
{
case TutorialQuery_MainData:
{
DataBinding* binding = gWorldManager->getDatabase()->CreateDataBinding(3);
binding->addField(DFT_uint32,offsetof(Tutorial,mState),4,0);
binding->addField(DFT_int32,offsetof(Tutorial,mSubState),4,1);
binding->addField(DFT_bstring,offsetof(Tutorial,mStartingProfession),64,2);
uint64 count = result->getRowCount();
if (count == 1)
{
result->GetNextRow(binding,this);
gLogger->log(LogManager::DEBUG,"Tutorial::handleDatabaseJobComplete: Starting profession = %s", mStartingProfession.getAnsi());
}
else if (count == 0)
{
// First time, no tutorial data saved.
mSubState = 1;
mState = 1;
// Save the state.
(gWorldManager->getDatabase())->ExecuteSqlAsync(0,0,"INSERT INTO character_tutorial VALUES (%"PRIu64",%u,%u)",asyncContainer->mId,mState, mSubState);
}
gWorldManager->getDatabase()->DestroyDataBinding(binding);
// Here we go...
this->startScript();
}
break;
case TutorialQuery_PlanetLocation:
{
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->mId));
if (player)
{
DataBinding* binding = gWorldManager->getDatabase()->CreateDataBinding(4);
TutorialStartingLocation startingLocation;
binding->addField(DFT_uint32, offsetof(TutorialStartingLocation, destinationPlanet), 4, 0);
binding->addField(DFT_float, offsetof(TutorialStartingLocation, destX), 4, 1);
binding->addField(DFT_float, offsetof(TutorialStartingLocation, destY), 4, 2);
binding->addField(DFT_float, offsetof(TutorialStartingLocation, destZ), 4, 3);
result->GetNextRow(binding, &startingLocation);
startingLocation.destX += (gRandom->getRand()%5 - 2);
startingLocation.destZ += (gRandom->getRand()%5 - 2);
gLogger->log(LogManager::DEBUG,"Tutorial::handleDatabaseJobComplete: New destination planet = %u", startingLocation.destinationPlanet);
gMessageLib->sendClusterZoneTransferRequestByPosition(player,
glm::vec3(startingLocation.destX, startingLocation.destY, startingLocation.destZ),
startingLocation.destinationPlanet);
// create waypoint at starting location.
glm::vec3 position;
position.x = startingLocation.destX;
position.z = startingLocation.destZ;
Datapad* datapad = player->getDataPad();
WaypointObject* wp = datapad->getWaypointByName("@ui:cpt_avatar_location");
if(wp)
{
datapad->removeWaypoint(wp->getId());
}
datapad->requestNewWaypoint("@ui:cpt_avatar_location", position, startingLocation.destinationPlanet, Waypoint_blue);
//send starting emails
sendStartingMails();
}
else
{
gLogger->log(LogManager::DEBUG,"Tutorial::handleDatabaseJobComplete: Player gone!");
}
}
break;
default:
{
gLogger->log(LogManager::DEBUG,"Tutorial::handleDatabaseJobComplete: Unknown query = %u\n", asyncContainer->mQueryType);
}
break;
}
delete asyncContainer;
}
示例10: handleUIEvent
//.........这里部分代码省略.........
{
//action costs
if(!ham->checkMainPool(player->GetCreature(), HamBar_Action ,mSampleActionCost*2))
{
gStateManager.setCurrentPostureState(player->GetCreature(), CreaturePosture_Upright);
player->getSampleData()->mSampleEventFlag = false;
player->getSampleData()->mSampleGambleFlag = false;
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_no_action"), player);
return;
}
player->getSampleData()->mPendingSample = true;
//determine whether gamble is good or not
int32 gambleRoll = int(gRandom->getRand()%2) + 1;
if(gambleRoll == 1)
{
player->getSampleData()->mSampleEventFlag = true;
player->getSampleData()->mSampleGambleFlag = true;
}
else
{
player->getSampleData()->mSampleEventFlag = false;
player->getSampleData()->mSampleGambleFlag = false;
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_fail"), player);
}
SurveyTool* tool = dynamic_cast<SurveyTool*>(gWorldManager->getObjectById(AsyncContainer->ToolId));
CurrentResource* resource = (CurrentResource*)AsyncContainer->CurrentResource;
player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 1000;
sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_gamble"),0, 1000,
std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));
}
}
}
break;
case SUI_Window_SmplWaypNode_ListBox:
{
if(action == 0)
{
//we hit ok and went for the wp
if(element == 1)
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleNodeFlag = true;
player->getSampleData()->Position.x = player->mPosition.x +(((gRandom->getRand()%50)+1));
player->getSampleData()->Position.z = player->mPosition.z +(((gRandom->getRand()%50)+1));
player->getSampleData()->zone = gWorldManager->getZoneId();
player->getSampleData()->resource = (CurrentResource*)AsyncContainer->CurrentResource;
Datapad* datapad = player->getDataPad();
std::string name("Resource Node");
std::u16string name_u16 (name.begin(), name.end());
datapad->requestNewWaypoint(name_u16, player->getSampleData()->Position ,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "node_waypoint"), player);
gStateManager.setCurrentPostureState(player->GetCreature(), CreaturePosture_Upright);
return;
}
//we ignored the node - so continue sampling
if(element == 0)
{
player->getSampleData()->mPendingSample = true;
player->getSampleData()->mSampleGambleFlag = false;
SurveyTool* tool = dynamic_cast<SurveyTool*>(gWorldManager->getObjectById(AsyncContainer->ToolId));
CurrentResource* resource = (CurrentResource*)AsyncContainer->CurrentResource;
player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 10000;
sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_continue"),0, 10000,
std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));
}
}
else
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleNodeFlag = false;
player->getSampleData()->Position.x = 0;
player->getSampleData()->Position.z = 0;
player->getSampleData()->resource = NULL;
player->getSampleData()->zone = 0;
gStateManager.setCurrentPostureState(player->GetCreature(), CreaturePosture_Upright);
return;
}
}
break;
}
//notify the listeners
if (sample_UI_event)
gEventDispatcher.Notify(sample_UI_event);
}
示例11: handleUIEvent
//.........这里部分代码省略.........
}
else
{
//action costs
if(!ham->checkMainPools(0,mSampleActionCost*2,0))
{
gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
player->getSampleData()->mSampleEventFlag = false;
player->getSampleData()->mSampleGambleFlag = false;
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_no_action"), player);
return;
}
player->getSampleData()->mPendingSample = true;
//determine whether gamble is good or not
int32 gambleRoll = int(gRandom->getRand()%2) + 1;
if(gambleRoll == 1)
{
player->getSampleData()->mSampleEventFlag = true;
player->getSampleData()->mSampleGambleFlag = true;
}
else
{
player->getSampleData()->mSampleEventFlag = false;
player->getSampleData()->mSampleGambleFlag = false;
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_fail"), player);
}
SurveyTool* tool = dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId));
CurrentResource* resource = (CurrentResource*)asyncContainer->CurrentResource;
player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 1000;
sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_gamble"),0, 1000,
std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));
}
}
}
break;
case SUI_Window_SmplWaypNode_ListBox:
{
if(action == 0)
{
//we hit ok and went for the wp
if(element == 1)
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleNodeFlag = true;
player->getSampleData()->Position.x = player->mPosition.x +(((gRandom->getRand()%50)+1));
player->getSampleData()->Position.z = player->mPosition.z +(((gRandom->getRand()%50)+1));
player->getSampleData()->zone = gWorldManager->getZoneId();
player->getSampleData()->resource = (CurrentResource*)asyncContainer->CurrentResource;
Datapad* datapad = player->getDataPad();
datapad->requestNewWaypoint("Resource Node", player->getSampleData()->Position ,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "node_waypoint"), player);
gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
return;
}
//we ignored the node - so continue sampling
if(element == 0)
{
player->getSampleData()->mPendingSample = true;
player->getSampleData()->mSampleGambleFlag = false;
SurveyTool* tool = dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId));
CurrentResource* resource = (CurrentResource*)asyncContainer->CurrentResource;
player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 10000;
sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_continue"),0, 10000,
std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));
}
}
else
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleNodeFlag = false;
player->getSampleData()->Position.x = 0;
player->getSampleData()->Position.z = 0;
player->getSampleData()->resource = NULL;
player->getSampleData()->zone = 0;
gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
return;
}
}
break;
}
//notify the listeners
if (sample_UI_event)
gEventDispatcher.Notify(sample_UI_event);
SAFE_DELETE(asyncContainer);
}