Skip to content

Commit

Permalink
Fix #197 provide projectile pointer to config
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed Oct 12, 2019
1 parent 1ec3119 commit c5917a6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion _work/data/Scripts/Content/GFA/_intern/collectable.d
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ func void GFA_RP_KeepProjectileInWorld() {
// Replace the projectile if desired, retrieve new projectile instance from config
var C_Npc emptyNpc; emptyNpc = MEM_NullToInst(); // No NPC was hit, so pass an empty instance as argument
var C_Npc shooter; shooter = _^(MEM_ReadInt(arrowAI+oCAIArrow_origin_offset));
GFA_ProjectilePtr = projectilePtr; // Temporarily provide projectile
var int projInst; projInst = GFA_GetUsedProjectileInstance(projectile.instanz, shooter, emptyNpc);
GFA_ProjectilePtr = 0;

// Check if the new projectile instance is valid, -1 for invalid instance, 0 for empty
if (projInst > 0) {
Expand Down Expand Up @@ -121,7 +123,8 @@ func void GFA_RP_PutProjectileIntoInventory() {
return;
};

var oCItem projectile; projectile = _^(MEM_ReadInt(arrowAI+oCAIArrowBase_hostVob_offset));
var int projectilePtr; projectilePtr = MEM_ReadInt(arrowAI+oCAIArrowBase_hostVob_offset);
var oCItem projectile; projectile = _^(projectilePtr);

// Differentiate between positive hit and collision without damage (in case of auto aim hit registration)
var int positiveHit; positiveHit = MEMINT_SwitchG1G2(
Expand All @@ -133,7 +136,9 @@ func void GFA_RP_PutProjectileIntoInventory() {
var C_Npc shooter; shooter = _^(MEM_ReadInt(arrowAI+oCAIArrow_origin_offset));

// Replace the projectile if desired, retrieve new projectile instance from config
GFA_ProjectilePtr = projectilePtr; // Temporarily provide projectile
var int projInst; projInst = GFA_GetUsedProjectileInstance(projectile.instanz, shooter, victim);
GFA_ProjectilePtr = 0;
if (projInst > 0) {
CreateInvItem(victim, projInst); // Put respective instance in inventory
};
Expand Down
5 changes: 4 additions & 1 deletion _work/data/Scripts/Content/GFA/_intern/criticalHit.d
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ func void GFA_CH_DetectCriticalHit() {
};

// Do this for one damage type only. It gets too complicated for multiple damage types
var oCItem projectile; projectile = _^(MEM_ReadInt(arrowAI+oCAIArrowBase_hostVob_offset));
var int projectilePtr; projectilePtr = MEM_ReadInt(arrowAI+oCAIArrowBase_hostVob_offset);
var oCItem projectile; projectile = _^(projectilePtr);
var int iterator; iterator = projectile.damageType;
var int damageIndex; damageIndex = 0;
// Find damage index from bit field
Expand Down Expand Up @@ -244,7 +245,9 @@ func void GFA_CH_DetectCriticalHit() {
damage.info = "";

// Update damage message in config
GFA_ProjectilePtr = projectilePtr; // Temporarily provide projectile
GFA_CH_GetCriticalHit_(targetNpc, dmgMsgPtr);
GFA_ProjectilePtr = 0;

// Adjust damage for damage behavior
var string damageBehaviorStr; // Debug output on zSpy
Expand Down
2 changes: 2 additions & 0 deletions _work/data/Scripts/Content/GFA/_intern/rangedShooting.d
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ func void GFA_SetupProjectile() {
} else {
// Retrieve and update damage
baseDamage = MEM_ReadStatArr(_@(projectile.damage), damageIndex);
GFA_ProjectilePtr = projectilePtr; // Temporarily provide projectile
newBaseDamage = GFA_GetInitialBaseDamage_(baseDamage, damageIndex, distPlayer);
GFA_ProjectilePtr = 0;

// Apply new damage to projectile
projectile.damageTotal = newBaseDamage;
Expand Down
7 changes: 7 additions & 0 deletions _work/data/Scripts/Content/GFA/config/ranged.d
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,12 @@ func int GFA_GetInitialBaseDamage(var int baseDamage, var int damageType, var C_
aimingDistance = (-aimingDistance+100); // Inverse distance percentage
baseDamage = (baseDamage * aimingDistance) / 100; */

/*
// Optionally, add a special effect to the projectile if it is fired with maximum draw force
if (GFA_GetDrawForce(weapon, talent) > 90) {
var C_Item projectile; projectile = _^(GFA_ProjectilePtr); // This global variable is only filled temporarily
Wld_PlayEffect("spellFX_BELIARSRAGE_COLLIDE", projectile, projectile, 0, 0, 0, FALSE);
};*/

return baseDamage;
};

0 comments on commit c5917a6

Please sign in to comment.