void cItem::explode(NXWSOCKET s) { if (s < 0 || s > now) return; //Luxor unsigned int dmg=0,len=0; P_CHAR pc_current=MAKE_CHAR_REF(currchar[s]); VALIDATEPC(pc_current); if(!isInWorld()) return; type=0; //needed for recursive explosion //Luxor - recursive explosions!! :DD NxwItemWrapper si; si.fillItemsNearXYZ( getPosition(), 5, true ); for( si.rewind(); !si.isEmpty(); si++ ) { P_ITEM p_nearbie=si.getItem(); if(ISVALIDPI(p_nearbie) && p_nearbie->type == ITYPE_POTION && p_nearbie->morey == 3) { //It's an explosion potion! p_nearbie->explode(s); } } //End Luxor recursive explosions staticeffect2(this, 0x36, 0xB0, 0x10, 0x80, 0x00); soundeffect3(this, 0x0207); len=morex/250; //4 square max damage at 100 alchemy switch (morez) { case 1:dmg=RandomNum( 5,10) ;break; case 2:dmg=RandomNum(10,20) ;break; case 3:dmg=RandomNum(20,40) ;break; default: ErrOut("Switch fallout. NoX-Wizard.cpp, explodeitem()\n"); //Morrolan dmg=RandomNum(5,10); } if (dmg<5) dmg=RandomNum(5,10); // 5 points minimum damage if (len<2) len=2; // 2 square min damage range NxwCharWrapper sc; sc.fillCharsNearXYZ( getPosition(), len, true ); for( sc.rewind(); !sc.isEmpty(); sc++ ) { P_CHAR pc=sc.getChar(); if( ISVALIDPC(pc) ) { pc->damage( dmg+(2-pc->distFrom(this)), DAMAGE_FIRE ); } } Delete(); }
void UpdateStatusWindow(NXWSOCKET socket, P_ITEM pi) { P_CHAR pc = MAKE_CHAR_REF( currchar[socket] ); VALIDATEPC( pc ); VALIDATEPI( pi ); P_ITEM pack = pc->getBackpack(); VALIDATEPI( pack ); if( pi->getContSerial() != pack->getSerial32() || pi->getContSerial() == pc->getSerial32() ) statwindow( pc, pc ); }
LOGICAL inbankrange(int i) { P_CHAR pc=MAKE_CHAR_REF(i); VALIDATEPCR(pc,false); NxwCharWrapper sc; sc.fillCharsNearXYZ( pc->getPosition(), 6, true, false ); for( sc.rewind(); !sc.isEmpty(); sc++ ) { P_CHAR pcm=sc.getChar(); if (ISVALIDPC(pcm) && pcm->npcaitype==NPCAI_BANKER) { return true; } } return false; }
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; }
void deadattack (NXWSOCKET s, CHARACTER i) { CHARACTER cc = currchar[s]; P_CHAR pc = MAKE_CHAR_REF( cc ); VALIDATEPC( pc ); P_CHAR pc_other = MAKE_CHAR_REF( i ); VALIDATEPC( pc_other ); if(pc_other->npc) { if(pc_other->npcaitype==NPCAI_HEALER) { if( pc->IsInnocent() ) { if ( pc->distFrom( pc_other ) <= 3 ) {//let's resurrect him! pc_other->playAction(0x10); pc->resurrect(); staticeffect(cc, 0x37, 0x6A, 0x09, 0x06); switch(RandomNum(0, 4)) { case 0: pc_other->talkAll( TRANSLATE("Thou art dead, but 'tis within my power to resurrect thee. Live!"),0); break; case 1: pc_other->talkAll( TRANSLATE("Allow me to resurrect thee ghost. Thy time of true death has not yet come."),0); break; case 2: pc_other->talkAll( TRANSLATE("Perhaps thou shouldst be more careful. Here, I shall resurrect thee."),0); break; case 3: pc_other->talkAll( TRANSLATE("Live again, ghost! Thy time in this world is not yet done."),0); break; case 4: pc_other->talkAll( TRANSLATE("I shall attempt to resurrect thee."),0); break; } } else {//if dist>3 pc_other->talkAll( TRANSLATE("Come nearer, ghost, and i'll give you life!"),1); } } else {//if a bad guy pc_other->talkAll( TRANSLATE("I will not give life to a scoundrel like thee!"),1); } } else if( pc_other->npcaitype == NPCAI_EVILHEALER ) { if( pc->IsMurderer()) { if ( pc->distFrom( pc_other ) <=3 ) {//let's resurrect him! pc_other->playAction(0x10); pc->resurrect(); staticeffect(cc, 0x37, 0x09, 0x09, 0x19); //Flamestrike effect switch(rand()%5) { case 0: pc_other->talkAll( TRANSLATE("Fellow minion of Mondain, Live!!"),0); break; case 1: pc_other->talkAll( TRANSLATE("Thou has evil flowing through your vains, so I will bring you back to life."),0); break; case 2: pc_other->talkAll( TRANSLATE("If I res thee, promise to raise more hell!."),0); break; case 3: pc_other->talkAll( TRANSLATE("From hell to Britannia, come alive!."),0); break; case 4: pc_other->talkAll( TRANSLATE("Since you are Evil, I will bring you back to consciouness."),0); break; } } else {//if dist >3 pc_other->talkAll( TRANSLATE("Come nearer, evil soul, and i'll give you life!"),1); } } else {//if player is a good guy pc_other->talkAll( TRANSLATE("I dispise all things good. I shall not give thee another chance!"),1); } } else { sysmessage(s,TRANSLATE("You are dead and cannot do that.")); }//npcaitype check } else {//if this not a npc but a player if(SrvParms->persecute) {//start persecute stuff - AntiChrist pc->targserial = pc_other->getSerial32(); Skills::Persecute(s); } else { sysmessage(s,TRANSLATE("You are dead and cannot do that.")); } }//if npc }
void AttackStuff(NXWSOCKET s, P_CHAR victim) { if ( s < 0 || s >= now ) return; P_CHAR attacker = MAKE_CHAR_REF( currchar[s] ); VALIDATEPC( attacker ); VALIDATEPC( victim ); if( attacker->getSerial32() == victim->getSerial32() ) return; if ( attacker->amxevents[EVENT_CHR_ONBEGINATTACK]) { g_bByPass = false; attacker->amxevents[EVENT_CHR_ONBEGINATTACK]->Call( attacker->getSerial32(), victim->getSerial32() ); if (g_bByPass==true) return; } if ( victim->amxevents[EVENT_CHR_ONBEGINDEFENSE]) { g_bByPass = false; victim->amxevents[EVENT_CHR_ONBEGINDEFENSE]->Call( victim->getSerial32(), attacker->getSerial32() ); if (g_bByPass==true) return; } /* attacker->runAmxEvent( EVENT_CHR_ONBEGINATTACK, attacker->getSerial32(), victim->getSerial32() ); if (g_bByPass==true) return; victim->runAmxEvent( EVENT_CHR_ONBEGINDEFENSE, victim->getSerial32(), attacker->getSerial32() ); if (g_bByPass==true) return; */ attacker->targserial=victim->getSerial32(); attacker->unHide(); attacker->disturbMed(); if( victim->dead || victim->hp <= 0 )//AntiChrist { attacker->sysmsg( TRANSLATE("That person is already dead!") ); return; } if ( victim->npcaitype==NPCAI_PLAYERVENDOR) { attacker->sysmsg( TRANSLATE("%s cannot be harmed."), victim->getCurrentNameC() ); return; } SndAttackOK(s, victim->getSerial32()); //keep the target highlighted if (!( victim->targserial== INVALID)) { victim->attackerserial=attacker->getSerial32(); victim->ResetAttackFirst(); } attacker->SetAttackFirst(); attacker->attackerserial=victim->getSerial32(); if( victim->guarded ) { NxwCharWrapper sc; sc.fillOwnedNpcs( victim, false, false ); for ( sc.rewind(); !sc.isEmpty(); sc++ ) { P_CHAR guard = sc.getChar(); if ( ISVALIDPC( guard ) ) if ( guard->npcaitype == NPCAI_PETGUARD && ( attacker->distFrom( guard )<= 10 ) ) npcattacktarget(attacker, guard); } } if ((region[ victim->region].priv & RGNPRIV_GUARDED) && (SrvParms->guardsactive)) { if (victim->IsGrey()) attacker->SetGrey(); if (victim->npc==0 && victim->IsInnocent() && (!victim->IsGrey()) && Guildz.compareGuilds( attacker->getGuild(), victim->getGuild() )==0) //REPSYS { criminal( attacker ); if (ServerScp::g_nInstantGuard==1) npcs::SpawnGuard(attacker, victim,attacker->getPosition() ); } else if( victim->npc && victim->IsInnocent() && !victim->HasHumanBody() && victim->npcaitype!=NPCAI_TELEPORTGUARD ) { criminal( attacker ); if (ServerScp::g_nInstantGuard==1) npcs::SpawnGuard(attacker, victim, attacker->getPosition() ); } else if( victim->npc && victim->IsInnocent() && victim->HasHumanBody() && victim->npcaitype!=NPCAI_TELEPORTGUARD ) { victim->talkAll( TRANSLATE("Help! Guards! I've been attacked!"), 1); criminal( victim ); callguards(DEREF_P_CHAR(victim)); // Sparhawk must check if npcs can call guards } else if( victim->npc && victim->npcaitype==NPCAI_TELEPORTGUARD) { criminal( attacker ); npcattacktarget(victim, attacker); } else if ((victim->npc || victim->tamed) && !victim->war && victim->npcaitype!=NPCAI_TELEPORTGUARD) { victim->fight( attacker ); } else { victim->setNpcMoveTime(); } //attacker->emoteall( "You see %s attacking %s!", 1, attacker->getCurrentNameC(), victim->getCurrentNameC() ); } else // not a guarded area { if ( victim->IsInnocent()) { if ( victim->IsGrey()) attacker->SetGrey(); if (!victim->npc && (!victim->IsGrey()) && Guildz.compareGuilds(attacker->getGuild(), victim->getGuild() )==0) { criminal( attacker ); } else if (victim->npc && victim->tamed) { criminal( attacker ); npcattacktarget(victim, attacker); } else if (victim->npc) { criminal( attacker ); npcattacktarget(victim, attacker); if (victim->HasHumanBody() ) { victim->talkAll(TRANSLATE("Help! Guards! Tis a murder being commited!"), 1); } } } } }
void updatehtml()//HTML { double eps=0.00000000001; char sect[512],time_str[80],hfile[512] /*,sh[3],sm[3],ss[3]*/; int a, n=0; //unsigned long int ip; int gm=0,cns=0,ccount=0,npccount=0,loopexit=0; unsigned long int total; unsigned int hr,min,sec; FILE *html; cScpIterator* iter = NULL; //char script1[1024]; //char script2[1024]; std::string script1; std::string script2; strcpy(sect,"SECTION ONLINE"); iter = Scripts::HtmlStrm->getNewIterator(sect); if (iter==NULL) return; script1 = iter->getEntry()->getFullLine(); //discard { script1 = iter->getEntry()->getFullLine(); strcpy( hfile, script1.c_str() ); //html=fopen(hfile,"w+"); //a=remove(hfile); //ConOut("html-a: %i %s\n",a,hfile); html=fopen(hfile,"w"); // remove old one first if (html == NULL) // LB { WarnOut("Could not create html file, please check html.xss\n"); safedelete(iter); return; } do { iter->parseLine(script1, script2); if( script1 == "LINE" ) { fprintf(html,"%s\n",script2.c_str() ); } else if( script1 == "TIME" ) { fprintf(html,"%s <BR>",RealTime(time_str)); } else if( script1 == "NOW" ) { P_CHAR pc= MAKE_CHAR_REF(currchar[n]); //if(online(currchar[n])) //bugfix LB if( ISVALIDPC(pc) && pc->IsOnline() ) { fprintf(html,pc->getCurrentNameC()); n++; } } else if( script1 == "WHOLIST" ) { a=0; for (n=0;n<now;n++) { P_CHAR pc= MAKE_CHAR_REF(currchar[n]); //if (online(currchar[n])) // bugfix, LB if( ISVALIDPC(pc) && pc->IsOnline() ) { a++; fprintf(html,"%i) %s <BR>\n",a,pc->getCurrentNameC()); // bugfix lb } } } else if( script1 == "NOWNUM") fprintf(html,"%i",now); else if( script1 == "ACCOUNTNUM" ) fprintf(html,"%i",Accounts->Count()); else if( script1 == "CHARCOUNT" ) { if(ccount==0) { npccount=0; /*for(a=0;a<charcount;a++) { P_CHAR pc_a=MAKE_CHAR_REF(a); if(ISVALIDPC(pc_a)) { if(!pc_a->free) ccount++; if(pc_a->npc && !pc_a->free) npccount++; } }*/ } fprintf(html,"%i",ccount); } else if( script1 == "NPCS" ) { if(npccount==0) { ccount=0; /*for(a=0;a<charcount;a++) { P_CHAR pc_a=MAKE_CHAR_REF(a); if(ISVALIDPC(pc_a)) { if(!pc_a->free) ccount++; if(pc_a->npc && !pc_a->free) npccount++; //bugfix LB } }*/ } fprintf(html,"%i",npccount); } else if( script1 == "ITEMCOUNT" ) { //fprintf(html,"%i",itemcount); } else if( script1 == "UPTIME" ) { total=(uiCurrentTime-starttime)/MY_CLOCKS_PER_SEC; hr=total/3600; // if(hr<10 && hr<=60) sprintf(sh,"0%lu",hr); // else sprintf(sh,"%lu",hr); total-=hr*3600; min=total/60; // if(min<10 && min<=60) sprintf(sm,"0%lu",min); // else sprintf(sm,"%lu",min); total-=min*60; sec=total; // if(sec<10 && sec <=60) sprintf(ss,"0%lu",sec); // else sprintf(ss,"%lu",sec); // fprintf(html,"%s:%s:%s",sh,sm,ss); fprintf(html,"%02d:%02d:%02d",hr,min,sec); } else if( script1 == "IP" ) { //ip=inet_addr(serv[str2num(script2)-1][1]); fprintf(html,serv[str2num(script2)-1][1]); } else if( script1 == "GMNUM" ) { if(gm==0) { for(a=0;a<now;a++) { P_CHAR pc_a=MAKE_CHAR_REF(currchar[a]); if(ISVALIDPC(pc_a) && clientInfo[a]->ingame ) { if( pc_a->IsGM() ) gm++; else if( pc_a->IsCounselor() ) cns++; } } } fprintf(html,"%i",gm); } else if( script1 == "CNSNUM" ) { if(cns==0) { for(a=0;a<now;a++) { P_CHAR pc_a=MAKE_CHAR_REF(currchar[a]); if(ISVALIDPC(pc_a) && clientInfo[a]->ingame ) { if( pc_a->IsGM() ) gm++; else if( pc_a->IsCounselor() ) cns++; //bugfix LB } } } fprintf(html,"%i",cns); } else if( script1 == "PDUMP" ) { fprintf(html,"Network code: %fmsec [%i samples] <BR>",(float)((float)networkTime/(float)networkTimeCount), networkTimeCount); fprintf(html,"Timer code: %fmsec [%i samples] <BR>" , (float)((float)timerTime/(float)timerTimeCount) , timerTimeCount); fprintf(html,"Auto code: %fmsec [%i samples] <BR>" , (float)((float)autoTime/(float)autoTimeCount) , autoTimeCount); fprintf(html,"Loop Time: %fmsec [%i samples] <BR>" , (float)((float)loopTime/(float)loopTimeCount) , loopTimeCount); // fprintf(html,"Characters: %i/Dynamic Items: %i/Dynamic <BR>" , charcount, itemcount); if (!(loopTime <eps || loopTimeCount<eps)) //Bugfix LB fprintf(html,"Simulation Cycles: %f per sec <BR>" , (1000.0*(1.0/(float)((float)loopTime/(float)loopTimeCount)))); else fprintf(html,"Simulation Cylces: too fast to be measured <BR>"); } else if( script1 == "SIMCYC" ) { if (!(loopTime <eps || loopTimeCount<eps)) fprintf(html,"%f" , (1000.0*(1.0/(float)((float)loopTime/(float)loopTimeCount)))); else fprintf(html,"too fast to be measured"); } else if( script1 == "UDTIME" ) fprintf(html,"%f",(float)(SrvParms->html/60)); else if( script1 == "VER" ) fprintf(html,"%s %s [%s]",VER, VERNUMB, OS); } while( (script1[0]!='}') && (++loopexit < MAXLOOPS) ); fclose(html); safedelete(iter); }
void do_lsd(UOXSOCKET s) { P_CHAR pc_currchar = MAKE_CHAR_REF(currchar[s]); if (rand()%15==0) { int c1,c2,color,ctr=0,b,xx,yy,di,icnt=0; signed char zz; int StartGrid=mapRegions->StartGrid(pc_currchar->pos.x,pc_currchar->pos.y); unsigned int increment=0; for (unsigned int checkgrid=StartGrid+(increment*mapRegions->GetColSize());increment<3;increment++, checkgrid=StartGrid+(increment*mapRegions->GetColSize())) { for (int a=0;a<3;a++) { vector<SERIAL> vecEntries = mapRegions->GetCellEntries(checkgrid + a); for ( unsigned int k = 0; k < vecEntries.size(); k++) { P_ITEM pi = FindItemBySerial(vecEntries[k]); P_CHAR mapchar = FindCharBySerial(vecEntries[k]); if (pi != NULL) { color=(pi->color1<<8)+pi->color2; // fetch item's color and covert to 16 bit if (rand()%44==0) color+=pi->pos.x-pi->pos.y; else color+=pc_currchar->pos.x+pc_currchar->pos.y; color+=rand()%3; // add random "noise" ctr++; // lots of color consistancy checks color=color%0x03E9; c1=color>>8; c2=color%256; if ((((c1<<8)+c2)<0x0002) || (((c1<<8)+c2)>0x03E9) ) { c1=0x03; c2=0xE9; } b=((((c1<<8)+c2)&0x4000)>>14)+((((c1<<8)+c2)&0x8000)>>15); if (b) { c1=0x1; c2=rand()%255; } if (rand()%10==0) zz=pi->pos.z+rand()%33; else zz=pi->pos.z; if (rand()%10==0) xx=pi->pos.x+rand()%3; else xx=pi->pos.x; if (rand()%10==0) yy=pi->pos.y+rand()%3; else yy=pi->pos.y; di = itemdist(DEREF_P_CHAR(pc_currchar), pi); if (di<13) if (rand()%7==0) { icnt++; if (icnt%10==0 || icnt<10) senditem_lsd(s, pi, c1, c2, xx, yy, zz); // attempt to cut packet-bombing by this thing } }// end of if item else if (mapchar != NULL)// character { di = chardist(DEREF_P_CHAR(pc_currchar), DEREF_P_CHAR(mapchar)); if (di<10) if (rand()%10==0) { icnt++; if (icnt%10==0 || icnt<10) sendperson_lsd(s, DEREF_P_CHAR(mapchar),c1,c2); // attempt to cut packet-bombing by this thing } } } }
void cTmpEff::Expire() { int mortar,k,ccc; int s=calcCharFromSer(getDest()); if ( num != 9 // grinding && num != 10 // create potion && num != 13 // door close && num != 14 // training dummy && num != 17) // explosion { //Added by TANiS to fix errors, memory corruption and door auto-close 10-6-98 // Check to see if it's a dead char and delete the wrong effect, or if it's just // a door auto-close effect and process it the right way. if ( s < 0 || s >= cmem ) { return; // just remove this effect } //End of TANiS' change } // P_CHAR pc_s = MAKE_CHARREF_LR(s); // enabling this reveals a nasty bug I have not found yet: some effects will not work (Duke,13.8.01) P_CHAR pc_s = MAKE_CHAR_REF(s); switch(num) { case 1: if (pc_s->priv2&0x02) { pc_s->priv2 &= 0xFD; int sk=calcSocketFromChar(s); if (sk!=-1) sysmessage(sk, "You are no longer frozen."); Magic->afterParticles(38, s); } break; case 2: pc_s->fixedlight='\xFF'; dolight(calcSocketFromChar(s), worldbrightlevel); break; case 3: pc_s->chgDex(more1); statwindow(calcSocketFromChar(s), s); break; case 4: pc_s->in+=more1; statwindow(calcSocketFromChar(s), s); break; case 5: pc_s->st+=more1; statwindow(calcSocketFromChar(s), s); break; case 6: pc_s->chgDex(-1 * more1); pc_s->stm=min(pc_s->stm, (int)pc_s->effDex()); statwindow(calcSocketFromChar(s), s); break; case 7: pc_s->in-=more1; pc_s->mn=min(pc_s->mn, pc_s->in); statwindow(calcSocketFromChar(s), s); break; case 8: pc_s->st-=more1; pc_s->hp=min(pc_s->hp, pc_s->st); statwindow(calcSocketFromChar(s), s); break; case 9: if (more1 == 0) { if (more2!=0) { sprintf((char*)temp, "*%s continues grinding.*", pc_s->name); npcemoteall(s, (char*)temp,1); } soundeffect2(s, 0x02, 0x42); } break; case 10: s=calcCharFromSer(getSour()); mortar=calcItemFromSer(getDest()); if(mortar>-1) //AntiChrist - to prevent crashes Skills->CreatePotion(s, more1, more2, mortar); break; case 11: pc_s->st-=more1; pc_s->hp=min(pc_s->hp, pc_s->st); pc_s->chgDex(-1 * more2); pc_s->stm=min(pc_s->stm, (int)pc_s->effDex()); pc_s->in-=more3; pc_s->mn=min(pc_s->mn, pc_s->in); statwindow(calcSocketFromChar(s), s); break; case 12: pc_s->st+=more1; pc_s->chgDex(more2); pc_s->in+=more3; statwindow(calcSocketFromChar(s), s); break; case 13: { P_ITEM pDoor = FindItemBySerial(getDest());// door if (pDoor) { if (pDoor->dooropen==0) break; pDoor->dooropen=0; dooruse(calcSocketFromChar(s), DEREF_P_ITEM(pDoor)); } break; } case 14: //- training dummies Tauriel check to see if item moved or not before searching for it { P_ITEM pTrainDummy = FindItemBySerial(getDest()); if (pTrainDummy) { if (pTrainDummy->id()==0x1071) { pTrainDummy->setId(0x1070); pTrainDummy->gatetime=0; RefreshItem(pTrainDummy);//AntiChrist } else if (pTrainDummy->id()==0x1075) { pTrainDummy->setId(0x1074); pTrainDummy->gatetime=0; RefreshItem(pTrainDummy);//AntiChrist } } } break; case 15: //reactive armor pc_s->ra=0; break; case 16: //Explosion potion messages Tauriel sprintf((char*)temp, "%i", more3); sysmessage(calcSocketFromChar(s), (char*)temp); // crashfix, LB break; case 17: //Explosion potion explosion Tauriel s=calcCharFromSer(getSour()); explodeitem(calcSocketFromChar(s), calcItemFromSer(getDest())); //explode this item break; case 18: //Polymorph spell by AntiChrist 9/99 if(pc_s->polymorph)//let's ensure it's under polymorph effect! { pc_s->id1=pc_s->xid1; pc_s->id2=pc_s->xid2; pc_s->polymorph=false; teleport(s); } break; case 19: //Incognito spell by AntiChrist 12/99 reverseIncognito(pc_s); break; case 20: // LSD potions, LB 5'th nov 1999 k=calcSocketFromChar(s); if (k==-1) return; LSD[k]=0; sysmessage(k,"LSD has worn off"); pc_s->stm=3; // stamina near 0 pc_s->mn=3; pc_s->hp=pc_s->hp/7; impowncreate(k,s,0); all_items(k); // absolutely necassairy here !!! for (ccc =0; ccc<charcount; ccc++) // that hurts, but there's no other good way { if (chardist(s,ccc)<15 && ( online(ccc) || chars[ccc].isNpc() ) ) updatechar(ccc); } break; case 21: int toDrop; toDrop = more1; //Effect->more1; if( ( pc_s->baseskill[PARRYING] - toDrop ) < 0 ) pc_s->baseskill[PARRYING] = 0; else pc_s->baseskill[PARRYING] -= toDrop; break; case 33: // delayed hiding for gms after flamestrike effect k=calcSocketFromChar(s); sysmessage(k,"You have hidden yourself well."); pc_s->hidden=1; updatechar(s); break; case 34: // delayed unhide for gms // Changed to be uniform with delayed hideing (Aldur) k = calcSocketFromChar(s); sysmessage(k, "You are now visible."); pc_s->hidden = 0; updatechar(s); break; case 35: //heals some pf - solarin int iHp; iHp=(int)more1; pc_s->hp+=iHp; updatestats(s, 0); if (!more2) tempeffect(s,s,35,more1+1,1,more3,0); break; default: LogErrorVar("Fallout of switch (num = %i).", num); break; } Items->CheckEquipment(s); //AntiChrist - checks equipments for stats requirements }
/////////////////////////////////////////////////////////////////// // Function name : racProcessInput // Description : processes input from socket s // Return type : void // Author : Xanathar // Argument : int s -> socket to process input // Changes : rewritten by Anthalir void RemoteAdmin::ProcessInput(int s) { char inp2[1024]= {'\0'}; char *inp= inp2; UI32 i; if (rac_port==0) return; if( !strncmp(&inputbufs[s][0], "!!", 2) ) { strcpy(inp2, oldinp[s]); } else { int j=0; for (int i=0; i<inputptrs[s]; i++) { if (inputbufs[s][i]!='\b') // \b = bell inp2[j++] = inputbufs[s][i]; } strncpy(oldinp[s], inp2, sizeof(oldinp[s])-1); } // remove spaces and tabulations at string start while( isspace(inp[0]) ) inp++; if (status[s]==RACST_STDIN) { for (i=0; i< strlen(inp); i++) { if ((inp[i]>='a')&&(inp[i]<='z')) inp[i] -= 'a'-'A'; if (inp[i]==' ') break; } } inputptrs[s] = 0; if (status[s]==RACST_CHECK_USR) { strcpy(loginname[s], inp); Printf(s, "password : "******"\r\nAccess Denied.\r\nPress any key to get disconnected..."); ConOut("Access Denied on Remote Console for user '%s' with pass '%s'\n", loginname[s], inp); status[s]=RACST_ACCESS_DENIED; return; } else { status[s]=RACST_STDIN; Printf(s,"\r\n\r\n"); Printf(s,"------------------------------------------------------------------------\r\n"); Printf(s,"Welcome to the administration console\r\n"); Printf(s,"\r\nType HELP to receive help on commands.\r\n"); Printf(s,"If you are not authorized to access this system\r\n"); Printf(s,"please exit immediately by typing the EXIT command\r\n"); Printf(s,"or by closing your client. Any other unauthorized\r\n"); Printf(s,"action can be persecuted by law.\r\n"); Printf(s,"\r\n"); // re-enable local echo for client Printf(s, "%c%c%c", IAC, DO, ECHO); Printf(s, "%c%c%c", IAC, WONT, ECHO); ConOut("Authorised acces on Remote Console by user %s\n", loginname[s]); return; } } if (status[s]!=RACST_STDIN) return; if (!strcmp(inp,"PDUMP")) { Printf(s, "Performace Dump:\r\n"); Printf(s, "Network code: %fmsec [%i]", (float)((float)networkTime/(float)networkTimeCount), networkTimeCount); Printf(s,"Timer code: %fmsec [%i]" , (float)((float)timerTime/(float)timerTimeCount) , timerTimeCount); Printf(s,"Auto code: %fmsec [%i]" , (float)((float)autoTime/(float)autoTimeCount) , autoTimeCount); Printf(s,"Loop Time: %fmsec [%i]" , (float)((float)loopTime/(float)loopTimeCount) , loopTimeCount); Printf(s,"Simulation Cycles/Sec: %f" , (1000.0*(1.0/(float)((float)loopTime/(float)loopTimeCount)))); return; } if (!strcmp(inp,"WHO")) { if(now==0) { Printf(s,"There are no users connected.\r\n"); return; } int i, j=0; Printf(s,"Current Users in the World:\r\n"); for (i=0;i<now;i++) { P_CHAR pc_i=MAKE_CHAR_REF(currchar[i]); if( ISVALIDPC(pc_i) && clientInfo[i]->ingame ) //Keeps NPC's from appearing on the list { j++; Printf(s, " %i) %s [%08x]\r\n", j, pc_i->getCurrentNameC(), pc_i->getSerial32()); } } Printf(s, "Total Users Online: %d\r\n", j); Printf(s, "End of userlist\r\n"); return; } if (!strcmp(inp,"QUIT") || !strcmp(inp, "EXIT")) { Printf(s, "Bye %s ! :)\r\n\r\n", loginname[s]); Disconnect(s); return; } if (!strcmp(inp,"HELP")) { Printf(s,"!! : repeats the last command\r\n"); Printf(s,"WHO : displays logon players\r\n"); Printf(s,"QUIT : close the connection\r\n"); Printf(s,"EXIT : close the connection\r\n"); Printf(s,"PDUMP : displays performance dump\r\n"); Printf(s,"SAVE : saves the world\r\n"); Printf(s,"SHUTDOWN : shuts the server\r\n"); Printf(s,"ABORT : shuts the server WITHOUT saving\r\n"); Printf(s,"BROADCAST, BC or '!' <msg> : broadcasts a message to everyone\r\n"); Printf(s,"CFG <section>.<property>=<value> : sets a server.cfg setting dynamically\r\n"); Printf(s,"ADDACCT <name>,<pwd> : creates a new account\r\n"); Printf(s,"REMACCT <name> : remove an account\r\n"); Printf(s,"CHANGEACCTPWD <name>,<pwd> : change an account password\r\n"); Printf(s,"RELOADCRON : reloads the crontab.scp file\r\n"); Printf(s,"AMXCALL <function> : executes a function of override.sma\r\n"); Printf(s,"AMXRUN <program> : executes an external AMX program\r\n"); Printf(s,"AMXBUILD <sourcefile> <outputprogram> : compiles a Small program\r\n"); Printf(s,"RELOADBLOCKS : reload hosts_deny.scp\r\n"); Printf(s,"RELOADSMALL : recompile and reload small scritps\r\n"); return; } char tkn[1024]; char *cmd = NULL, *par2 = NULL; for (i=0; i< strlen(inp); i++) { if (inp[i]==' ') { tkn[i] = '\0'; cmd = inp+i+1; break; } else { tkn[i]=inp[i]; } } // before the splitting of arguments if (!strcmp(tkn,"CFG")) { if ((cmd==NULL)) { Printf(s,"Syntax is : CFG <section>.<property>=<value>\r\nExample : CFG SERVER.STATCAP=200\r\nSections and properties are the ones contained in server.scp\r\n"); return; } int n=cfg_command(cmd); if (n!=0) Printf(s, "Error number : %d\r\n", n); else Printf(s, "OK.\r\n"); return; } if (!strcmp(tkn,"AMXCALL")) { if ((cmd==NULL)) { Printf(s,"Syntax is : AMXCALL <function>\r\nExample : AMXCALL foo\r\n"); return; } AmxFunction::g_prgOverride->CallFn(cmd); return; } if (!strcmp(tkn,"AMXRUN")) { if ((cmd==NULL)) { Printf(s,"Syntax is : AMXRUN <program>\r\nExample : AMXRUN myprog.amx\r\n"); return; } AmxProgram *prg = new AmxProgram(cmd); prg->CallFn(-1); safedelete(prg); return; } if (cmd!=NULL) { for (i=0; i< strlen(cmd); i++) { if ((cmd[i]==',')||(cmd[i]==' ')) { par2 = cmd+i+1; cmd[i] = '\0'; break; } } } if (!strcmp(inp,"SAVE")) { if ( !cwmWorldState->Saving() ) { Printf(s, "Saving worldfile..."); cwmWorldState->saveNewWorld(); saveserverscript(); Printf(s, "[DONE]\r\n"); Printf(s, "OK.\r\n"); } return; } if (!strcmp(inp,"SHUTDOWN")) { ConOut("NoX-Wizard: Immediate Shutdown initialized from Remote Console!\n"); Printf(s, "Bye! :)\r\n\r\n"); keeprun=0; return; } #ifdef DEBUG if (!strcmp(inp,"---CRASH")) { //this command is usefull to test crash recovery :) char *p = NULL; p[0] = 'X'; Printf(s, "OK.\r\n"); return; } #endif if (!strcmp(inp,"ABORT")) { exit(3); return; } if (!strcmp(inp,"RELOADCRON")) { killCronTab(); initCronTab(); return; } if (!strcmp(inp,"RELOADBLOCKS")) { Network->LoadHosts_deny(); Printf(s,"hosts_deny.scp reloaded."); return; } //wad } if (!strcmp(inp,"RELOADSMALL")) { initAmxEvents(); LoadOverrides (); AMXEXECV(AMXT_SPECIALS,0,AMX_AFTER); Printf(s,"Recompiled Small scripts"); return; } if ((!strcmp(tkn,"BROADCAST"))||(!strcmp(tkn,"BC"))||(!strcmp(tkn,"!"))) { if ((cmd==NULL)) { Printf(s,"Syntax is : BROADCAST <message>\r\nExample : BROADCAST Warning restarting server!\r\n"); return; } if (par2!=NULL) sysbroadcast("%s %s", cmd, par2); else sysbroadcast("%s", cmd); Printf(s, "OK.\r\n"); return; } if (!strcmp(tkn,"ADDACCT")) { if ((cmd==NULL)||(par2==NULL)) { Printf(s,"Syntax is : ADDACCT <name>,<password>\r\nExample : ADDACCT administrator,password\r\n"); return; } int acc = Accounts->CreateAccount(cmd, par2); if ( acc != INVALID ) { Printf(s, "Account %d created\r\n Name : %s\r\n Pass : %s\r\n", acc,cmd,par2); Printf(s, "[ OK ] \r\n"); } else { Printf(s, "Account %s not created. Username existant.\r\n", cmd); Printf(s, "[ERRORS]\r\n"); } return; } if ( !strcmp(tkn,"REMACCT") ) { if ((cmd==NULL)) { Printf(s,"Syntax is : REMACCT <name>\r\nExample : REMACCT administrator\r\n"); return; } if ( Accounts->RemoveAccount(cmd) ) { Printf(s, "Account %s deleted\r\n", cmd); Printf(s, "[ OK ]\r\n"); } else { Printf(s, "Account %s not deleted\r\n", cmd); Printf(s, "[ERRORS]\r\n"); } return; } if ( !strcmp(tkn,"CHANGEACCTPWD") ) { if ((cmd==NULL)||(par2==NULL)) { Printf(s,"Syntax is: CHANGEACCTPWD <name>,<password>\r\nExample : CHANGEACCTPWD administrator,newpassword\r\n"); return; } ACCOUNT acc = Accounts->GetAccountByName(cmd); if ( acc != INVALID ) { Accounts->ChangePassword(acc, par2); Printf(s, "Account %d has new password\r\n Password : %s\r\n", acc, par2); Printf(s, "[ OK ] \r\n"); } else { Printf(s, "Password of account %s not changed. Username not existant.\r\n", cmd); Printf(s, "[ERRORS]\r\n"); } return; } if (!strcmp(tkn,"AMXBUILD")) { if ((cmd==NULL)||(par2==NULL)) { Printf(s,"Syntax is : AMXBUILD <source> <output>\r\nExample : AMXBUILD myprog.sma myprog.amx\r\n"); return; } Printf(s,"Initializing build : NOTE that output will go to the main console. Sorry for that :(\r\n"); Printf(s,"Building..."); char *argv[4]; argv[0] = "noxwizard.internal.compiler"; argv[1] = new char[50]; argv[2] = new char[50]; argv[3] = new char[50]; strncpy(argv[1], cmd, 49); strncpy(argv[2], par2, 49); strncpy(argv[3], "", 49); int ret = compiler_main(3, (char **)argv); if (ret==0) Printf(s,"[ OK ]\r\n"); else if (ret==1) Printf(s,"[WARNINGS]\r\n"); else if (ret>1) Printf(s,"[ERRORS]\r\n"); delete argv[1]; delete argv[2]; delete argv[3]; return; } Printf(s,"Unknown command entered.\r\n"); }