CPowerUp::AI

This commit is contained in:
krystalgamer 2024-07-19 17:49:33 +02:00
parent 6daf353678
commit 871f95eb2a
3 changed files with 100 additions and 17 deletions

2
ob.h
View File

@ -43,7 +43,7 @@ public:
CItem *field_20;
unsigned int field_24;
u32 field_24;
__int16 field_28;
__int16 field_2A;
__int16 field_2C;

View File

@ -9,6 +9,76 @@ extern i32 TotalBitUsage;
EXPORT CBody* PowerUpList;
EXPORT i32 gPowerUpRelated;
// @MEDIUMTODO
void CPowerUp::DoPhysics(void)
{
printf("CPowerUp::DoPhysics");
}
// @Ok
void CPowerUp::AI(void)
{
if ( (this->mFlags & 1) && this->field_101)
this->field_D0 = 0;
else
this->field_D0 = 32;
if (this->field_124)
{
this->field_24 = 0x101010;
this->mFlags |= 0xC00;
this->field_124 = 0;
}
else
{
this->mFlags &= 0xF3FF;
}
if (this->field_128)
{
if (this->field_128 > 2)
{
this->mFlags |= 0x400;
this->field_128 -= 2;
u32 tmp = (255 * this->field_128 / 64);
tmp |= ((tmp << 8) | tmp) << 8;
this->field_24 = tmp;
}
else
{
this->Die();
return;
}
}
this->CheckAge();
if (this->field_E4 > 0x1F40)
{
this->DeleteStuff();
}
else
{
if (this->field_10C != 0xFFFFFFFF)
{
this->ShadowOn();
}
this->DoPhysics();
if (!this->field_101)
{
if (!this->pPickupBit)
this->CreateBit();
print_if_false(this->pPickupBit != 0, "Non-3d pickup has no pickup bit");
this->pPickupBit->SetPos(this->mPos);
}
}
}
// @Ok
void CPowerUp::CheckAge(void)
{
@ -101,9 +171,9 @@ void CPowerUp::DeleteStuff(void)
{
this->KillShadow();
if (this->field_130)
delete this->field_130;
this->field_130 = 0;
if (this->pPickupBit)
delete this->pPickupBit;
this->pPickupBit = 0;
CItem *unk = reinterpret_cast<CItem*>(this->field_F8);
if (unk)
@ -117,34 +187,34 @@ void CPowerUp::CreateBit(void)
TotalBitUsage = 0;
if (this->field_38 == 18)
{
this->field_130 = new CFlatBit();
this->pPickupBit = new CFlatBit();
Texture *pTexture = Spool_FindTextureEntry("TrainingPick-Up_01");
this->field_130->SetTexture(pTexture);
this->field_130->SetSemiTransparent();
this->pPickupBit->SetTexture(pTexture);
this->pPickupBit->SetSemiTransparent();
switch (this->field_E2)
{
case 0xA:
this->field_130->SetTint(0x6Au, 212, 105);
this->pPickupBit->SetTint(0x6Au, 212, 105);
break;
case 0x14:
this->field_130->SetTint(0x85u, 133, 255);
this->pPickupBit->SetTint(0x85u, 133, 255);
break;
case 0x28:
this->field_130->SetTint(0xFFu, 77, 77);
this->pPickupBit->SetTint(0xFFu, 77, 77);
break;
case 0x50:
this->field_130->SetTint(0xD8u, 216, 216);
this->pPickupBit->SetTint(0xD8u, 216, 216);
break;
default:
this->field_130->SetTint(0x80u, 128, 32);
this->pPickupBit->SetTint(0x80u, 128, 32);
break;
}
}
if (this->field_130)
this->field_130->mProtected = 1;
if (this->pPickupBit)
this->pPickupBit->mProtected = 1;
TotalBitUsage = 1;
}
@ -176,8 +246,12 @@ void validate_CPowerUp(void)
VALIDATE(CPowerUp, field_106, 0x106);
VALIDATE(CPowerUp, field_108, 0x108);
VALIDATE(CPowerUp, field_10C, 0x10C);
VALIDATE(CPowerUp, field_11E, 0x11E);
VALIDATE(CPowerUp, field_120, 0x120);
VALIDATE(CPowerUp, field_124, 0x124);
VALIDATE(CPowerUp, field_128, 0x128);
VALIDATE(CPowerUp, field_12C, 0x12C);

View File

@ -15,8 +15,10 @@ class CPowerUp : public CBody
EXPORT void SetNode(i32);
EXPORT void CreateBit(void);
EXPORT void CheckAge(void);
EXPORT void DoPhysics(void);
EXPORT virtual void Die(void);
EXPORT virtual void AI(void);
EXPORT virtual void DeleteStuff(void);
u8 padTop[0xF8-0xF4];
@ -30,15 +32,22 @@ class CPowerUp : public CBody
u16 field_106;
u16 field_108;
u8 padAfter108[0x11E-0x108-2];
u8 padAfter108[0x10C-0x108-2];
i32 field_10C;
u8 padAfter10C[0x11E-0x10C-4];
u16 field_11E;
u16 field_120;
u8 padAfter120[0x12C-0x120-2];
u8 padAfter120[0x124-0x120-2];
u8 field_124;
u8 padAfter124[0x128-0x124-1];
i32 field_128;
u16 field_12C;
u8 padAfter12C[2];
CFlatBit* field_130;
CFlatBit* pPickupBit;
u8 padBottom[0x138-0x130-4];
};