• R/O
  • SSH
  • HTTPS

コミット

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。


コミットメタ情報

リビジョン304 (tree)
日時2022-04-17 01:50:09
作者xops-mikan

ログメッセージ

R301にてAIの手榴弾投げパスが正しく動作しない場合がある問題の対策、一部処理を関数化

変更サマリ

差分

--- trunk/ai.cpp (revision 303)
+++ trunk/ai.cpp (revision 304)
@@ -63,6 +63,7 @@
6363 cautioncnt = 0;
6464 actioncnt = 0;
6565 longattack = false;
66+ EventWeaponShot = false;
6667 LevelParam = NULL;
6768
6869 MoveNavi = new AIMoveNavi;
@@ -1205,12 +1206,17 @@
12051206 ObjDriver->SetModeFlag(AI_CTRL_TURNDOWN);
12061207 }
12071208
1208- //投げる
1209+ //照準に定まっているか確認
12091210 if( (fabsf(atan_rx) < DegreeToRadian(1.5f))&&(fabsf(atan_ry) < DegreeToRadian(1.5f)) ){
1211+ //連射させない
1212+ if( (ctrlhuman->GetWeaponBlazingmode() == false)&&(EventWeaponShot == true) ){ return 0; }
1213+
12101214 //角度を設定
12111215 ctrlhuman->SetRxRy(rx, ry);
12121216
1217+ //投げる
12131218 if( ObjMgr->ShotWeapon(ctrlid) != 0 ){
1219+ EventWeaponShot = true;
12141220 return 1;
12151221 }
12161222 }
@@ -1630,6 +1636,7 @@
16301636 {
16311637 int newbattlemode = AI_NORMAL;
16321638 float caution_rx;
1639+ int EventThrowGrenade = 0;
16331640
16341641 MoveNavi->MovePathNowState();
16351642 enemyhuman = NULL;
@@ -1656,11 +1663,15 @@
16561663
16571664 //手榴弾パス
16581665 if( MoveNavi->GetMoveMode() == AI_GRENADE ){
1659- if( ThrowGrenade() != 0 ){
1666+ EventThrowGrenade = ThrowGrenade();
1667+ if( EventThrowGrenade != 0 ){
16601668 MoveNavi->MovePathNextState();
16611669 MoveNavi->MovePathNowState();
16621670 }
16631671 }
1672+ if( EventThrowGrenade != 1 ){
1673+ EventWeaponShot = false;
1674+ }
16641675
16651676 if( MoveNavi->GetMoveMode() == AI_RUN2 ){ //優先的な走りの処理
16661677 //敵を見つけたら攻撃に入る
@@ -1736,6 +1747,7 @@
17361747 cautioncnt = 0;
17371748 actioncnt = 0;
17381749 longattack = false;
1750+ EventWeaponShot = false;
17391751
17401752 MoveNavi->Init();
17411753 ObjDriver->Init();
--- trunk/ai.h (revision 303)
+++ trunk/ai.h (revision 304)
@@ -78,12 +78,13 @@
7878 bool FaceCaution_flag; //!< 警戒中に特定の報告を向くフラグ
7979 float FaceCaution_rx; //!< 警戒中に向く方向
8080 float total_move; //!< 合計移動量
81- int waitcnt; //!< 時間待ちカウント
82- int movejumpcnt; //!< ジャンプ判定カウント
83- int gotocnt; //!< 移動カウント
84- int cautioncnt; //!< 警戒中カウント
85- int actioncnt; //!< 攻撃中カウント
86- bool longattack; //!< 近距離・遠距離フラグ
81+ int waitcnt; //!< 時間待ちカウント
82+ int movejumpcnt; //!< ジャンプ判定カウント
83+ int gotocnt; //!< 移動カウント
84+ int cautioncnt; //!< 警戒中カウント
85+ int actioncnt; //!< 攻撃中カウント
86+ bool longattack; //!< 近距離・遠距離フラグ
87+ bool EventWeaponShot; //!< イベントによる手榴弾投げフラグ
8788 AIParameter *LevelParam; //!< AIの性能値
8889
8990 bool CheckTargetPos(bool back);
--- trunk/d3dgraphics-opengl.cpp (revision 303)
+++ trunk/d3dgraphics-opengl.cpp (revision 304)
@@ -791,7 +791,7 @@
791791 //! @param filename ファイル名
792792 //! @param nowformat 現在の判別値
793793 //! @return 新たな判別値
794-int D3DGraphics::CheckFileExtension(const char* filename, int nowformat)
794+int D3DGraphics::CheckTextureFileExtension(const char* filename, int nowformat)
795795 {
796796 char filename2[MAX_PATH];
797797
@@ -832,7 +832,7 @@
832832 //! @param filename ファイル名
833833 //! @param nowformat 現在の判別値
834834 //! @return 新たな判別値
835-int D3DGraphics::CheckFileTypeFlag(const char* filename, int nowformat)
835+int D3DGraphics::CheckTextureFileTypeFlag(const char* filename, int nowformat)
836836 {
837837 FILE *fp;
838838 unsigned char header[4];
@@ -893,10 +893,10 @@
893893 if( id == -1 ){ return -1; }
894894
895895 //まず拡張子でファイルフォーマットを判定
896- format = CheckFileExtension(filename, format);
896+ format = CheckTextureFileExtension(filename, format);
897897
898898 //ファイルヘッダーの情報でも確認
899- format = CheckFileTypeFlag(filename, format);
899+ format = CheckTextureFileTypeFlag(filename, format);
900900
901901 //対応してないフォーマット
902902 if( format == 0 ){ return -1; }
--- trunk/d3dgraphics.h (revision 303)
+++ trunk/d3dgraphics.h (revision 304)
@@ -272,8 +272,8 @@
272272 #endif
273273
274274 void CleanupD3Dresource();
275- int CheckFileExtension(const char* filename, int nowformat);
276- int CheckFileTypeFlag(const char* filename, int nowformat);
275+ int CheckTextureFileExtension(const char* filename, int nowformat);
276+ int CheckTextureFileTypeFlag(const char* filename, int nowformat);
277277 bool LoadBMPTexture(const char* filename, bool BlackTransparent, TEXTUREDATA *ptexture);
278278 bool LoadDDSTexture(const char* filename, bool BlackTransparent, TEXTUREDATA *ptexture);
279279 bool LoadJPEGTexture(const char* filename, bool BlackTransparent, TEXTUREDATA *ptexture);
--- trunk/datafile.cpp (revision 303)
+++ trunk/datafile.cpp (revision 304)
@@ -704,18 +704,9 @@
704704 mif = true;
705705
706706 //拡張子が.txtならば
707- //if( strcmp(PathFindExtension(fname), ".txt") == 0 ){
708- // //MIFフラグを無効に
709- // mif = false;
710- //}
711- for(int i=strlen(fname)-1; i>0; i--){
712- if( fname[i] == '.' ){
713- if( strcmp(&(fname[i]), ".txt") == 0 ){
714- //MIFフラグを無効に
715- mif = false;
716- }
717- break;
718- }
707+ if( CheckFileExtension(fname, ".txt") == true ){
708+ //MIFフラグを無効に
709+ mif = false;
719710 }
720711
721712 #ifdef ENABLE_PATH_DELIMITER_SLASH
@@ -1649,4 +1640,40 @@
16491640 if( dir[i] == '\\' ){ dir[i+1] = '\0'; break; }
16501641 if( dir[i] == '/' ){ dir[i+1] = '\0'; break; }
16511642 }
1643+}
1644+
1645+//! @brief ファイル拡張子を判定する
1646+//! @param filepath ファイル名
1647+//! @param checkstr 拡張子名
1648+//! @return 該当:true 非該当:false
1649+//! @attention 拡張子は"."込みで指定してください。大文字・小文字は区別しません。
1650+bool CheckFileExtension(const char *filepath, const char *checkstr)
1651+{
1652+ if( strlen(filepath) >= MAX_PATH ){ return false; }
1653+ if( strlen(checkstr) >= 16 ){ return false; }
1654+ if( strlen(filepath) < strlen(checkstr) ){ return false; }
1655+
1656+ char filepath2[MAX_PATH];
1657+ char checkstr2[16];
1658+
1659+ //ファイル名を小文字へ変換
1660+ for(int i=0; i<(int)strlen(filepath); i++){
1661+ filepath2[i] = (char)tolower((int)filepath[i]);
1662+ }
1663+ filepath2[ strlen(filepath) ] = '\0';
1664+
1665+ //拡張子名を小文字へ変換
1666+ for(int i=0; i<(int)strlen(checkstr); i++){
1667+ checkstr2[i] = (char)tolower((int)checkstr[i]);
1668+ }
1669+ checkstr2[ strlen(checkstr) ] = '\0';
1670+
1671+ //拡張子判定
1672+ for(int i=strlen(filepath2)-1; i>0; i--){
1673+ if( filepath2[i] == '.' ){
1674+ if( strcmp(&(filepath2[i]), checkstr2) == 0 ){ return true; }
1675+ return false;
1676+ }
1677+ }
1678+ return false;
16521679 }
\ No newline at end of file
--- trunk/datafile.h (revision 303)
+++ trunk/datafile.h (revision 304)
@@ -240,5 +240,6 @@
240240 int DeleteLinefeed(char str[]);
241241 bool CheckFullPath(const char *path);
242242 void GetFileDirectory(const char *path, char *dir);
243+bool CheckFileExtension(const char *filepath, const char *checkstr);
243244
244245 #endif
\ No newline at end of file
--- trunk/main.cpp (revision 303)
+++ trunk/main.cpp (revision 304)
@@ -90,9 +90,7 @@
9090 for(int param=1; param<__argc; param++){
9191 #ifdef ENABLE_DEBUGLOG
9292 //"Log"が与えられていたら、ログ出力を有効化
93- if( (strcmp(__argv[param], "-Log") == 0)||(strcmp(__argv[param], "/Log") == 0)||
94- (strcmp(__argv[param], "-log") == 0)||(strcmp(__argv[param], "/log") == 0)
95- ){
93+ if( CheckCommandParameter(__argv[param], "-Log") == true ){
9694 //ログ出力を有効化
9795 OutputLog.EnableOutputLog();
9896
@@ -103,9 +101,7 @@
103101
104102 #ifdef ENABLE_AUTOLOADMIF
105103 //"Dir"が与えられていたら、カレントディレクトリ移動
106- if( (strcmp(__argv[param], "-Dir") == 0)||(strcmp(__argv[param], "/Dir") == 0)||
107- (strcmp(__argv[param], "-dir") == 0)||(strcmp(__argv[param], "/dir") == 0)
108- ){
104+ if( CheckCommandParameter(__argv[param], "-Dir") == true ){
109105 if( (param+1) < __argc ){
110106 chdir(__argv[param+1]);
111107 param += 1;
@@ -114,22 +110,15 @@
114110 }
115111
116112 //"NoBriefing"が与えられていたら、(.mif指定時は)ブリーフィングを省略する
117- if( (strcmp(__argv[param], "-NoBriefing") == 0)||(strcmp(__argv[param], "/NoBriefing") == 0)||
118- (strcmp(__argv[param], "-nobriefing") == 0)||(strcmp(__argv[param], "/bobriefing") == 0)
119- ){
113+ if( CheckCommandParameter(__argv[param], "-NoBriefing") == true ){
120114 NoBriefingFlag = true;
121115 continue;
122116 }
123117
124- //それ以外の引数ならば拡張子を取り出してみる
125- for(int i=strlen(__argv[param])-1; i>0; i--){
126- if( __argv[param][i] == '.' ){
127- if( strcmp(&(__argv[param][i]), ".mif") == 0 ){
128- //.mifであればファイルパスとして記憶
129- strcpy(path, __argv[param]);
130- }
131- break;
132- }
118+ //それ以外の引数ならば拡張子を判定してみる
119+ if( CheckFileExtension(__argv[param], ".mif") == true ){
120+ //.mifであればファイルパスとして記憶
121+ strcpy(path, __argv[param]);
133122 }
134123 #endif
135124 }
@@ -266,6 +255,36 @@
266255 return 0;
267256 }
268257
258+//! @brief コマンド引数判定
259+//! @param param 元の文字列
260+//! @param cmd 判定する引数
261+//! @return 該当:true 非該当:false
262+//! @warning cmd引数の最初の一文字は無視されます。
263+//! @attention 次の引数を判定します。>/[引数]、-[引数]、/[引数(小文字)]、-[引数(小文字)]
264+bool CheckCommandParameter(const char *param, const char *cmd)
265+{
266+ if( strlen(param) >= 16 ){ return false; }
267+ if( strlen(cmd) >= 16 ){ return false; }
268+ if( strlen(param) != strlen(cmd) ){ return false; }
269+
270+ char str[16];
271+ strcpy(str, cmd);
272+
273+ str[0] = '/';
274+ if( strcmp(param, str) == 0 ){ return true; }
275+ str[0] = '-';
276+ if( strcmp(param, str) == 0 ){ return true; }
277+
278+ for(int i=0; i<strlen(str); i++){ str[i] = (char)tolower((int)(str[i])); }
279+
280+ str[0] = '/';
281+ if( strcmp(param, str) == 0 ){ return true; }
282+ str[0] = '-';
283+ if( strcmp(param, str) == 0 ){ return true; }
284+
285+ return false;
286+}
287+
269288 //! @brief 角度(ラジアン)正規化
270289 //! @param r 角度
271290 //! @return 正規化後の角度
--- trunk/main.h (revision 303)
+++ trunk/main.h (revision 304)
@@ -157,6 +157,7 @@
157157 extern class StateMachine GameState;
158158 extern class Config GameConfig;
159159
160+bool CheckCommandParameter(const char *param, const char *cmd);
160161 float AngleNormalization(float r);
161162
162163 #endif
\ No newline at end of file