// Name: item_bounce3 // Purpose: holds some statements that were COPIED some 50 times // Remarks: temporary functions to revamp the 30 occurences of the 'bouncing bugfix' // History: init Duke, 10.8.2000 / bugfix for bonus stats, Xanathar, 05-aug-2001 static void item_bounce3(const P_ITEM pi) { VALIDATEPI( pi ); pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer=pi->oldlayer; P_CHAR pc = pointers::findCharBySerial( pi->getContSerial(true) ); if(pc==NULL) return ; VALIDATEPC( pc ); if ( pi->layer > 0 ) { // Xanathar -- add BONUS STATS given by equipped special items pc->setStrength( pc->getStrength() + pi->st2, true ); //pc->st += pi->st2; pc->dx += pi->dx2; pc->in += pi->in2; // Xanathar -- for poisoned items if (pi->poisoned) { pc->poison += pi->poisoned; if ( pc->poison < 0) pc->poison = 0; } } }
/*! \brief Check when player is teleporting if overloaded \author Morrolan \return ?? \param pc the character */ int weights::CheckWeight2(P_CHAR pc) { if ((pc->weight > (pc->getStrength()*WEIGHT_PER_STR)+30)) { pc->mn -= 30; if (pc->mn<=0) { pc->mn=0; } return 1; } return 0; }
/*! \brief Check when player is walking if overloaded \author Unknow \return 1 if k, 0 if overloaded \param pc the character */ int weights::CheckWeight(P_CHAR pc) { const static char steps[4] = {25,50,75,100};//, //steps2[5] = {0,25,50,75}; //per cent steps int limit = pc->getStrength()*WEIGHT_PER_STR+30, //weight limit percent = int(((float)pc->weight/(float)limit)*100.0f), //current weight per cent ret=1, result; //for float rounding purposes UI08 index,x; float amount; if(pc->weight>limit) index=5; //overweight else if(percent==100) index=4; //100% weight else for(x=0;x<4;x++) if(percent<steps[x]) { index=x; break; } //less than 100% /* if(index<4) { float stepdiff = float(steps[index]-steps2[index]), percentdiff = float(percent-steps2[index]), stadiff = ServerScp::g_fStaminaUsage[index+1]-ServerScp::g_fStaminaUsage[index]; amount=ServerScp::g_fStaminaUsage[index]+(percentdiff/stepdiff)*stadiff; } else */ amount=ServerScp::g_fStaminaUsage[index]; if(pc->running) amount*=2; //if running, double the amount of stamina used if(pc->isMounting()) amount*=(float)server_data.staminaonhorse; pc->fstm+=amount; //increase the amount of stamina to be subtracted if(pc->fstm>=1.0f) //if stamina to be removed is less than 1, wait { result=(int)pc->fstm; //round it pc->fstm-=result; pc->stm-=result; if(pc->stm<=0) { pc->stm=0; ret=0; } pc->updateStats(2); } return ret; }
LOGICAL checkWearable(P_CHAR pc, P_ITEM pi) { NXWSOCKET s = pc->getSocket(); if (s < 0) return false; if( (pi->getId()>>8) >= 0x40) // LB, client crashfix if multi-objects are moved to PD return false; tile_st tile; data::seekTile(pi->getId(), tile); if( ( clientDimension[s]==3 ) && (tile.quality==0) ) { pc->sysmsg(TRANSLATE("You can't wear that")); return false; } else { P_ITEM outmost = pi->getOutMostCont(); P_CHAR vendor = pointers::findCharBySerial( outmost->getContSerial() ); if( ISVALIDPC( vendor ) && ( vendor->getOwnerSerial32() != pc->getSerial32() ) ) { return false; } } if ( !pc->IsGM() && pi->st > pc->getStrength() && !pi->isNewbie() ) // now you can equip anything if it's newbie { pc->sysmsg(TRANSLATE("You are not strong enough to use that.")); return false; } else if ( !pc->IsGM() && !checkItemUsability(pc, pi, ITEM_USE_WEAR) ) { return false; } else if ( (pc->getId() == BODY_MALE) && ( pi->getId()==0x1c00 || pi->getId()==0x1c02 || pi->getId()==0x1c04 || pi->getId()==0x1c06 || pi->getId()==0x1c08 || pi->getId()==0x1c0a || pi->getId()==0x1c0c ) ) // Ripper...so males cant wear female armor { pc->sysmsg(TRANSLATE("You cant wear female armor!")); return false; } else if ((((pi->magic==2)||((tile.weight==255)&&(pi->magic!=1))) && !pc->canAllMove()) || ( (pi->magic==3|| pi->magic==4) && !(pi->getOwnerSerial32()==pc->getSerial32()))) { return false; } return true; }
/*! \brief wrap for check usability \author Xanathar \return bool \param pc player trying using \param pi pointer to item to be used \param type type of usability \remarks Luxor - Added REQSKILL command support, three bug fix applied */ bool checkItemUsability(P_CHAR pc, P_ITEM pi, int type) { g_nType = type; VALIDATEPIR(pi, false); VALIDATEPCR(pc, false); NXWSOCKET s = pc->getSocket(); if( !pi->isNewbie() && ! pc->IsGM()) { if ( pi->st > pc->getStrength() ) { pc->sysmsg(TRANSLATE("You are not strong enough to use that.")); return false; } if ( pi->dx > pc->dx ) { pc->sysmsg(TRANSLATE("You are not quick enough to use that.")); return false; } if ( pi->in > pc->in ) { pc->sysmsg(TRANSLATE("You are not intelligent enough to use that.")); return false; } //Luxor: REQSKILL command support if (pi->reqskill[0] > 0 && pi->reqskill[1] > 0 ) { if (pi->reqskill[1] > pc->skill[pi->reqskill[0]]) { pc->sysmsg(TRANSLATE("You are not skilled enough to use that.")); return false; } } if ( (pi->getGender() != INVALID && pi->getGender() != GENDER_NEUTRAL ) && pi->getGender() != pc->getGender() ) { if ( pi->getGender() == 1 ) // it's a man item pc->sysmsg(TRANSLATE("Only males of your species may use that !")); else if ( pi->getGender() == 2 ) // it's a man item pc->sysmsg(TRANSLATE("Only females of your species may use that !")); else pc->sysmsg(TRANSLATE("You may not use that !")); // Damn, whats the political correct term for "Get some recreational extensions to your body" return false; } if ( Race::isRaceSystemActive() ) if ( pi->getRace() != INVALID && pi->getRace() != pc->getRace() ) { pc->sysmsg(TRANSLATE("Your race may not use this item!")); // Hope no one sues me because of racial discrimination in item use return false; } } if (s >-1 && s < now) //Luxor { if (pi->amxevents[EVENT_IONCHECKCANUSE]==NULL) return true; return (0!=pi->amxevents[EVENT_IONCHECKCANUSE]->Call(pi->getSerial32(), pc->getSerial32(), g_nType)); /* AmxEvent* event = pi->getAmxEvent( EVENT_IONCHECKCANUSE ); if ( !event ) return true; return ( 0 != event->Call(pi->getSerial32(), s, g_nType ) ); */ } return true; }
void wear_item(NXWCLIENT ps) // Item is dropped on paperdoll { if ( ps == NULL ) return; NXWSOCKET s = ps->toInt(); if (s < 0) return; P_CHAR pc=ps->currChar(); VALIDATEPC( pc ); P_CHAR pck = pointers::findCharBySerPtr(buffer[s]+6); VALIDATEPC( pck ); if( pck->dead ) //Exploit fix: Dead ppl can't equip anything. return; P_ITEM pi=pointers::findItemBySerPtr(buffer[s]+1); VALIDATEPI(pi); bool resetDragging = false; if( (pi->getId()>>8) >= 0x40) // LB, client crashfix if multi-objects are moved to PD resetDragging = true; tile_st tile; int serial/*, letsbounce=0*/; // AntiChrist (5) - new ITEMHAND system data::seekTile(pi->getId(), tile); if( ( clientDimension[s]==3 ) && (tile.quality==0) ) { ps->sysmsg(TRANSLATE("You can't wear that")); resetDragging = true; } else { P_ITEM outmost = pi->getOutMostCont(); P_CHAR vendor = pointers::findCharBySerial( outmost->getContSerial() ); if( ISVALIDPC( vendor ) && ( vendor->getOwnerSerial32() != pc->getSerial32() ) ) { resetDragging = true; } } if( resetDragging ) { Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce4(s,pi); UpdateStatusWindow(s,pi); } return; } if ( pck->getSerial32() == pc->getSerial32() || pc->IsGM() ) { if ( !pc->IsGM() && pi->st > pck->getStrength() && !pi->isNewbie() ) // now you can equip anything if it's newbie { ps->sysmsg(TRANSLATE("You are not strong enough to use that.")); resetDragging = true; } else if ( !pc->IsGM() && !checkItemUsability(pc, pi, ITEM_USE_WEAR) ) { resetDragging = true; } else if ( (pc->getId() == BODY_MALE) && ( pi->getId()==0x1c00 || pi->getId()==0x1c02 || pi->getId()==0x1c04 || pi->getId()==0x1c06 || pi->getId()==0x1c08 || pi->getId()==0x1c0a || pi->getId()==0x1c0c ) ) // Ripper...so males cant wear female armor { ps->sysmsg(TRANSLATE("You cant wear female armor!")); resetDragging = true; } else if ((((pi->magic==2)||((tile.weight==255)&&(pi->magic!=1))) && !pc->canAllMove()) || ( (pi->magic==3|| pi->magic==4) && !(pi->getOwnerSerial32()==pc->getSerial32()))) { resetDragging = true; } if( resetDragging ) { Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce4(s,pi); UpdateStatusWindow(s,pi); } return; } // - AntiChrist (4) - checks for new ITEMHAND system // - now you can't equip 2 hnd weapons with 1hnd weapons nor shields!! serial= pck->getSerial32(); //xan -> k not cc :) P_ITEM pj = NULL; P_CHAR pc_currchar= pck; // P_ITEM pack= pc_currchar->getBackpack(); //<Luxor> P_ITEM pW = pc_currchar->getWeapon(); if (tile.quality == 1 || tile.quality == 2) { //weapons layers if ( (pi->layer == LAYER_2HANDWEAPON && ISVALIDPI(pc_currchar->getShield())) ) { ps->sysmsg(TRANSLATE("You cannot wear two weapons.")); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } if (ISVALIDPI(pW)) { if (pi->itmhand != 3 && pi->lodamage != 0 && pi->itmhand == pW->itmhand) { ps->sysmsg(TRANSLATE("You cannot wear two weapons.")); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } } } //</Luxor> int drop[2]= {-1, -1}; // list of items to drop // there no reason for it to be larger int curindex= 0; NxwItemWrapper si; si.fillItemWeared( pc_currchar, false, true, true ); for( si.rewind(); !si.isEmpty(); si++ ) { // we CANNOT directly bounce the item, or the containersearch() function will not work // so we store the item ID in letsbounce, and at the end we bounce the item pj=si.getItem(); if(!ISVALIDPI(pj)) continue; if ((tile.quality == 1) || (tile.quality == 2))// weapons { if (pi->itmhand == 2) // two handed weapons or shield { if (pj->itmhand == 2) drop[curindex++]= DEREF_P_ITEM(pj); if ( (pj->itmhand == 1) || (pj->itmhand == 3) ) drop[curindex++]= DEREF_P_ITEM(pj); } if (pi->itmhand == 3) { if ((pj->itmhand == 2) || pj->itmhand == 3) drop[curindex++]= DEREF_P_ITEM(pj); } if ((pi->itmhand == 1) && ((pj->itmhand == 2) || (pj->itmhand == 1))) drop[curindex++]= DEREF_P_ITEM(pj); } else // not a weapon { if (pj->layer == tile.quality) drop[curindex++]= DEREF_P_ITEM(pj); } } if (ServerScp::g_nUnequipOnReequip) { if (drop[0] > -1) // there is at least one item to drop { for (int i= 0; i< 2; i++) { if (drop[i] > -1) { P_ITEM p_drop=MAKE_ITEM_REF(drop[i]); if(ISVALIDPI(p_drop)) pc_currchar->UnEquip( p_drop, 0); } } } pc->playSFX( itemsfx(pi->getId()) ); // pc_currchar->Equip(pi, 1); // Item is equipped twice ???? } else { if (drop[0] == -1) { pc->playSFX( itemsfx(pi->getId()) ); // pc_currchar->Equip(pi, 1);// Item is equipped twice ???? } else { ps->sysmsg("You cannot wear two weapons."); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } } if (!(pc->IsGM())) //Ripper..players cant equip items on other players or npc`s paperdolls. { if ((pck->getSerial32() != pc->getSerial32())/*&&(chars[s].npc!=k)*/) //-> really don't understand this! :|, xan { ps->sysmsg(TRANSLATE("You can't put items on other people!")); item_bounce6(ps,pi); return; } } NxwSocketWrapper sws; sws.fillOnline( pi ); for( sws.rewind(); !sws.isEmpty(); sws++ ) SendDeleteObjectPkt( sws.getSocket(), pi->getSerial32() ); pi->layer=buffer[s][5]; pi->setContSerial(LongFromCharPtr(buffer[s] +6)); if (g_nShowLayers) InfoOut("Item equipped on layer %i.\n",pi->layer); wearIt(s,pi); NxwSocketWrapper sw; sw.fillOnline( pck, false ); for( sw.rewind(); !sw.isEmpty(); sw++ ) { NXWSOCKET j=sw.getSocket(); if( j!=INVALID ) wornitems(j, pck ); } pc->playSFX( itemsfx(pi->getId()) ); weights::NewCalc(pc); // Ison 2-20-99 statwindow(pc_currchar,pc_currchar); // if (pi->glow>0) // { // pc->removeHalo(pi); // if gm equips on differnt player it needs to be deleted out of the hashteble // pck->addHalo(pi); // pck->glowHalo(pi); // } if ( pck->Equip(pi, 1) == 2) // bypass called { P_ITEM pack = pck->getBackpack(); pc->playSFX( itemsfx(pi->getId()) ); pi->layer= 0; pi->setContSerial( pack->getSerial32() ); sendbpitem(s, pi); return; } } }