Skip to content

Commit 62891e7

Browse files
Allow user to load difficulty (#518)
* Allow user to load difficulty * Add getSpeed call * Test push * test commit * test commit * Add dumps to ignore and back to v141 * remove spurior recipes * Fix for remaster darkpilo.cfg which is not located in the game folder. * Add for linux compatibility * Update Linux pathing. * fix for nix paths * change the path path based on testing on proton. * patching jereth's float changes * Update angle values * updating angle code * Delete TheForceEngine/x64/Debug/TheForceEngine.exe.recipe Removing spurious file. * Fix for angles --------- Co-authored-by: Karjala22 <78927981+Karjala22@users.noreply.github.com>
1 parent 3c73ce6 commit 62891e7

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,6 @@ CMakeFiles/
8181

8282
# Linux
8383
TheForceEngine/tfelnx
84+
85+
# Ignore dumps
86+
*.dmp

TheForceEngine/TFE_DarkForces/Scripting/gs_level.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "scriptWall.h"
66
#include "scriptSector.h"
77
#include "scriptObject.h"
8+
#include <TFE_DarkForces/agent.h>
89
#include <TFE_DarkForces/player.h>
910
#include <TFE_DarkForces/projectile.h>
1011
#include <TFE_System/system.h>
@@ -331,6 +332,8 @@ namespace TFE_DarkForces
331332
ScriptLambdaPropertyGet("int get_textureCount()", s32, { return s_levelState.textureCount; });
332333
ScriptLambdaPropertyGet("int get_elevatorCount()", s32, { return allocator_getCount(s_infSerState.infElevators); });
333334
ScriptLambdaPropertyGet("float2 get_parallax()", TFE_ForceScript::float2, { return TFE_ForceScript::float2(fixed16ToFloat(s_levelState.parallax0), fixed16ToFloat(s_levelState.parallax1)); });
335+
336+
ScriptLambdaPropertyGet("int get_difficulty()", u8, { return s_agentData[s_agentId].difficulty; });
334337

335338
// Gameplay sector pointers.
336339
ScriptLambdaPropertyGet("Sector get_bossSector()", ScriptSector, { ScriptSector sector(-1); if (s_levelState.bossSector) { sector.m_id = s_levelState.bossSector->id; } return sector; });

TheForceEngine/TFE_DarkForces/Scripting/scriptElev.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ namespace TFE_DarkForces
2323
return (data->updateFlags & ELEV_MASTER_ON) != 0;
2424
}
2525

26-
void setElevSpeed(s32 value, ScriptElev* elev)
26+
float getElevSpeed(ScriptElev* elev)
27+
{
28+
if (!ScriptElev::isScriptElevValid(elev)) { return 0; }
29+
30+
InfElevator* data = (InfElevator*)allocator_getByIndex(s_infSerState.infElevators, elev->m_id);
31+
return data->type == IELEV_ROTATE_WALL ? fixedAngleToDegrees(data->speed) : fixed16ToFloat(data->speed);
32+
}
33+
34+
void setElevSpeed(float value, ScriptElev* elev)
2735
{
2836
if (!ScriptElev::isScriptElevValid(elev)) { return; }
2937

3038
InfElevator* data = (InfElevator*)allocator_getByIndex(s_infSerState.infElevators, elev->m_id);
31-
data->speed = data->type == IELEV_ROTATE_WALL ? FIXED(floatToAngle((f32)value)) : FIXED(value);
39+
data->speed = data->type == IELEV_ROTATE_WALL ? degreesToFixedAngle(value) : floatToFixed16(value);
3240
}
3341

3442
void ScriptElev::registerType()
@@ -37,13 +45,15 @@ namespace TFE_DarkForces
3745
asIScriptEngine* engine = (asIScriptEngine*)TFE_ForceScript::getEngine();
3846

3947
ScriptValueType("Elevator");
48+
4049
// Variables
4150
ScriptMemberVariable("int id", m_id);
4251
// Functions
4352
ScriptObjFunc("bool isValid()", isScriptElevValid);
4453
// Properties
4554
ScriptPropertyGetFunc("bool get_master()", getElevMaster);
46-
47-
ScriptPropertySetFunc("void set_speed(int)", setElevSpeed);
55+
56+
ScriptPropertyGetFunc("float get_speed()", getElevSpeed);
57+
ScriptPropertySetFunc("void set_speed(float)", setElevSpeed);
4858
}
4959
}

TheForceEngine/TFE_Jedi/Math/fixedPoint.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ namespace TFE_Jedi
137137
return fixed16_16(16384.0f * angle / 360.0f);
138138
}
139139

140+
inline f32 fixedAngleToDegrees(fixed16_16 angle)
141+
{
142+
return fixed16ToFloat(angle) / 45.5111f;
143+
}
144+
145+
inline fixed16_16 degreesToFixedAngle(f32 angle)
146+
{
147+
return floatToFixed16(angle * 45.5111f);
148+
}
149+
140150
inline s32 fixed16to12(fixed16_16 x)
141151
{
142152
return s32(x >> 4);

0 commit comments

Comments
 (0)