[wpdev-commits] wolfpack spawnregions.cpp,1.73,1.74
Brought to you by:
rip,
thiagocorrea
From: Richard M. <dr...@us...> - 2004-10-03 23:04:52
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27933 Modified Files: spawnregions.cpp Log Message: Changed some things to the following... <maxitemamount value="5 " /> <maxnpcamount value="10" /> <npcspercycle value="3 " /> <itemspercycle value="3" /> I believe it's just easier to write this way. Also, I think having a min/max option for the percycle tags would be useful. Also, I removed mintime and maxtime from the code. Index: spawnregions.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/spawnregions.cpp,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** spawnregions.cpp 2 Oct 2004 22:28:21 -0000 1.73 --- spawnregions.cpp 3 Oct 2004 23:03:18 -0000 1.74 *************** *** 101,105 **** Coord_cl pos = Coord_cl(RandomNum(x1, x2), RandomNum(y1, y2), z, map); ! // If a fixed z value should not be used, make sure to // find a good one. if (!fixedZ) { --- 101,105 ---- Coord_cl pos = Coord_cl(RandomNum(x1, x2), RandomNum(y1, y2), z, map); ! // If a fixed z value should not be used, make sure to // find a good one. if (!fixedZ) { *************** *** 150,154 **** Coord_cl findSpot() { Coord_cl pos; ! // now get a point on this circle around the m_npc float rnddist = (float)RandomNum(0, radius); --- 150,154 ---- Coord_cl findSpot() { Coord_cl pos; ! // now get a point on this circle around the m_npc float rnddist = (float)RandomNum(0, radius); *************** *** 159,163 **** pos.map = map; ! // If a fixed z value should not be used, make sure to // find a good one. if (!fixedZ) { --- 159,163 ---- pos.map = map; ! // If a fixed z value should not be used, make sure to // find a good one. if (!fixedZ) { *************** *** 182,186 **** minTime_ = 0; maxTime_ = 600; ! nextTime_ = 0; id_ = tag->getAttribute("id"); positions_.setAutoDelete(true); --- 182,186 ---- minTime_ = 0; maxTime_ = 600; ! nextTime_ = 0; id_ = tag->getAttribute("id"); positions_.setAutoDelete(true); *************** *** 268,274 **** itemNodesTotal_ += value; } - // <maxnpcamount>10</maxnpcamount> - else if ( name == "maxnpcamount" ) - this->maxNpcAmt_ = value.toUShort(); else if ( name == "checkfreespot" ) --- 268,271 ---- *************** *** 278,292 **** this->checkFreeSpot_ = false; ! // <maxitemamount>5</maxitemamount> ! else if ( name == "maxitemamount" ) ! this->maxItemAmt_ = value.toUShort(); ! // <npcspercycle>3</npcspercycle> ! else if ( name == "npcspercycle" ) ! this->npcsPerCycle_ = value.toUShort(); ! // <itemspercycle>3</itemspercycle> ! else if ( name == "itemspercycle" ) ! this->itemsPerCycle_ = value.toUShort(); // <delay min="xx" max="xx" /> --- 275,293 ---- this->checkFreeSpot_ = false; ! // <maxnpcamount value="10" /> ! else if ( name == "maxnpcamount" && tag->hasAttribute("value") ) ! this->maxNpcAmt_ = tag->getAttribute("value").toUInt(); ! // <maxitemamount value="5 " /> ! else if ( name == "maxitemamount" && tag->hasAttribute("value") ) ! this->maxItemAmt_ = tag->getAttribute("value").toUInt(); ! // <npcspercycle value="3 " /> ! else if ( name == "npcspercycle" && tag->hasAttribute("value" ) ) ! this->npcsPerCycle_ = tag->getAttribute("value").toUInt(); ! ! // <itemspercycle value="3" /> ! else if ( name == "itemspercycle" && tag->hasAttribute("value" ) ) ! this->itemsPerCycle_ = tag->getAttribute("value").toUInt(); // <delay min="xx" max="xx" /> *************** *** 298,302 **** } ! else if ( name == "delay" && tag->hasAttribute("min") && tag->hasAttribute("max")) { minTime_ = tag->getAttribute("min").toUInt(); maxTime_ = tag->getAttribute("max").toUInt(); --- 299,303 ---- } ! else if ( name == "delay" && tag->hasAttribute("min") && tag->hasAttribute("max") ) { minTime_ = tag->getAttribute("min").toUInt(); maxTime_ = tag->getAttribute("max").toUInt(); *************** *** 304,311 **** // <active /> - // <inactive /> else if ( name == "active" ) this->active_ = true; else if ( name == "inactive" ) this->active_ = false; --- 305,312 ---- // <active /> else if ( name == "active" ) this->active_ = true; + // <inactive /> else if ( name == "inactive" ) this->active_ = false; *************** *** 315,326 **** this->groups_.append(value); - // <mintime>10</mintime> - else if ( name == "mintime" ) - this->minTime_ = value.toInt(); - - // <maxtime>20</maxtime> - else if ( name == "maxtime" ) - this->maxTime_ = value.toInt(); - // <rectangle from="0,1000" to="0,1000" map="" z="" /> else if ( name == "rectangle" && tag->hasAttribute("from") && tag->hasAttribute("to") && tag->hasAttribute("map") ) { --- 316,319 ---- *************** *** 443,447 **** } ! bool cSpawnRegion::findValidSpot(Coord_cl& result, int tries) { if (tries == -1) { tries = 20; // Try 20 times (should be a config option instead) --- 436,440 ---- } ! bool cSpawnRegion::findValidSpot(Coord_cl& result, int tries) { if (tries == -1) { tries = 20; // Try 20 times (should be a config option instead) *************** *** 451,455 **** unsigned int points = countPoints(); // Count the number of available points ! if (points == 0) { return false; // No points available --- 444,448 ---- unsigned int points = countPoints(); // Count the number of available points ! if (points == 0) { return false; // No points available *************** *** 457,461 **** unsigned int chosen = RandomNum(0, points - 1); // Chose one random point ! unsigned int offset = 0; // Initialize the offset cSpawnPosition *position; // Current partition --- 450,454 ---- unsigned int chosen = RandomNum(0, points - 1); // Chose one random point ! unsigned int offset = 0; // Initialize the offset cSpawnPosition *position; // Current partition *************** *** 489,497 **** } } ! } result = rndPos; return true; ! } } --- 482,490 ---- } } ! } result = rndPos; return true; ! } } *************** *** 504,508 **** if ( findValidSpot( pos ) ) { ! // This is a little tricky. // There are some regions where one NPC should be spawned more often than others // So we treat every NPC section as a 1 point section and then select accordingly... --- 497,501 ---- if ( findValidSpot( pos ) ) { ! // This is a little tricky. // There are some regions where one NPC should be spawned more often than others // So we treat every NPC section as a 1 point section and then select accordingly... *************** *** 513,517 **** unsigned int i = 0; // Index for the npcNodeFrequencies const cElement *tag = 0; ! // Search the selected element for (node = npcNodes_.first(); node; node = npcNodes_.next()) { --- 506,510 ---- unsigned int i = 0; // Index for the npcNodeFrequencies const cElement *tag = 0; ! // Search the selected element for (node = npcNodes_.first(); node; node = npcNodes_.next()) { *************** *** 552,556 **** pChar->setBaseid(id.latin1()); pChar->moveTo( pos ); ! pChar->applyDefinition( parent ); // Apply the definition from the id first --- 545,549 ---- pChar->setBaseid(id.latin1()); pChar->moveTo( pos ); ! pChar->applyDefinition( parent ); // Apply the definition from the id first *************** *** 586,590 **** if ( findValidSpot( pos ) ) { ! // This is a little tricky. // There are some regions where one item should be spawned more often than others // So we treat every item section as a 1 point section and then select accordingly... --- 579,583 ---- if ( findValidSpot( pos ) ) { ! // This is a little tricky. // There are some regions where one item should be spawned more often than others // So we treat every item section as a 1 point section and then select accordingly... *************** *** 595,599 **** unsigned int i = 0; // Index for the npcNodeFrequencies const cElement *tag = 0; ! // Search the selected element for (node = itemNodes_.first(); node; node = itemNodes_.next()) { --- 588,592 ---- unsigned int i = 0; // Index for the npcNodeFrequencies const cElement *tag = 0; ! // Search the selected element for (node = itemNodes_.first(); node; node = itemNodes_.next()) { *************** *** 634,638 **** pItem->setBaseid(id.latin1()); pItem->moveTo( pos ); ! pItem->applyDefinition( parent ); // Apply the definition from the id first pItem->applyDefinition( tag ); // Now apply the given tag --- 627,631 ---- pItem->setBaseid(id.latin1()); pItem->moveTo( pos ); ! pItem->applyDefinition( parent ); // Apply the definition from the id first pItem->applyDefinition( tag ); // Now apply the given tag *************** *** 681,688 **** while ( npcs() < maxNpcAmt_ ) spawnSingleNPC(); ! while ( items() < maxItemAmt_ ) spawnSingleItem(); ! this->nextTime_ = Server::instance()->time() + RandomNum( this->minTime_, this->maxTime_ ) * MY_CLOCKS_PER_SEC; } --- 674,681 ---- while ( npcs() < maxNpcAmt_ ) spawnSingleNPC(); ! while ( items() < maxItemAmt_ ) spawnSingleItem(); ! this->nextTime_ = Server::instance()->time() + RandomNum( this->minTime_, this->maxTime_ ) * MY_CLOCKS_PER_SEC; } |