- useIncDecGen + setDataValueOfObject

This commit is contained in:
Christoph Oelckers 2021-10-03 17:47:59 +02:00
parent ab41ac9e05
commit 017bcb056f
2 changed files with 54 additions and 39 deletions

View file

@ -4789,7 +4789,7 @@ void modernTypeTrigger(int destObjType, int destObjIndex, DBloodActor* destactor
break; break;
// iterate data filed value of destination object // iterate data filed value of destination object
case kModernObjDataAccumulator: case kModernObjDataAccumulator:
useIncDecGen(pXSource, destObjType, destObjIndex); useIncDecGen(event.actor, destObjType, destObjIndex, destactor);
break; break;
// change data field value of destination object // change data field value of destination object
case kModernObjDataChanger: case kModernObjDataChanger:
@ -6382,17 +6382,26 @@ void useSoundGen(DBloodActor* sourceactor, DBloodActor* actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void useIncDecGen(XSPRITE* pXSource, short objType, int objIndex) { void useIncDecGen(DBloodActor* sourceactor, short objType, int objIndex, DBloodActor* objactor)
char buffer[5]; int data = -65535; short tmp = 0; int dataIndex = 0; {
sprintf(buffer, "%d", abs(pXSource->data1)); int len = int(strlen(buffer)); auto pXSource = &sourceactor->x();
spritetype* pSource = &sourceactor->s();
for (int i = 0; i < len; i++) { char buffer[7];
int data = -65535;
short tmp = 0;
int dataIndex = 0;
snprintf(buffer, 7, "%d", abs(pXSource->data1));
int len = int(strlen(buffer));
for (int i = 0; i < len; i++)
{
dataIndex = (buffer[i] - 52) + 4; dataIndex = (buffer[i] - 52) + 4;
if ((data = getDataFieldOfObject(objType, objIndex, &bloodActors[objIndex], dataIndex)) == -65535) { if ((data = getDataFieldOfObject(objType, objIndex, objactor, dataIndex)) == -65535)
{
Printf(PRINT_HIGH, "\nWrong index of data (%c) for IncDec Gen #%d! Only 1, 2, 3 and 4 indexes allowed!\n", buffer[i], objIndex); Printf(PRINT_HIGH, "\nWrong index of data (%c) for IncDec Gen #%d! Only 1, 2, 3 and 4 indexes allowed!\n", buffer[i], objIndex);
continue; continue;
} }
spritetype* pSource = &sprite[pXSource->reference];
if (pXSource->data2 < pXSource->data3) if (pXSource->data2 < pXSource->data3)
{ {
@ -6444,7 +6453,7 @@ void useIncDecGen(XSPRITE* pXSource, short objType, int objIndex) {
} }
} }
pXSource->sysData1 = data; pXSource->sysData1 = data;
setDataValueOfObject(objType, objIndex, dataIndex, data); setDataValueOfObject(objType, objIndex, objactor, dataIndex, data);
} }
} }
@ -6604,28 +6613,29 @@ void useSlopeChanger(XSPRITE* pXSource, int objType, int objIndex) {
void useDataChanger(XSPRITE* pXSource, int objType, int objIndex) { void useDataChanger(XSPRITE* pXSource, int objType, int objIndex) {
auto objActor = &bloodActors[objIndex];
spritetype* pSource = &sprite[pXSource->reference]; spritetype* pSource = &sprite[pXSource->reference];
switch (objType) { switch (objType) {
case OBJ_SECTOR: case OBJ_SECTOR:
if ((pSource->flags & kModernTypeFlag1) || (pXSource->data1 != -1 && pXSource->data1 != 32767)) if ((pSource->flags & kModernTypeFlag1) || (pXSource->data1 != -1 && pXSource->data1 != 32767))
setDataValueOfObject(objType, objIndex, 1, pXSource->data1); setDataValueOfObject(objType, objIndex, nullptr, 1, pXSource->data1);
break; break;
case OBJ_SPRITE: case OBJ_SPRITE:
if ((pSource->flags & kModernTypeFlag1) || (pXSource->data1 != -1 && pXSource->data1 != 32767)) if ((pSource->flags & kModernTypeFlag1) || (pXSource->data1 != -1 && pXSource->data1 != 32767))
setDataValueOfObject(objType, objIndex, 1, pXSource->data1); setDataValueOfObject(objType, objIndex, objActor, 1, pXSource->data1);
if ((pSource->flags & kModernTypeFlag1) || (pXSource->data2 != -1 && pXSource->data2 != 32767)) if ((pSource->flags & kModernTypeFlag1) || (pXSource->data2 != -1 && pXSource->data2 != 32767))
setDataValueOfObject(objType, objIndex, 2, pXSource->data2); setDataValueOfObject(objType, objIndex, objActor, 2, pXSource->data2);
if ((pSource->flags & kModernTypeFlag1) || (pXSource->data3 != -1 && pXSource->data3 != 32767)) if ((pSource->flags & kModernTypeFlag1) || (pXSource->data3 != -1 && pXSource->data3 != 32767))
setDataValueOfObject(objType, objIndex, 3, pXSource->data3); setDataValueOfObject(objType, objIndex, objActor, 3, pXSource->data3);
if ((pSource->flags & kModernTypeFlag1) || pXSource->data4 != 65535) if ((pSource->flags & kModernTypeFlag1) || pXSource->data4 != 65535)
setDataValueOfObject(objType, objIndex, 4, pXSource->data4); setDataValueOfObject(objType, objIndex, objActor, 4, pXSource->data4);
break; break;
case OBJ_WALL: case OBJ_WALL:
if ((pSource->flags & kModernTypeFlag1) || (pXSource->data1 != -1 && pXSource->data1 != 32767)) if ((pSource->flags & kModernTypeFlag1) || (pXSource->data1 != -1 && pXSource->data1 != 32767))
setDataValueOfObject(objType, objIndex, 1, pXSource->data1); setDataValueOfObject(objType, objIndex, nullptr, 1, pXSource->data1);
break; break;
} }
} }
@ -7220,16 +7230,18 @@ int getDataFieldOfObject(int objType, int objIndex, DBloodActor* actor, int data
} }
} }
bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value) { bool setDataValueOfObject(int objType, int objIndex, DBloodActor* objActor, int dataIndex, int value)
{
switch (objType) switch (objType)
{ {
case OBJ_SPRITE: case OBJ_SPRITE:
{ {
XSPRITE* pXSprite = &xsprite[sprite[objIndex].extra]; XSPRITE* pXSprite = &objActor->x();
int type = objActor->s().type;
// exceptions // exceptions
if (IsDudeSprite(&sprite[objIndex]) && pXSprite->health <= 0) return true; if (objActor->IsDudeActor() && pXSprite->health <= 0) return true;
switch (sprite[objIndex].type) switch (type)
{ {
case kThingBloodBits: case kThingBloodBits:
case kThingBloodChunks: case kThingBloodChunks:
@ -7241,45 +7253,48 @@ bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value) {
switch (dataIndex) switch (dataIndex)
{ {
case 1: case 1:
xsprite[sprite[objIndex].extra].data1 = value; pXSprite->data1 = value;
switch (sprite[objIndex].type) { switch (type)
{
case kSwitchCombo: case kSwitchCombo:
if (value == xsprite[sprite[objIndex].extra].data2) SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 1); if (value == pXSprite->data2) SetSpriteState(objActor, 1);
else SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 0); else SetSpriteState(objActor, 0);
break; break;
case kDudeModernCustom: case kDudeModernCustom:
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
gGenDudeExtra[objIndex].updReq[kGenDudePropertyWeapon] = true; objActor->genDudeExtra().updReq[kGenDudePropertyWeapon] = true;
gGenDudeExtra[objIndex].updReq[kGenDudePropertyDmgScale] = true; objActor->genDudeExtra().updReq[kGenDudePropertyDmgScale] = true;
evPostActor(&bloodActors[objIndex], kGenDudeUpdTimeRate, kCallbackGenDudeUpdate); evPostActor(objActor, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate);
break; break;
} }
return true; return true;
case 2: case 2:
xsprite[sprite[objIndex].extra].data2 = value; pXSprite->data2 = value;
switch (sprite[objIndex].type) { switch (type)
{
case kDudeModernCustom: case kDudeModernCustom:
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
gGenDudeExtra[objIndex].updReq[kGenDudePropertySpriteSize] = true; objActor->genDudeExtra().updReq[kGenDudePropertySpriteSize] = true;
gGenDudeExtra[objIndex].updReq[kGenDudePropertyMass] = true; objActor->genDudeExtra().updReq[kGenDudePropertyMass] = true;
gGenDudeExtra[objIndex].updReq[kGenDudePropertyDmgScale] = true; objActor->genDudeExtra().updReq[kGenDudePropertyDmgScale] = true;
gGenDudeExtra[objIndex].updReq[kGenDudePropertyStates] = true; objActor->genDudeExtra().updReq[kGenDudePropertyStates] = true;
gGenDudeExtra[objIndex].updReq[kGenDudePropertyAttack] = true; objActor->genDudeExtra().updReq[kGenDudePropertyAttack] = true;
evPostActor(&bloodActors[objIndex], kGenDudeUpdTimeRate, kCallbackGenDudeUpdate); evPostActor(objActor, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate);
break; break;
} }
return true; return true;
case 3: case 3:
xsprite[sprite[objIndex].extra].data3 = value; pXSprite->data3 = value;
switch (sprite[objIndex].type) { switch (type)
{
case kDudeModernCustom: case kDudeModernCustom:
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
xsprite[sprite[objIndex].extra].sysData1 = value; pXSprite->sysData1 = value;
break; break;
} }
return true; return true;
case 4: case 4:
xsprite[sprite[objIndex].extra].data4 = value; pXSprite->data4 = value;
return true; return true;
default: default:
return false; return false;

View file

@ -324,7 +324,7 @@ void damageSprites(DBloodActor* pXSource, DBloodActor* pSprite);
void useRandomItemGen(DBloodActor* pSource); void useRandomItemGen(DBloodActor* pSource);
void useUniMissileGen(DBloodActor* sourceactor, DBloodActor* actor); void useUniMissileGen(DBloodActor* sourceactor, DBloodActor* actor);
void useSoundGen(DBloodActor* sourceactor, DBloodActor* actor); void useSoundGen(DBloodActor* sourceactor, DBloodActor* actor);
void useIncDecGen(XSPRITE* pXSource, short objType, int objIndex); void useIncDecGen(DBloodActor* sourceactor, short objType, int objIndex, DBloodActor* objactor);
void useDataChanger(XSPRITE* pXSource, int objType, int objIndex); void useDataChanger(XSPRITE* pXSource, int objType, int objIndex);
void useSectorLigthChanger(XSPRITE* pXSource, XSECTOR* pXSector); void useSectorLigthChanger(XSPRITE* pXSource, XSECTOR* pXSector);
void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite); void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite);
@ -366,7 +366,7 @@ bool IsBurningDude(spritetype* pSprite);
bool IsKillableDude(spritetype* pSprite); bool IsKillableDude(spritetype* pSprite);
bool isActive(int nSprite); bool isActive(int nSprite);
int getDataFieldOfObject(int objType, int objIndex, DBloodActor* objActor, int dataIndex); int getDataFieldOfObject(int objType, int objIndex, DBloodActor* objActor, int dataIndex);
bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value); bool setDataValueOfObject(int objType, int objIndex, DBloodActor* objActor, int dataIndex, int value);
bool incDecGoalValueIsReached(XSPRITE* pXSprite); bool incDecGoalValueIsReached(XSPRITE* pXSprite);
int getSpriteMassBySize(DBloodActor* pSprite); int getSpriteMassBySize(DBloodActor* pSprite);
bool ceilIsTooLow(DBloodActor* pSprite); bool ceilIsTooLow(DBloodActor* pSprite);