⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atcomand.c

📁 CS反恐精英1.6的部分C源代码。
💻 C
📖 第 1 页 / 共 2 页
字号:
//
// PvPGN YARE MOD V1.0 (Yeat Another Ragnarok Emulator) - (Server)
// Copyright (c) Project-YARE & PvPGN 2003
// www.project-yare.com
// forum.project-yare.net
// www.pvpgn.org
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//atcommand.c : Command Functions

{
/************************************************************************************/

// Check if the item ID that was asked for exists
int is_item(int object){
	char str[80];
	FILE *fp;
	int item_id=0,result=0;

	if((fp = fopen("item_all.list","r"))==NULL){
		printf("Open the item list!\n");
	}
	while(fgets(str,80,fp)!=NULL){
		sscanf(str,"%d",&item_id);
		if(item_id==object){
			result=1;//found
				break;
		}
	}
	fclose(fp);
	return result;
}
  	
      	char *message;
      	message = strchr(RFIFOP(fd,4)+strlen(sd->status.name),'!');
if((int*)message!=NULL){//when ! appears in a message
	  	char comand[40];	//enters system command strings
	  	char temp0[40];		//1st argument
	  	char temp1[24];		//2nd argument
//	  	char temp2[40];		//3rd argument
	  	char moji[200];		//long character string
      	int  x=0,y=0,z=0;	//coordinates
      	int i;

		struct mmo_charstatus *p;
   		sscanf(message,"%s",comand);
  		p=&sd->status;
 if(sd->account_id < 100000) { 
		sscanf(message,"%s",comand);
		if(strncmp(comand,"!save",5)==0){
					char moji[200];
			strcpy(p->last_point.map,sd->mapname);
			strcpy(p->save_point.map,sd->mapname);
			p->last_point.x = sd->x;
			p->save_point.x = sd->x;
			p->last_point.y = sd->y;
			p->save_point.y = sd->y;
			mmo_char_save(sd);
					strcpy(moji,"Location saved.");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
			goto idou;//hide the !command text from other users
		}
 }

 if(sd->account_id > 100000) { 
//!rura and !map commands
//!rura or !map <map filename [倶, y cords]>
	  sscanf(message,"%s%s%d%d",comand,temp0,&x,&y);
      if( (strncmp(comand,"!rura",5)==0) || (strncmp(comand,"!map",4)==0))  {
      	if(x>0 && x<325 && y>0 && y<325){
					char moji[200];
      	    for(i=0;map[i][0];i++){
    			if(strcmp(map[i],temp0)==0){
					char moji[200];
          			mmo_map_changemap(fd,sd,temp0,x,y,2);
					strcpy(moji,"Warped!");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
          			goto idou;//hide the !command text from other users
    				}
				}
					strcpy(moji,"Well..");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
          			goto idou;//hide the !command text from other users
      	}
	}


//!save command saves current location
//!save <no input>
		sscanf(message,"%s",comand);
		if(strncmp(comand,"!save",5)==0){
					char moji[200];
			strcpy(p->last_point.map,sd->mapname);
			strcpy(p->save_point.map,sd->mapname);
			p->last_point.x = sd->x;
			p->save_point.x = sd->x;
			p->last_point.y = sd->y;
			p->save_point.y = sd->y;
			mmo_char_save(sd);
					strcpy(moji,"Location saved.");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
			goto idou;//hide the !command text from other users
		}

//!load command returns to saved location
//!load <no input>
		sscanf(message,"%s",comand);
		if(strncmp(comand,"!load",5)==0){
					char moji[200];
			strcpy(sd->mapname,p->last_point.map);
			//strcpy(p->save_point.map,sd->mapname);
			sd->x = p->save_point.x;
			sd->y = p->save_point.y;
			mmo_map_changemap(fd,sd,sd->mapname,sd->x,sd->y,2);
					strcpy(moji,"Returning to saved location...");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
			goto idou;//hide the !command text from other users
		}

//!speed command alters walking speed 
//!speed <value[1-1000]> (the lower the value, the faster the movement, but with jerky motions)
		sscanf(message,"%s%d",comand,&x);
		if(strncmp(comand,"!speed",6)==0){
			if(x>0 && x<1000){
					char moji[200];
				sd->speed=x;
				sd->walktimer=x;
					strcpy(moji,"Speed changed!");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
			goto idou;//hide the !command text from other users
			}
		}
// Storage code
// !storage command
        	sscanf(message,"%s%d",comand,&x);
        	if( strncmp(comand,"!storage",8)==0 ) {
            		mmo_open_storage(fd);
            		goto idou;
        	}

			 		// WHO! - added by silentavenger
 		
 		sscanf(message,"%s",comand);
 			if(strncmp(comand,"!who",4)==0){
				int i;
				char moji[200];
					strcpy(moji,"Chars currently online:");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
					strcpy(moji,"");
 				for(i=0;i<FD_SETSIZE;i++)
 				{
 					if(session[i]!=NULL && session[i]->session_data!=NULL)
 					{
						struct map_session_data *sd=NULL;
						sd = session[i]->session_data;
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(sd->status.name);
					memcpy(WFIFOP(fd,4),sd->status.name,strlen(sd->status.name));
					WFIFOSET(fd,4 + strlen(sd->status.name));
 					}
 				}
 				goto idou;
			}
// Kill <nick> added by silentavenger
			sscanf(message,"%s%s",comand,temp1);
 			if(strncmp(comand,"!kill",5)==0){
				int cfd;
				char moji[200];
                cfd = find_char(temp1);
				if(cfd==-1)
				{
					strcpy(moji,"No such char.");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
 				    goto idou;
				}
				else
				{
					struct map_session_data *sd=NULL;
					sd = session[cfd]->session_data;
					mmo_char_save(sd);
					if(cfd==char_fd)
						char_fd=-1;
					if(sd && sd->state.auth){
						if(sd->chatID)
							mmo_map_leavechat(cfd,(struct mmo_chat*)sd->chatID,sd->status.name);
						del_block(&sd->block);
						WFIFOW(cfd,0)=0x80;
						WFIFOL(cfd,2)=sd->account_id;
						WFIFOB(cfd,6)=2;	//logout?
						mmo_map_sendarea(cfd,WFIFOP(cfd,0),packet_len_table[0x80], 1 );
						map_data[sd->mapno].users--;
						if(char_fd>0){
							memcpy(sd->status.last_point.map,sd->mapname,16);
							sd->status.last_point.x = sd->x;
							sd->status.last_point.y = sd->y;
							
							WFIFOW(char_fd,0)=0x2b01;
							WFIFOW(char_fd,2)=sizeof(sd->status)+12;
							WFIFOL(char_fd,4)=sd->account_id;
							WFIFOL(char_fd,8)=sd->char_id;
							memcpy(WFIFOP(char_fd,12),&sd->status,sizeof(sd->status));
							WFIFOSET(char_fd,WFIFOW(char_fd,2));
						}
					}
					close(cfd);
					delete_session(cfd);
				}
				goto idou;
			}	
   // Warpto by SilentAvenger
			sscanf(message,"%s%s",comand,temp1);
			if(strncmp(comand,"!warpto",7)==0){
				char moji[200];
				int cfd = find_char(temp1);
				if(cfd==-1)
				{
					strcpy(moji,"No such char.");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
					goto idou;
				}
				else
				{
					struct map_session_data *csd=NULL;
					csd = session[cfd]->session_data;
					mmo_map_changemap(fd,sd,csd->mapname,csd->x,csd->y,2);
					strcpy(moji,"Warped!");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
					goto idou;//hide the !command text from other users
				}
			}

//status modification
//!option 1 20 15
/*
	Value descriptions:
	R 0119 <ID>.l <param1>.w <param2>.w <param3>.w ?.B
	Visual effects:
	param1=01 petrification?
	param1=02 frozen with frostdiver?
	param1=03 傄傛傞
	param1=04 sleep
	param1=06 darkness(you can still walk)

	param2=01 poison
	param2=02 back spirit?
	param2=04 silence
	param2=16 darkness
	param3=01 sight or ruwach?
	param3=02 hiding?
	param3=04 cloaking
	param3=08 cart attachment
	param3=16 戦晅偒 (???)
	param3=32 Peco Peco riding
	param3=64 徚偊傞 (out?)
*/
		sscanf(message,"%s%d%d%d",comand,&x,&y,&z);
		if(strncmp(comand,"!option",7)==0){
					char moji[200];
			/*
			p->option consists of the following type of bit丠
			pram1	0000 0000 0000 0000
			pram2	0000 0000 0000 0000
			pram3	0000 0000 0000 0000

			*/

			WFIFOW(fd,0)=0x0119;
			WFIFOL(fd,2)=sd->account_id;
			WFIFOW(fd,6)=x;
			WFIFOW(fd,8)=y;
			WFIFOW(fd,10)=z;
			mmo_map_sendarea( fd, WFIFOP(fd,0), packet_len_table[0x0119], 0 );

			//x = x<<16;
			//y = y<<8;
			p->option=x|y|z;

					strcpy(moji,"Lots of changes!!");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
			goto idou;//hide the !command text from other users
		}
// !hide
sscanf(message,"%s",comand);
  if(strncmp(comand,"!hide",5)==0)
  {
    WFIFOW(fd,0)=0x0119;
    WFIFOL(fd,2)=sd->account_id;
    WFIFOW(fd,6)=00;
    WFIFOW(fd,8)=00;
  if(WFIFOW(fd,10)==04)
    WFIFOW(fd,10)=00;
    else
    WFIFOW(fd,10)=04;
    mmo_map_sendarea( fd, WFIFOP(fd,0), packet_len_table[0x0119], 0 );
    goto idou;
  }
//!jobchange switches jobs
//!jobchange (ID[0-12])
/*
Job descriptions: 
侽 novice
侾 swordsman
俀 mage
俁 archer
係 acolyte
俆 merchant
俇 theif
俈 knight
俉 priest
俋 wizard
侾侽 blacksmith
侾侾 hunter
侾俀 assassin

侾俁
*/

		sscanf(message,"%s%d",comand,&x);
		if(strncmp(comand,"!jobchange",10)==0){
			if(x>=0 && x<=12){
					char moji[200];
			mmo_map_jobchange(fd,x);
					strcpy(moji,"Job changed!");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
			goto idou;//hide the !command text from other users
			}
		}

//suicide
//!die <no input>
		sscanf(message,"%s",comand);
		if(strncmp(comand,"!die",4)==0){
					char moji[200];
			p->hp = 0;
			WFIFOW(fd,0) = 0xb0;
			WFIFOW(fd,2) = 0005;
			WFIFOL(fd,4) = p->hp;
			WFIFOSET(fd,8);
			WFIFOW(fd,0) = 0x80;
            WFIFOL(fd,2) = sd->account_id;
            WFIFOB(fd,6) =  1;
			mmo_map_sendarea( fd, WFIFOP(fd,0), packet_len_table[0x80], 0 );
					strcpy(moji,"T-Bone!");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
			goto idou;//hide the !command text from other users
		}

//!alive reanimates character
//!alive <no input>
		sscanf(message,"%s",comand);
		if(strncmp(comand,"!alive",6)==0){
					char moji[200];
					p->hp = p->max_hp;
					WFIFOW(fd,0) = 0xb0;
					WFIFOW(fd,2) = 0005;
					WFIFOL(fd,4) = p->hp;
					WFIFOSET(fd,8);

					WFIFOW(fd,0) = 0x148;
					WFIFOL(fd,2) = sd->account_id;
					mmo_map_sendarea( fd, WFIFOP(fd,0), packet_len_table[0x148], 0 );
					strcpy(moji,"Life! We have LIFE!!");
					WFIFOW(fd,0) = 0x8e;
					WFIFOW(fd,2) = 4 + strlen(moji);
					memcpy(WFIFOP(fd,4),moji,strlen(moji));
					WFIFOSET(fd,4 + strlen(moji));
			goto idou;//hide the !command text from other users
		}

//GM Chat (Voice of Heaven)
//!kami <text input>
      		sscanf(message,"%s%s",comand,moji);
		if(strncmp(comand,"!kami",5)==0){
			x=0;
			x=strlen(message)+4;
      WFIFOW(fd,0)=0x9a;
      WFIFOW(fd,2)=x;
      strcpy(WFIFOP(fd,4),moji);
      mmo_map_sendall(fd, WFIFOP(fd,0), WFIFOW(fd,2), 0 );
      goto idou;//hide the !command text from other users
      }

//HP,SP Recovery
//!heal <#(HP) #(SP)>
//if !heal is used with no input, HP/SP are fully healed
		x=y=0;
      		sscanf(message,"%s%d%d",comand,&x,&y);
		if(strncmp(comand,"!heal",5)==0){
					char moji[200];
			if(x==0 && y==0){//徣棯婰弎偱慡夞暅
				WFIFOW(fd,0) = 0x13d;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -