int NPC_TimeWarpCheck(int meindex, char *buf, int mode) { LSTIME nowlstime; char *time[4] = {"N", "M", "A"}; int now; int i = 0; RealTimeToLSTime(NowTime.tv_sec, &nowlstime); now = getLSTime(&nowlstime); if(mode == 0) { for(i = 0; i < 3; i++) { if(strstr(buf, time[i]) != NULL) { return i; } } return -1;; } if(mode == 1) { if(now == CHAR_getWorkInt(meindex, CHAR_WORKEVENTTYPE)) { return now; } return -1; } return -1; }
/** まわりに何かが起こったときに呼ばれる*/ void NPC_TimeManWatch( int meobjindex, int objindex, CHAR_ACTION act, int x,int y,int dir, int* opt,int optlen ) { int meindex=0; int index; LSTIME nowlstime; int born; int dead; if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return; index = OBJECT_getIndex( objindex); /* プレイヤーにのみ反応する */ if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; meindex = OBJECT_getIndex( meobjindex); born = CHAR_getWorkInt( meindex , E_INT_BORN ); dead = CHAR_getWorkInt( meindex , E_INT_DEAD ); // print("now_hour=%d",nowlstime.hour); /* 時間を見て状態を決める */ if(born < dead){ RealTimeToLSTime( NowTime.tv_sec, &nowlstime); if( (born < nowlstime.hour) && (dead > nowlstime.hour) ){ if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC)) return; CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, CHAR_getWorkInt( meindex, E_INT_GRAPHIC)); CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); CHAR_setWorkInt(meindex,E_INT_MODE,0); CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); }else{ /*-消えている--*/ if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)) return; CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)); CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); CHAR_setWorkInt(meindex,E_INT_MODE,1); CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); } }else{ RealTimeToLSTime( NowTime.tv_sec, &nowlstime); if( (born < nowlstime.hour && 1024 > nowlstime.hour) || ( 0 < nowlstime.hour && dead > nowlstime.hour) ){ if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC)) return; CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, CHAR_getWorkInt( meindex, E_INT_GRAPHIC)); CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); CHAR_setWorkInt(meindex,E_INT_MODE,0); CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); }else{ if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)) return; CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)); CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); CHAR_setWorkInt(meindex,E_INT_MODE,1); CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); } } }