• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

Revision129 (tree)
Time2016-04-24 23:32:59
Authorxops-mikan

Log Message

同じ人に対して銃弾の当たり判定が2回以上行われることがある問題の修正。「フリーカメラ」での発砲機能を削除。

Change Summary

Incremental Difference

--- trunk/objectmanager.cpp (revision 128)
+++ trunk/objectmanager.cpp (revision 129)
@@ -46,6 +46,7 @@
4646 Human_kill = new int[MAX_HUMAN];
4747 Human_headshot = new int[MAX_HUMAN];
4848 Human_ShotFlag = new bool[MAX_HUMAN];
49+ BulletObj_HumanIndex = new BulletObjectHumanIndex[MAX_BULLET];
4950 FriendlyFire = false;
5051 Player_HumanID = 0;
5152 AddHumanIndex_TextureID = -1;
@@ -74,6 +75,7 @@
7475 if( Human_kill != NULL ){ delete [] Human_kill; }
7576 if( Human_headshot != NULL ){ delete [] Human_headshot; }
7677 if( Human_ShotFlag != NULL ){ delete [] Human_ShotFlag; }
78+ if( BulletObj_HumanIndex != NULL ){ delete [] BulletObj_HumanIndex; }
7779 }
7880
7981 //! @brief 参照するクラスを設定
@@ -603,6 +605,7 @@
603605 //使用されていない弾丸ならば、処理せずに返す。
604606 if( in_bullet->GetEnableFlag() == false ){ return false; }
605607
608+ int objectID;
606609 float bx, by, bz;
607610 float brx, bry;
608611 int attacks;
@@ -626,6 +629,9 @@
626629 int id, face;
627630 float Dist;
628631
632+ //弾オブジェクトのデータ番号を取得
633+ objectID = GetBulletObjectID(in_bullet);
634+
629635 //弾丸の座標を取得し、ベクトルを算出。
630636 in_bullet->GetPosData(&bx, &by, &bz, &brx, &bry);
631637 in_bullet->GetParamData(&attacks, &penetration, &speed, &teamid, &humanid);
@@ -675,6 +681,9 @@
675681 if( HumanIndex[i].GetEnableFlag() == false ){ continue; }
676682 if( HumanIndex[i].GetHP() <= 0 ){ continue; }
677683
684+ //既に当たった人なら、処理しない。
685+ if( BulletObj_HumanIndex[objectID].GetIndexFlag(i) == true ){ continue; }
686+
678687 //座標を取得
679688 float ox, oy, oz;
680689 int h_teamid;
@@ -774,6 +783,9 @@
774783 //人に当たった処理
775784 HitBulletHuman(HumanHead_id, 0, bx + vx*(HumanHead_Dist+TotalDist), by + vy*(HumanHead_Dist+TotalDist), bz + vz*(HumanHead_Dist+TotalDist), brx, attacks, humanid);
776785
786+ //対人判定用リスト設定
787+ BulletObj_HumanIndex[objectID].SetIndexFlag(HumanHead_id);
788+
777789 //攻撃力と貫通力を計算
778790 attacks = (int)((float)attacks * 0.6f);
779791 penetration -= 1;
@@ -786,6 +798,9 @@
786798 //人に当たった処理
787799 HitBulletHuman(HumanUp_id, 1, bx + vx*(HumanUp_Dist+TotalDist), by + vy*(HumanUp_Dist+TotalDist), bz + vz*(HumanUp_Dist+TotalDist), brx, attacks, humanid);
788800
801+ //対人判定用リスト設定
802+ BulletObj_HumanIndex[objectID].SetIndexFlag(HumanUp_id);
803+
789804 //攻撃力と貫通力を計算
790805 attacks = (int)((float)attacks * 0.6f);
791806 penetration -= 1;
@@ -798,6 +813,9 @@
798813 //人に当たった処理
799814 HitBulletHuman(HumanLeg_id, 2, bx + vx*(HumanLeg_Dist+TotalDist), by + vy*(HumanLeg_Dist+TotalDist), bz + vz*(HumanLeg_Dist+TotalDist), brx, attacks, humanid);
800815
816+ //対人判定用リスト設定
817+ BulletObj_HumanIndex[objectID].SetIndexFlag(HumanLeg_id);
818+
801819 //攻撃力と貫通力を計算
802820 attacks = (int)((float)attacks * 0.7f);
803821 penetration -= 1;
@@ -1500,6 +1518,20 @@
15001518 return &(BulletIndex[id]);
15011519 }
15021520
1521+//! @brief 指定したbulletポインタのデータ番号を取得
1522+//! @param object 弾オブジェクトのポインタ
1523+//! @return データ番号 (エラー:-1)
1524+int ObjectManager::GetBulletObjectID(bullet* object)
1525+{
1526+ for(int i=0; i<MAX_BULLET; i++){
1527+ if( &(BulletIndex[i]) == object ){
1528+ return i;
1529+ }
1530+ }
1531+
1532+ return -1;
1533+}
1534+
15031535 //! @brief 使用されていないbulletクラスを取得
15041536 //! @return 現在未使用の弾オブジェクトのポインタ (失敗すると NULL)
15051537 bullet* ObjectManager::GetNewBulletObject()
@@ -1722,6 +1754,9 @@
17221754 newbullet->SetPosData(pos_x, pos_y + WEAPONSHOT_HEIGHT, pos_z, rx, ry);
17231755 newbullet->SetParamData(attacks, ParamData.penetration, ParamData.speed * BULLET_SPEEDSCALE, teamid, human_id, true);
17241756 newbullet->SetEnableFlag(true);
1757+
1758+ //対人判定用リスト初期化
1759+ BulletObj_HumanIndex[ GetBulletObjectID(newbullet) ].Init();
17251760 }
17261761 else{
17271762 //発射する未使用のオブジェクトを取得
@@ -2550,4 +2585,43 @@
25502585 {
25512586 //ポイントデータ解放
25522587 CleanupPointDataToObject();
2588+}
2589+
2590+//! @brief コンストラクタ
2591+BulletObjectHumanIndex::BulletObjectHumanIndex()
2592+{
2593+ HumanIndex = new bool[MAX_HUMAN];
2594+
2595+ Init();
2596+}
2597+
2598+//! @brief ディストラクタ
2599+BulletObjectHumanIndex::~BulletObjectHumanIndex()
2600+{
2601+ if( HumanIndex == NULL ){ delete [] HumanIndex; }
2602+}
2603+
2604+//! @brief 初期化
2605+void BulletObjectHumanIndex::Init()
2606+{
2607+ for(int i=0; i<MAX_HUMAN; i++){
2608+ HumanIndex[i] = false;
2609+ }
2610+}
2611+
2612+//! @brief フラグを取得
2613+//! @param id 人のデータ番号
2614+//! @return フラグ値
2615+bool BulletObjectHumanIndex::GetIndexFlag(int id)
2616+{
2617+ if( (id < 0)||(MAX_HUMAN <= id) ){ return false; }
2618+ return HumanIndex[id];
2619+}
2620+
2621+//! @brief フラグを有効化
2622+//! @param id 人のデータ番号
2623+void BulletObjectHumanIndex::SetIndexFlag(int id)
2624+{
2625+ if( (id < 0)||(MAX_HUMAN <= id) ){ return; }
2626+ HumanIndex[id] = true;
25532627 }
\ No newline at end of file
--- trunk/gamemain.cpp (revision 128)
+++ trunk/gamemain.cpp (revision 129)
@@ -1292,7 +1292,6 @@
12921292 void maingame::Input()
12931293 {
12941294 time = GetTimeMS();
1295- static unsigned int bullettime = 0;
12961295
12971296 //プレイヤーのクラスを取得
12981297 human *myHuman = ObjMgr.GetPlayerHumanObject();
@@ -1438,34 +1437,7 @@
14381437 }
14391438
14401439 if( Camera_Debugmode == true ){ //デバックモードならば
1441- //発砲操作かチェック
1442- if( CheckInputControl(KEY_Shot, 0) ){
1443- //前回の発射より、4フレーム分よりも時間が経っていれば
1444- if( bullettime + 4*((int)GAMEFPS) < GetTimeMS() ){
1445- float x, y, z, rx, ry;
1446- x = camera_x;
1447- y = camera_y;
1448- z = camera_z;
1449- rx = camera_rx;
1450- ry = camera_ry;
1451-
1452- //未使用の弾オブジェクトを取得
1453- bullet* newbullet = ObjMgr.GetNewBulletObject();
1454- if( newbullet != NULL ){
1455- //弾オブジェクトを設定
1456- newbullet->SetPosData(x, y, z, rx, ry);
1457- newbullet->SetParamData(40, 5, 10, 1024, ObjMgr.GetPlayerID(), true);
1458- newbullet->SetEnableFlag(true);
1459- GameSound->ShotWeapon(x, y, z, 0, 1024, true);
1460-
1461- //スコアに加算
1462- MainGameInfo.fire += 1;
1463-
1464- //発射時間を記憶(連射間隔判定用)
1465- bullettime = GetTimeMS();
1466- }
1467- }
1468- }
1440+ //
14691441 }
14701442 else{ //デバックモードでなければ
14711443 HumanParameter humandata;
--- trunk/objectmanager.h (revision 128)
+++ trunk/objectmanager.h (revision 129)
@@ -81,6 +81,7 @@
8181 int *Human_kill; //!< 倒した敵の数
8282 int *Human_headshot; //!< 敵の頭部に命中した数
8383 bool *Human_ShotFlag; //!< 発砲フラグ(マズルフラッシュ用)
84+ class BulletObjectHumanIndex *BulletObj_HumanIndex; //!< 弾対人判定用オブジェクト
8485
8586 bool FriendlyFire; //!< FF(同士討ち)有効化
8687
@@ -134,6 +135,7 @@
134135 weapon* GetWeaponObject(int id);
135136 smallobject* GetSmallObject(int id);
136137 bullet* GetBulletObject(int id);
138+ int GetBulletObjectID(bullet* object);
137139 bullet* GetNewBulletObject();
138140 grenade* GetNewGrenadeObject();
139141 human* SearchHuman(signed char p4);
@@ -163,4 +165,18 @@
163165 void Cleanup();
164166 };
165167
168+//! @brief 弾対人判定用クラス
169+//! @details 弾と人の当たり判定の有無を管理するクラスです。ObjectManagerクラス内で使用します。
170+class BulletObjectHumanIndex
171+{
172+ bool *HumanIndex; //!< リスト
173+
174+public:
175+ BulletObjectHumanIndex();
176+ ~BulletObjectHumanIndex();
177+ void Init();
178+ bool GetIndexFlag(int id);
179+ void SetIndexFlag(int id);
180+};
181+
166182 #endif
\ No newline at end of file