Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed Dec 9, 2018
2 parents 42d32b4 + 639aa85 commit e8375a4
Show file tree
Hide file tree
Showing 33 changed files with 352 additions and 250 deletions.
1 change: 0 additions & 1 deletion _work/data/Scripts/Content/GFA/GFA_G1.src
Expand Up @@ -8,7 +8,6 @@ config\settings.d
config\ranged.d
config\spell.d
config\reticleTextures.d
config\reticleBySpellID_G1.d
config\reticle.d
config\collision.d
config\collectable.d
Expand Down
1 change: 0 additions & 1 deletion _work/data/Scripts/Content/GFA/GFA_G2.src
Expand Up @@ -7,7 +7,6 @@ config\settings.d
config\ranged.d
config\spell.d
config\reticleTextures.d
config\reticleBySpellID_G2.d
config\reticle.d
config\collision.d
config\collectable.d
Expand Down
16 changes: 10 additions & 6 deletions _work/data/Scripts/Content/GFA/_intern/activate.d
@@ -1,7 +1,7 @@
/*
* Activate free aiming and set internal settings
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down Expand Up @@ -37,8 +37,10 @@ func void GFA_UpdateSettings(var int on) {
if (on) {
// Turn free aiming on
if (GFA_Flags & GFA_RANGED) {
// Set stricter focus collection
Focus_Ranged.npc_azi = castFromIntf(castToIntf(GFA_FOCUS_FAR_NPC)); // Cast twice, Deadalus floats are dumb
if (GFA_NO_AIM_NO_FOCUS) {
// Set stricter focus collection
Focus_Ranged.npc_azi = castFromIntf(castToIntf(GFA_FOCUS_FAR_NPC)); // Cast twice for, Deadalus floats
};

// New camera mode (does not affect Gothic 1)
MEM_WriteString(zString_CamModRanged, STR_Upper(GFA_CAMERA));
Expand Down Expand Up @@ -160,7 +162,7 @@ func void GFA_IsActive() {

// Check if falling (body state BS_FALL is unreliable, because it is set after the falling animation has started)
var zCAIPlayer playerAI; playerAI = _^(her.anictrl);
if (gef(playerAI.aboveFloor, mkf(12))) {
if (gef(playerAI.aboveFloor, mkf(50))) {
GFA_ResetSpell();
GFA_AimMovement(0, "");
GFA_RemoveReticle();
Expand Down Expand Up @@ -224,8 +226,10 @@ func void GFA_IsActive() {
return;
};
} else {
// Spell uses free aiming: Set stricter focus collection
Focus_Magic.npc_azi = castFromIntf(castToIntf(GFA_FOCUS_SPL_NPC)); // Cast twice, Deadalus floats are dumb
if (GFA_NO_AIM_NO_FOCUS) {
// Spell uses free aiming: Set stricter focus collection
Focus_Magic.npc_azi = castFromIntf(castToIntf(GFA_FOCUS_SPL_NPC)); // Cast twice for Deadalus floats
};
Focus_Magic.item_prio = GFA_FOCUS_SPL_ITM;
};

Expand Down
6 changes: 3 additions & 3 deletions _work/data/Scripts/Content/GFA/_intern/aimRay.d
@@ -1,7 +1,7 @@
/*
* Aim-specific trace ray and focus collection
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down Expand Up @@ -117,9 +117,9 @@ func int GFA_AimRayHead(var int npcPtr, var int fromPosPtr, var int dirPosPtr, v
*/
func int GFA_AimRay(var int distance, var int focusType, var int vobPtr, var int posPtr, var int distPtr,
var int trueDistPtr) {
// Only run full trace ray machinery every so often (see GFA_AimRayInterval) to allow weaker machines to run this
// Only run full trace ray machinery every so often (see GFA_RAY_INTERVAL) to allow weaker machines to run this
var int curTime; curTime = MEM_Timer.totalTime; // Get current time
if (curTime-GFA_AimRayPrevCalcTime >= GFA_AimRayInterval) { // If the interval has passed, recompute trace ray
if (curTime-GFA_AimRayPrevCalcTime >= GFA_RAY_INTERVAL) { // If the interval has passed, recompute trace ray
// Update time of previous calculation
GFA_AimRayPrevCalcTime = curTime;

Expand Down
2 changes: 1 addition & 1 deletion _work/data/Scripts/Content/GFA/_intern/aimVob.d
@@ -1,7 +1,7 @@
/*
* Definition and manipulation of aim vob (targeting system)
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down
2 changes: 1 addition & 1 deletion _work/data/Scripts/Content/GFA/_intern/auxiliary.d
@@ -1,7 +1,7 @@
/*
* Auxiliary functions including finding the active spell instance and ranged weapon and offering animated reticles
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down
19 changes: 17 additions & 2 deletions _work/data/Scripts/Content/GFA/_intern/ccommands.d
@@ -1,7 +1,7 @@
/*
* Definition of all console commands
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down Expand Up @@ -38,8 +38,13 @@ func string GFA_DebugPrint(var string _) {
/*
* Console function to enable/disable trace ray debug output. This function is registered as console command.
* When enabled, the trace ray is continuously drawn, as well as the nearest intersection with it.
* The visualizations require the LeGo package Draw3D to be initialized.
*/
func string GFA_DebugTraceRay(var string _) {
if (!(_LeGo_Flags & LeGo_Draw3D)) {
return "LeGo_Draw3D is not initialized. Cannot comply.";
};

if (!Hlp_IsValidHandle(GFA_DebugTRTrj)) {
GFA_DebugTRTrj = DrawLineAddr(0, zCOLOR_GREEN);
HideLine(GFA_DebugTRTrj);
Expand Down Expand Up @@ -72,8 +77,13 @@ func string GFA_DebugTraceRay(var string _) {
/*
* Console function to enable/disable trace ray debug output. This function is registered as console command.
* When enabled, the trajectory of the projectile is continuously drawn.
* The visualizations require the LeGo package Draw3D to be initialized.
*/
func string GFA_DebugTrajectory(var string _) {
if (!(_LeGo_Flags & LeGo_Draw3D)) {
return "LeGo_Draw3D is not initialized. Cannot comply.";
};

if (!Hlp_IsValidHandle(GFA_DebugCollTrj)) {
GFA_DebugCollTrj = DrawLineAddr(_@(GFA_CollTrj), zCOLOR_RED);
} else {
Expand All @@ -91,8 +101,13 @@ func string GFA_DebugTrajectory(var string _) {
/*
* Console function to enable/disable bone debug visualization. This function is registered as console command.
* When enabled, the hit model node of the last shot NPC is visualized by a bounding box or oriented bounding box.
* The visualizations require the LeGo package Draw3D to be initialized.
*/
func string GFA_DebugBone(var string _) {
if (!(_LeGo_Flags & LeGo_Draw3D)) {
return "LeGo_Draw3D is not initialized. Cannot comply.";
};

if (!Hlp_IsValidHandle(GFA_DebugBoneBBox)) {
GFA_DebugBoneBBox = DrawBBoxAddr(0, zCOLOR_RED);
HideBBox(GFA_DebugBoneBBox);
Expand Down Expand Up @@ -232,7 +247,7 @@ func string GFA_GetInfo(var string _) {
SB(MEM_ReadStatStringArr(onOff, GFA_STRAFING > 0));

SB(". Focus update every ");
SBi(GFA_AimRayInterval);
SBi(GFA_RAY_INTERVAL);
SB(" ms");
};
SBc(13); SBc(10);
Expand Down
2 changes: 1 addition & 1 deletion _work/data/Scripts/Content/GFA/_intern/classes.d
@@ -1,7 +1,7 @@
/*
* GFA Classes
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down
8 changes: 5 additions & 3 deletions _work/data/Scripts/Content/GFA/_intern/collectable.d
@@ -1,7 +1,7 @@
/*
* Collectable projectiles feature
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down Expand Up @@ -46,8 +46,10 @@ func void GFA_RP_KeepProjectileInWorld() {
};

// Always keep the projectile alive, set infinite life time
MEM_WriteInt(arrowAI+oCAIArrowBase_lifeTime_offset, -1082130432); // -1
projectile._zCVob_visualAlpha = FLOATONE; // Fully visible
if (gef(MEM_ReadInt(arrowAI+oCAIArrowBase_lifeTime_offset), FLOATNULL)) {
MEM_WriteInt(arrowAI+oCAIArrowBase_lifeTime_offset, FLOATONE_NEG);
projectile._zCVob_visualAlpha = FLOATONE; // Fully visible
};

// Check if the projectile stopped moving
if (!(projectile._zCVob_bitfield[0] & zCVob_bitfield0_physicsEnabled)) {
Expand Down
42 changes: 35 additions & 7 deletions _work/data/Scripts/Content/GFA/_intern/collision.d
@@ -1,7 +1,7 @@
/*
* Custom projectile collision behaviors feature
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down Expand Up @@ -121,11 +121,8 @@ func void GFA_CC_ProjectileStuck(var int projectilePtr) {
* It is called for both Gothic 1 and Gothic 2.
*/
func void GFA_CC_ProjectileDestroy(var int arrowAI) {
if (GOTHIC_BASE_VERSION == 1) {
MEM_WriteInt(arrowAI+oCAIArrow_destroyProjectile_offset, 1); // Gothic 1
} else {
MEM_WriteInt(arrowAI+oCAIArrowBase_lifeTime_offset, FLOATNULL); // Gothic 2
};
MEM_WriteInt(arrowAI+oCAIArrow_destroyProjectile_offset, 1);
MEM_WriteInt(arrowAI+oCAIArrowBase_lifeTime_offset, FLOATNULL);
};


Expand Down Expand Up @@ -227,7 +224,9 @@ func void GFA_CC_ProjectileCollisionWithNpc() {
if (collision == DEFLECT) {
var oCItem projectile; projectile = _^(MEM_ReadInt(arrowAI+oCAIArrowBase_hostVob_offset));
GFA_CC_ProjectileDeflect(projectile._zCVob_rigidBody);
MEM_WriteInt(arrowAI+oCAIArrow_destroyProjectile_offset, -1); // Mark as deflecting, such that it is ignored
if (GFA_Flags & GFA_REUSE_PROJECTILES) {
MEM_WriteInt(arrowAI+oCAIArrow_destroyProjectile_offset, -1); // Mark as deflecting to ignored it
};
} else {
MEM_WriteInt(arrowAI+oCAIArrow_destroyProjectile_offset, 1); // Destroy projectile on impact
};
Expand Down Expand Up @@ -473,6 +472,35 @@ func void GFA_CC_ProjectileCollisionWithWorld() {
};


/*
* Complete the half-implemented feature in Gothic 1 of fading out the visibility of a projectile before removing it.
* This function hooks oCAIArrowBase::DoAI(), if the collectable feature is not enabled.
*/
func void GFA_CC_FadeProjectileVisibility() {
// Check if AI was already removed
var int destroyed; destroyed = MEM_ReadInt(EDI);
if (destroyed) {
return;
};

// Check validity of projectile
var int projectilePtr; projectilePtr = EBX; // oCItem*
if (!projectilePtr) {
return;
};
var zCVob projectile; projectile = _^(projectilePtr);

// Check if the projectile stopped moving
if (!(projectile.bitfield[0] & zCVob_bitfield0_physicsEnabled)) {
var int arrowAI; arrowAI = ESI; // oCAIArrow*
var int lifeTime; lifeTime = MEM_ReadInt(arrowAI+oCAIArrowBase_lifeTime_offset);
if (lifeTime == FLOATONE_NEG) {
MEM_WriteInt(arrowAI+oCAIArrowBase_lifeTime_offset, FLOATONE);
};
};
};


/*
* Disable collision of projectiles with NPCs once the projectiles have bounced off of another surface. This function is
* called from GFA_ExtendCollisionCheck() only if GFA_COLL_PRIOR_NPC == -1.
Expand Down
19 changes: 9 additions & 10 deletions _work/data/Scripts/Content/GFA/_intern/const.d
@@ -1,7 +1,7 @@
/*
* Internal constants of GFA
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down Expand Up @@ -29,13 +29,10 @@

/* Initialization */

const string GFA_VERSION = "Gothic Free Aim v1.0.1";
const string GFA_VERSION = "Gothic Free Aim v1.1.0";
const int GFA_LEGO_FLAGS = LeGo_HookEngine // For initializing all hooks
| LeGo_FrameFunctions // For projectile gravity
| LeGo_ConsoleCommands // For console commands and debugging
| LeGo_Random // For scattering and other uses of random numbers
| LeGo_Draw3D // For debug visualizations
| LeGo_PrintS; // To be safe (in case it is used in critical hit event)
| LeGo_Random; // For scattering and other uses of random numbers

var int GFA_Flags; // Flags for initialization of GFA
const int GFA_RANGED = 1<<0; // Free aiming for ranged combat (bow and crossbow)
Expand Down Expand Up @@ -64,12 +61,13 @@ const float GFA_MAX_TURN_RATE_G1 = 2.0; // Gothic 1 has a ma

const int GFA_MIN_AIM_DIST = 140; // Minimum targeting distance. Fixes vertical shooting bug
const int GFA_MAX_DIST = 5000; // Distance for shooting/reticle. Do not change
var int GFA_AimRayInterval; // Perform trace ray every x ms (change in ini-file)
var int GFA_NO_AIM_NO_FOCUS; // Remove focus when not aiming (change in ini-file)
var int GFA_RAY_INTERVAL; // Perform trace ray every x ms (change in ini-file)
var int GFA_AimRayPrevCalcTime; // Time of last trace ray calculation

const int GFA_RETICLE_MIN_SIZE = 32; // Smallest reticle size in pixels
const int GFA_RETICLE_MAX_SIZE = 64; // Biggest reticle size in pixels
var int GFA_ReticleHndl; // Handle of the reticle
const int GFA_RETICLE_MIN_SIZE = 32; // Reticle size in pixels (at its smallest)
const int GFA_RETICLE_MAX_SIZE = 64; // Reticle size in pixels (at its biggest)
const int GFA_RETICLE_PTR = 0; // Reticle zCView
var int GFA_AimVobHasFX; // For performance: check whether FX needs to be removed

const string GFA_CAMERA = "CamModGFA"; // CCamSys_Def script instance
Expand Down Expand Up @@ -157,6 +155,7 @@ var int GFA_DebugBoneOBBox; // Handle of bone or

/* Numerical constants */

const int FLOATONE_NEG = -1082130432; // -1 as float
const int FLOAT1C = 1120403456; // 100 as float
const int FLOAT3C = 1133903872; // 300 as float
const int FLOAT1K = 1148846080; // 1000 as float
13 changes: 9 additions & 4 deletions _work/data/Scripts/Content/GFA/_intern/controls.d
@@ -1,7 +1,7 @@
/*
* Input and controls manipulation
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down Expand Up @@ -399,7 +399,9 @@ func void GFA_PreventFocusCollectionBodyStates() {
var oCNpc her; her = getPlayerInst();
if ((her.fmode == FMODE_FAR) || (her.fmode == FMODE_FAR+1)) && (GFA_Flags & GFA_RANGED) // Bow or crossbow
|| ((her.fmode == FMODE_MAGIC) && (GFA_Flags & GFA_SPELLS)) { // Spell
GFA_SetFocusAndTarget(0);
if (GFA_NO_AIM_NO_FOCUS) || ((GFA_ACTIVE_CTRL_SCHEME == 2) && (her.fmode == FMODE_MAGIC)) {
GFA_SetFocusAndTarget(0);
};

// With Gothic 2 controls, the reticle is still visible
if (GFA_ACTIVE_CTRL_SCHEME == 2) {
Expand Down Expand Up @@ -430,8 +432,11 @@ func void GFA_FixStandingBodyState() {
};
} else {
// oCAniCtrl_Human::SearchStandAni()
var zCAIPlayer playerAI; playerAI = _^(ESI);
npcPtr = playerAI.vob;
npcPtr = MEM_ReadInt(ESI+oCAniCtrl_Human_npc_offset);

if (!Hlp_Is_oCNpc(npcPtr)) {
return;
};
};

// Reset body state back to standing (instead of running/walking/sneaking)
Expand Down
2 changes: 1 addition & 1 deletion _work/data/Scripts/Content/GFA/_intern/criticalHit.d
@@ -1,7 +1,7 @@
/*
* Critical hit detection for ranged combat
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down
2 changes: 1 addition & 1 deletion _work/data/Scripts/Content/GFA/_intern/externals_G1.d
@@ -1,7 +1,7 @@
/*
* Constants and (external) functions that do not exist in Gothic 1
*
* Gothic Free Aim (GFA) v1.0.1 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Gothic Free Aim (GFA) v1.1.0 - Free aiming for the video games Gothic 1 and Gothic 2 by Piranha Bytes
* Copyright (C) 2016-2018 mud-freak (@szapp)
*
* This file is part of Gothic Free Aim.
Expand Down

0 comments on commit e8375a4

Please sign in to comment.