Exemple #1
0
void NPC_WarpWarpCharacter(int warpnpcindex, int charaindex) {
  char arg[NPC_UTIL_GETARGSTR_BUFSIZE];
  int i = 0;
#ifdef _NEW_WARPPOINT
  char buf1[256], buf2[256], buf3[256], freemsg[256];
  int nBefind = FALSE;
  struct wapepoints {
    int m_floor;
    int m_x;
    int m_y;
  } Wpoint[10] = {
      {-1, 0, 0},
      {-1, 0, 0},
      {-1, 0, 0},
      {-1, 0, 0},
      {-1, 0, 0},
      {-1, 0, 0},
      {-1, 0, 0},
      {-1, 0, 0},
      {-1, 0, 0},
      {-1, 0, 0}
  };
  int iRand = 0;
#endif
  if(CHAR_getInt(charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) {
    return;
  }

  if(NPC_Util_GetArgStr(warpnpcindex, arg, sizeof(arg)) == NULL) {
    return;
  }

  {
    char token[16];
    int floor = 0, x = 0, y = 0;
    int ret;

#ifdef _NEW_WARPPOINT
    i = 1;
    if(strstr(arg, "FREEMORE") != NULL) {
      int k = 1, pw = -1;
      while(getStringFromIndexWithDelim(arg, "OVER", i, buf1, sizeof(buf1)) != FALSE) {
        i++;
        if(NPC_Util_GetStrFromStrWithDelim(buf1, "FREE", buf2, sizeof(buf2)) == NULL)
          continue;
        if(NPC_ActionPassCheck(warpnpcindex, charaindex, buf2) == FALSE) {
          continue;
        } else {
          iRand = 0;
          if(NPC_Util_GetStrFromStrWithDelim(buf1, "TO", buf2, sizeof(buf2)) != FALSE) {
            k = 1;
            while(getStringFromIndexWithDelim(buf2, "&", k, freemsg, sizeof(freemsg)) != FALSE) {
              k++;
              if(getStringFromIndexWithDelim(freemsg, ",", 1, buf3, sizeof(buf3)) == FALSE)
                break;
              Wpoint[iRand].m_floor = atoi(buf3);
              if(getStringFromIndexWithDelim(freemsg, ",", 2, buf3, sizeof(buf3)) == FALSE)
                break;
              Wpoint[iRand].m_x = atoi(buf3);
              if(getStringFromIndexWithDelim(freemsg, ",", 3, buf3, sizeof(buf3)) == FALSE)
                break;
              Wpoint[iRand].m_y = atoi(buf3);
              iRand++;
              nBefind = TRUE;
              if(iRand >= arraysizeof(Wpoint))
                break;
            }
            break;
          }
        }
        if(nBefind == TRUE)
          break;
      }

      if(nBefind == FALSE || iRand <= 0) {  //没找到条件
        floor = CHAR_getInt(warpnpcindex, CHAR_FLOOR);
        x = CHAR_getInt(warpnpcindex, CHAR_X);
        y = CHAR_getInt(warpnpcindex, CHAR_Y);
      } else {
        pw = RAND(0, (iRand - 1));
        floor = Wpoint[pw].m_floor;
        x = Wpoint[pw].m_x;
        y = Wpoint[pw].m_y;
        if(NPC_Util_GetStrFromStrWithDelim(arg, "CHECKPARTY", buf1, sizeof(buf1)) != NULL) {
          if(strstr(buf1, "TRUE") != NULL) {
            if(CHAR_getWorkInt(charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER) {
              CHAR_DischargeParty(charaindex, 0); // 拆队
            }
          }
        }
        if(MAP_IsValidCoordinate(floor, x, y) == FALSE) {
          print("*Warp NPC:Invalid %d %d %d", floor, x, y);
          return;
        }
        k = 0;
      }
    } else {
#endif
      ret = getStringFromIndexWithDelim(arg, "|", 1, token, sizeof(token));
      if(ret == FALSE)return;
      floor = atoi(token);

      ret = getStringFromIndexWithDelim(arg, "|", 2, token, sizeof(token));
      if(ret == FALSE)return;
      x = atoi(token);

      ret = getStringFromIndexWithDelim(arg, "|", 3, token, sizeof(token));
      if(ret == FALSE)return;
      y = atoi(token);
#ifdef _NEW_WARPPOINT
    }
#endif
    {
      int ff = floor;

      int of = CHAR_getInt(charaindex, CHAR_FLOOR);
      int fd = CHAR_getWorkInt(charaindex, CHAR_WORKFD);
      int eqen = getEqNoenemy(fd);
      if(eqen < 200) {
        if(eqen >= 120) {
          if((ff == 100) || (ff == 200) || (ff == 300) || (ff == 400) || (ff == 500)) {
            if((of != 100) && (of != 200) && (of != 300) && (of != 400) && (of != 500)) {
              CHAR_talkToCli(charaindex, -1, "太阳神的首饰发出一道奇异的光芒,隐藏了你的行踪。", CHAR_COLORWHITE);
            }
          } else {
            if((of == 100) || (of == 200) || (of == 300) || (of == 400) || (of == 500)) {
              CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE);
            }
          }
        } else if(eqen >= 80) {
          if((ff == 100) || (ff == 200) || (ff == 300) || (ff == 400)) {
            if((of != 100) && (of != 200) && (of != 300) && (of != 400)) {
              CHAR_talkToCli(charaindex, -1, "太阳神的首饰发出一道奇异的光芒,隐藏了你的行踪。", CHAR_COLORWHITE);
            }
          } else {
            if((of == 100) || (of == 200) || (of == 300) || (of == 400)) {
              CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE);
            }
          }
        } else if(eqen >= 40) {
          if((ff == 100) || (ff == 200)) {
            if((of != 100) && (of != 200)) {
              CHAR_talkToCli(charaindex, -1, "太阳神的首饰发出一道奇异的光芒,隐藏了你的行踪。", CHAR_COLORWHITE);
            }
          } else {
            if((of == 100) || (of == 200)) {
              CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE);
            }
          }
        }
      }
    }

#ifdef _DROPSTAKENEW
    {
      i = 0;
      for(i = 0; i < MAXSTAKENUM; i++) {
        if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + i) > 0) {
          char tmpbuf[256];
          snprintf(tmpbuf, sizeof(tmpbuf), "由於你离开了房间,所以将无法取回彩券!");
          CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + i, 0);
          CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW);
        }
      }
      CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, 0);
