static bool ItemDroppedOnTrainer(P_CLIENT ps, PKGx08 *pp, P_ITEM pi) { UOXSOCKET s=ps->GetSocket(); CHARACTER cc=ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,true); int t=calcCharFromSer(pp->Tserial); if( pi->id() ==0x0EED ) { // They gave the NPC gold char sk=chars[t].trainingplayerin; npctalk(s, t, "I thank thee for thy payment. That should give thee a good start on thy way. Farewell!",0); int sum = pc_currchar->getSkillSum(); int delta = chars[t].getTeachingDelta(pc_currchar, sk, sum); if(pi->amount>delta) // Paid too much { pi->amount-=delta; Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce5(s,pi); } } else { if(pi->amount < delta) // Gave less gold delta = pi->amount; // so adjust skillgain Items->DeleItem(pi); } pc_currchar->baseskill[sk]+=delta; Skills->updateSkillLevel(DEREF_P_CHAR(pc_currchar), sk); updateskill(s,sk); pc_currchar->trainer=-1; chars[t].trainingplayerin='\xFF'; itemsfx(s, pi->id());//AntiChrist - do the gold sound return true; } else // Did not give gold { npctalk(s, t, "I am sorry, but I can only accept gold.",0); Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce5(s,pi); return true; } else return true; }//if items[i]=gold return true; }
static bool ItemDroppedOnTrainer(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi) { if (ps == NULL) return false; VALIDATEPIR(pi, false); NXWSOCKET s = ps->toInt(); P_CHAR pc = ps->currChar(); VALIDATEPCR(pc,false); P_CHAR pc_t = pointers::findCharBySerial(pp->Tserial); VALIDATEPCR(pc_t,false); if( pi->getId() == ITEMID_GOLD ) { // They gave the NPC gold UI08 sk=pc_t->trainingplayerin; pc_t->talk( s, TRANSLATE("I thank thee for thy payment. That should give thee a good start on thy way. Farewell!"),0); int sum = pc->getSkillSum(); int delta = pc_t->getTeachingDelta(pc, sk, sum); if(pi->amount>delta) // Paid too much { pi->amount-=delta; Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); } } else { if(pi->amount < delta) // Gave less gold delta = pi->amount; // so adjust skillgain pi->Delete(); } pc->baseskill[sk]+=delta; Skills::updateSkillLevel(pc, sk); updateskill(s,sk); pc->trainer=-1; pc_t->trainingplayerin=0xFF; pc->playSFX( itemsfx(pi->getId()) ); } else // Did not give gold { pc_t->talk( s, TRANSLATE("I am sorry, but I can only accept gold."),0); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); } }//if items[i]=gold return true; }
static bool ItemDroppedOnBeggar(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi) { if (ps == NULL) return false; VALIDATEPIR(pi, false); char temp[TEMP_STR_SIZE]; //xan -> this overrides the global temp var NXWSOCKET s=ps->toInt(); P_CHAR pc=ps->currChar(); VALIDATEPCR(pc,false); P_CHAR pc_t=pointers::findCharBySerial(pp->Tserial); //beggar VALIDATEPCR(pc_t,false); if(pi->getId()!=ITEMID_GOLD) { sprintf(temp,TRANSLATE("Sorry %s i can only use gold"), pc->getCurrentNameC()); pc_t->talk( s,temp,0); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); return true; } } else { sprintf(temp,TRANSLATE("Thank you %s for the %i gold!"), pc->getCurrentNameC(), pi->amount); pc_t->talk( s,temp,0); if(pi->amount<=100) { pc->IncreaseKarma(10); ps->sysmsg(TRANSLATE("You have gain a little karma!")); } else if(pi->amount>100) { pc->IncreaseKarma(50); ps->sysmsg(TRANSLATE("You have gain some karma!")); } pi->Delete(); return true; } return true; }
static bool ItemDroppedOnBanker(P_CLIENT ps, PKGx08 *pp, P_ITEM pi) { UOXSOCKET s=ps->GetSocket(); CHARACTER cc=ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,true); int t=calcCharFromSer(pp->Tserial); P_ITEM bankbox = pc_currchar->GetBankBox(); int amt = pi->amount; int value = pi->value; if (pi->id() == 0x14F0 && pi->type == 1000) { const P_ITEM pi_n = Items->SpawnItem(DEREF_P_CHAR(pc_currchar), DEREF_P_CHAR(pc_currchar),value,"#",1,0x0E,0xED,0,0,0,0); if(pi_n == NULL) return false; sprintf((char*)temp,"%s I have cashed your check and deposited %i gold.",pc_currchar->name, value); npctalk(s,t,(char*)temp,0); bankbox->AddItem(pi_n); statwindow(s, DEREF_P_CHAR(pc_currchar)); return true; } else { if (pi->id() == 0x0EED) { sprintf((char*)temp,"%s you have deposited %i gold.",pc_currchar->name, amt); npctalk(s,t,(char*)temp,0); bankbox->AddItem(pi); statwindow(s, DEREF_P_CHAR(pc_currchar)); return true; } else { sprintf((char*)temp,"Sorry %s i can only deposit gold",pc_currchar->name); npctalk(s,t,(char*)temp,0); Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce5(s,pi); return true; } } return true; } }
static bool ItemDroppedOnPet(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi) { if (ps == NULL) return false; VALIDATEPIR(pi, false); P_CHAR pet = pointers::findCharBySerial(pp->Tserial); VALIDATEPCR(pet, false); NXWSOCKET s = ps->toInt(); P_CHAR pc = ps->currChar(); VALIDATEPCR(pc, false); if((pet->hunger<6) && (pi->type==ITYPE_FOOD))//AntiChrist new hunger code for npcs { pc->playSFX( (UI16)(0x3A+(rand()%3)) ); //0x3A - 0x3C three different sounds if(pi->poisoned) { pet->applyPoison(PoisonType(pi->poisoned)); } std::string itmname; if( pi->getCurrentName() == "#" ) { char temp2[TEMP_STR_SIZE]; //xan -> this overrides the global temp var pi->getName(temp2); itmname = temp2; } else itmname = pi->getCurrentName(); pet->emotecolor = 0x0026; pet->emoteall(TRANSLATE("* You see %s eating %s *"), 1, pet->getCurrentNameC(), itmname.c_str() ); pet->hunger++; } else { ps->sysmsg(TRANSLATE("It doesn't appear to want the item")); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); } } return true; }
static bool ItemDroppedOnPet(P_CLIENT ps, PKGx08 *pp, P_ITEM pi) { UOXSOCKET s = ps->GetSocket(); CHARACTER cc = ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHAR_REF(cc); P_CHAR pc_target = FindCharBySerial(pp->Tserial); if( pc_target->hunger < 6 && pi->type == 14 )//AntiChrist new hunger code for npcs { soundeffect2(DEREF_P_CHAR(pc_currchar), 0x00, 0x3A+(rand()%3)); //0x3A - 0x3C three different sounds if((pi->poisoned)&&(pc_target->poisoned<pi->poisoned)) { soundeffect2(DEREF_P_CHAR(pc_target), 0x02, 0x46); //poison sound - SpaceDog pc_target->poisoned=pi->poisoned; pc_target->poisontime=uiCurrentTime+(MY_CLOCKS_PER_SEC*(40/pc_target->poisoned)); // a lev.1 poison takes effect after 40 secs, a deadly pois.(lev.4) takes 40/4 secs - AntiChrist pc_target->poisonwearofftime=pc_target->poisontime+(MY_CLOCKS_PER_SEC*SrvParms->poisontimer); //wear off starts after poison takes effect - AntiChrist impowncreate(s,DEREF_P_CHAR(pc_target),1); //Lb, sends the green bar ! } if(pi->name[0]=='#') pi->getName(temp2); sprintf((char*)temp,"* You see %s eating %s *",pc_target->name,temp2); pc_target->emotecolor1=0x00; pc_target->emotecolor2=0x26; npcemoteall(DEREF_P_CHAR(pc_target),(char*)temp,1); pc_target->hunger++; } else { sysmessage(s,"It doesn't appear to want the item"); Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce5(s,pi); } } return true; }
static bool ItemDroppedOnBeggar(P_CLIENT ps, PKGx08 *pp, P_ITEM pi) { UOXSOCKET s=ps->GetSocket(); CHARACTER cc=ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,true); int t=calcCharFromSer(pp->Tserial); if(pi->id()!=0x0EED) { sprintf((char*)temp,"Sorry %s i can only use gold",pc_currchar->name); npctalk(s,t,(char*)temp,0); Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce5(s,pi); return true; } } else { sprintf((char*)temp,"Thank you %s for the %i gold!",pc_currchar->name,pi->amount); npctalk(s,t,(char*)temp,0); if(pi->amount<=100) { pc_currchar->karma += 10; sysmessage(s,"You have gain a little karma!"); } else if(pi->amount>100) { pc_currchar->karma += 50; sysmessage(s,"You have gain some karma!"); } Items->DeleItem(pi); return true; } return true; }
static bool ItemDroppedOnChar(P_CLIENT ps, PKGx08 *pp, P_ITEM pi) { UOXSOCKET s=ps->GetSocket(); CHARACTER cc=ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,true); P_CHAR pTC=FindCharBySerial(pp->Tserial); // the targeted character if (!pTC) return true; if (DEREF_P_CHAR(pTC)!=DEREF_P_CHAR(pc_currchar)) { if (pTC->isNpc()) { if(!pTC->isHuman()) { ItemDroppedOnPet( ps, pp, pi); } else // Item dropped on a Human character { // Item dropped on a Guard (possible bounty quest) if( ( pTC->isNpc() ) && ( pTC->npcaitype == 4 ) ) { if (!ItemDroppedOnGuard( ps, pp, pi) ) { Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce5(s,pi); } } return true; } if ( pTC->npcaitype == 5 ) { if (!ItemDroppedOnBeggar( ps, pp, pi)) { Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce5(s,pi); } } return true; } if ( pTC->npcaitype == 8 ) { if (!ItemDroppedOnBanker( ps, pp, pi)) { Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce5(s,pi); } } return true; } //This crazy training stuff done by Anthracks ([email protected]) if(pc_currchar->trainer!=pTC->serial) { npctalk(s, DEREF_P_CHAR(pTC), "Thank thee kindly, but I have done nothing to warrant a gift.",0); Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce5(s,pi); } return true; } else // The player is training from this NPC { ItemDroppedOnTrainer( ps, pp, pi); return true; } }//if human or not } else // dropped on another player { // By Polygon: Avoid starting the trade if GM drops item on logged on char (crash fix) if ((pc_currchar->isGM()) && !online(DEREF_P_CHAR(pTC))) { // Drop the item in the players pack instead // Get the pack P_ITEM pack = Packitem(pTC); if (pack != NULL) // Valid pack? { pack->AddItem(pi); // Add it Weight->NewCalc(DEREF_P_CHAR(pTC)); } else // No pack, give it back to the GM { pack = Packitem(pc_currchar); if (pack != NULL) // Valid pack? { pack->AddItem(pi); // Add it Weight->NewCalc(DEREF_P_CHAR(pc_currchar)); } else // Even GM has no pack? { // Drop it to it's feet pi->MoveTo(pc_currchar->pos.x, pc_currchar->pos.y, pc_currchar->pos.z); RefreshItem(pi); } } } else { P_ITEM pj = Trade->tradestart(s, DEREF_P_CHAR(pTC)); //trade-stuff pi->SetContSerial(pj->serial); pi->pos.x=30; pi->pos.y=30; pi->pos.z=9; SndRemoveitem(pi->serial); RefreshItem(pi); } } } else // dumping stuff to his own backpack ! { ItemDroppedOnSelf( ps, pp, pi); } return true; }
static bool ItemDroppedOnChar(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi) { if (ps == NULL) return true; VALIDATEPIR(pi, false); NXWSOCKET s = ps->toInt(); // CHARACTER cc=ps->currCharIdx(); P_CHAR pTC = pointers::findCharBySerial(pp->Tserial); // the targeted character VALIDATEPCR(pTC, false); P_CHAR pc_currchar = ps->currChar(); //MAKE_CHAR_REF(cc); VALIDATEPCR(pc_currchar, false); Location charpos = pc_currchar->getPosition(); if (!pTC) return true; if (pi->amxevents[EVENT_IDROPONCHAR]!=NULL) { g_bByPass = false; pi->amxevents[EVENT_IDROPONCHAR]->Call( pi->getSerial32(), pc_currchar->getSerial32(), pTC->getSerial32() ); if (g_bByPass) { pi->Refresh(); return true; } } if (pc_currchar->getSerial32() != pTC->getSerial32() /*DEREF_P_CHAR(pTC)!=cc*/) { if (pTC->npc) { if(!pTC->HasHumanBody()) { ItemDroppedOnPet( ps, pp, pi); } else // Item dropped on a Human character { // Item dropped on a Guard (possible bounty quest) if( ( pTC->npc == 1 ) && ( pTC->npcaitype == NPCAI_TELEPORTGUARD ) ) { ItemDroppedOnGuard( ps, pp, pi); } if ( pTC->npcaitype == NPCAI_BEGGAR ) { ItemDroppedOnBeggar( ps, pp, pi); } //This crazy training stuff done by Anthracks ([email protected]) if(pc_currchar->isBeingTrained() ) { if ( pc_currchar->trainer != pTC->getSerial32()) { pTC->talk(s, TRANSLATE("Thank thee kindly, but I have done nothing to warrant a gift."),0); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); } return true; } else // The player is training from this NPC { ItemDroppedOnTrainer( ps, pp, pi); } } if ( pTC->isHirable() ) { // test if gold is enough if ( pi->amount < pTC->getHireFee() ) { pTC->talk(s, TRANSLATE("I need much more gold if i shall be working for you !"),0); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); } return true; } else if ( pi->amount >= pTC->getHireFee() ) { if ( pi->amount > pTC->getHireFee() ) { pi->amount=(UI16)(pi->amount - pTC->getHireFee()); pTC->talk(s, TRANSLATE("Thank thee kindly, but this is more than i need for the day."),0); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); } } pTC->setOwner(pc_currchar); tempfx::add(pTC, pc_currchar, tempfx::NPC_HIRECOST, 0, 0, 0, 0, (UI16)(MY_CLOCKS_PER_SEC*secondsperuominute*60*24 )); // call callback every uo day return true; } } }//if human or not } else // dropped on another player { // By Polygon: Avoid starting the trade if GM drops item on logged on char (crash fix) if ((pc_currchar->IsGM()) && !pTC->IsOnline()) { // Drop the item in the players pack instead // Get the pack P_ITEM pack = pTC->getBackpack(); if (pack != NULL) // Valid pack? { pack->AddItem(pi); // Add it weights::NewCalc(pTC); } else // No pack, give it back to the GM { pack = pc_currchar->getBackpack(); if (pack != NULL) // Valid pack? { pack->AddItem(pi); // Add it weights::NewCalc(pc_currchar); } else // Even GM has no pack? { // Drop it to it's feet pi->MoveTo( charpos ); pi->Refresh(); } } } else { //<Luxor>: secure trade P_ITEM tradeCont = tradestart(pc_currchar, pTC); if (ISVALIDPI(tradeCont)) { tradeCont->AddItem( pi, 30, 30 ); } else { Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } } //</Luxor> } } } else // dumping stuff to his own backpack ! { ItemDroppedOnSelf( ps, pp, pi); } return true; }