From 1ec3119dfeb465d0e8cb2558627c2644072d6517 Mon Sep 17 00:00:00 2001 From: szapp Date: Thu, 10 Oct 2019 22:01:52 +0200 Subject: [PATCH] Temporarily provide colliding projectile The collision configuration functions lacked access to the current projectile and the position of collision. Both can now be accessed via the pointer of the colliding projectile which is temporarily provided with the global variable GFA_ProjectilePtr. It can be accessed with var oCItem proj; proj = _^(GFA_ProjectilePtr); Print(proj.name); This unconventional method of providing information to the config functions preserves the function signatures and thus prevents issues in backward compatibility. --- _work/data/Scripts/Content/GFA/_intern/collision.d | 4 ++++ _work/data/Scripts/Content/GFA/_intern/const.d | 2 ++ 2 files changed, 6 insertions(+) diff --git a/_work/data/Scripts/Content/GFA/_intern/collision.d b/_work/data/Scripts/Content/GFA/_intern/collision.d index f7cb0df..f4c5906 100644 --- a/_work/data/Scripts/Content/GFA/_intern/collision.d +++ b/_work/data/Scripts/Content/GFA/_intern/collision.d @@ -216,7 +216,9 @@ func void GFA_CC_ProjectileCollisionWithNpc() { } else { // Retrieve the collision behavior based on the shooter, target and the material type of their armor var C_Npc target; target = _^(MEMINT_SwitchG1G2(EBX, MEM_ReadInt(/*esp+1ACh-190h*/ ESP+28))); + GFA_ProjectilePtr = MEM_ReadInt(arrowAI+oCAIArrowBase_hostVob_offset); // Temporarily provide projectile collision = GFA_CC_GetCollisionWithNpc_(shooter, target); + GFA_ProjectilePtr = 0; }; // Apply collision behavior @@ -359,7 +361,9 @@ func void GFA_CC_ProjectileCollisionWithWorld() { var int speed; speed = sqrtf(addf(addf(sqrf(vel[0]), sqrf(vel[1])), sqrf(vel[2]))); // Norm of vel // Retrieve the collision behavior based on the shooter, the material types and the textures of the collision object + GFA_ProjectilePtr = projectilePtr; // Temporarily provide projectile var int collision; collision = GFA_CC_GetCollisionWithWorld_(shooter, materials, textures); + GFA_ProjectilePtr = 0; const int DESTROY = 0; // Projectile breaks and vanishes const int STUCK = 1; // Projectile stays and is stuck in the surface of the collision object const int DEFLECT = 2; // Projectile deflects off of the surfaces and bounces off diff --git a/_work/data/Scripts/Content/GFA/_intern/const.d b/_work/data/Scripts/Content/GFA/_intern/const.d index 54e25d6..4e08ceb 100644 --- a/_work/data/Scripts/Content/GFA/_intern/const.d +++ b/_work/data/Scripts/Content/GFA/_intern/const.d @@ -131,6 +131,8 @@ const float GFA_SCATTER_MAX = 6.0; // (Visual angle)/2 var int GFA_CollTrj[6]; // Projectile trajectory of last collision candidate var string GFA_HitModelNode; // Name of model node that was hit +var int GFA_ProjectilePtr; // Pointer of currently colliding projectile (temporary) + const int DMG_NO_CHANGE = 0; // Do not adjust the damage const int DMG_DO_NOT_KNOCKOUT = 1; // Normal damage, shot may kill but never knockout (HP != 1) const int DMG_DO_NOT_KILL = 2; // Normal damage, shot may knockout but never kill (HP > 0)