598 lines
20 KiB
C
598 lines
20 KiB
C
![]() |
#include "version.h"
|
|||
|
#include <stdio.h>
|
|||
|
#include <string.h>
|
|||
|
#include <math.h>
|
|||
|
#ifdef _REDHAT_V9
|
|||
|
#include <errno.h>
|
|||
|
#endif
|
|||
|
|
|||
|
#include "common.h"
|
|||
|
#include "util.h"
|
|||
|
#include "buf.h"
|
|||
|
#include "char_base.h"
|
|||
|
#include "char.h"
|
|||
|
#include "configfile.h"
|
|||
|
#include "encount.h"
|
|||
|
#include "enemy.h"
|
|||
|
|
|||
|
#ifdef _ADD_ENCOUNT // WON ADD <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#include "encount.h"
|
|||
|
#endif
|
|||
|
|
|||
|
/* <20><EFBFBD><DEBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ĩ<EFBFBD><C4A9><EFBFBD><EFBFBD> */
|
|||
|
|
|||
|
#ifndef _ADD_ENCOUNT // WON ADD <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
typedef struct tagENCOUNT_Table
|
|||
|
{
|
|||
|
int index;
|
|||
|
int floor;
|
|||
|
int encountprob_min; /* <20><EFBFBD><DEBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
int encountprob_max; /* <20><EFBFBD><DEBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
int enemymaxnum; /* <20><>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>¾<EFBFBD> */
|
|||
|
int zorder;
|
|||
|
int groupid[ENCOUNT_GROUPMAXNUM]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>No */
|
|||
|
int createprob[ENCOUNT_GROUPMAXNUM]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
RECT rect;
|
|||
|
}ENCOUNT_Table;
|
|||
|
ENCOUNT_Table *ENCOUNT_table;
|
|||
|
#endif
|
|||
|
|
|||
|
int ENCOUNT_encountnum;
|
|||
|
#define ENCOUNT_ENEMYMAXCREATENUM 10
|
|||
|
|
|||
|
static INLINE BOOL ENCOUNT_CHECKENCOUNTTABLEARRAY( int array)
|
|||
|
{
|
|||
|
if( array < 0 || array > ENCOUNT_encountnum-1) return FALSE;
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
|
|||
|
/*------------------------------------------------------------
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɬ<EFBFBD>ü<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* filename char* ɬ<EFBFBD>ð<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD>
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> TRUE(1)
|
|||
|
* <EFBFBD><EFBFBD> FALSE(0)
|
|||
|
*------------------------------------------------------------*/
|
|||
|
BOOL ENCOUNT_initEncount( char* filename )
|
|||
|
{
|
|||
|
FILE* f;
|
|||
|
char line[256];
|
|||
|
int linenum=0;
|
|||
|
int encount_readlen=0;
|
|||
|
|
|||
|
f = fopen(filename,"r");
|
|||
|
if( f == NULL ){
|
|||
|
errorprint;
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
|
|||
|
ENCOUNT_encountnum=0;
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD> <20><>ئ<EFBFBD>滥<EFBFBD>ϵ<EFBFBD>ؤ<EFBFBD>¾<EFBFBD><C2BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʃ<EFBFBD><C6A9><EFBFBD><EFBFBD> */
|
|||
|
while( fgets( line, sizeof( line ), f ) ){
|
|||
|
linenum ++;
|
|||
|
if( line[0] == '#' )continue; /* comment */
|
|||
|
if( line[0] == '\n' )continue; /* none */
|
|||
|
chomp( line );
|
|||
|
|
|||
|
ENCOUNT_encountnum++;
|
|||
|
}
|
|||
|
|
|||
|
if( fseek( f, 0, SEEK_SET ) == -1 ){
|
|||
|
fprint( "Ѱ<EFBFBD>Ҵ<EFBFBD><EFBFBD><EFBFBD>\n" );
|
|||
|
fclose(f);
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
|
|||
|
ENCOUNT_table = allocateMemory( sizeof(struct tagENCOUNT_Table)
|
|||
|
* ENCOUNT_encountnum );
|
|||
|
if( ENCOUNT_table == NULL ){
|
|||
|
fprint( "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> %d\n" ,
|
|||
|
sizeof(ENCOUNT_table)*ENCOUNT_encountnum);
|
|||
|
fclose( f );
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
{
|
|||
|
int i,j;
|
|||
|
for( i = 0; i < ENCOUNT_encountnum; i ++ ) {
|
|||
|
ENCOUNT_table[i].index = -1;
|
|||
|
ENCOUNT_table[i].floor = 0;
|
|||
|
ENCOUNT_table[i].encountprob_min = 1;
|
|||
|
ENCOUNT_table[i].encountprob_min = 50;
|
|||
|
ENCOUNT_table[i].enemymaxnum = 4;
|
|||
|
ENCOUNT_table[i].rect.x = 0;
|
|||
|
ENCOUNT_table[i].rect.y = 0;
|
|||
|
ENCOUNT_table[i].rect.height = 0;
|
|||
|
ENCOUNT_table[i].rect.width = 0;
|
|||
|
ENCOUNT_table[i].zorder = 0;
|
|||
|
for( j = 0; j < ENCOUNT_GROUPMAXNUM; j ++ ) {
|
|||
|
ENCOUNT_table[i].groupid[j] = -1;
|
|||
|
ENCOUNT_table[i].createprob[j] = -1;
|
|||
|
}
|
|||
|
#ifdef _ADD_ENCOUNT // WON ADD <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ENCOUNT_table[i].event_now = -1;
|
|||
|
ENCOUNT_table[i].event_end = -1;
|
|||
|
ENCOUNT_table[i].enemy_group = -1;
|
|||
|
#endif
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD> <20><> <20><> */
|
|||
|
linenum = 0;
|
|||
|
while( fgets( line, sizeof( line ), f ) ){
|
|||
|
linenum ++;
|
|||
|
if( line[0] == '#' )continue; /* comment */
|
|||
|
if( line[0] == '\n' )continue; /* none */
|
|||
|
chomp( line );
|
|||
|
|
|||
|
/* <20><>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
/* <20><><EFBFBD><EFBFBD> tab ë " " <20><> <20>徧<EFBFBD><E5BEA7><EFBFBD><EFBFBD> */
|
|||
|
replaceString( line, '\t' , ' ' );
|
|||
|
/* <20><> <20><><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>£<EFBFBD>*/
|
|||
|
{
|
|||
|
int i;
|
|||
|
char buf[256];
|
|||
|
for( i = 0; i < strlen( line); i ++) {
|
|||
|
if( line[i] != ' ' ) {
|
|||
|
break;
|
|||
|
}
|
|||
|
strcpy( buf, &line[i]);
|
|||
|
}
|
|||
|
if( i != 0 ) {
|
|||
|
strcpy( line, buf);
|
|||
|
}
|
|||
|
}
|
|||
|
{
|
|||
|
char token[256];
|
|||
|
int ret;
|
|||
|
int x1,x2,y1,y2;
|
|||
|
int j;
|
|||
|
|
|||
|
/* պ<><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
ENCOUNT_table[encount_readlen].index = -1;
|
|||
|
ENCOUNT_table[encount_readlen].floor = 0;
|
|||
|
ENCOUNT_table[encount_readlen].encountprob_min = 1;
|
|||
|
ENCOUNT_table[encount_readlen].encountprob_min = 50;
|
|||
|
ENCOUNT_table[encount_readlen].enemymaxnum = 4;
|
|||
|
ENCOUNT_table[encount_readlen].rect.x = 0;
|
|||
|
ENCOUNT_table[encount_readlen].rect.y = 0;
|
|||
|
ENCOUNT_table[encount_readlen].rect.height = 0;
|
|||
|
ENCOUNT_table[encount_readlen].rect.width = 0;
|
|||
|
ENCOUNT_table[encount_readlen].zorder = 0;
|
|||
|
for( j = 0; j < ENCOUNT_GROUPMAXNUM; j ++ ) {
|
|||
|
ENCOUNT_table[encount_readlen].groupid[j] = -1;
|
|||
|
ENCOUNT_table[encount_readlen].createprob[j] = -1;
|
|||
|
}
|
|||
|
#ifdef _ADD_ENCOUNT // WON ADD <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ENCOUNT_table[encount_readlen].event_now = -1;
|
|||
|
ENCOUNT_table[encount_readlen].event_end = -1;
|
|||
|
ENCOUNT_table[encount_readlen].enemy_group = -1;
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
/* <20><><EFBFBD>繴<EFBFBD><E7B9B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",1,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
ENCOUNT_table[encount_readlen].index = atoi(token);
|
|||
|
|
|||
|
/* 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",2,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
ENCOUNT_table[encount_readlen].floor = atoi(token);
|
|||
|
|
|||
|
/* 3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",3,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
x1 = atoi(token);
|
|||
|
|
|||
|
/* 4<><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",4,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
y1= atoi(token);
|
|||
|
|
|||
|
/* 5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",5,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
x2 = atoi(token);
|
|||
|
|
|||
|
/* 6<><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",6,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
y2= atoi(token);
|
|||
|
|
|||
|
ENCOUNT_table[encount_readlen].rect.x = min(x1,x2);
|
|||
|
ENCOUNT_table[encount_readlen].rect.width = max(x1,x2) - min(x1,x2);
|
|||
|
ENCOUNT_table[encount_readlen].rect.y = min(y1,y2);
|
|||
|
ENCOUNT_table[encount_readlen].rect.height = max(y1,y2) - min(y1,y2);
|
|||
|
|
|||
|
/* 7<><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",7,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
ENCOUNT_table[encount_readlen].encountprob_min = atoi(token);
|
|||
|
|
|||
|
/* 8<><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",8,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
ENCOUNT_table[encount_readlen].encountprob_max = atoi(token);
|
|||
|
|
|||
|
{
|
|||
|
int a,b;
|
|||
|
a = ENCOUNT_table[encount_readlen].encountprob_min;
|
|||
|
b = ENCOUNT_table[encount_readlen].encountprob_max;
|
|||
|
/* <20><><EFBFBD><EFBFBD>Ʃ<EFBFBD><C6A9> */
|
|||
|
ENCOUNT_table[encount_readlen].encountprob_min
|
|||
|
= min( a,b);
|
|||
|
ENCOUNT_table[encount_readlen].encountprob_max
|
|||
|
= max( a,b);
|
|||
|
}
|
|||
|
/* 9<><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",9,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
{
|
|||
|
int maxnum = atoi( token);
|
|||
|
/* <20>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뼰<EFBFBD><EBBCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
if( maxnum < 1 || maxnum > ENCOUNT_ENEMYMAXCREATENUM ) {
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
ENCOUNT_table[encount_readlen].enemymaxnum = maxnum;
|
|||
|
}
|
|||
|
/* 10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
ret = getStringFromIndexWithDelim( line,",",10,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
ENCOUNT_table[encount_readlen].zorder = atoi(token);
|
|||
|
#define CREATEPROB_TOKEN 11
|
|||
|
|
|||
|
/* 11 31<33><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ëέ<C3AB><CEAD> */
|
|||
|
{
|
|||
|
int i;
|
|||
|
|
|||
|
for( i = CREATEPROB_TOKEN; i < CREATEPROB_TOKEN +ENCOUNT_GROUPMAXNUM*2; i ++) {
|
|||
|
ret = getStringFromIndexWithDelim( line,",",i,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
if( strlen( token) != 0 ) {
|
|||
|
if( i < CREATEPROB_TOKEN + ENCOUNT_GROUPMAXNUM ) {
|
|||
|
ENCOUNT_table[encount_readlen].groupid[i-CREATEPROB_TOKEN]
|
|||
|
= atoi(token);
|
|||
|
}
|
|||
|
else {
|
|||
|
ENCOUNT_table[encount_readlen].createprob[i-(CREATEPROB_TOKEN + ENCOUNT_GROUPMAXNUM)]
|
|||
|
= atoi(token);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/* <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
if( checkRedundancy( ENCOUNT_table[encount_readlen].groupid,
|
|||
|
arraysizeof( ENCOUNT_table[encount_readlen].groupid)))
|
|||
|
{
|
|||
|
fprint( "<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",
|
|||
|
filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#ifdef _ADD_ENCOUNT // WON ADD <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ret = getStringFromIndexWithDelim( line,",",31,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
ENCOUNT_table[encount_readlen].event_now = atoi(token);
|
|||
|
|
|||
|
ret = getStringFromIndexWithDelim( line,",",32,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
ENCOUNT_table[encount_readlen].event_end = atoi(token);
|
|||
|
|
|||
|
ret = getStringFromIndexWithDelim( line,",",33,token,
|
|||
|
sizeof(token));
|
|||
|
if( ret==FALSE ){
|
|||
|
fprint("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s <20><>%d<><64>\n",filename,linenum);
|
|||
|
continue;
|
|||
|
}
|
|||
|
ENCOUNT_table[encount_readlen].enemy_group = atoi(token);
|
|||
|
#endif
|
|||
|
|
|||
|
encount_readlen ++;
|
|||
|
}
|
|||
|
}
|
|||
|
fclose(f);
|
|||
|
|
|||
|
ENCOUNT_encountnum = encount_readlen;
|
|||
|
|
|||
|
print( "<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %d..", ENCOUNT_encountnum );
|
|||
|
|
|||
|
#if 0
|
|||
|
|
|||
|
{
|
|||
|
int i;
|
|||
|
for( i=0; i <ENCOUNT_encountnum ; i++ )
|
|||
|
print( "encount idx[%d] fl[%d] prob_min[%d] prob_max[%d] e_max[%d] x[%d] wth[%d] y[%d] hgt[%d] \n",
|
|||
|
ENCOUNT_table[i].index,
|
|||
|
ENCOUNT_table[i].floor,
|
|||
|
ENCOUNT_table[i].encountprob_min,
|
|||
|
ENCOUNT_table[i].encountprob_max,
|
|||
|
ENCOUNT_table[i].enemymaxnum,
|
|||
|
ENCOUNT_table[i].rect.x,
|
|||
|
ENCOUNT_table[i].rect.width,
|
|||
|
ENCOUNT_table[i].rect.y,
|
|||
|
ENCOUNT_table[i].rect.height);
|
|||
|
}
|
|||
|
#endif
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
/*------------------------------------------------------------------------
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɬ<EFBFBD>ð<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
|
|||
|
*-----------------------------------------------------------------------*/
|
|||
|
BOOL ENCOUNT_reinitEncount( void )
|
|||
|
{
|
|||
|
freeMemory( ENCOUNT_table);
|
|||
|
return( ENCOUNT_initEncount( getEncountfile()));
|
|||
|
}
|
|||
|
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ENCOUNT_table<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٯëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* zorder<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٯëέ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* floor int <EFBFBD><EFBFBD>ʧID
|
|||
|
* x int x<EFBFBD><EFBFBD>
|
|||
|
* y int y<EFBFBD><EFBFBD>
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ٯ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getEncountAreaArray( int floor, int x, int y)
|
|||
|
{
|
|||
|
int i;
|
|||
|
int index = -1;
|
|||
|
for( i=0 ; i<ENCOUNT_encountnum ; i++ ) {
|
|||
|
if( ENCOUNT_table[i].floor == floor ) {
|
|||
|
if( CoordinateInRect( &ENCOUNT_table[i].rect, x, y) ) {
|
|||
|
int curZorder = ENCOUNT_getZorderFromArray(i);
|
|||
|
if( curZorder >0) {
|
|||
|
if( index != -1 ) {
|
|||
|
/* <20><><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD>ëƩ<C3AB><C6A9><EFBFBD><EFBFBD> */
|
|||
|
/* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
|
|||
|
if( curZorder > ENCOUNT_getZorderFromArray(index)) {
|
|||
|
index = i;
|
|||
|
}
|
|||
|
}
|
|||
|
else {
|
|||
|
index = i;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return index;
|
|||
|
}
|
|||
|
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* floor int <EFBFBD><EFBFBD>ʧID
|
|||
|
* x int x<EFBFBD><EFBFBD>
|
|||
|
* y int y<EFBFBD><EFBFBD>
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getEncountPercentMin( int charaindex, int floor , int x, int y )
|
|||
|
{
|
|||
|
int ret;
|
|||
|
|
|||
|
ret = ENCOUNT_getEncountAreaArray( floor, x, y);
|
|||
|
if( ret != -1 ) {
|
|||
|
ret = ENCOUNT_table[ret].encountprob_min;
|
|||
|
/* <20><>Ŀ<EFBFBD><EFBFBD><F2B5A9B6><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
if( CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT) > 0 ) {
|
|||
|
ret = ceil( ret *
|
|||
|
((100 + CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_CUTRATE))
|
|||
|
/ 100.0));
|
|||
|
}
|
|||
|
if( ret < 0 ) ret = 0;
|
|||
|
if( ret > 100 ) ret = 100;
|
|||
|
}
|
|||
|
return ret;
|
|||
|
}
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* floor int <EFBFBD><EFBFBD>ʧID
|
|||
|
* x int x<EFBFBD><EFBFBD>
|
|||
|
* y int y<EFBFBD><EFBFBD>
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getEncountPercentMax( int charaindex, int floor , int x, int y )
|
|||
|
{
|
|||
|
int ret;
|
|||
|
|
|||
|
ret = ENCOUNT_getEncountAreaArray( floor, x, y);
|
|||
|
if( ret != -1 ) {
|
|||
|
ret = ENCOUNT_table[ret].encountprob_max;
|
|||
|
/* <20><>Ŀ<EFBFBD><EFBFBD><F2B5A9B6><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
if( CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT) > 0 ) {
|
|||
|
ret = ceil( ret *
|
|||
|
((100 + CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_CUTRATE))
|
|||
|
/ 100.0));
|
|||
|
}
|
|||
|
if( ret < 0 ) ret = 0;
|
|||
|
if( ret > 100 ) ret = 100;
|
|||
|
}
|
|||
|
return ret;
|
|||
|
}
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD>MAX<EFBFBD><EFBFBD>ëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* floor int <EFBFBD><EFBFBD>ʧID
|
|||
|
* x int x<EFBFBD><EFBFBD>
|
|||
|
* y int y<EFBFBD><EFBFBD>
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getCreateEnemyMaxNum( int floor , int x, int y )
|
|||
|
{
|
|||
|
int ret;
|
|||
|
|
|||
|
ret = ENCOUNT_getEncountAreaArray( floor, x, y);
|
|||
|
if( ret != -1 ) {
|
|||
|
ret = ENCOUNT_table[ret].enemymaxnum;
|
|||
|
}
|
|||
|
return ret;
|
|||
|
}
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ū<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>indexëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* floor int <EFBFBD><EFBFBD>ʧID
|
|||
|
* x int x<EFBFBD><EFBFBD>
|
|||
|
* y int y<EFBFBD><EFBFBD>
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getEncountIndex( int floor , int x, int y )
|
|||
|
{
|
|||
|
int ret;
|
|||
|
|
|||
|
ret = ENCOUNT_getEncountAreaArray( floor, x, y);
|
|||
|
if( ret != -1 ) {
|
|||
|
ret = ENCOUNT_table[ret].index;
|
|||
|
}
|
|||
|
return ret;
|
|||
|
}
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ū<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>indexëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* array int ENCOUNTTABLE<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٯ
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getEncountIndexFromArray( int array )
|
|||
|
{
|
|||
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|||
|
return ENCOUNT_table[array].index;
|
|||
|
}
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* array int ENCOUNTTABLE<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٯ
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getEncountPercentFromArray( int array )
|
|||
|
{
|
|||
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|||
|
return ENCOUNT_table[array].encountprob_min;
|
|||
|
}
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD>MAX<EFBFBD><EFBFBD>ëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* array int ENCOUNTTABLE<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٯ
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getCreateEnemyMaxNumFromArray( int array )
|
|||
|
{
|
|||
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|||
|
return ENCOUNT_table[array].enemymaxnum;
|
|||
|
}
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD>ٯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> įëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* array int ENCOUNTTABLE<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٯ
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getGroupIdFromArray( int array, int grouparray )
|
|||
|
{
|
|||
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|||
|
return ENCOUNT_table[array].groupid[grouparray];
|
|||
|
}
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD>ٯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* array int ENCOUNTTABLE<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٯ
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getGroupProbFromArray( int array, int grouparray )
|
|||
|
{
|
|||
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|||
|
return ENCOUNT_table[array].createprob[grouparray];
|
|||
|
}
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD>ٯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD>ëƩ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|||
|
* ¦<EFBFBD><EFBFBD>
|
|||
|
* array int ENCOUNTTABLE<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٯ
|
|||
|
* ߯Ի<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>߶<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> -1
|
|||
|
------------------------------------------------------------*/
|
|||
|
int ENCOUNT_getZorderFromArray( int array )
|
|||
|
{
|
|||
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|||
|
return ENCOUNT_table[array].zorder;
|
|||
|
}
|