Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent collision with triggers #99

Closed
szapp opened this issue Nov 17, 2016 · 1 comment
Closed

Prevent collision with triggers #99

szapp opened this issue Nov 17, 2016 · 1 comment

Comments

@szapp
Copy link
Owner

szapp commented Nov 17, 2016

Projectiles can collide with triggers (levers, switches). However, this behavior is not disabled for triggers that should not respond to objects. Projectiles collide with any trigger which causes a loud metallic noise and will cause the projectile to drop in some cases.

Fix this with this script.

Make sure triggers in the original gothic are initialized with the correct respondToObject flags.

/* ... */

const int oCAIArrow__CanThisCollideWith = 6952080; //0x6A1490 // Hook length 7
const int zCTrigger_vtbl = 8627196;
const int zCTriggerScript_vtbl = 8582148;

/* ... */

// virtual int __thiscall oCAIArrow::CanThisCollideWith(class zCVob *)
HookEngineF(oCAIArrow__CanThisCollideWith, 7, freeAimTriggerCollisionCheck);

/* ... */

func void freeAimTriggerCollisionCheck() {
    var int vobPtr; vobPtr = ESP + 4;
    var int shooter; shooter = MEM_ReadInt(ECX + 92);
    var int vtbl; vtbl = MEM_ReadInt(MEM_ReadInt(vobPtr));
    if(vtbl != zCTrigger_vtbl) && (vtbl != zCTriggerScript_vtbl) { return; }; // It is no Trigger
    var zCTrigger trigger; trigger = _^(MEM_ReadInt(vobPtr));
    if (trigger.bitfield & zCTrigger_bitfield_respondToObject) { return; }; // Object-reacting trigger
    MEM_WriteInt(vobPtr, shooter); // The engine ignores the shooter
};

Source

@szapp
Copy link
Owner Author

szapp commented Nov 17, 2016

Fix #99 apply trigger collision fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant