[Vanilla Enhancement] 2 customizeble of DiskLaser#2243
Conversation
|
Nightly build for this pull request:
This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build. |
|
To Chinese users:
|
| DEFINE_HOOK(0x4A7696, DiskLaserClass_AI_SimulateFiring, 0x6) | ||
| { | ||
| enum { ReturnFromFunction = 0x4A76F4 }; | ||
|
|
||
| GET(DiskLaserClass*, pDiskLaser, ESI); | ||
| const auto pWeapon = pDiskLaser->Weapon; | ||
| const auto pWeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon); | ||
|
|
||
| if (!pWeaponExt->DiskLaser_SimulateFire) | ||
| return 0; | ||
|
|
||
| REF_STACK(CoordStruct, targetCoords, STACK_OFFSET(0x50, -0x18)); | ||
| REF_STACK(CoordStruct, fireCoords, STACK_OFFSET(0x50, -0x24)); | ||
| const CoordStruct targetCoords2D { targetCoords.X, targetCoords.Y, 0 }; | ||
| const CoordStruct fireCoords2D { fireCoords.X, fireCoords.Y, 0 }; | ||
|
|
||
| int bulletSpeed = pWeapon->GetSpeed(static_cast<int>(fireCoords2D.DistanceFrom(targetCoords2D))); | ||
|
|
||
| const auto pOwner = pDiskLaser->Owner; | ||
| const auto pData = DiskLaserTemp::DataMap.get_or_default(pDiskLaser); | ||
| const int damage = static_cast<int>(pDiskLaser->Damage * pData->FirepowerMultiplier); | ||
|
|
||
| if (const auto pBullet = pWeapon->Projectile->CreateBullet(pDiskLaser->Target, pOwner, damage, pWeapon->Warhead, bulletSpeed, pWeapon->Bright)) | ||
| { | ||
| BulletExt::ExtMap.Find(pBullet)->FirepowerMult = pData->FirepowerMultiplier; | ||
| BulletExt::SimulatedFiringUnlimbo(pBullet, pOwner->Owner, pWeapon, fireCoords, false); | ||
| BulletExt::SimulatedFiringEffects(pBullet, pOwner->Owner, pOwner, true, false); | ||
| } | ||
|
|
||
| pDiskLaser->unknown_30 = static_cast<DWORD>(-1); // Restrore overriden instruction and skip Ares's hook here | ||
| return ReturnFromFunction; | ||
| } |
There was a problem hiding this comment.
Since you want to simulate firing, why not directly call TechnoClass::Fire when DiskLaser fires (and skip the processing for the DiskLaser part)?
There was a problem hiding this comment.
Maybe the rof part either
There was a problem hiding this comment.
I don't want too many unnecessary operations mixed in; And calling the Fire() function directly will use the current Owner's firepower multiplier, which is an incorrect behavior. If a hook is added for this, why call Fire()? The current one is already sufficient
DiskLaser.SimulateFiredetermines whether aDiskLaser=trueweapon simulates firing, avoiding the limitations of the original hardcoded kill method.DiskLaser.ChargeUpcustomizes the charge‑up sound forDiskLaser=trueweapons.In
rulesmd.ini: