2016-12-24 08:45:52 +08:00
|
|
|
|
#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"
|
|
|
|
|
|
2017-01-13 05:24:03 +08:00
|
|
|
|
#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件
|
2016-12-24 08:45:52 +08:00
|
|
|
|
#include "encount.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* エンカウント関連のソース */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
|
2017-01-13 05:24:03 +08:00
|
|
|
|
#ifndef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件
|
2016-12-24 08:45:52 +08:00
|
|
|
|
typedef struct tagENCOUNT_Table
|
|
|
|
|
{
|
|
|
|
|
int index;
|
|
|
|
|
int floor;
|
2017-01-15 05:21:15 +08:00
|
|
|
|
int encountprob_min; /* エンカウント確率 */
|
|
|
|
|
int encountprob_max; /* エンカウント確率 */
|
|
|
|
|
int enemymaxnum; /* どれだけ敵を作るか */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
int zorder;
|
2017-01-15 05:21:15 +08:00
|
|
|
|
int groupid[ENCOUNT_GROUPMAXNUM]; /* グループNo */
|
|
|
|
|
int createprob[ENCOUNT_GROUPMAXNUM]; /* そのグループの出現率 */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* エンカウント設定の初期化をする。
|
|
|
|
|
* 引数
|
|
|
|
|
* filename char* 設定ファイル名
|
|
|
|
|
* 返り値
|
|
|
|
|
* 成功 TRUE(1)
|
|
|
|
|
* 失敗 FALSE(0)
|
2016-12-24 08:45:52 +08:00
|
|
|
|
*------------------------------------------------------------*/
|
|
|
|
|
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;
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* まず有効な行が何行あるかどうか調べる */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
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 ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint( "寻找错误\n" );
|
2016-12-24 08:45:52 +08:00
|
|
|
|
fclose(f);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ENCOUNT_table = allocateMemory( sizeof(struct tagENCOUNT_Table)
|
|
|
|
|
* ENCOUNT_encountnum );
|
|
|
|
|
if( ENCOUNT_table == NULL ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint( "无法分配内存 %d\n" ,
|
2016-12-24 08:45:52 +08:00
|
|
|
|
sizeof(ENCOUNT_table)*ENCOUNT_encountnum);
|
|
|
|
|
fclose( f );
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 初期化 */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
2017-01-13 05:24:03 +08:00
|
|
|
|
#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ENCOUNT_table[i].event_now = -1;
|
|
|
|
|
ENCOUNT_table[i].event_end = -1;
|
|
|
|
|
ENCOUNT_table[i].enemy_group = -1;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* また読み直す */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
linenum = 0;
|
|
|
|
|
while( fgets( line, sizeof( line ), f ) ){
|
|
|
|
|
linenum ++;
|
|
|
|
|
if( line[0] == '#' )continue; /* comment */
|
|
|
|
|
if( line[0] == '\n' )continue; /* none */
|
|
|
|
|
chomp( line );
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 行を整形する */
|
|
|
|
|
/* まず tab を " " に置き換える */
|
|
|
|
|
|
2016-12-24 08:45:52 +08:00
|
|
|
|
replaceString( line, '\t' , ' ' );
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 先頭のスペースを取る。*/
|
2016-12-24 08:45:52 +08:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 二度めのループに入った時の為の初期化 */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
2017-01-13 05:24:03 +08:00
|
|
|
|
#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ENCOUNT_table[encount_readlen].event_now = -1;
|
|
|
|
|
ENCOUNT_table[encount_readlen].event_end = -1;
|
|
|
|
|
ENCOUNT_table[encount_readlen].enemy_group = -1;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* ひとつめのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",1,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ENCOUNT_table[encount_readlen].index = atoi(token);
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 2つめのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",2,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ENCOUNT_table[encount_readlen].floor = atoi(token);
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 3つめのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",3,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
x1 = atoi(token);
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 4つめのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",4,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
y1= atoi(token);
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 5つめのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",5,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x2 = atoi(token);
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 6つめのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",6,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
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);
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 7めのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",7,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ENCOUNT_table[encount_readlen].encountprob_min = atoi(token);
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 8めのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",8,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
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;
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 大小の調整 */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ENCOUNT_table[encount_readlen].encountprob_min
|
|
|
|
|
= min( a,b);
|
|
|
|
|
ENCOUNT_table[encount_readlen].encountprob_max
|
|
|
|
|
= max( a,b);
|
|
|
|
|
}
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 9つめのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",9,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
int maxnum = atoi( token);
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 数の正当性のチェック */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
if( maxnum < 1 || maxnum > ENCOUNT_ENEMYMAXCREATENUM ) {
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ENCOUNT_table[encount_readlen].enemymaxnum = maxnum;
|
|
|
|
|
}
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 10めのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",10,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ENCOUNT_table[encount_readlen].zorder = atoi(token);
|
|
|
|
|
#define CREATEPROB_TOKEN 11
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 11~31めのトークンを見る */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for( i = CREATEPROB_TOKEN; i < CREATEPROB_TOKEN +ENCOUNT_GROUPMAXNUM*2; i ++) {
|
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",i,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 重複チェック */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
if( checkRedundancy( ENCOUNT_table[encount_readlen].groupid,
|
|
|
|
|
arraysizeof( ENCOUNT_table[encount_readlen].groupid)))
|
|
|
|
|
{
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint( "文件语法错误:%s 第%d行\n",
|
2016-12-24 08:45:52 +08:00
|
|
|
|
filename,linenum);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-01-13 05:24:03 +08:00
|
|
|
|
#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件
|
2016-12-24 08:45:52 +08:00
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",31,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ENCOUNT_table[encount_readlen].event_now = atoi(token);
|
|
|
|
|
|
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",32,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ENCOUNT_table[encount_readlen].event_end = atoi(token);
|
|
|
|
|
|
|
|
|
|
ret = getStringFromIndexWithDelim( line,",",33,token,
|
|
|
|
|
sizeof(token));
|
|
|
|
|
if( ret==FALSE ){
|
2017-01-13 05:24:03 +08:00
|
|
|
|
fprint("文件语法错误:%s 第%d行\n",filename,linenum);
|
2016-12-24 08:45:52 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ENCOUNT_table[encount_readlen].enemy_group = atoi(token);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
encount_readlen ++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
|
|
ENCOUNT_encountnum = encount_readlen;
|
|
|
|
|
|
2017-01-13 05:24:03 +08:00
|
|
|
|
print( "有效的遇敌坐标数是 %d..", ENCOUNT_encountnum );
|
2016-12-24 08:45:52 +08:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* エンカウント設定ファイル読み直し
|
2016-12-24 08:45:52 +08:00
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
|
BOOL ENCOUNT_reinitEncount( void )
|
|
|
|
|
{
|
|
|
|
|
freeMemory( ENCOUNT_table);
|
|
|
|
|
return( ENCOUNT_initEncount( getEncountfile()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された座標のENCOUNT_tableの添字を調べる。
|
|
|
|
|
* zorderの数字を見て優先順位の高い物を取得する。
|
|
|
|
|
* 引数
|
|
|
|
|
* floor int フロアID
|
|
|
|
|
* x int x座標
|
|
|
|
|
* y int y座標
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 添字
|
|
|
|
|
* 取得失敗 -1
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
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 ) {
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* 優先順位を調べる */
|
|
|
|
|
/* 大きい方優先 */
|
|
|
|
|
|
2016-12-24 08:45:52 +08:00
|
|
|
|
if( curZorder > ENCOUNT_getZorderFromArray(index)) {
|
|
|
|
|
index = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
index = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された座標のエンカウント確率を調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* floor int フロアID
|
|
|
|
|
* x int x座標
|
|
|
|
|
* y int y座標
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上の確率
|
|
|
|
|
* 取得失敗 -1
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
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;
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* トヘロス効果をつける */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された座標のエンカウント確率を調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* floor int フロアID
|
|
|
|
|
* x int x座標
|
|
|
|
|
* y int y座標
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上の確率
|
|
|
|
|
* 取得失敗 -1
|
|
|
|
|
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
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;
|
2017-01-15 05:21:15 +08:00
|
|
|
|
/* トヘロス効果をつける */
|
2016-12-24 08:45:52 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された座標の敵生成MAX数を調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* floor int フロアID
|
|
|
|
|
* x int x座標
|
|
|
|
|
* y int y座標
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上の確率
|
|
|
|
|
* 取得失敗 -1
|
|
|
|
|
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された座標のエンカウントフィールドのindexを調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* floor int フロアID
|
|
|
|
|
* x int x座標
|
|
|
|
|
* y int y座標
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上
|
|
|
|
|
* 取得失敗 -1
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された座標のエンカウントフィールドのindexを調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* array int ENCOUNTTABLEの添字
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上
|
|
|
|
|
* 取得失敗 -1
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
int ENCOUNT_getEncountIndexFromArray( int array )
|
|
|
|
|
{
|
|
|
|
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|
|
|
|
return ENCOUNT_table[array].index;
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された座標のエンカウント確率を調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* array int ENCOUNTTABLEの添字
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上
|
|
|
|
|
* 取得失敗 -1
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
int ENCOUNT_getEncountPercentFromArray( int array )
|
|
|
|
|
{
|
|
|
|
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|
|
|
|
return ENCOUNT_table[array].encountprob_min;
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された座標の敵生成MAX数を調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* array int ENCOUNTTABLEの添字
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上
|
|
|
|
|
* 取得失敗 -1
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
int ENCOUNT_getCreateEnemyMaxNumFromArray( int array )
|
|
|
|
|
{
|
|
|
|
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|
|
|
|
return ENCOUNT_table[array].enemymaxnum;
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された添字のグループ番号を調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* array int ENCOUNTTABLEの添字
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上
|
|
|
|
|
* 取得失敗 -1
|
|
|
|
|
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
int ENCOUNT_getGroupIdFromArray( int array, int grouparray )
|
|
|
|
|
{
|
|
|
|
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|
|
|
|
return ENCOUNT_table[array].groupid[grouparray];
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された添字のグループの出現率を調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* array int ENCOUNTTABLEの添字
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上
|
|
|
|
|
* 取得失敗 -1
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
int ENCOUNT_getGroupProbFromArray( int array, int grouparray )
|
|
|
|
|
{
|
|
|
|
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|
|
|
|
return ENCOUNT_table[array].createprob[grouparray];
|
|
|
|
|
}
|
|
|
|
|
/*------------------------------------------------------------
|
2017-01-15 05:21:15 +08:00
|
|
|
|
* 指定された添字の優先順位を調べる。
|
|
|
|
|
* 引数
|
|
|
|
|
* array int ENCOUNTTABLEの添字
|
|
|
|
|
* 返り値
|
|
|
|
|
* 正常 0以上
|
|
|
|
|
* 取得失敗 -1
|
2016-12-24 08:45:52 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
int ENCOUNT_getZorderFromArray( int array )
|
|
|
|
|
{
|
|
|
|
|
if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1;
|
|
|
|
|
return ENCOUNT_table[array].zorder;
|
|
|
|
|
}
|