mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
-Fix xspriData2Array function
-Fix kModernSpriteDamager type # Conflicts: # source/blood/src/actor.cpp # source/blood/src/gameutil.cpp # source/blood/src/gameutil.h # source/blood/src/triggers.h
This commit is contained in:
parent
da47ebbd2c
commit
1eb50414ab
7 changed files with 38 additions and 47 deletions
|
@ -20,8 +20,6 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include <random>
|
||||
//#include <iostream>
|
||||
|
||||
#include "ns.h" // Must come before everything else!
|
||||
|
@ -7356,17 +7354,6 @@ int GetDataVal(spritetype* pSprite, int data) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int STD_Random(int a, int b) {
|
||||
|
||||
|
||||
std::default_random_engine rng;
|
||||
rng.seed(std::random_device()());
|
||||
std::uniform_int_distribution<int> dist_a_b(a, b);
|
||||
return dist_a_b(rng);
|
||||
}
|
||||
|
||||
// tries to get random data field of sprite
|
||||
int GetRandDataVal(int *rData) {
|
||||
dassert(rData != NULL);
|
||||
|
@ -7392,10 +7379,8 @@ int GetRandDataVal(int *rData) {
|
|||
|
||||
// this function drops random item using random pickup generator(s)
|
||||
spritetype* DropRandomPickupObject(spritetype* pSprite, short prevItem) {
|
||||
spritetype* pSprite2 = NULL; int* rData = xspriData2Array(pSprite->extra);
|
||||
int selected = -1;
|
||||
|
||||
if (rData != NULL) {
|
||||
spritetype* pSprite2 = NULL; int rData[4]; int selected = -1;
|
||||
if (xspriData2Array(pSprite->extra,rData)) {
|
||||
|
||||
// randomize only in case if at least 2 data fields fits.
|
||||
for (int i = 0; i <= 3; i++)
|
||||
|
@ -7438,9 +7423,8 @@ spritetype* DropRandomPickupObject(spritetype* pSprite, short prevItem) {
|
|||
|
||||
// this function spawns random dude using dudeSpawn
|
||||
spritetype* spawnRandomDude(spritetype* pSprite) {
|
||||
spritetype* pSprite2 = NULL;
|
||||
int* rData = xspriData2Array(pSprite->extra); int selected = -1;
|
||||
if (rData != NULL) {
|
||||
spritetype* pSprite2 = NULL; int rData[4]; int selected = -1;
|
||||
if (xspriData2Array(pSprite->extra, rData)) {
|
||||
// randomize only in case if at least 2 data fields fits.
|
||||
for (int i = 0; i <= 3; i++)
|
||||
if (rData[i] < kDudeBase || rData[i] >= kDudeMax)
|
||||
|
|
|
@ -269,7 +269,6 @@ void MakeSplash(spritetype *pSprite, XSPRITE *pXSprite);
|
|||
spritetype* DropRandomPickupObject(spritetype* pSprite, short prevItem);
|
||||
spritetype* spawnRandomDude(spritetype* pSprite);
|
||||
int GetDataVal(spritetype* pSprite, int data);
|
||||
int STD_Random(int a, int b);
|
||||
int GetRandDataVal(int *rData);
|
||||
bool sfxPlayMissileSound(spritetype* pSprite, int missileId);
|
||||
bool sfxPlayVectorSound(spritetype* pSprite, int vectorId);
|
||||
|
|
|
@ -145,10 +145,9 @@ static void forcePunch(spritetype* pSprite, XSPRITE* pXSprite) {
|
|||
bool genDudeAdjustSlope(spritetype* pSprite, XSPRITE* pXSprite, int dist, int weaponType, int by) {
|
||||
if (spriRangeIsFine(pXSprite->target)) {
|
||||
int fStart = 0; int fEnd = 0; GENDUDEEXTRA* pExtra = genDudeExtra(pSprite);
|
||||
|
||||
|
||||
unsigned int clipMask = (weaponType == kGenDudeWeaponMissile) ? CLIPMASK0 : CLIPMASK1;
|
||||
for (int i = -8191; i < 8192; i += by) {
|
||||
HitScan(pSprite, pSprite->z, Cos(pSprite->ang) >> 16, Sin(pSprite->ang) >> 16, i, CLIPMASK0 | CLIPMASK1, dist);
|
||||
HitScan(pSprite, pSprite->z, Cos(pSprite->ang) >> 16, Sin(pSprite->ang) >> 16, i, clipMask, dist);
|
||||
if (!fStart && pXSprite->target == gHitInfo.hitsprite) fStart = i;
|
||||
else if (fStart && pXSprite->target != gHitInfo.hitsprite) { fEnd = i; break; }
|
||||
}
|
||||
|
@ -519,7 +518,6 @@ static void thinkChase( spritetype* pSprite, XSPRITE* pXSprite ) {
|
|||
if (((int)gFrameClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(pSprite, false))
|
||||
playGenDudeSound(pSprite, kGenDudeSndChasing);
|
||||
|
||||
aiSetTarget(pXSprite, pXSprite->target);
|
||||
gDudeSlope[pSprite->extra] = divscale(pTarget->z - pSprite->z, dist, 10);
|
||||
|
||||
short curWeapon = gGenDudeExtra[pSprite->index].curWeapon; short weaponType = gGenDudeExtra[pSprite->index].weaponType;
|
||||
|
@ -725,7 +723,7 @@ static void thinkChase( spritetype* pSprite, XSPRITE* pXSprite ) {
|
|||
//if (hit == 1) viewSetSystemMessage("CEIL HIT %d", gHitInfo.hitsect);
|
||||
fallthrough__;
|
||||
case 2:
|
||||
if (hit == 2) viewSetSystemMessage("FLOOR HIT %d", gHitInfo.hitsect);
|
||||
//if (hit == 2) viewSetSystemMessage("FLOOR HIT %d", gHitInfo.hitsect);
|
||||
if (weaponType != kGenDudeWeaponMissile && genDudeAdjustSlope(pSprite, pXSprite, dist, weaponType)
|
||||
&& dist < (int)(6000 + Random(2000)) && pExtra->baseDispersion < kGenDudeMaxDispersion >> 1) break;
|
||||
|
||||
|
@ -892,7 +890,8 @@ static void thinkChase( spritetype* pSprite, XSPRITE* pXSprite ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
aiSetTarget(pXSprite, pXSprite->target);
|
||||
switch (state) {
|
||||
case 1:
|
||||
aiGenDudeNewState(pSprite, &genDudeFireW);
|
||||
|
@ -908,6 +907,7 @@ static void thinkChase( spritetype* pSprite, XSPRITE* pXSprite ) {
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if (seqGetID(3, pSprite->extra) == pXSprite->data2 + ((state < 3) ? 8 : 6)) {
|
||||
|
|
|
@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <random>
|
||||
#include "build.h"
|
||||
#include "common_game.h"
|
||||
|
||||
|
@ -916,4 +917,23 @@ int picHeight(short nPic, short repeat) {
|
|||
return ClipLow((tilesiz[nPic].y * repeat) << 2, 0);
|
||||
}
|
||||
|
||||
bool xspriData2Array(int nXSprite, int* rData) {
|
||||
if (xspriRangeIsFine(nXSprite) && rData) {
|
||||
rData[0] = xsprite[nXSprite].data1; rData[2] = xsprite[nXSprite].data3;
|
||||
rData[1] = xsprite[nXSprite].data2; rData[3] = xsprite[nXSprite].data4;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// by NoOne: used for better randomness in single player
|
||||
int STD_Random(int a, int b) {
|
||||
|
||||
std::default_random_engine rng;
|
||||
rng.seed(std::random_device()());
|
||||
std::uniform_int_distribution<int> dist_a_b(a, b);
|
||||
return dist_a_b(rng);
|
||||
}
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -51,7 +51,7 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
// by NoOne: functions to quckly check range of specifical arrays
|
||||
// by NoOne: functions to quickly check range of specifical arrays
|
||||
inline bool spriRangeIsFine(int nIndex) {
|
||||
return (nIndex >= 0 && nIndex < kMaxSprites);
|
||||
}
|
||||
|
@ -85,5 +85,7 @@ int GetClosestSectors(int nSector, int x, int y, int nDist, short *pSectors, cha
|
|||
int GetClosestSpriteSectors(int nSector, int x, int y, int nDist, short *pSectors, char *pSectBit, short *a8);
|
||||
int picWidth(short nPic, short repeat);
|
||||
int picHeight(short nPic, short repeat);
|
||||
bool xspriData2Array(int nXSprite, int* rData);
|
||||
int STD_Random(int a, int b);
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -69,17 +69,7 @@ int nUniMissileTrapClient = seqRegisterClient(UniMissileTrapSeqCallback);
|
|||
int nMGunFireClient = seqRegisterClient(MGunFireSeqCallback);
|
||||
int nMGunOpenClient = seqRegisterClient(MGunOpenSeqCallback);
|
||||
|
||||
int gRdata[4];
|
||||
int* xspriData2Array(int nXSprite) {
|
||||
if (xspriRangeIsFine(nXSprite)) {
|
||||
gRdata[0] = xsprite[nXSprite].data1; gRdata[2] = xsprite[nXSprite].data3;
|
||||
gRdata[1] = xsprite[nXSprite].data2; gRdata[3] = xsprite[nXSprite].data4;
|
||||
return gRdata;
|
||||
}
|
||||
|
||||
memset(gRdata, 0, sizeof(gRdata));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int GetWaveValue(unsigned int nPhase, int nType)
|
||||
{
|
||||
|
@ -473,8 +463,8 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
|||
|
||||
} else {
|
||||
|
||||
int* rData = xspriData2Array(pSprite->extra);
|
||||
if (rData != NULL) {
|
||||
int rData[4];
|
||||
if (xspriData2Array(pSprite->extra, rData)) {
|
||||
while (maxRetries > 0) {
|
||||
if ((tx = GetRandDataVal(rData)) > 0 && tx != pXSprite->txID) break;
|
||||
maxRetries--;
|
||||
|
@ -602,8 +592,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
|||
case kModernSpriteDamager:
|
||||
if (pXSprite->txID <= 0) {
|
||||
if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy) == 1) {
|
||||
if (spriRangeIsFine(event.causedBy))
|
||||
useSpriteDamager(pXSprite, &sprite[event.causedBy]);
|
||||
if (pXSprite->data1 == 0 && spriRangeIsFine(event.causedBy)) useSpriteDamager(pXSprite, &sprite[event.causedBy]);
|
||||
else if (pXSprite->data1 > 0) {
|
||||
PLAYER* pPlayer = getPlayerById(pXSprite->data1);
|
||||
if (pPlayer != NULL)
|
||||
|
@ -2039,13 +2028,13 @@ void useSpriteDamager(XSPRITE* pXSource, spritetype* pSprite) {
|
|||
XSPRITE* pXSprite = &xsprite[pSprite->extra];
|
||||
DAMAGE_TYPE dmgType = (DAMAGE_TYPE) ClipRange(pXSource->data2, kDmgFall, kDmgElectric);
|
||||
int dmg = (pXSource->data3 == 0) ? 65535 : ClipRange(pXSource->data3 << 1, 1, 65535);
|
||||
if (pXSprite->data2 >= 0) actDamageSprite(pSource->index, pSprite, dmgType, dmg);
|
||||
if (pXSource->data2 >= 0) actDamageSprite(pSource->index, pSprite, dmgType, dmg);
|
||||
else if (pXSource->data2 == -1 && IsDudeSprite(pSprite)) {
|
||||
PLAYER* pPlayer = getPlayerById(pSprite->type);
|
||||
if (pPlayer == NULL || !pPlayer->godMode) {
|
||||
xsprite[pSprite->extra].health = ClipLow(xsprite[pSprite->extra].health - dmg, 0);
|
||||
if (xsprite[pSprite->extra].health == 0)
|
||||
actKillDude(pSource->index, pSprite, dmgType, 65535);
|
||||
actKillDude(pSource->index, pSprite, DAMAGE_TYPE_0, 65535);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,9 +86,6 @@ bool valueIsBetween(int val, int min, int max);
|
|||
void trPlayerCtrlLink(XSPRITE* pXSource, PLAYER* pPlayer);
|
||||
void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer, int causedBy);
|
||||
void trPlayerCtrlStopScene(XSPRITE* pXSource, PLAYER* pPlayer);
|
||||
|
||||
extern int gRdata[4];
|
||||
int* xspriData2Array(int nXSprite);
|
||||
// -------------------------------------------------------
|
||||
|
||||
END_BLD_NS
|
||||
|
|
Loading…
Reference in a new issue