Skip to content

Commit

Permalink
Temporarily provide colliding projectile
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
szapp committed Oct 10, 2019
1 parent e9c295c commit 1ec3119
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions _work/data/Scripts/Content/GFA/_intern/collision.d
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions _work/data/Scripts/Content/GFA/_intern/const.d
Expand Up @@ -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)
Expand Down

0 comments on commit 1ec3119

Please sign in to comment.