#ifdef _FIX_GAMBLENUM
      if(CHAR_getInt(charaindex, CHAR_GAMBLENUM) < 0)
        CHAR_setInt(charaindex, CHAR_GAMBLENUM, 0);
#endif
    }
#endif
    if(floor == -1) {
      return;
    } else {
      if(MAP_IsValidCoordinate(floor, x, y) == FALSE) {
        print("Warp NPC:Invalid %d %d %d", floor, x, y);
        return;
      }

      CHAR_warpToSpecificPoint(charaindex, floor, x, y);
    }
  }
}
Exemple #2
0
/*------------------------------------------------------------
 * 啖  允月[
 * 娄醒
 *  index       int     平乓仿及奶件犯永弁旦
 *  dir         int       轾
 * 忒曰袄
 *  CHAR_WALKRET
 ------------------------------------------------------------*/
static CHAR_WALKRET CHAR_walk_move( int charaindex, int dir )
{
    int     i;
    int     fx,fy,ff;
    int     ox,oy,of;
    int     objbuf[128];
    int     objbufindex=0;
    int     notover=FALSE;
    int     retvalue=CHAR_WALKSUCCESSED;

    if( !CHAR_CHECKINDEX( charaindex )) return CHAR_WALKSYSTEMERROR;
    ox = CHAR_getInt(charaindex,CHAR_X);
    oy = CHAR_getInt(charaindex,CHAR_Y);
    of = CHAR_getInt(charaindex,CHAR_FLOOR);
    CHAR_getCoordinationDir( dir,ox,oy,1,&fx,&fy);
    ff = of;

    if( CHAR_getInt( charaindex,CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){
        RECT    walkr;
        POINT   nextp;
        int npccreateindex;
        npccreateindex = CHAR_getInt( charaindex,CHAR_NPCCREATEINDEX );
        if( CHAR_isInvincibleArea( ff,fx,fy)) {
            CHAR_setInt(charaindex,CHAR_DIR,dir);
            retvalue = CHAR_WALKEXTEND;
            goto CHAR_AFTERWALK;
        }
        if( NPC_isBoundarySet( npccreateindex ) &&
            NPC_createGetRECT( npccreateindex,&walkr ) == TRUE )
        {
            nextp.x = fx;
            nextp.y = fy;
            if( PointInRect( &walkr,&nextp ) == FALSE ){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALKEXTEND;
                goto CHAR_AFTERWALK;
            }
        }else{
            ;
        }
    }


    if( CHAR_getFlg( charaindex, CHAR_ISBIG ) == 1 ){
        static POINT offset[5]={
            { 0,-1},
            {-1, 0},
            { 0, 0},
            { 1, 0},
            { 0, 1},
        };
        int     k;
        for( k=0 ; k<5; k++ ){
            if( !MAP_walkAble( charaindex, ff, fx+offset[k].x,
                               fy+offset[k].y )){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }
        }

    }else{
        if( CHAR_getDX(dir)*CHAR_getDY(dir) == 0 ){
            if( !MAP_walkAble( charaindex,ff, fx, fy ) ){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }
        }else{
            int     xflg,yflg;
            if( !MAP_walkAble( charaindex,ff, fx, fy ) ){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }

            xflg = MAP_walkAble( charaindex,of, ox+CHAR_getDX(dir), oy );
            yflg = MAP_walkAble( charaindex,of, ox, oy+CHAR_getDY(dir) );

            if( !xflg || !yflg ) {
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }
        }
    }
    objbufindex = CHAR_getSameCoordinateObjects( objbuf, arraysizeof( objbuf ), ff,fx,fy );
    for( i = 0 ; i < objbufindex ; i ++ ){
        int     objindex= objbuf[i];
        switch( OBJECT_getType(objindex) ){
        case OBJTYPE_CHARA:
            if( !CHAR_getFlg( OBJECT_getIndex(objindex),CHAR_ISOVERED) ){
            	if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){
	            	printf("自动删除一个问题对象!");
	        			endObjectOne(objindex);
	        			break;
	        		}
              notover= TRUE;
            }
            break;
        case OBJTYPE_ITEM:
            if( !ITEM_getInt( OBJECT_getIndex(objindex), ITEM_ISOVERED ) )
                notover= TRUE;
            break;
        case OBJTYPE_GOLD:
            break;
        default:
            break;
        }
    }
    if( notover == TRUE ){
        CHAR_setInt(charaindex,CHAR_DIR,dir);
        retvalue = CHAR_WALKHITOBJECT;
    }else{
        for( i = 0 ; i < objbufindex ; i ++ ){
            typedef void (*PREOFUNC)(int,int);
            PREOFUNC   pfunc=NULL;
            int     objindex=objbuf[i];
            switch( OBJECT_getType(objindex) ){
            case OBJTYPE_CHARA:
                pfunc = (PREOFUNC)CHAR_getFunctionPointer(
                    OBJECT_getIndex(objindex),
                    CHAR_PREOVERFUNC);
                break;
            case OBJTYPE_ITEM:
                pfunc = (PREOFUNC)ITEM_getFunctionPointer(
                    OBJECT_getIndex(objindex),
                    ITEM_PREOVERFUNC);
                break;
            case OBJTYPE_GOLD:
                break;
            default:
                break;
            }
            if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex );
        }

        CHAR_setInt(charaindex,CHAR_X,fx);
        CHAR_setInt(charaindex,CHAR_Y,fy);
        CHAR_setInt(charaindex,CHAR_FLOOR,ff);
        CHAR_setInt(charaindex,CHAR_DIR,dir);

        {
            int objindex;
            int ox,oy,of;
            objindex = CHAR_getWorkInt( charaindex,CHAR_WORKOBJINDEX );
            of = OBJECT_setFloor(objindex,
                                 CHAR_getInt(charaindex,CHAR_FLOOR));
            ox = OBJECT_setX(objindex,CHAR_getInt(charaindex,CHAR_X));
            oy = OBJECT_setY(objindex,CHAR_getInt(charaindex,CHAR_Y));
            if( !MAP_objmove( objindex, of,ox,oy,ff,fx,fy ) ){
                /*  仇氏卅氏升丹仄方丹手卅中    */
                fprint( "ERROR MAP_OBJMOVE objindex=%d(%s)\n",objindex,
                	CHAR_getUseName( charaindex ) );
            }
        }

        CHAR_setInt(charaindex,CHAR_WALKCOUNT,
                    CHAR_getInt(charaindex,CHAR_WALKCOUNT) + 1 );


        for( i = 0 ; i < objbufindex ; i ++ ){
            typedef void (*POSTOFUNC)(int,int);
            POSTOFUNC   pfunc=NULL;
            int     objindex=objbuf[i];

            switch( OBJECT_getType(objindex) ){
            case OBJTYPE_CHARA:
                pfunc = (POSTOFUNC)CHAR_getFunctionPointer(
                    OBJECT_getIndex(objindex),
                    CHAR_POSTOVERFUNC);
                break;
            case OBJTYPE_ITEM:
                pfunc = (POSTOFUNC)ITEM_getFunctionPointer( OBJECT_getIndex(objindex), ITEM_POSTOVERFUNC);
                break;
            case OBJTYPE_GOLD:
                break;
            default:
                break;
            }
            if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex );
        }
        objbufindex = CHAR_getSameCoordinateObjects(objbuf, arraysizeof(objbuf), of, ox, oy );
        for( i=0 ;i<objbufindex;i++){
            typedef void (*OFFFUNC)(int,int);
            OFFFUNC   ofunc=NULL;
            int     objindex = objbuf[i];

            switch( OBJECT_getType( objindex ) ){
            case OBJTYPE_CHARA:
                ofunc = (OFFFUNC)CHAR_getFunctionPointer( OBJECT_getIndex(objindex), CHAR_OFFFUNC);
                break;
            case OBJTYPE_ITEM:
                /*    卞窒手仄卅中  */
                break;
            case OBJTYPE_GOLD:
                /*    卞窒手仄卅中  */
                break;
            default:
                break;
            }
            if( ofunc )ofunc( OBJECT_getIndex(objindex), charaindex );

        }
    }
