Skip to content

Commit

Permalink
Find C_NpcIsUndead and adjacent only once
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed May 8, 2024
1 parent 4409274 commit d9d448e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 27 deletions.
67 changes: 41 additions & 26 deletions _work/data/Scripts/Content/GFA/_intern/auxiliary.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func void GFA_WriteNOP(var int addr, var int len) {


/*
* Emulate GFA_SwitchExe of Ikarus for older Ikarus versions
* Emulate MEMINT_SwitchExe of Ikarus for older Ikarus versions
* In order of likelihood for performance micro-optimization
*/
func int GFA_SwitchExe(var int g1Val, var int g112Val, var int g130Val, var int g2Val) {
Expand Down Expand Up @@ -655,41 +655,56 @@ func int GFA_NpcIsDown(var C_Npc slf) {
* Gothic 1: oCSpell::IsTargetTypeValid()+149h 0x47DD09
*/
func int GFA_NpcIsUndead(var C_Npc slf) {
var int funcId; funcId = MEM_GetSymbolIndex("C_NPCISUNDEAD");
const int funcId = -2;
const int GIL_ZOMBIE = 0;
const int GIL_UNDEADORC = 0;
const int GIL_SKELETON = 0;

// Search for symbols once only
if (funcId == -2) {
funcId = MEM_GetSymbolIndex("C_NPCISUNDEAD");

var int symbPtr;
var zCPar_Symbol symb;

symbPtr = MEM_GetSymbol("GIL_ZOMBIE");
if (symbPtr) {
symb = _^(symbPtr);
GIL_ZOMBIE = symb.content;
};

symbPtr = MEM_GetSymbol("GIL_UNDEADORC");
if (symbPtr) {
symb = _^(symbPtr);
GIL_UNDEADORC = symb.content;
};

symbPtr = MEM_GetSymbol("GIL_SKELETON");
if (symbPtr) {
symb = _^(symbPtr);
GIL_SKELETON = symb.content;
};

};

// Call script function if it exists
if (funcId != -1) {
MEM_PushInstParam(slf);
MEM_CallById(funcId);
return MEM_PopIntResult();
};

var int symbPtr;
var zCPar_Symbol symb;

// if (slf.guild == GIL_ZOMBIE)
symbPtr = MEM_GetSymbol("GIL_ZOMBIE");
if (symbPtr) {
symb = _^(symbPtr);
if (slf.guild == symb.content) {
return TRUE;
};
// Emulate conditions
if (slf.guild == GIL_ZOMBIE) {
return TRUE;
};

// if (slf.guild == GIL_UNDEADORC)
symbPtr = MEM_GetSymbol("GIL_UNDEADORC");
if (symbPtr) {
symb = _^(symbPtr);
if (slf.guild == symb.content) {
return TRUE;
};
if (slf.guild == GIL_UNDEADORC) {
return TRUE;
};

// if (slf.guild == GIL_SKELETON)
symbPtr = MEM_GetSymbol("GIL_SKELETON");
if (symbPtr) {
symb = _^(symbPtr);
if (slf.guild == symb.content) {
return TRUE;
};
if (slf.guild == GIL_SKELETON) {
return TRUE;
};

return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion _work/data/Scripts/Content/GFA/_intern/collision.d
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func void GFA_CC_ProjectileCollisionWithNpc() {
MEM_WriteInt(arrowAI+oCAIArrowBase_creatingImpactFX_offset, collisionCounter+1);

// Collision behaviors
const int DESTROY = 0; // Projectile doest not cause damage and vanishes
const int DESTROY = 0; // Projectile does not cause damage and vanishes
const int DAMAGE = 1; // Projectile causes damage and may stay in the inventory of the victim
const int DEFLECT = 2; // Projectile deflects off of the surfaces and bounces off

Expand Down

0 comments on commit d9d448e

Please sign in to comment.