CHAR_AFTERWALK:
    if( retvalue == CHAR_WALK1357 || retvalue == CHAR_WALKHITOBJECT ){
	    {
	        int     opt[2] = { ox, oy};
	        CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex,
	                                             CHAR_WORKOBJINDEX),
	                             CHAR_ACTWALK,opt,2,TRUE );
	    }
        CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY, "");
		if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) {
		    CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex, CHAR_WORKOBJINDEX),
    		                     CHAR_ACTWARP,NULL,0,TRUE);
		}
    }else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){

		BOOL	flg = FALSE;
		int		par;
		int		count;
		CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1 );
		if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){
			CHAR_sendCharaAtWalk( charaindex, of,ox,oy,CHAR_getDX(dir), CHAR_getDY(dir));
		}

	    {
	        int     opt[2] = { ox, oy};
	        CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex,
	                                             CHAR_WORKOBJINDEX),
	                             CHAR_ACTWALK,opt,2,TRUE );
	    }
		if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) {
			CHAR_sendMapAtWalk( charaindex, of,
								ox,oy,
								CHAR_getInt( charaindex, CHAR_X),
								CHAR_getInt( charaindex, CHAR_Y));
		}
		count = CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT);
		if( count > 0 ) {
			CHAR_setWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT, count -1);
			if( count -1 == 0 ) {
				CHAR_talkToCli( charaindex, -1, "道具的效力已到。", CHAR_COLORWHITE);
			}
		}
		par = ENCOUNT_getEncountPercentMin( charaindex, of,ox,oy);
		if( par != -1 ) {
			if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN) != par ){
				flg = TRUE;
				CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, par);
			}
		}

		par = ENCOUNT_getEncountPercentMax( charaindex, of,ox,oy);
		if( par != -1 ) {
			if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX) != par ){
				flg = TRUE;
				CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, par);
			}
		}
		// Arminius 7.12 login announce
		/*
		{
		  int enfd = getfdFromCharaIndex( charaindex );
		  if (CONNECT_get_announced(enfd)==0) {
		    // Robin 0720
		    //AnnounceToPlayer(charaindex);
		    AnnounceToPlayerWN( enfd );
		    CONNECT_set_announced(enfd,1);
		  }
		}
		*/
		// Arminius 6.22 check Encounter
		// Nuke 0622: Provide No Enemy function
		{
		  int enfd = getfdFromCharaIndex( charaindex );
		  int eqen = getEqNoenemy( enfd );	// Arminius 7.2: Ra's amulet
		  int noen = getNoenemy(enfd);

          // Arminius 7.31 cursed stone
      if (getStayEncount(enfd)>0) {
			  clearStayEncount(enfd);
		  }
		  //print("\n enfd=%d,eqen=%d,noen=%d", enfd, eqen, noen);

		  // Arminius 7.2 Ra's amulet
		  if (eqen>=200) {
		    noen=1;
		  } else if (eqen>=120) {
		    if ((ff==100)||(ff==200)||(ff==300)||(ff==400)||(ff==500)) noen=1;
		  } else if (eqen>=80) {
		    if ((ff==100)||(ff==200)||(ff==300)||(ff==400)) noen=1;
		  } else if (eqen>=40) {
		    if ((ff==100)||(ff==200)) noen=1;
		  }


		  //print("\n noen=%d", noen);
		  if (noen==0) {
				int maxep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX);
		    int minep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN);
		    int cep = CONNECT_get_CEP(enfd);

		    if (cep<minep) cep=minep;
		    if (cep>maxep) cep=maxep;
		    if (CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)==BATTLE_CHARMODE_NONE) {
				int entflag=1;
				{
					int objindex,index;
					OBJECT obj;
					for ( obj = MAP_getTopObj( ff, fx, fy); obj; obj = NEXT_OBJECT( obj)) {
						objindex = GET_OBJINDEX( obj);
						if (OBJECT_getType( objindex) == OBJTYPE_CHARA) {
							int etype;
							index = OBJECT_getIndex( objindex);
							if (!CHAR_CHECKINDEX( index)) continue;
							if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPENPCENEMY &&
								CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE) == CHAR_EVENT_ENEMY )	{
								CHAR_setInt( charaindex, CHAR_X, ox);
								CHAR_setInt( charaindex, CHAR_Y, oy);
								lssproto_XYD_send( getfdFromCharaIndex(charaindex),
								CHAR_getInt( charaindex, CHAR_X ),
								CHAR_getInt( charaindex, CHAR_Y ),
								CHAR_getInt( charaindex, CHAR_DIR ) );
								break;
							}
							etype = CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE);
							if (etype!=CHAR_EVENT_NONE) {
								if (etype==CHAR_EVENT_WARP) entflag=0;
							}
						}
					}
				}
#ifdef _ENEMY_ACTION
				if( rand()%(120*getEnemyAction()) < cep ){
#else
		      if (rand()%120<cep){	// Arminius 6.28 lower encounter prob.
#endif
					if (entflag) {
#ifdef _Item_MoonAct
						if( getEqRandenemy( enfd) > 0 )	{
							int Rnum=0;
							int RandEnemy = getEqRandenemy( enfd);
							Rnum = RAND(0,100);
							if( Rnum > RandEnemy )	{
#endif
								//encounter!!
								cep = minep;
								lssproto_EN_recv(enfd,
								CHAR_getInt(charaindex,CHAR_X),
								CHAR_getInt(charaindex,CHAR_Y));
#ifdef _Item_MoonAct
							}
						}else{
								cep = minep;
								lssproto_EN_recv(enfd,
								CHAR_getInt(charaindex,CHAR_X),
								CHAR_getInt(charaindex,CHAR_Y));
						}
#endif
					}
		      } else {
		        if (cep<maxep) cep++;
		      }
		    }
		    CONNECT_set_CEP(enfd, cep);
		  }
		}
		if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE )!= CHAR_PARTY_CLIENT ){
			CHAR_setFlg( charaindex, CHAR_ISWARP, 0);
		}
    }
    else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ||