Class Flow.Settings
-
Settings that will be run on game startup.
-
-
-
+
Global engine settings which don't fall into particular category or can't be assigned to a specific object.
+
Can be accessed using Flow.SetSettings and Flow.GetSettings functions.
-
+
+
+
+
+
+
+
+
+
+ mesh
+ Root mesh to which hair object will attach to.
+
+
+ offset
+ Relative braid offset to a headmesh.
+
+
+ indices
+ Braid connection indices.
+
+
+
+
+
+
+
+
+
errorMode
@@ -126,8 +311,924 @@
-
+
+
+ These settings determine whether a specific moveset is available in-game.
+
+
+
+
+ crawlExtended
+
+
+ Extended crawl moveset.
+
+
+
+
+ crawlExtended
+ bool
+ when enabled, player will be able to traverse across one-click steps in crawlspaces.
+
+
+
+
+
+
+
+
+
+
+ crouchRoll
+
+
+ Crouch roll.
+
+
+
+
+ crouchRoll
+ bool
+ when enabled, player can perform crawlspace roll by pressing sprint key.
+
+
+
+
+
+
+
+
+
+
+ crawlspaceSwandive
+
+
+ Crawlspace dive.
+
+
+
+
+ crawlspaceSwandive
+ bool
+ when enabled, player will be able to swandive into crawlspaces.
+
+
+
+
+
+
+
+
+
+
+ sprintJump
+
+
+ Sprint jump.
+
+
+
+
+ sprintJump
+ bool
+ if enabled, player will be able to perform extremely long jump when sprinting.
+
+
+
+
+
+
+
+
+
+
+ ledgeJumps
+
+
+ Ledge jumps.
+
+
+
+
+ ledgeJumps
+ bool
+ if this setting is enabled, player will be able to jump upwards while hanging on the ledge.
+
+
+
+
+
+
+
+
+
+
+ poseTimeout
+
+
+ Pose timeout.
+
+
+
+
+ poseTimeout
+ int
+ if this setting is larger than 0, idle standing pose animation will be performed after given timeout (in seconds).
+
+
+
+
+
+
+
+
+
+
+
+
+ Parameters to customize camera and everything related to it.
+
+
+
+
+ binocularLightColor
+
+
+ Determines highlight color in binocular mode.
+
+
+
+
+ binocularLightColor
+ Color
+ color of highlight, when player presses action. Zero color means there will be no highlight.
+
+
+
+
+
+
+
+
+
+
+ lasersightLightColor
+
+
+ Determines highlight color in lasersight mode.
+
+
+
+
+ lasersightLightColor
+ Color
+ lasersight highlight color. Zero color means there will be no highlight.
+
+
+
+
+
+
+
+
+
+
+ objectCollision
+
+
+ Specify whether camera can collide with objects.
+
+
+
+
+ objectCollision
+ bool
+ when enabled, camera will collide with moveables and statics. Disable or TR4-like camera behaviour.
+
+
+
+
+
+
+
+
+
+
+
+
+ These settings change appearance and behaviour of a flare.
+
+
+
+
+ color
+
+
+ Flare color.
+
+
+
+
+ color
+ Color
+ flare color. Used for sparks and lensflare coloring as well.
+
+
+
+
+
+
+
+
+
+
+ offset
+
+
+ Muzzle offset.
+
+
+
+
+ offset
+ Vec3
+ a relative muzzle offset where light and particle effects originate from.
+
+
+
+
+
+
+
+
+
+
+ range
+
+
+ Light range.
+
+
+
+
+ range
+ int
+ flare light radius or range. Represented in "clicks" equal to 256 world units.
+
+
+
+
+
+
+
+
+
+
+ timeout
+
+
+ Burn timeout.
+
+
+
+
+ timeout
+ int
+ flare burn timeout. Flare will stop working after given timeout (specified in seconds).
+
+
+
+
+
+
+
+
+
+
+ pickupCount
+
+
+ Default flare pickup count.
+
+
+
+
+ pickupCount
+ int
+ specifies amount of flares that you get when you pick up a box of flares.
+
+
+
+
+
+
+
+
+
+
+ lensflareBrightness
+
+
+ Lens flare brightness.
+
+
+
+
+ lensflareBrightness
+ float
+ brightness multiplier. Specifies how bright lens flare is in relation to light (on a range from 0 to 1).
+
+
+
+
+
+
+
+
+
+
+ sparks
+
+
+ Toggle spark effect.
+
+
+
+
+ sparks
+ bool
+ spark effect. Determines whether flare generates sparks when burning.
+
+
+
+
+
+
+
+
+
+
+ smoke
+
+
+ Toggle smoke effect.
+
+
+
+
+ smoke
+ bool
+ smoke effect. Determines whether flare generates smoke when burning.
+
+
+
+
+
+
+
+
+
+
+ flicker
+
+
+ Toggle flicker effect.
+
+
+
+
+ flicker
+ bool
+ light and lensflare flickering. When turned off, flare light will be constant.
+
+
+
+
+
+
+
+
+
+
+
+
+ This is a table of braid object settings.
+ Table consists of three entries, with first one representing classic Lara braid, and 2 and 3 representing left and right young Lara braids respectively.
+ Therefore, if you want to access classic Lara braid settings, use settings.Hair[1]
, and so on.
+
+
+
+
+ mesh
+
+
+ Root mesh to which hair object will attach to.
+
+
+
+
+ mesh
+ int
+ index of a root mesh to which hair will attach. Root mesh may be different for each hair object.
+
+
+
+
+
+
+
+
+
+
+ offset
+
+
+ Relative braid offset to a headmesh.
+
+
+
+
+ offset
+ Vec3
+ specifies how braid is positioned in relation to a headmesh.
+
+
+
+
+
+
+
+
+
+
+ indices
+
+
+ Braid connection indices.
+
+
+
+
+ indices
+ table
+ a list of headmesh's vertex connection indices. Each index corresponds to nearest braid rootmesh vertex. Amount of indices is unlimited.
+
+
+
+
+
+
+
+
+
+
+
+
+ These settings determine visibility of particular in-game HUD elements.
+
+
+
+
+ statusBars
+
+
+ Toggle in-game status bars visibility.
+
+
+
+
+ statusBars
+ bool
+ if disabled, all status bars (health, air, stamina) will be hidden.
+
+
+
+
+
+
+
+
+
+
+ loadingBar
+
+
+ Toggle loading bar visibility.
+
+
+
+
+ loadingBar
+ bool
+ if disabled, loading bar will be invisible in game.
+
+
+
+
+
+
+
+
+
+
+ speedometer
+
+
+ Toggle speedometer visibility.
+
+
+
+
+ speedometer
+ bool
+ if disabled, speedometer will be invisible in game.
+
+
+
+
+
+
+
+
+
+
+ pickupNotifier
+
+
+ Toggle pickup notifier visibility.
+
+
+
+
+ pickupNotifier
+ bool
+ if disabled, pickup notifier will be invisible in game.
+
+
+
+
+
+
+
+
+
+
+
+
+ Here you will find various settings for game world physics.
+
+
+
+
+ gravity
+
+
+ Global world gravity.
+
+
+
+
+ gravity
+ float
+ specifies global gravity. Mostly affects Lara and several other objects.
+
+
+
+
+
+
+
+
+
+
+ swimVelocity
+
+
+ Swim velocity.
+
+
+
+
+ swimVelocity
+ float
+ specifies swim velocity for Lara. Affects both surface and underwater.
+
+
+
+
+
+
+
+
+
+
+
+
+ This is a table of weapon settings, with several parameters available for every weapon.
+ Access particular weapon's settings by using
Objects.WeaponType as an index for this table, e.g.
settings.Weapons[Flow.WeaponType.PISTOLS]
.
+
+
+
+
+ accuracy
+
+
+ Shooting accuracy.
+
+
+
+
+ accuracy
+ float
+ determines accuracy range in angles (smaller angles mean higher accuracy). Applicable only for firearms.
+
+
+
+
+
+
+
+
+
+
+ targetingDistance
+
+
+ Targeting distance.
+
+
+
+
+ targetingDistance
+ float
+ specifies maximum targeting distance in world units (1 block = 1024 world units) for a given weapon.
+
+
+
+
+
+
+
+
+
+
+ interval
+
+
+ Shooting interval.
+
+
+
+
+ interval
+ float
+ specifies an interval (in frames), after which Lara is able to shoot again. Not applicable for backholster weapons.
+
+
+
+
+
+
+
+
+
+
+ damage
+
+
+ Damage.
+
+
+
+
+ damage
+ int
+ amount of hit points taken for every hit.
+
+
+
+
+
+
+
+
+
+
+ alternateDamage
+
+
+ Alternate damage.
+
+
+
+
+ alternateDamage
+ int
+ for Revolver and HK, specifies damage in lasersight mode. For crossbow, specifies damage for explosive ammo.
+
+
+
+
+
+
+
+
+
+
+ waterLevel
+
+
+ Water level.
+
+
+
+
+ waterLevel
+ int
+ specifies water depth, at which Lara will put weapons back into holsters, indicating it's not possible to use it in water.
+
+
+
+
+
+
+
+
+
+
+ pickupCount
+
+
+ Default ammo pickup count.
+
+
+
+
+ pickupCount
+ int
+ amount of ammo which is given with every ammo pickup for this weapon.
+
+
+
+
+
+
+
+
+
+
+ flashColor
+
+
+ Gunflash color.
+
+
+
+
+ flashColor
+ Color
+ specifies the color of the gunflash. Applicable only for firearms.
+
+
+
+
+
+
+
+
+
+
+ flashRange
+
+
+ Gunflash range.
+
+
+
+
+ flashRange
+ Color
+ specifies the range of the gunflash. Applicable only for firearms.
+
+
+
+
+
+
+
+
+
+
+ flashDuration
+
+
+ Gunflash duration.
+
+
+
+
+ flashDuration
+ int
+ specifies the duration of a gunflash effect. Applicable only for firearms.
+
+
+
+
+
+
+
+
+
+
+ smoke
+
+
+ Gun smoke.
+
+
+
+
+ smoke
+ bool
+ if set to true, indicates that weapon emits gun smoke. Not applicable for crossbow and harpoon gun.
+
+
+
+
+
+
+
+
+
+
+ shell
+
+
+ Gun shell.
+
+
+
+
+ shell
+ bool
+ if set to true, indicates that weapon emits gun shell. Applicable only for firearms.
+
+
+
+
+
+
+
+
+
+
+ muzzleFlash
+
+
+ Display muzzle flash.
+
+
+
+
+ muzzleFlash
+ bool
+ specifies whether muzzle flash should be displayed or not. Applicable only for firearms.
+
+
+
+
+
+
+
+
+
+
+ colorizeMuzzleFlash
+
+
+ Colorize muzzle flash.
+
+
+
+
+ colorizeMuzzleFlash
+ bool
+ specifies whether muzzle flash should be tinted with the same color as gunflash color. Applicable only for firearms.
+
+
+
+
+
+
+
+
+
+
+
+
+ Global system settings that is not directly related to gameplay.
+
@@ -135,24 +1236,15 @@
How should the application respond to script errors?
-
-Must be one of the following:
-ErrorMode.TERMINATE
- print to the log file and return to the title level when any script error is hit.
-This is the one you will want to go for if you want to know IMMEDIATELY if something has gone wrong.
-
-ErrorMode.WARN
- print to the log file and continue running the application when a recoverable script error is hit.
-Choose this one if booting to the title level is too much for you.
-
-ErrorMode.SILENT
- do nothing when a recoverable script error is hit.
-Think very carefully before using this setting. These error modes are here to help you to keep your scripts
-working properly, but if you opt to ignore errors, you won't be alerted if you've misused a function or passed
-an invalid argument.
-
-In all of these modes, an unrecoverable error will boot you to the title level. If the title level itself
-has an unrecoverable error, the game will close.
+
+ errorMode
+ ErrorMode
+ error mode to use. */
+
+
@@ -164,14 +1256,19 @@ has an unrecoverable error, the game will close.
fastReload
- Can the game utilize the fast reload feature?
-
+ Can the game utilize the fast reload feature?
When set to true
, the game will attempt to perform fast savegame reloading if current level is the same as
the level loaded from the savegame. It will not work if the level timestamp or checksum has changed
(i.e. level was updated). If set to false
, this functionality is turned off.
+
+ fastReload
+ bool
+ toggle fast reload on or off.
+
+
diff --git a/Documentation/doc/2 classes/Flow.Statistics.html b/Documentation/doc/2 classes/Flow.Statistics.html
new file mode 100644
index 000000000..69b1e6cac
--- /dev/null
+++ b/Documentation/doc/2 classes/Flow.Statistics.html
@@ -0,0 +1,334 @@
+
+
+
+
+ TombEngine 1.6 Lua API
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
TombEngine
+
+
+
+
1 Modules
+
+
2 Classes
+
+
3 Primitive Classes
+
+
4 Enums
+
+
5 Lua utility modules
+
+
+
+
+
+
+
Class Flow.Statistics
+
A set of gameplay statistics.
+
Can be accessed using Flow.GetStatistics and Flow.SetStatistics functions.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ammoHits
+
+
+ Ammo hits.
+
+
+
+
+ ammoHits
+ int
+ amount of successful enemy hits.
+
+
+
+
+
+
+
+
+
+
+ ammoUsed
+
+
+ Ammo used.
+
+
+
+
+ ammoUsed
+ int
+ amount of used ammo.
+
+
+
+
+
+
+
+
+
+
+ traveledDistance
+
+
+ Distance traveled.
+
+
+
+
+ traveledDistance
+ int
+ amount of traveled distance in world units. One meter is 420 world units.
+
+
+
+
+
+
+
+
+
+
+ healthPacksUsed
+
+
+ Health packs used.
+
+
+
+
+ healthPacksUsed
+ int
+ amount of used medipacks.
+
+
+
+
+
+
+
+
+
+
+ damageTaken
+
+
+ Damage taken.
+
+
+
+
+ damageTaken
+ int
+ overall amount of taken damage.
+
+
+
+
+
+
+
+
+
+
+ kills
+
+
+ Kills.
+
+
+
+
+ kills
+ int
+ amount of killed enemies.
+
+
+
+
+
+
+
+
+
+
+ secrets
+
+
+ Secrets.
+
+
+
+
+ secrets
+ int
+ amount of found secrets.
+
+
+
+
+
+
+
+
+
+
+ timeTaken
+
+
+ Time taken.
+
+
+
+
+ timeTaken
+ Time
+ amount of time passed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Documentation/doc/2 classes/Objects.AIObject.html b/Documentation/doc/2 classes/Objects.AIObject.html
index 084d7fea8..fcdf27cda 100644
--- a/Documentation/doc/2 classes/Objects.AIObject.html
+++ b/Documentation/doc/2 classes/Objects.AIObject.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/Objects.Camera.html b/Documentation/doc/2 classes/Objects.Camera.html
index 2bdb9ed5a..bc97292d9 100644
--- a/Documentation/doc/2 classes/Objects.Camera.html
+++ b/Documentation/doc/2 classes/Objects.Camera.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/Objects.LaraObject.html b/Documentation/doc/2 classes/Objects.LaraObject.html
index 51f890f32..ff4b23280 100644
--- a/Documentation/doc/2 classes/Objects.LaraObject.html
+++ b/Documentation/doc/2 classes/Objects.LaraObject.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
@@ -529,8 +531,8 @@
Returns:
- int
- weapon type 0=None, 1=Pistols, 2=Revolver, 3=Uzi, 4=Shotgun, 5=HK, 6=Crossbow, 7=Flare, 8=Torch, 9=GrenadeLauncher, 10=Harpoon, 11=RocketLauncher.
+ Flow.WeaponType
+ current weapon type.
@@ -553,28 +555,14 @@
Parameters:
@@ -583,7 +571,7 @@ ROCKETLAUNCHER
Usage:
Lara:SetWeaponType(LaraWeaponType.PISTOLS, false )
+
Lara:SetWeaponType(WeaponType.PISTOLS, false )
@@ -600,7 +588,7 @@ ROCKETLAUNCHER
Returns:
- int
+ Flow.AmmoType
player weapon ammo type
diff --git a/Documentation/doc/2 classes/Objects.Moveable.html b/Documentation/doc/2 classes/Objects.Moveable.html
index 1f08a41eb..e22e256ae 100644
--- a/Documentation/doc/2 classes/Objects.Moveable.html
+++ b/Documentation/doc/2 classes/Objects.Moveable.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/Objects.Room.html b/Documentation/doc/2 classes/Objects.Room.html
index e8084443f..0831a5b08 100644
--- a/Documentation/doc/2 classes/Objects.Room.html
+++ b/Documentation/doc/2 classes/Objects.Room.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/Objects.Sink.html b/Documentation/doc/2 classes/Objects.Sink.html
index e7094070a..f3b4692c2 100644
--- a/Documentation/doc/2 classes/Objects.Sink.html
+++ b/Documentation/doc/2 classes/Objects.Sink.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/Objects.SoundSource.html b/Documentation/doc/2 classes/Objects.SoundSource.html
index f344ad98d..6e650f5d3 100644
--- a/Documentation/doc/2 classes/Objects.SoundSource.html
+++ b/Documentation/doc/2 classes/Objects.SoundSource.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/Objects.Static.html b/Documentation/doc/2 classes/Objects.Static.html
index 0a66cb292..852ca7bb9 100644
--- a/Documentation/doc/2 classes/Objects.Static.html
+++ b/Documentation/doc/2 classes/Objects.Static.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/Objects.Volume.html b/Documentation/doc/2 classes/Objects.Volume.html
index 5132490d2..e258625b8 100644
--- a/Documentation/doc/2 classes/Objects.Volume.html
+++ b/Documentation/doc/2 classes/Objects.Volume.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/Strings.DisplayString.html b/Documentation/doc/2 classes/Strings.DisplayString.html
index 3c99ac6e6..f88b2beaf 100644
--- a/Documentation/doc/2 classes/Strings.DisplayString.html
+++ b/Documentation/doc/2 classes/Strings.DisplayString.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/View.DisplaySprite.html b/Documentation/doc/2 classes/View.DisplaySprite.html
index 007df1615..28186b80f 100644
--- a/Documentation/doc/2 classes/View.DisplaySprite.html
+++ b/Documentation/doc/2 classes/View.DisplaySprite.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/3 primitive classes/Color.html b/Documentation/doc/3 primitive classes/Color.html
index 70f66f9cb..cac27d90e 100644
--- a/Documentation/doc/3 primitive classes/Color.html
+++ b/Documentation/doc/3 primitive classes/Color.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/2 classes/Flow.Fog.html b/Documentation/doc/3 primitive classes/Flow.Fog.html
similarity index 86%
rename from Documentation/doc/2 classes/Flow.Fog.html
rename to Documentation/doc/3 primitive classes/Flow.Fog.html
index 393062f23..dfbacdc19 100644
--- a/Documentation/doc/2 classes/Flow.Fog.html
+++ b/Documentation/doc/3 primitive classes/Flow.Fog.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
@@ -103,8 +105,8 @@
-
Class Flow.Fog
-
Fog
+
Primitive Class Flow.Fog
+
Distance fog.
@@ -162,13 +164,8 @@
minDistance
-
-(int) min distance.
-
- This is the distance at which the fog starts
-
-
-
+ (int) min distance.
+ This is the distance at which the fog starts.*
@@ -183,13 +180,8 @@
maxDistance
-
-(int) max distance.
-
- This is the distance at which the fog reaches the maximum strength
-
-
-
+ (int) max distance.
+ This is the distance at which the fog reaches the maximum strength.
@@ -233,7 +225,7 @@
Returns:
- Fog
+ Fog
A fog object.
diff --git a/Documentation/doc/2 classes/Flow.InventoryItem.html b/Documentation/doc/3 primitive classes/Flow.InventoryItem.html
similarity index 90%
rename from Documentation/doc/2 classes/Flow.InventoryItem.html
rename to Documentation/doc/3 primitive classes/Flow.InventoryItem.html
index 6e9b4164b..fdf6e4361 100644
--- a/Documentation/doc/2 classes/Flow.InventoryItem.html
+++ b/Documentation/doc/3 primitive classes/Flow.InventoryItem.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
@@ -103,7 +105,7 @@
-
Class Flow.InventoryItem
+
Primitive Class Flow.InventoryItem
Represents the properties of an object as it appears in the inventory.
@@ -191,7 +193,7 @@ EXAMINE
Returns:
- InventoryItem
+ InventoryItem
an InventoryItem
diff --git a/Documentation/doc/2 classes/Flow.LensFlare.html b/Documentation/doc/3 primitive classes/Flow.LensFlare.html
similarity index 91%
rename from Documentation/doc/2 classes/Flow.LensFlare.html
rename to Documentation/doc/3 primitive classes/Flow.LensFlare.html
index 22c0b4621..926086455 100644
--- a/Documentation/doc/2 classes/Flow.LensFlare.html
+++ b/Documentation/doc/3 primitive classes/Flow.LensFlare.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
@@ -103,8 +105,8 @@
-
Class Flow.LensFlare
-
Represents a lens flare.
+
Primitive Class Flow.LensFlare
+
Represents a global lens flare (not to be confused with lensflare object).
@@ -191,7 +193,7 @@
Returns:
- LensFlare
+ LensFlare
A new LensFlare object.
diff --git a/Documentation/doc/2 classes/Flow.SkyLayer.html b/Documentation/doc/3 primitive classes/Flow.SkyLayer.html
similarity index 88%
rename from Documentation/doc/2 classes/Flow.SkyLayer.html
rename to Documentation/doc/3 primitive classes/Flow.SkyLayer.html
index 8a3c3b2b5..efb6f362c 100644
--- a/Documentation/doc/2 classes/Flow.SkyLayer.html
+++ b/Documentation/doc/3 primitive classes/Flow.SkyLayer.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
@@ -103,7 +105,7 @@
-
Class Flow.SkyLayer
+
Primitive Class Flow.SkyLayer
Describes a layer of moving clouds.
As seen in TR4's City of the Dead.
@@ -205,7 +207,7 @@
Returns:
- SkyLayer
+ SkyLayer
A SkyLayer object.
diff --git a/Documentation/doc/2 classes/Flow.Starfield.html b/Documentation/doc/3 primitive classes/Flow.Starfield.html
similarity index 92%
rename from Documentation/doc/2 classes/Flow.Starfield.html
rename to Documentation/doc/3 primitive classes/Flow.Starfield.html
index 12525a94f..332aa86fa 100644
--- a/Documentation/doc/2 classes/Flow.Starfield.html
+++ b/Documentation/doc/3 primitive classes/Flow.Starfield.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
@@ -103,7 +105,7 @@
-
Class Flow.Starfield
+
Primitive Class Flow.Starfield
Represents a starfield.
@@ -189,7 +191,7 @@
Returns:
- Starfield
+ Starfield
A new Starfield object.
@@ -221,7 +223,7 @@
Returns:
- Starfield
+ Starfield
A new Starfield object.
diff --git a/Documentation/doc/3 primitive classes/Rotation.html b/Documentation/doc/3 primitive classes/Rotation.html
index fc7ffcb82..db42b771f 100644
--- a/Documentation/doc/3 primitive classes/Rotation.html
+++ b/Documentation/doc/3 primitive classes/Rotation.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
diff --git a/Documentation/doc/3 primitive classes/Time.html b/Documentation/doc/3 primitive classes/Time.html
new file mode 100644
index 000000000..c3f82ec81
--- /dev/null
+++ b/Documentation/doc/3 primitive classes/Time.html
@@ -0,0 +1,422 @@
+
+
+
+
+ TombEngine 1.6 Lua API
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
TombEngine
+
+
+
+
1 Modules
+
+
2 Classes
+
+
3 Primitive Classes
+
+
4 Enums
+
+
5 Lua utility modules
+
+
+
+
+
+
+
Primitive Class Time
+
Represents a time value in game frames, with support for formatting to hours, minutes, seconds, and centiseconds (1/100th of a second).
+
+
+
+
+
+
+
+
+ h
+ (int) Hours component.
+
+
+ m
+ (int) Minutes component.
+
+
+ s
+ (int) Seconds component.
+
+
+ c
+ (int) Centiseconds component.
+
+
+
+
+
+ Time()
+ Create a Time object.
+
+
+ Time(gameFrames)
+ Create a Time object from a total game frame count (1 second = 30 frames).
+
+
+ Time(formattedTime)
+ Create a Time object from a formatted string.
+
+
+ Time(timeUnits)
+ Create a Time object from a time unit table (hours, minutes, seconds, centiseconds).
+
+
+ Time:GetFrameCount()
+ Get the total game frame count.
+
+
+ Time:GetTimeUnits()
+ Get the time in hours, minutes, seconds, and centiseconds as a table.
+
+
+ tostring(this)
+ Convert this Time object to a formatted string.
+
+
+
+
+
+
+
+
+
+
+
+
+ h
+
+
+ (int) Hours component.
+
+
+
+
+
+
+
+
+
+
+
+ m
+
+
+ (int) Minutes component.
+
+
+
+
+
+
+
+
+
+
+
+ s
+
+
+ (int) Seconds component.
+
+
+
+
+
+
+
+
+
+
+
+ c
+
+
+ (int) Centiseconds component.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Time()
+
+
+ Create a Time object.
+
+
+
+
+ Returns:
+
+
+ Time
+ A new Time object initialized to zero time.
+
+
+
+
+
+
+
+
+ Time(gameFrames)
+
+
+ Create a Time object from a total game frame count (1 second = 30 frames).
+
+
+
+ Parameters:
+
+ gameFrames
+ int
+ Total game frame count.
+
+
+
+ Returns:
+
+
+ Time
+ A new Time object initialized with the given frame count.
+
+
+
+
+
+
+
+
+ Time(formattedTime)
+
+
+ Create a Time object from a formatted string.
+
+
+
+ Parameters:
+
+ formattedTime
+ string
+ Time in the format "HH:MM:SS[.CC]", where [.CC] is centiseconds and is optional.
+
+
+
+ Returns:
+
+
+ Time
+ A new Time object parsed from the given string.
+
+
+
+
+
+
+
+
+ Time(timeUnits)
+
+
+ Create a Time object from a time unit table (hours, minutes, seconds, centiseconds).
+
+
+
+ Parameters:
+
+ timeUnits
+ table
+ A time unit table in the format {HH, MM, SS, [CC]}, where [CC] is optional.
+
+
+
+ Returns:
+
+
+ Time
+ A new Time object initialized with the given values.
+
+
+
+
+
+
+
+
+ Time:GetFrameCount()
+
+
+ Get the total game frame count.
+
+
+
+
+ Returns:
+
+
+ int
+ Total number of game frames.
+
+
+
+
+
+
+
+
+ Time:GetTimeUnits()
+
+
+ Get the time in hours, minutes, seconds, and centiseconds as a table.
+
+
+
+
+ Returns:
+
+
+ table
+ A table in the format {HH, MM, SS, CC}.
+
+
+
+
+
+
+
+
+ tostring(this)
+
+
+ Convert this Time object to a formatted string.
+
+
+
+ Parameters:
+
+ this
+ Time
+ Time object.
+
+
+
+ Returns:
+
+
+ string
+ A string showing time in "HH:MM:SS.CC" format.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Documentation/doc/3 primitive classes/Vec2.html b/Documentation/doc/3 primitive classes/Vec2.html
index 19e0c140a..c00ec0d29 100644
--- a/Documentation/doc/3 primitive classes/Vec2.html
+++ b/Documentation/doc/3 primitive classes/Vec2.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
@@ -211,7 +213,7 @@
Vec2(x, y)
- Create a Vec2 object. (x, y)
+ Create a Vec2 object.
@@ -243,7 +245,7 @@
Vec(value)
- Create a Vec2 object. (value)
+ Create a Vec2 object.
@@ -299,7 +301,7 @@
Vec2:Normalize()
- Get a copy of this Vec2 normalized to length 1. ()
+ Get a copy of this Vec2 normalized to length 1.
@@ -320,7 +322,7 @@
Vec2:Rotate(rot)
- Get a copy of this Vec2 rotated by the input rotation in degrees. (rot)
+ Get a copy of this Vec2 rotated by the input rotation in degrees.
@@ -348,7 +350,7 @@
Vec2:Lerp(vector, alpha)
- Get the linearly interpolated Vec2 between this Vec2 and the input Vec2 according to the input interpolation alpha. (vector)
+ Get the linearly interpolated Vec2 between this Vec2 and the input Vec2 according to the input interpolation alpha.
@@ -380,7 +382,7 @@
Vec2:Cross(vector)
- Get the cross product of this Vec2 and the input Vec2. (vector)
+ Get the cross product of this Vec2 and the input Vec2.
@@ -408,7 +410,7 @@
Vec2:Dot(vector)
- Get the dot product of this Vec2 and the input Vec2. (vector)
+ Get the dot product of this Vec2 and the input Vec2.
@@ -436,7 +438,7 @@
Vec2:Distance(vector)
- Get the distance between this Vec2 and the input Vec2. (vector)
+ Get the distance between this Vec2 and the input Vec2.
@@ -464,7 +466,7 @@
Vec2:Length()
- Get the length of this Vec2. ()
+ Get the length of this Vec2.
diff --git a/Documentation/doc/3 primitive classes/Vec3.html b/Documentation/doc/3 primitive classes/Vec3.html
index 0bcf33289..7dde0e822 100644
--- a/Documentation/doc/3 primitive classes/Vec3.html
+++ b/Documentation/doc/3 primitive classes/Vec3.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
Effects.BlendID
Effects.EffectID
+ Flow.ErrorMode
Flow.FreezeMode
Flow.GameStatus
Input.ActionID
Objects.AmmoType
+ Objects.WeaponType
Objects.MoveableStatus
Objects.ObjID
Objects.RoomFlagID
@@ -230,7 +232,7 @@
Vec3(x, y, z)
- Create a Vec3 object. (x, y, z)
+ Create a Vec3 object.
@@ -266,7 +268,7 @@
Vec3(value)
- Create a Vec3 object. (value)
+ Create a Vec3 object.
@@ -294,7 +296,7 @@
Vec3:Normalize()
- Get a copy of this Vec3 normalized to length 1. ()
+ Get a copy of this Vec3 normalized to length 1.
@@ -315,7 +317,7 @@
Vec3:Rotate(rot)
- Get a copy of this Vec3 rotated by the input Rotation object. (rot)
+ Get a copy of this Vec3 rotated by the input Rotation object.
@@ -343,7 +345,7 @@
Vec3:Lerp(vector, alpha)
- Get the linearly interpolated Vec3 between this Vec3 and the input Vec3 according to the input interpolation alpha. (vector)
+ Get the linearly interpolated Vec3 between this Vec3 and the input Vec3 according to the input interpolation alpha.
@@ -375,7 +377,7 @@
Vec3:Cross(vector)
- Get the cross product of this Vec3 and the input Vec3. (vector)
+ Get the cross product of this Vec3 and the input Vec3.
@@ -403,7 +405,7 @@
Vec3:Dot(vector)
- Get the dot product of this Vec3 and the input Vec3. (vector)
+ Get the dot product of this Vec3 and the input Vec3.
@@ -431,7 +433,7 @@
Vec3:Distance(vector)
- Get the distance between this Vec3 and the input Vec3. (vector)
+ Get the distance between this Vec3 and the input Vec3.
@@ -459,7 +461,7 @@
Vec3:Length()
- Get the length of this Vec3. ()
+ Get the length of this Vec3.
diff --git a/Documentation/doc/4 enums/Effects.BlendID.html b/Documentation/doc/4 enums/Effects.BlendID.html
index 98f3570f3..6fbe33ddc 100644
--- a/Documentation/doc/4 enums/Effects.BlendID.html
+++ b/Documentation/doc/4 enums/Effects.BlendID.html
@@ -24,7 +24,7 @@
-
TombEngine
+
TombEngine
2 Classes
3 Primitive Classes
@@ -77,10 +77,12 @@
2 Classes
3 Primitive Classes
+
+ Flow.Fog
+ Distance fog.
+
+
+ Flow.InventoryItem
+ Represents the properties of an object as it appears in the inventory.
+
+
+ Flow.LensFlare
+ Represents a global lens flare (not to be confused with lensflare object).
+
+
+ Flow.SkyLayer
+ Describes a layer of moving clouds.
+
+
+ Flow.Starfield
+ Represents a starfield.
+
Color
Represents an RGBA or RGB color.
@@ -262,6 +260,10 @@ local door = GetMoveableByName("door_type4_14")
Rotation
Represents a degree-based 3D rotation.
+
+ Time
+ Represents a time value in game frames, with support for formatting to hours, minutes, seconds, and centiseconds (1/100th of a second).
+
Vec2
Represents a float-based 2D vector.
@@ -281,6 +283,10 @@ local door = GetMoveableByName("door_type4_14")
Effects.EffectID
Constants for effect IDs.
+
+ Flow.ErrorMode
+ Constants for error modes.
+
Flow.FreezeMode
Constants for freeze modes.
@@ -297,6 +303,10 @@ local door = GetMoveableByName("door_type4_14")
Objects.AmmoType
Constants for player weapon ammo types.
+
+ Objects.WeaponType
+ Constants for weapon types.
+
Objects.MoveableStatus
Constants for moveable statuses.
@@ -339,7 +349,7 @@ local door = GetMoveableByName("door_type4_14")
View.ScaleMode
- Constants for scale modes.
+ Constants for display sprite scale modes.
5 Lua utility modules
diff --git a/Scripts/Settings.lua b/Scripts/Settings.lua
index b6d230a98..081e268e8 100644
--- a/Scripts/Settings.lua
+++ b/Scripts/Settings.lua
@@ -4,17 +4,145 @@
local Flow = TEN.Flow
local settings = Flow.Settings.new()
-settings.errorMode = Flow.ErrorMode.WARN
-settings.fastReload = true
-Flow.SetSettings(settings)
-local anims = Flow.Animations.new()
-anims.crawlExtended = true
-anims.crouchRoll = true
-anims.crawlspaceSwandive = true
-anims.overhangClimb = false
-anims.slideExtended = false
-anims.sprintJump = false
-anims.pose = false
-anims.ledgeJumps = false
-Flow.SetAnimations(anims)
\ No newline at end of file
+ settings.Animations.crouchRoll = true
+ settings.Animations.crawlspaceSwandive = true
+ settings.Animations.sprintJump = false
+ settings.Animations.ledgeJumps = false
+ settings.Animations.poseTimeout = 0
+
+ settings.Camera.binocularLightColor = Color(192, 192, 96)
+ settings.Camera.lasersightLightColor = Color(255, 0, 0)
+ settings.Camera.objectCollision = true
+
+ settings.Flare.color = Color(128, 64, 0)
+ settings.Flare.offset = Vec3(0, 0, 41)
+ settings.Flare.range = 9
+ settings.Flare.timeout = 60
+ settings.Flare.lensflareBrightness = 0.5
+ settings.Flare.sparks = true
+ settings.Flare.smoke = true
+ settings.Flare.flicker = true
+ settings.Flare.pickupCount = 12
+
+ settings.Hud.statusBars = true
+ settings.Hud.loadingBar = true
+ settings.Hud.speedometer = true
+ settings.Hud.pickupNotifier = true
+
+ settings.Physics.gravity = 6
+ settings.Physics.swimVelocity = 50
+
+ settings.System.errorMode = Flow.ErrorMode.WARN
+ settings.System.fastReload = true
+
+ -- Hair[1] is normal player hair. Types [2] and [3] are for left and right young Lara hair.
+
+ settings.Hair[1].rootMesh = 14
+ settings.Hair[1].offset = Vec3(-4, -4, -48)
+ settings.Hair[1].indices = { 37, 39, 40, 38 }
+
+ settings.Hair[2].rootMesh = 14
+ settings.Hair[2].offset = Vec3(-48, -48, -50)
+ settings.Hair[2].indices = { 79, 78, 76, 77 }
+
+ settings.Hair[3].rootMesh = 14
+ settings.Hair[3].offset = Vec3(48, -48, -50)
+ settings.Hair[3].indices = { 68, 69, 70, 71 }
+
+ -- Not all weapon settings are applicable to every weapon. Those which are not applicable
+ -- for a particular weapon type are omitted. See documentation for more details.
+
+ settings.Weapons[WeaponType.PISTOLS].accuracy = 8
+ settings.Weapons[WeaponType.PISTOLS].targetingDistance = 8192
+ settings.Weapons[WeaponType.PISTOLS].interval = 9
+ settings.Weapons[WeaponType.PISTOLS].waterLevel = 650
+ settings.Weapons[WeaponType.PISTOLS].flashDuration = 3
+ settings.Weapons[WeaponType.PISTOLS].flashRange = 9
+ settings.Weapons[WeaponType.PISTOLS].flashColor = Color(192, 128, 0)
+ settings.Weapons[WeaponType.PISTOLS].damage = 1
+ settings.Weapons[WeaponType.PISTOLS].smoke = true
+ settings.Weapons[WeaponType.PISTOLS].shell = true
+ settings.Weapons[WeaponType.PISTOLS].muzzleFlash = true
+ settings.Weapons[WeaponType.PISTOLS].colorizeMuzzleFlash = false
+ settings.Weapons[WeaponType.PISTOLS].pickupCount = 30
+
+ settings.Weapons[WeaponType.REVOLVER].accuracy = 8
+ settings.Weapons[WeaponType.REVOLVER].targetingDistance = 8192
+ settings.Weapons[WeaponType.REVOLVER].interval = 16
+ settings.Weapons[WeaponType.REVOLVER].waterLevel = 650
+ settings.Weapons[WeaponType.REVOLVER].flashDuration = 3
+ settings.Weapons[WeaponType.REVOLVER].flashRange = 9
+ settings.Weapons[WeaponType.REVOLVER].flashColor = Color(192, 128, 0)
+ settings.Weapons[WeaponType.REVOLVER].damage = 21
+ settings.Weapons[WeaponType.REVOLVER].alternateDamage = 21
+ settings.Weapons[WeaponType.REVOLVER].smoke = true
+ settings.Weapons[WeaponType.REVOLVER].shell = false
+ settings.Weapons[WeaponType.REVOLVER].muzzleFlash = true
+ settings.Weapons[WeaponType.REVOLVER].colorizeMuzzleFlash = false
+ settings.Weapons[WeaponType.REVOLVER].pickupCount = 6
+
+ settings.Weapons[WeaponType.UZI].accuracy = 8
+ settings.Weapons[WeaponType.UZI].targetingDistance = 8192
+ settings.Weapons[WeaponType.UZI].interval = 3
+ settings.Weapons[WeaponType.UZI].waterLevel = 650
+ settings.Weapons[WeaponType.UZI].flashDuration = 2
+ settings.Weapons[WeaponType.UZI].flashRange = 9
+ settings.Weapons[WeaponType.UZI].flashColor = Color(192, 128, 0)
+ settings.Weapons[WeaponType.UZI].damage = 1
+ settings.Weapons[WeaponType.UZI].smoke = true
+ settings.Weapons[WeaponType.UZI].shell = true
+ settings.Weapons[WeaponType.UZI].muzzleFlash = true
+ settings.Weapons[WeaponType.UZI].colorizeMuzzleFlash = false
+ settings.Weapons[WeaponType.UZI].pickupCount = 30
+
+ settings.Weapons[WeaponType.SHOTGUN].accuracy = 10
+ settings.Weapons[WeaponType.SHOTGUN].targetingDistance = 8192
+ settings.Weapons[WeaponType.SHOTGUN].waterLevel = 500
+ settings.Weapons[WeaponType.SHOTGUN].flashDuration = 3
+ settings.Weapons[WeaponType.SHOTGUN].flashRange = 12
+ settings.Weapons[WeaponType.SHOTGUN].flashColor = Color(192, 128, 0)
+ settings.Weapons[WeaponType.SHOTGUN].damage = 3
+ settings.Weapons[WeaponType.SHOTGUN].smoke = true
+ settings.Weapons[WeaponType.SHOTGUN].shell = true
+ settings.Weapons[WeaponType.SHOTGUN].muzzleFlash = false
+ settings.Weapons[WeaponType.SHOTGUN].colorizeMuzzleFlash = false
+ settings.Weapons[WeaponType.SHOTGUN].pickupCount = 6
+
+ settings.Weapons[WeaponType.HK].accuracy = 4
+ settings.Weapons[WeaponType.HK].targetingDistance = 12288
+ settings.Weapons[WeaponType.HK].waterLevel = 500
+ settings.Weapons[WeaponType.HK].flashDuration = 2
+ settings.Weapons[WeaponType.HK].flashRange = 12
+ settings.Weapons[WeaponType.HK].flashColor = Color(192, 128, 0)
+ settings.Weapons[WeaponType.HK].damage = 4
+ settings.Weapons[WeaponType.HK].alternateDamage = 4
+ settings.Weapons[WeaponType.HK].smoke = true
+ settings.Weapons[WeaponType.HK].shell = true
+ settings.Weapons[WeaponType.HK].muzzleFlash = true
+ settings.Weapons[WeaponType.HK].colorizeMuzzleFlash = false
+ settings.Weapons[WeaponType.HK].pickupCount = 30
+
+ settings.Weapons[WeaponType.CROSSBOW].targetingDistance = 8192
+ settings.Weapons[WeaponType.CROSSBOW].waterLevel = 500
+ settings.Weapons[WeaponType.CROSSBOW].damage = 5
+ settings.Weapons[WeaponType.CROSSBOW].alternateDamage = 20
+ settings.Weapons[WeaponType.CROSSBOW].pickupCount = 10
+
+ settings.Weapons[WeaponType.GRENADE_LAUNCHER].targetingDistance = 8192
+ settings.Weapons[WeaponType.GRENADE_LAUNCHER].waterLevel = 500
+ settings.Weapons[WeaponType.GRENADE_LAUNCHER].damage = 20
+ settings.Weapons[WeaponType.GRENADE_LAUNCHER].smoke = true
+ settings.Weapons[WeaponType.GRENADE_LAUNCHER].pickupCount = 10
+
+ settings.Weapons[WeaponType.ROCKET_LAUNCHER].targetingDistance = 8192
+ settings.Weapons[WeaponType.ROCKET_LAUNCHER].waterLevel = 500
+ settings.Weapons[WeaponType.ROCKET_LAUNCHER].damage = 30
+ settings.Weapons[WeaponType.ROCKET_LAUNCHER].smoke = true
+ settings.Weapons[WeaponType.ROCKET_LAUNCHER].pickupCount = 1
+
+ settings.Weapons[WeaponType.HARPOON_GUN].targetingDistance = 8192
+ settings.Weapons[WeaponType.HARPOON_GUN].damage = 6
+ settings.Weapons[WeaponType.HARPOON_GUN].pickupCount = 10
+
+Flow.SetSettings(settings)
diff --git a/Scripts/SystemStrings.lua b/Scripts/SystemStrings.lua
index fdd9821c2..03d40cd29 100644
--- a/Scripts/SystemStrings.lua
+++ b/Scripts/SystemStrings.lua
@@ -100,7 +100,7 @@ local strings =
reverb = { "Reverb" },
rumble = { "Rumble" },
save_game = { "Save Game" },
- savegame_timestamp = { "%02d Days %02d:%02d:%02d" },
+ savegame_timestamp = { "%02d:%02d:%02d" },
screen_resolution = { "Screen Resolution" },
select_level = { "Select Level" },
separate = { "Separate" },
diff --git a/TombEngine/Game/Hud/PickupSummary.cpp b/TombEngine/Game/Hud/PickupSummary.cpp
index 4376cf80b..8c9e8b65d 100644
--- a/TombEngine/Game/Hud/PickupSummary.cpp
+++ b/TombEngine/Game/Hud/PickupSummary.cpp
@@ -6,6 +6,7 @@
#include "Game/pickup/pickup_consumable.h"
#include "Math/Math.h"
#include "Renderer/Renderer.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/clock.h"
using namespace TEN::Math;
@@ -174,6 +175,9 @@ namespace TEN::Hud
{
//DrawDebug();
+ if (!g_GameFlow->GetSettings()->Hud.PickupNotifier)
+ return;
+
if (_displayPickups.empty())
return;
diff --git a/TombEngine/Game/Hud/Speedometer.cpp b/TombEngine/Game/Hud/Speedometer.cpp
index 58e25c801..6253fc6ac 100644
--- a/TombEngine/Game/Hud/Speedometer.cpp
+++ b/TombEngine/Game/Hud/Speedometer.cpp
@@ -3,8 +3,9 @@
#include "Game/effects/DisplaySprite.h"
#include "Math/Math.h"
-#include "Specific/clock.h"
#include "Renderer/Renderer.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
+#include "Specific/clock.h"
using namespace TEN::Effects::DisplaySprite;
using namespace TEN::Math;
@@ -58,6 +59,9 @@ namespace TEN::Hud
//DrawDebug();
+ if (!g_GameFlow->GetSettings()->Hud.Speedometer)
+ return;
+
if (_life <= 0.0f)
return;
diff --git a/TombEngine/Game/Hud/StatusBars.cpp b/TombEngine/Game/Hud/StatusBars.cpp
index b9ab5a415..d819db6f4 100644
--- a/TombEngine/Game/Hud/StatusBars.cpp
+++ b/TombEngine/Game/Hud/StatusBars.cpp
@@ -8,6 +8,7 @@
#include "Game/Lara/lara_helpers.h"
#include "Objects/game_object_ids.h"
#include "Renderer/Renderer.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/clock.h"
using namespace TEN::Renderer;
@@ -63,7 +64,7 @@ namespace TEN::Hud
constexpr auto FLASH_INTERVAL = 0.2f;
// Update flash.
- if ((GameTimer % (int)round(FLASH_INTERVAL * FPS)) == 0)
+ if ((GlobalCounter % (int)round(FLASH_INTERVAL * FPS)) == 0)
_doFlash = !_doFlash;
// Update bars.
@@ -75,6 +76,10 @@ namespace TEN::Hud
void StatusBarsController::Draw(const ItemInfo& item) const
{
+ // Avoid drawing if HUD is disabled.
+ if (!g_GameFlow->GetSettings()->Hud.StatusBars)
+ return;
+
// Avoid drawing in title level and during cutscenes.
if (CurrentLevel == 0 || CinematicBarsHeight > 0)
return;
diff --git a/TombEngine/Game/Lara/PlayerContext.cpp b/TombEngine/Game/Lara/PlayerContext.cpp
index 99ac6a5b9..423b3007d 100644
--- a/TombEngine/Game/Lara/PlayerContext.cpp
+++ b/TombEngine/Game/Lara/PlayerContext.cpp
@@ -95,7 +95,7 @@ namespace TEN::Entities::Player
const auto& player = GetLaraInfo(item);
// 1) Check if AFK posing is enabled.
- if (!g_GameFlow->HasAFKPose())
+ if (!g_GameFlow->GetSettings()->Animations.PoseTimeout)
return false;
// 2) Test player hand and water status.
@@ -417,7 +417,7 @@ namespace TEN::Entities::Player
bool CanSteerOnSlide(const ItemInfo& item, const CollisionInfo& coll)
{
- return g_GameFlow->HasSlideExtended();
+ return g_GameFlow->GetSettings()->Animations.SlideExtended;
}
bool IsInLowSpace(const ItemInfo& item, const CollisionInfo& coll)
@@ -519,7 +519,7 @@ namespace TEN::Entities::Player
const auto& player = GetLaraInfo(item);
// 1) Check if crouch roll is enabled.
- if (!g_GameFlow->HasCrouchRoll())
+ if (!g_GameFlow->GetSettings()->Animations.CrouchRoll)
return false;
// 2) Test water depth.
@@ -609,7 +609,7 @@ namespace TEN::Entities::Player
auto pointColl = GetPointCollision(item);
// 2) Test for slippery ceiling slope and check if overhang climb is disabled.
- if (pointColl.IsSteepCeiling() && !g_GameFlow->HasOverhangClimb())
+ if (pointColl.IsSteepCeiling() && !g_GameFlow->GetSettings()->Animations.OverhangClimb)
return true;
// 3) Assess point collision.
@@ -963,7 +963,7 @@ namespace TEN::Entities::Player
const auto& player = GetLaraInfo(item);
// 1) Check if sprint jump is enabled.
- if (!g_GameFlow->HasSprintJump())
+ if (!g_GameFlow->GetSettings()->Animations.SprintJump)
return false;
// 2) Check for jump state dispatch.
@@ -990,7 +990,7 @@ namespace TEN::Entities::Player
return true;
// Check whether extended slide mechanics are enabled.
- if (!g_GameFlow->HasSlideExtended())
+ if (!g_GameFlow->GetSettings()->Animations.SlideExtended)
return true;
// TODO: Broken on diagonal slides?
@@ -1013,7 +1013,7 @@ namespace TEN::Entities::Player
constexpr auto LEDGE_HEIGHT_MIN = CLICK(2);
// 1) Check if ledge jumps are enabled.
- if (!g_GameFlow->HasLedgeJumps())
+ if (!g_GameFlow->GetSettings()->Animations.LedgeJumps)
return false;
// Ray collision setup at minimum ledge height.
diff --git a/TombEngine/Game/Lara/lara.cpp b/TombEngine/Game/Lara/lara.cpp
index 46b34aec8..8b66a63b1 100644
--- a/TombEngine/Game/Lara/lara.cpp
+++ b/TombEngine/Game/Lara/lara.cpp
@@ -331,7 +331,9 @@ void LaraControl(ItemInfo* item, CollisionInfo* coll)
break;
}
- SaveGame::Statistics.Game.Distance += (int)round(Vector3i::Distance(prevPos, item->Pose.Position));
+ int deltaDist = (int)round(Vector3i::Distance(prevPos, item->Pose.Position));
+ SaveGame::Statistics.Game.Distance += deltaDist;
+ SaveGame::Statistics.Level.Distance += deltaDist;
if (DebugMode)
{
diff --git a/TombEngine/Game/Lara/lara.h b/TombEngine/Game/Lara/lara.h
index 0d426f036..69ce7e5f6 100644
--- a/TombEngine/Game/Lara/lara.h
+++ b/TombEngine/Game/Lara/lara.h
@@ -59,14 +59,12 @@ constexpr auto LARA_DEATH_VELOCITY = 155.0f;
constexpr auto LARA_DIVE_DEATH_VELOCITY = 134.0f;
constexpr auto LARA_TERMINAL_VELOCITY = CLICK(10);
-constexpr auto LARA_SWIM_VELOCITY_ACCEL = 2.0f;
-constexpr auto LARA_SWIM_VELOCITY_DECEL = 1.5f;
-constexpr auto LARA_TREAD_VELOCITY_MAX = 17.5f;
-constexpr auto LARA_SWIM_VELOCITY_MAX = 50.0f;
-constexpr auto LARA_SWIM_INTERTIA_VELOCITY_MIN = 33.5f;
+constexpr auto LARA_SWIM_VELOCITY_ACCEL_COEFF = 0.04f;
+constexpr auto LARA_SWIM_VELOCITY_DECEL_COEFF = 0.03f;
+constexpr auto LARA_TREAD_VELOCITY_MAX_COEFF = 0.35f;
+constexpr auto LARA_SWIM_INTERTIA_VELOCITY_MIN_COEFF = 0.67f;
constexpr auto PLAYER_POSITION_ADJUST_MAX_TIME = 3 * FPS; // 3 seconds allowed for position adjustment.
-constexpr auto PLAYER_POSE_TIME = 20 * FPS; // 20 seconds to AFK pose.
constexpr auto PLAYER_RUN_JUMP_TIME = 22; // Frames to count before a running jump is possible.
constexpr auto PLAYER_SPRINT_JUMP_TIME = 46; // Frames to count before a sprint jump is possible.
@@ -92,6 +90,7 @@ constexpr auto SHALLOW_WATER_DEPTH = (int)CLICK(0.5f);
constexpr auto WADE_WATER_DEPTH = STEPUP_HEIGHT;
constexpr auto SWIM_WATER_DEPTH = CLICK(2.75f);
constexpr auto SLOPE_DIFFERENCE = 60;
+constexpr auto SWAMP_GRAVITY_COEFF = 3.0f;
extern LaraInfo Lara;
extern ItemInfo* LaraItem;
diff --git a/TombEngine/Game/Lara/lara_basic.cpp b/TombEngine/Game/Lara/lara_basic.cpp
index 5e65451a7..7d1563d3f 100644
--- a/TombEngine/Game/Lara/lara_basic.cpp
+++ b/TombEngine/Game/Lara/lara_basic.cpp
@@ -594,7 +594,7 @@ void lara_as_idle(ItemInfo* item, CollisionInfo* coll)
}
// TODO: Without animation blending, the AFK state's movement lock interferes with responsiveness. -- Sezz 2021.10.31
- if (CanStrikeAfkPose(*item, *coll) && player.Control.Count.Pose >= PLAYER_POSE_TIME)
+ if (CanStrikeAfkPose(*item, *coll) && player.Control.Count.Pose >= (g_GameFlow->GetSettings()->Animations.PoseTimeout * FPS))
{
item->Animation.TargetState = LS_POSE;
return;
@@ -1694,7 +1694,7 @@ void lara_as_sprint(ItemInfo* item, CollisionInfo* coll)
if (IsHeld(In::Jump) || player.Control.IsRunJumpQueued)
{
// TODO: CanSprintJumpForward() should handle HasSprintJump() check.
- if (IsHeld(In::Walk) || !g_GameFlow->HasSprintJump())
+ if (IsHeld(In::Walk) || !g_GameFlow->GetSettings()->Animations.SprintJump)
{
item->Animation.TargetState = LS_SPRINT_DIVE;
return;
diff --git a/TombEngine/Game/Lara/lara_cheat.cpp b/TombEngine/Game/Lara/lara_cheat.cpp
index 4b52d97fa..3e87b6583 100644
--- a/TombEngine/Game/Lara/lara_cheat.cpp
+++ b/TombEngine/Game/Lara/lara_cheat.cpp
@@ -8,6 +8,7 @@
#include "Game/Lara/lara_swim.h"
#include "Game/Setup.h"
#include "Sound/sound.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/Input/Input.h"
using namespace TEN::Input;
@@ -16,6 +17,8 @@ namespace TEN::Entities::Player
{
void lara_as_fly_cheat(ItemInfo* item, CollisionInfo* coll)
{
+ float baseVel = g_GameFlow->GetSettings()->Physics.SwimVelocity;
+
if (IsHeld(In::Forward))
{
item->Pose.Orientation.x -= ANGLE(3.0f);
@@ -41,13 +44,13 @@ namespace TEN::Entities::Player
{
float velCoeff = IsHeld(In::Sprint) ? 2.5f : 1.0f;
- item->Animation.Velocity.y += (LARA_SWIM_VELOCITY_ACCEL * 4) * velCoeff;
- if (item->Animation.Velocity.y > (LARA_SWIM_VELOCITY_MAX * 2) * velCoeff)
- item->Animation.Velocity.y = (LARA_SWIM_VELOCITY_MAX * 2) * velCoeff;
+ item->Animation.Velocity.y += ((baseVel * LARA_SWIM_VELOCITY_ACCEL_COEFF) * 4) * velCoeff;
+ if (item->Animation.Velocity.y > (baseVel * 2) * velCoeff)
+ item->Animation.Velocity.y = (baseVel * 2) * velCoeff;
}
else
{
- if (item->Animation.Velocity.y >= LARA_SWIM_VELOCITY_ACCEL)
+ if (item->Animation.Velocity.y >= (baseVel * LARA_SWIM_VELOCITY_ACCEL_COEFF))
{
item->Animation.Velocity.y -= item->Animation.Velocity.y / 8;
}
diff --git a/TombEngine/Game/Lara/lara_collide.cpp b/TombEngine/Game/Lara/lara_collide.cpp
index e87e37f00..1ab07d0e6 100644
--- a/TombEngine/Game/Lara/lara_collide.cpp
+++ b/TombEngine/Game/Lara/lara_collide.cpp
@@ -436,7 +436,7 @@ void LaraResetGravityStatus(ItemInfo* item, CollisionInfo* coll)
void LaraSnapToHeight(ItemInfo* item, CollisionInfo* coll)
{
if (TestEnvironment(ENV_FLAG_SWAMP, item) && coll->Middle.Floor > 0)
- item->Pose.Position.y += SWAMP_GRAVITY;
+ item->Pose.Position.y += g_GameFlow->GetSettings()->Physics.Gravity / SWAMP_GRAVITY_COEFF;
else if (coll->Middle.Floor != NO_HEIGHT)
item->Pose.Position.y += coll->Middle.Floor;
}
diff --git a/TombEngine/Game/Lara/lara_fire.cpp b/TombEngine/Game/Lara/lara_fire.cpp
index 27e0e4d91..f1f7d6efc 100644
--- a/TombEngine/Game/Lara/lara_fire.cpp
+++ b/TombEngine/Game/Lara/lara_fire.cpp
@@ -25,6 +25,7 @@
#include "Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h"
#include "Scripting/Include/ScriptInterfaceGame.h"
#include "Scripting/Include/ScriptInterfaceLevel.h"
+#include "Scripting/Internal/TEN/Objects/Lara/WeaponTypes.h"
#include "Sound/sound.h"
#include "Specific/configuration.h"
#include "Specific/Input/Input.h"
@@ -147,7 +148,7 @@ WeaponInfo Weapons[(int)LaraWeaponType::NumWeapons] =
std::pair(EulerAngles(ANGLE(-70.0f), ANGLE(-80.0f), 0), EulerAngles(ANGLE(65.0f), ANGLE(80.0f), 0)),
std::pair(EulerAngles(ANGLE(-70.0f), ANGLE(-80.0f), 0), EulerAngles(ANGLE(65.0f), ANGLE(80.0f), 0)),
ANGLE(10.0f),
- 0,
+ ANGLE(10.0f),
500,
BLOCK(8),
3,
@@ -304,6 +305,26 @@ const WeaponInfo& GetWeaponInfo(LaraWeaponType weaponType)
return (Weapons[(int)weaponType]);
}
+void InitializeWeaponInfo(const Settings& settings)
+{
+ for (const auto& [name, weaponType] : WEAPON_TYPES)
+ {
+ if ((int)weaponType <= 0 || (int)weaponType >= (int)LaraWeaponType::NumWeapons)
+ continue;
+
+ auto& weapon = Weapons[(int)weaponType];
+ const auto& weaponSettings = settings.Weapons[(int)weaponType - 1]; // Lua counts from 1.
+
+ weapon.Damage = weaponSettings.Damage;
+ weapon.AlternateDamage = weaponSettings.AlternateDamage;
+ weapon.FlashTime = weaponSettings.FlashDuration;
+ weapon.GunHeight = weaponSettings.WaterLevel;
+ weapon.ShotAccuracy = ANGLE(weaponSettings.Accuracy);
+ weapon.TargetDist = weaponSettings.Distance;
+ weapon.RecoilFrame = weaponSettings.Interval;
+ }
+}
+
void InitializeNewWeapon(ItemInfo& laraItem)
{
auto& player = *GetLaraInfo(&laraItem);
@@ -539,7 +560,7 @@ void HandleWeapon(ItemInfo& laraItem)
player.Control.Weapon.RequestGunType = player.Control.Weapon.LastGunType;
}
// Draw flare.
- else if (IsHeld(In::Flare) && (g_GameFlow->GetLevel(CurrentLevel)->GetLaraType() != LaraType::Young))
+ else if (IsHeld(In::Flare))
{
if (player.Control.Weapon.GunType == LaraWeaponType::Flare)
{
@@ -882,7 +903,6 @@ FireWeaponType FireWeapon(LaraWeaponType weaponType, ItemInfo& targetEntity, Ite
}
else
{
- SaveGame::Statistics.Game.AmmoHits++;
target = origin + (directionNorm * closestDist);
auto vTarget = GameVector(target);
diff --git a/TombEngine/Game/Lara/lara_fire.h b/TombEngine/Game/Lara/lara_fire.h
index 662d4b359..51a6a1934 100644
--- a/TombEngine/Game/Lara/lara_fire.h
+++ b/TombEngine/Game/Lara/lara_fire.h
@@ -4,6 +4,9 @@
class EulerAngles;
struct CollisionInfo;
struct ItemInfo;
+namespace TEN::Scripting { struct Settings; };
+
+using namespace TEN::Scripting;
enum class FireWeaponType
{
@@ -40,13 +43,14 @@ struct WeaponInfo
int FlashTime = 0;
int DrawFrame = 0;
int SampleNum = 0;
- int ExplosiveDamage = 0;
+ int AlternateDamage = 0;
};
extern int FlashGrenadeAftershockTimer;
extern WeaponInfo Weapons[(int)LaraWeaponType::NumWeapons];
void InitializeNewWeapon(ItemInfo& laraItem);
+void InitializeWeaponInfo(const Settings& settings);
const WeaponInfo& GetWeaponInfo(LaraWeaponType weaponType);
Ammo& GetAmmo(LaraInfo& lara, LaraWeaponType weaponType);
diff --git a/TombEngine/Game/Lara/lara_flare.cpp b/TombEngine/Game/Lara/lara_flare.cpp
index aae02115e..0e99f0e11 100644
--- a/TombEngine/Game/Lara/lara_flare.cpp
+++ b/TombEngine/Game/Lara/lara_flare.cpp
@@ -15,14 +15,16 @@
#include "Game/Lara/lara_tests.h"
#include "Game/Setup.h"
#include "Math/Math.h"
+#include "Objects/Effects/LensFlare.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/clock.h"
#include "Specific/level.h"
using namespace TEN::Collision::Point;
+using namespace TEN::Entities::Effects;
using namespace TEN::Math;
-constexpr auto FLARE_LIFE_MAX = 60.0f * FPS;
constexpr auto FLARE_DEATH_DELAY = 1.0f * FPS;
void FlareControl(short itemNumber)
@@ -62,15 +64,17 @@ void FlareControl(short itemNumber)
}
else
{
- flareItem.Animation.Velocity.y += 6;
+ flareItem.Animation.Velocity.y += g_GameFlow->GetSettings()->Physics.Gravity;
}
flareItem.Pose.Position.y += flareItem.Animation.Velocity.y;
DoProjectileDynamics(itemNumber, prevPos.x, prevPos.y, prevPos.z, vel.x, vel.y, vel.z);
+ const auto& settings = g_GameFlow->GetSettings()->Flare;
+
int& life = flareItem.Data;
life &= 0x7FFF;
- if (life >= FLARE_LIFE_MAX)
+ if (life >= (settings.Timeout * FPS))
{
if (flareItem.Animation.Velocity.y == 0.0f &&
flareItem.Animation.Velocity.z == 0.0f)
@@ -84,7 +88,9 @@ void FlareControl(short itemNumber)
life++;
}
- if (DoFlareLight(flareItem.Pose.Position, life))
+ auto offset = settings.Offset.ToVector3i() + Vector3i(-6, 6, 0);
+ auto lightPos = GetJointPosition(flareItem, 0, offset);
+ if (DoFlareLight(flareItem, lightPos, life))
{
TriggerChaffEffects(flareItem, life);
life |= 0x8000;
@@ -376,10 +382,14 @@ void CreateFlare(ItemInfo& laraItem, GAME_OBJECT_ID objectID, bool isThrown)
flareItem.Data = (int)0;
int& life = flareItem.Data;
- if (DoFlareLight(flareItem.Pose.Position, lara.Flare.Life))
+ if (DoFlareLight(flareItem, flareItem.Pose.Position, lara.Flare.Life))
+ {
life = lara.Flare.Life | 0x8000;
+ }
else
+ {
life = lara.Flare.Life & 0x7FFF;
+ }
}
else
{
@@ -392,14 +402,16 @@ void CreateFlare(ItemInfo& laraItem, GAME_OBJECT_ID objectID, bool isThrown)
void DoFlareInHand(ItemInfo& laraItem, int flareLife)
{
- auto& lara = *GetLaraInfo(&laraItem);
+ auto& player = *GetLaraInfo(&laraItem);
+ const auto& settings = g_GameFlow->GetSettings()->Flare;
+
+ auto offset = settings.Offset.ToVector3i() + Vector3i(11, 32, 0);
+ auto lightPos = GetJointPosition(&laraItem, LM_LHAND, offset);
- auto pos = GetJointPosition(&laraItem, LM_LHAND, Vector3i(11, 32, 41));
+ if (DoFlareLight(laraItem, lightPos, flareLife))
+ TriggerChaffEffects(player.Control.Look.IsUsingBinoculars ? 0 : flareLife);
- if (DoFlareLight(pos, flareLife))
- TriggerChaffEffects(lara.Control.Look.IsUsingBinoculars ? 0 : flareLife);
-
- if (lara.Flare.Life >= FLARE_LIFE_MAX - (FLARE_DEATH_DELAY / 2))
+ if (player.Flare.Life >= ((settings.Timeout * FPS) - (FLARE_DEATH_DELAY / 2)))
{
// Prevent player from intercepting reach/jump states with flare throws.
if (laraItem.Animation.IsAirborne ||
@@ -409,16 +421,16 @@ void DoFlareInHand(ItemInfo& laraItem, int flareLife)
return;
}
- if (lara.Control.HandStatus == HandStatus::Free)
- lara.Control.HandStatus = HandStatus::WeaponUndraw;
+ if (player.Control.HandStatus == HandStatus::Free)
+ player.Control.HandStatus = HandStatus::WeaponUndraw;
}
- else if (lara.Flare.Life != 0)
+ else if (player.Flare.Life != 0)
{
- lara.Flare.Life++;
+ player.Flare.Life++;
}
}
-bool DoFlareLight(const Vector3i& pos, int flareLife)
+bool DoFlareLight(ItemInfo& item, const Vector3i& pos, int flareLife)
{
constexpr auto START_DELAY = 0.25f * FPS;
constexpr auto END_DELAY = 3.0f * FPS;
@@ -427,18 +439,22 @@ bool DoFlareLight(const Vector3i& pos, int flareLife)
constexpr auto CHAFF_SPAWN_CHANCE = 4 / 10.0f;
constexpr auto CHAFF_SPAWN_ENDING_CHANCE = CHAFF_SPAWN_CHANCE / 2;
constexpr auto CHAFF_SPAWN_DYING_CHANCE = CHAFF_SPAWN_CHANCE / 4;
- constexpr auto LIGHT_RADIUS = 9.0f;
constexpr auto LIGHT_SPHERE_RADIUS = BLOCK(1 / 16.0f);
constexpr auto LIGHT_POS_OFFSET = Vector3(0.0f, -BLOCK(1 / 8.0f), 0.0f);
- constexpr auto LIGHT_COLOR = Vector3(0.9f, 0.5f, 0.3f);
- if (flareLife >= FLARE_LIFE_MAX || flareLife == 0)
+ auto& settings = g_GameFlow->GetSettings()->Flare;
+
+ float flareRange = settings.Range * BLOCK(0.25f);
+ auto flareColor = Vector3(settings.Color);
+ int flareTimeout = settings.Timeout * FPS;
+
+ if (flareLife >= flareTimeout || flareLife == 0)
return false;
// Determine flare progress.
bool isStarting = (flareLife <= START_DELAY);
- bool isEnding = (flareLife > (FLARE_LIFE_MAX - END_DELAY));
- bool isDying = (flareLife > (FLARE_LIFE_MAX - FLARE_DEATH_DELAY));
+ bool isEnding = (flareLife > (flareTimeout - END_DELAY));
+ bool isDying = (flareLife > (flareTimeout - FLARE_DEATH_DELAY));
bool spawnChaff = false;
float mult = 1.0f;
@@ -450,7 +466,7 @@ bool DoFlareLight(const Vector3i& pos, int flareLife)
}
else if (isDying)
{
- mult = (FLARE_LIFE_MAX - (float)flareLife) / FLARE_DEATH_DELAY;
+ mult = (flareTimeout - (float)flareLife) / FLARE_DEATH_DELAY;
spawnChaff = Random::TestProbability(CHAFF_SPAWN_DYING_CHANCE);
}
else if (isEnding)
@@ -464,15 +480,38 @@ bool DoFlareLight(const Vector3i& pos, int flareLife)
}
// Determine light position.
- auto sphere = BoundingSphere(pos.ToVector3() + LIGHT_POS_OFFSET, LIGHT_SPHERE_RADIUS);
- auto lightPos = Random::GeneratePointInSphere(sphere);
+ auto lightPos = pos.ToVector3();
+ float intensity = 1.0f;
+
+ // Handle flicker effect if specified.
+ if (settings.Flicker)
+ {
+ auto sphere = BoundingSphere(pos.ToVector3() + LIGHT_POS_OFFSET, LIGHT_SPHERE_RADIUS);
+ lightPos = Random::GeneratePointInSphere(sphere);
+ intensity = Random::GenerateFloat(INTENSITY_MIN, INTENSITY_MAX);
+ }
// Calculate color.
- float intensity = Random::GenerateFloat(INTENSITY_MIN, INTENSITY_MAX);
- float falloff = intensity * mult * LIGHT_RADIUS;
- auto color = (LIGHT_COLOR * intensity * std::clamp(mult, 0.0f, 1.0f)) * UCHAR_MAX;
+ float falloff = intensity * mult * flareRange;
+ auto color = (flareColor * intensity * std::clamp(mult, 0.0f, 1.0f));
- TriggerDynamicLight(lightPos.x, lightPos.y, lightPos.z, (int)falloff, color.x, color.y, color.z);
+ // Spawn dynamic light.
+ TriggerDynamicPointLight(lightPos, Color(color), falloff, false);
+
+ // Spawn lensflare if brightness is not 0.
+ if (settings.LensflareBrightness > EPSILON)
+ {
+ if (item.ObjectNumber == GAME_OBJECT_ID::ID_FLARE_ITEM)
+ {
+ float currentIntensity = (float)item.ItemFlags[0] / LENSFLARE_ITEMFLAG_BRIGHTNESS_SCALE;
+ SetupLensFlare(pos.ToVector3(), item.RoomNumber, Color(color) * settings.LensflareBrightness, ¤tIntensity, 0);
+ item.ItemFlags[0] = short(currentIntensity * LENSFLARE_ITEMFLAG_BRIGHTNESS_SCALE);
+ }
+ else
+ {
+ SetupLensFlare(pos.ToVector3(), item.RoomNumber, Color(color) * settings.LensflareBrightness, nullptr, 0);
+ }
+ }
// Return chaff spawn status.
return ((isDying || isEnding) ? spawnChaff : true);
diff --git a/TombEngine/Game/Lara/lara_flare.h b/TombEngine/Game/Lara/lara_flare.h
index f3aa4d2b8..fa47b0f19 100644
--- a/TombEngine/Game/Lara/lara_flare.h
+++ b/TombEngine/Game/Lara/lara_flare.h
@@ -18,4 +18,4 @@ void SetFlareArm(ItemInfo& laraItem, int armFrame);
void CreateFlare(ItemInfo& laraItem, GAME_OBJECT_ID objectID, bool isThrown);
void DoFlareInHand(ItemInfo& laraItem, int flareLife);
-bool DoFlareLight(const Vector3i& pos, int flareLife);
+bool DoFlareLight(ItemInfo& item, const Vector3i& pos, int flareLife);
diff --git a/TombEngine/Game/Lara/lara_helpers.cpp b/TombEngine/Game/Lara/lara_helpers.cpp
index b3feabf88..288703527 100644
--- a/TombEngine/Game/Lara/lara_helpers.cpp
+++ b/TombEngine/Game/Lara/lara_helpers.cpp
@@ -56,9 +56,8 @@ void HandleLaraMovementParameters(ItemInfo* item, CollisionInfo* coll)
auto* lara = GetLaraInfo(item);
// Update AFK pose timer.
- if (lara->Control.Count.Pose < PLAYER_POSE_TIME &&
- !(IsHeld(In::Look) || IsOpticActionHeld()) &&
- g_GameFlow->HasAFKPose())
+ if (lara->Control.Count.Pose < (g_GameFlow->GetSettings()->Animations.PoseTimeout * FPS) &&
+ !(IsHeld(In::Look) || IsOpticActionHeld()))
{
lara->Control.Count.Pose++;
}
@@ -113,7 +112,7 @@ void HandlePlayerStatusEffects(ItemInfo& item, WaterStatus waterStatus, PlayerWa
player.Status.Poison = LARA_POISON_MAX;
if (!(Wibble & 0xFF))
- item.HitPoints -= player.Status.Poison;
+ DoDamage(&item, player.Status.Poison, true);
}
// Update stamina status.
@@ -135,7 +134,7 @@ void HandlePlayerStatusEffects(ItemInfo& item, WaterStatus waterStatus, PlayerWa
if (player.Status.Air < 0)
{
player.Status.Air = -1;
- item.HitPoints -= 10;
+ DoDamage(&item, 10, true);
}
}
}
@@ -169,7 +168,7 @@ void HandlePlayerStatusEffects(ItemInfo& item, WaterStatus waterStatus, PlayerWa
if (player.Status.Exposure <= 0)
{
player.Status.Exposure = 0;
- item.HitPoints -= 10;
+ DoDamage(&item, 10, true);
}
}
}
@@ -189,7 +188,7 @@ void HandlePlayerStatusEffects(ItemInfo& item, WaterStatus waterStatus, PlayerWa
if (player.Status.Exposure <= 0)
{
player.Status.Exposure = 0;
- item.HitPoints -= 10;
+ DoDamage(&item, 10, true);
}
}
else
@@ -212,8 +211,8 @@ void HandlePlayerStatusEffects(ItemInfo& item, WaterStatus waterStatus, PlayerWa
if (player.Status.Air < 0)
{
- item.HitPoints -= 5;
player.Status.Air = -1;
+ DoDamage(&item, 5, true);
}
if (water.IsCold)
@@ -222,7 +221,7 @@ void HandlePlayerStatusEffects(ItemInfo& item, WaterStatus waterStatus, PlayerWa
if (player.Status.Exposure <= 0)
{
player.Status.Exposure = 0;
- item.HitPoints -= 10;
+ DoDamage(&item, 10, true);
}
}
else
@@ -248,7 +247,7 @@ void HandlePlayerStatusEffects(ItemInfo& item, WaterStatus waterStatus, PlayerWa
if (player.Status.Exposure <= 0)
{
player.Status.Exposure = 0;
- item.HitPoints -= 10;
+ DoDamage(&item, 10, true);
}
}
}
@@ -1028,7 +1027,7 @@ void EasePlayerElevation(ItemInfo* item, int relHeight)
// Handle swamp case.
if (TestEnvironment(ENV_FLAG_SWAMP, item) && relHeight > 0)
{
- item->Pose.Position.y += SWAMP_GRAVITY;
+ item->Pose.Position.y += g_GameFlow->GetSettings()->Physics.Gravity / SWAMP_GRAVITY_COEFF;
return;
}
@@ -1172,7 +1171,7 @@ void DoLaraFallDamage(ItemInfo* item)
else
{
float base = item->Animation.Velocity.y - (LARA_DAMAGE_VELOCITY - 1.0f);
- item->HitPoints -= LARA_HEALTH_MAX * (SQUARE(base) / 196.0f);
+ DoDamage(item, LARA_HEALTH_MAX * (SQUARE(base) / 196.0f));
}
float rumblePower = (item->Animation.Velocity.y / LARA_DEATH_VELOCITY) * RUMBLE_POWER_COEFF;
@@ -1296,7 +1295,7 @@ short GetPlayerSlideHeadingAngle(ItemInfo* item, CollisionInfo* coll)
return coll->Setup.ForwardAngle;
// Return slide heading angle.
- if (g_GameFlow->HasSlideExtended())
+ if (g_GameFlow->GetSettings()->Animations.SlideExtended)
{
return Geometry::GetSurfaceAspectAngle(pointColl.GetFloorNormal());
}
@@ -1489,7 +1488,7 @@ void ModulateLaraSlideVelocity(ItemInfo* item, CollisionInfo* coll)
constexpr int minVelocity = 50;
constexpr int maxVelocity = LARA_TERMINAL_VELOCITY;
- if (g_GameFlow->HasSlideExtended())
+ if (g_GameFlow->GetSettings()->Animations.SlideExtended)
{
auto probe = GetPointCollision(*item);
short minSlideAngle = ANGLE(33.75f);
@@ -1639,7 +1638,7 @@ void newSetLaraSlideAnimation(ItemInfo* item, CollisionInfo* coll)
short headinAngle = GetPlayerSlideHeadingAngle(item, coll);
short deltaAngle = headinAngle - item->Pose.Orientation.y;
- if (!g_GameFlow->HasSlideExtended())
+ if (!g_GameFlow->GetSettings()->Animations.SlideExtended)
item->Pose.Orientation.y = headinAngle;
// Snap to height upon slide entrance.
@@ -1702,7 +1701,7 @@ void SetLaraSwimDiveAnimation(ItemInfo* item)
SetAnimation(item, LA_ONWATER_DIVE);
item->Animation.TargetState = LS_UNDERWATER_SWIM_FORWARD;
- item->Animation.Velocity.y = LARA_SWIM_VELOCITY_MAX * 0.4f;
+ item->Animation.Velocity.y = g_GameFlow->GetSettings()->Physics.SwimVelocity * 0.4f;
item->Pose.Orientation.x = -ANGLE(45.0f);
lara->Control.WaterStatus = WaterStatus::Underwater;
}
diff --git a/TombEngine/Game/Lara/lara_jump.cpp b/TombEngine/Game/Lara/lara_jump.cpp
index 5b940035f..07d0eff87 100644
--- a/TombEngine/Game/Lara/lara_jump.cpp
+++ b/TombEngine/Game/Lara/lara_jump.cpp
@@ -744,7 +744,7 @@ void lara_as_swan_dive(ItemInfo* item, CollisionInfo* coll)
if (item->HitPoints <= 0)
item->Animation.TargetState = LS_DEATH;
else if ((IsHeld(In::Crouch) || CanCrawlspaceDive(*item, *coll)) &&
- g_GameFlow->HasCrawlspaceDive())
+ g_GameFlow->GetSettings()->Animations.CrawlspaceDive)
{
item->Animation.TargetState = LS_CROUCH_IDLE;
TranslateItem(item, coll->Setup.ForwardAngle, CLICK(0.5f)); // HACK: Move forward to avoid standing up or falling out on an edge.
@@ -773,7 +773,7 @@ void lara_col_swan_dive(ItemInfo* item, CollisionInfo* coll)
auto& player = GetLaraInfo(*item);
auto bounds = GameBoundingBox(item);
- int realHeight = g_GameFlow->HasCrawlspaceDive() ? (bounds.GetHeight() * 0.7f) : LARA_HEIGHT;
+ int realHeight = g_GameFlow->GetSettings()->Animations.CrawlspaceDive ? (bounds.GetHeight() * 0.7f) : LARA_HEIGHT;
player.Control.MoveAngle = item->Pose.Orientation.y;
coll->Setup.Height = std::max(LARA_HEIGHT_CRAWL, realHeight);
diff --git a/TombEngine/Game/Lara/lara_one_gun.cpp b/TombEngine/Game/Lara/lara_one_gun.cpp
index d3771a6cb..b4a494ec3 100644
--- a/TombEngine/Game/Lara/lara_one_gun.cpp
+++ b/TombEngine/Game/Lara/lara_one_gun.cpp
@@ -63,9 +63,7 @@ constexpr auto HK_BURST_MODE_SHOT_COUNT = 5;
constexpr auto HK_BURST_AND_SNIPER_MODE_SHOT_INTERVAL = 12.0f;
constexpr auto HK_RAPID_MODE_SHOT_INTERVAL = 3.0f;
-constexpr auto SHOTGUN_PELLET_COUNT = 6;
-constexpr auto SHOTGUN_NORMAL_PELLET_SCATTER = 10.0f;
-constexpr auto SHOTGUN_WIDESHOT_PELLET_SCATTER = 30.0f;
+constexpr auto SHOTGUN_PELLET_COUNT = 6;
static Vector3i GetWeaponSmokeRelOffset(LaraWeaponType weaponType)
{
@@ -223,7 +221,7 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType)
}
else
{
- FireHK(laraItem, 0);
+ FireHK(laraItem, false);
player.Control.Weapon.Timer = 1.0f;
item.Animation.TargetState = WEAPON_STATE_RECOIL;
@@ -304,7 +302,7 @@ void AnimateShotgun(ItemInfo& laraItem, LaraWeaponType weaponType)
}
else
{
- FireHK(laraItem, 1);
+ FireHK(laraItem, true);
player.Control.Weapon.Timer = 1.0f;
item.Animation.TargetState = WEAPON_STATE_UNDERWATER_RECOIL;
@@ -387,8 +385,8 @@ void FireShotgun(ItemInfo& laraItem)
armOrient += EulerAngles(player.ExtraTorsoRot.x, player.ExtraTorsoRot.y, 0);
bool hasFired = false;
- int scatter = ((player.Weapons[(int)LaraWeaponType::Shotgun].SelectedAmmo == WeaponAmmoType::Ammo1) ?
- ANGLE(SHOTGUN_NORMAL_PELLET_SCATTER) : ANGLE(SHOTGUN_WIDESHOT_PELLET_SCATTER));
+ int scatter = Weapons[(int)LaraWeaponType::Shotgun].ShotAccuracy *
+ (player.Weapons[(int)LaraWeaponType::Shotgun].SelectedAmmo == WeaponAmmoType::Ammo1) ? 1 : 3;
for (int i = 0; i < SHOTGUN_PELLET_COUNT; i++)
{
@@ -433,6 +431,7 @@ void FireShotgun(ItemInfo& laraItem)
Rumble(0.5f, 0.2f);
+ SaveGame::Statistics.Level.AmmoUsed++;
SaveGame::Statistics.Game.AmmoUsed++;
}
}
@@ -851,7 +850,7 @@ void GrenadeControl(short itemNumber)
grenadeItem.Pose.Orientation.y = sYOrient;
}
- HandleProjectile(grenadeItem, *LaraItem, prevPos, (ProjectileType)grenadeItem.ItemFlags[0], Weapons[(int)LaraWeaponType::GrenadeLauncher].ExplosiveDamage);
+ HandleProjectile(grenadeItem, *LaraItem, prevPos, (ProjectileType)grenadeItem.ItemFlags[0], Weapons[(int)LaraWeaponType::GrenadeLauncher].Damage);
}
void FireRocket(ItemInfo& laraItem)
@@ -990,7 +989,7 @@ void RocketControl(short itemNumber)
auto prevPos = rocketItem.Pose.Position;
TranslateItem(&rocketItem, rocketItem.Pose.Orientation, rocketItem.Animation.Velocity.z);
- HandleProjectile(rocketItem, *LaraItem, prevPos, ProjectileType::Explosive, Weapons[(int)LaraWeaponType::RocketLauncher].ExplosiveDamage);
+ HandleProjectile(rocketItem, *LaraItem, prevPos, ProjectileType::Explosive, Weapons[(int)LaraWeaponType::RocketLauncher].Damage);
}
void FireCrossbow(ItemInfo& laraItem, const std::optional
& pose)
@@ -1106,12 +1105,12 @@ void CrossbowBoltControl(short itemNumber)
TranslateItem(&boltItem, boltItem.Pose.Orientation, boltItem.Animation.Velocity.z);
int damage = (boltItem.ItemFlags[0] == (int)ProjectileType::Explosive) ?
- Weapons[(int)LaraWeaponType::Crossbow].ExplosiveDamage : Weapons[(int)LaraWeaponType::Crossbow].Damage;
+ Weapons[(int)LaraWeaponType::Crossbow].AlternateDamage : Weapons[(int)LaraWeaponType::Crossbow].Damage;
HandleProjectile(boltItem, *LaraItem, prevPos, (ProjectileType)boltItem.ItemFlags[0], damage);
}
-void FireHK(ItemInfo& laraItem, int mode)
+void FireHK(ItemInfo& laraItem, bool inaccurateMode)
{
auto& player = *GetLaraInfo(&laraItem);
const auto& weapon = player.Weapons[(int)LaraWeaponType::HK];
@@ -1142,16 +1141,15 @@ void FireHK(ItemInfo& laraItem, int mode)
player.ExtraTorsoRot.y + player.LeftArm.Orientation.y + laraItem.Pose.Orientation.y,
0);
}
+
+ // HACK: Backup unmodified accuracy/damage values.
+ short accuracy = Weapons[(int)LaraWeaponType::HK].ShotAccuracy;
+ int damage = Weapons[(int)LaraWeaponType::HK].Damage;
- if (mode)
+ if (inaccurateMode)
{
- Weapons[(int)LaraWeaponType::HK].ShotAccuracy = ANGLE(12.0f);
- Weapons[(int)LaraWeaponType::HK].Damage = 1;
- }
- else
- {
- Weapons[(int)LaraWeaponType::HK].ShotAccuracy = ANGLE(4.0f);
- Weapons[(int)LaraWeaponType::HK].Damage = 3;
+ Weapons[(int)LaraWeaponType::HK].ShotAccuracy = accuracy * 3;
+ Weapons[(int)LaraWeaponType::HK].Damage = damage / 3;
}
if (FireWeapon(LaraWeaponType::HK, *player.TargetEntity, laraItem, angles) != FireWeaponType::NoAmmo)
@@ -1163,6 +1161,10 @@ void FireHK(ItemInfo& laraItem, int mode)
Rumble(0.2f, 0.1f);
}
+
+ // HACK: Restore accuracy/damage values.
+ Weapons[(int)LaraWeaponType::HK].ShotAccuracy = accuracy;
+ Weapons[(int)LaraWeaponType::HK].Damage = damage;
}
void LasersightWeaponHandler(ItemInfo& item, LaraWeaponType weaponType)
@@ -1195,6 +1197,7 @@ void LasersightWeaponHandler(ItemInfo& item, LaraWeaponType weaponType)
if (player.Control.Weapon.GunType == LaraWeaponType::Revolver)
{
player.Control.Weapon.Interval = 16.0f;
+ SaveGame::Statistics.Level.AmmoUsed++;
SaveGame::Statistics.Game.AmmoUsed++;
isFiring = true;
@@ -1294,20 +1297,20 @@ void RifleHandler(ItemInfo& laraItem, LaraWeaponType weaponType)
if (player.RightArm.GunFlash)
{
+ auto& settings = g_GameFlow->GetSettings()->Weapons[(int)weaponType - 1];
+
+ auto color = Color(settings.FlashColor);
+ color += Color(Random::GenerateFloat(-0.2f, 0.2f));
+
if (weaponType == LaraWeaponType::Shotgun || weaponType == LaraWeaponType::HK)
{
auto pos = GetJointPosition(&laraItem, LM_RHAND, Vector3i(0, -64, 0));
- TriggerDynamicLight(
- pos.x, pos.y, pos.z,
- 12,
- (GetRandomControl() & 0x3F) + 192,
- (GetRandomControl() & 0x1F) + 128,
- GetRandomControl() & 0x3F);
+ TriggerDynamicPointLight(pos.ToVector3(), color, CLICK(settings.FlashRange));
}
else if (weaponType == LaraWeaponType::Revolver)
{
auto pos = GetJointPosition(&laraItem, LM_RHAND, Vector3i(0, -32, 0));
- TriggerDynamicLight(pos.x, pos.y, pos.z, 12, (GetRandomControl() & 0x3F) + 192, (GetRandomControl() & 0x1F) + 128, (GetRandomControl() & 0x3F));
+ TriggerDynamicPointLight(pos.ToVector3(), color, CLICK(settings.FlashRange));
}
}
}
@@ -1331,9 +1334,11 @@ void DoExplosiveDamage(ItemInfo& emitter, ItemInfo& target, ItemInfo& projectile
if (&target != &emitter)
{
SaveGame::Statistics.Game.AmmoHits++;
+ SaveGame::Statistics.Level.AmmoHits++;
if (target.HitPoints <= 0)
{
SaveGame::Statistics.Level.Kills++;
+ SaveGame::Statistics.Game.Kills++;
CreatureDie(target.Index, true);
}
}
diff --git a/TombEngine/Game/Lara/lara_one_gun.h b/TombEngine/Game/Lara/lara_one_gun.h
index b583b7eba..17495531e 100644
--- a/TombEngine/Game/Lara/lara_one_gun.h
+++ b/TombEngine/Game/Lara/lara_one_gun.h
@@ -45,7 +45,7 @@ void FireCrossbow(ItemInfo& laraItem, const std::optional& pose = std::nul
void FireCrossBowFromLaserSight(ItemInfo& laraItem, GameVector* origin, GameVector* target);
void CrossbowBoltControl(short itemNumber);
-void FireHK(ItemInfo& laraItem, int mode);
+void FireHK(ItemInfo& laraItem, bool inaccurateMode);
void RifleHandler(ItemInfo& laraItem, LaraWeaponType weaponType);
void LasersightWeaponHandler(ItemInfo& item, LaraWeaponType weaponType);
diff --git a/TombEngine/Game/Lara/lara_overhang.cpp b/TombEngine/Game/Lara/lara_overhang.cpp
index 12f04361e..abd103708 100644
--- a/TombEngine/Game/Lara/lara_overhang.cpp
+++ b/TombEngine/Game/Lara/lara_overhang.cpp
@@ -832,7 +832,7 @@ void lara_as_sclimbend(ItemInfo* item, CollisionInfo* coll)
// Extends LS_HANG (10)
void SlopeHangExtra(ItemInfo* item, CollisionInfo* coll)
{
- if (!g_GameFlow->HasOverhangClimb())
+ if (!g_GameFlow->GetSettings()->Animations.OverhangClimb)
return;
auto slopeData = GetSlopeData(item);
@@ -877,7 +877,7 @@ void SlopeHangExtra(ItemInfo* item, CollisionInfo* coll)
// Extends LS_REACH (11)
void SlopeReachExtra(ItemInfo* item, CollisionInfo* coll)
{
- if (!g_GameFlow->HasOverhangClimb())
+ if (!g_GameFlow->GetSettings()->Animations.OverhangClimb)
return;
auto slopeData = GetSlopeData(item);
@@ -911,7 +911,7 @@ void SlopeReachExtra(ItemInfo* item, CollisionInfo* coll)
// Extends LS_CLIMB_IDLE (56)
void SlopeClimbExtra(ItemInfo* item, CollisionInfo* coll)
{
- if (!g_GameFlow->HasOverhangClimb())
+ if (!g_GameFlow->GetSettings()->Animations.OverhangClimb)
return;
auto slopeData = GetSlopeData(item);
@@ -987,7 +987,7 @@ bool LadderMonkeyExtra(ItemInfo* item, CollisionInfo* coll)
// Extends LS_LADDER_DOWN (61)
void SlopeClimbDownExtra(ItemInfo* item, CollisionInfo* coll)
{
- if (!g_GameFlow->HasOverhangClimb())
+ if (!g_GameFlow->GetSettings()->Animations.OverhangClimb)
return;
auto slopeData = GetSlopeData(item);
@@ -1049,7 +1049,7 @@ void SlopeMonkeyExtra(ItemInfo* item, CollisionInfo* coll)
{
auto* lara = GetLaraInfo(item);
- if (!g_GameFlow->HasOverhangClimb())
+ if (!g_GameFlow->GetSettings()->Animations.OverhangClimb)
return;
auto slopeData = GetSlopeData(item);
diff --git a/TombEngine/Game/Lara/lara_slide.cpp b/TombEngine/Game/Lara/lara_slide.cpp
index 9efdd8de2..19dd4a0b9 100644
--- a/TombEngine/Game/Lara/lara_slide.cpp
+++ b/TombEngine/Game/Lara/lara_slide.cpp
@@ -10,6 +10,7 @@
#include "Game/Lara/lara_helpers.h"
#include "Game/Lara/lara_tests.h"
#include "Sound/sound.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/Input/Input.h"
#include "Specific/level.h"
@@ -40,7 +41,7 @@ void lara_as_slide_forward(ItemInfo* item, CollisionInfo* coll)
{
/*short direction = GetPlayerSlideHeadingAngle(item, coll);
- if (g_GameFlow->Animations.HasSlideExtended)
+ if (g_GameFlow->GetSettings()->Animations.SlideExtended)
{
ApproachLaraTargetOrientation(item, direction, 12);
ModulateLaraSlideVelocity(item, coll);
@@ -147,7 +148,7 @@ void lara_as_slide_back(ItemInfo* item, CollisionInfo* coll)
{
/*short direction = GetPlayerSlideHeadingAngle(item, coll) + ANGLE(180.0f);
- if (g_GameFlow->Animations.HasSlideExtended)
+ if (g_GameFlow->GetSettings()->Animations.SlideExtended)
{
ApproachLaraTargetOrientation(item, direction, 12);
ModulateLaraSlideVelocity(item, coll);
diff --git a/TombEngine/Game/Lara/lara_surface.cpp b/TombEngine/Game/Lara/lara_surface.cpp
index 9ec72f52f..652d7d53c 100644
--- a/TombEngine/Game/Lara/lara_surface.cpp
+++ b/TombEngine/Game/Lara/lara_surface.cpp
@@ -10,6 +10,7 @@
#include "Game/Lara/lara_helpers.h"
#include "Game/Lara/lara_swim.h"
#include "Game/Lara/lara_tests.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/level.h"
#include "Specific/Input/Input.h"
@@ -43,7 +44,7 @@ void lara_as_surface_idle(ItemInfo* item, CollisionInfo* coll)
lara->Control.Look.Mode = LookMode::Free;
- item->Animation.Velocity.y -= LARA_SWIM_VELOCITY_DECEL;
+ item->Animation.Velocity.y -= g_GameFlow->GetSettings()->Physics.SwimVelocity * LARA_SWIM_VELOCITY_DECEL_COEFF;
if (item->Animation.Velocity.y < 0)
item->Animation.Velocity.y = 0;
@@ -126,9 +127,11 @@ void lara_as_surface_swim_forward(ItemInfo* item, CollisionInfo* coll)
if (IsClicked(In::Jump))
SetLaraSwimDiveAnimation(item);
- item->Animation.Velocity.y += LARA_SWIM_VELOCITY_ACCEL;
- if (item->Animation.Velocity.y > LARA_TREAD_VELOCITY_MAX)
- item->Animation.Velocity.y = LARA_TREAD_VELOCITY_MAX;
+ float baseVel = g_GameFlow->GetSettings()->Physics.SwimVelocity;
+
+ item->Animation.Velocity.y += baseVel * LARA_SWIM_VELOCITY_ACCEL_COEFF;
+ if (item->Animation.Velocity.y > baseVel * LARA_TREAD_VELOCITY_MAX_COEFF)
+ item->Animation.Velocity.y = baseVel * LARA_TREAD_VELOCITY_MAX_COEFF;
}
// State: LS_ONWATER_FORWARD (34)
@@ -170,9 +173,11 @@ void lara_as_surface_swim_left(ItemInfo* item, CollisionInfo* coll)
if (IsClicked(In::Jump))
SetLaraSwimDiveAnimation(item);
- item->Animation.Velocity.y += LARA_SWIM_VELOCITY_ACCEL;
- if (item->Animation.Velocity.y > LARA_TREAD_VELOCITY_MAX)
- item->Animation.Velocity.y = LARA_TREAD_VELOCITY_MAX;
+ float baseVel = g_GameFlow->GetSettings()->Physics.SwimVelocity;
+
+ item->Animation.Velocity.y += baseVel * LARA_SWIM_VELOCITY_ACCEL_COEFF;
+ if (item->Animation.Velocity.y > baseVel * LARA_TREAD_VELOCITY_MAX_COEFF)
+ item->Animation.Velocity.y = baseVel * LARA_TREAD_VELOCITY_MAX_COEFF;
}
// State: LS_ONWATER_LEFT (48)
@@ -211,9 +216,11 @@ void lara_as_surface_swim_right(ItemInfo* item, CollisionInfo* coll)
if (IsClicked(In::Jump))
SetLaraSwimDiveAnimation(item);
- item->Animation.Velocity.y += LARA_SWIM_VELOCITY_ACCEL;
- if (item->Animation.Velocity.y > LARA_TREAD_VELOCITY_MAX)
- item->Animation.Velocity.y = LARA_TREAD_VELOCITY_MAX;
+ float baseVel = g_GameFlow->GetSettings()->Physics.SwimVelocity;
+
+ item->Animation.Velocity.y += baseVel * LARA_SWIM_VELOCITY_ACCEL_COEFF;
+ if (item->Animation.Velocity.y > baseVel * LARA_TREAD_VELOCITY_MAX_COEFF)
+ item->Animation.Velocity.y = baseVel * LARA_TREAD_VELOCITY_MAX_COEFF;
}
// State: LS_ONWATER_RIGHT (49)
@@ -249,9 +256,11 @@ void lara_as_surface_swim_back(ItemInfo* item, CollisionInfo* coll)
if (!IsHeld(In::Back))
item->Animation.TargetState = LS_ONWATER_IDLE;
- item->Animation.Velocity.y += LARA_SWIM_VELOCITY_ACCEL;
- if (item->Animation.Velocity.y > LARA_TREAD_VELOCITY_MAX)
- item->Animation.Velocity.y = LARA_TREAD_VELOCITY_MAX;
+ float baseVel = g_GameFlow->GetSettings()->Physics.SwimVelocity;
+
+ item->Animation.Velocity.y += baseVel * LARA_SWIM_VELOCITY_ACCEL_COEFF;
+ if (item->Animation.Velocity.y > baseVel * LARA_TREAD_VELOCITY_MAX_COEFF)
+ item->Animation.Velocity.y = baseVel * LARA_TREAD_VELOCITY_MAX_COEFF;
}
// State: LS_ONWATER_BACK (47)
diff --git a/TombEngine/Game/Lara/lara_swim.cpp b/TombEngine/Game/Lara/lara_swim.cpp
index c814159aa..65344e1e9 100644
--- a/TombEngine/Game/Lara/lara_swim.cpp
+++ b/TombEngine/Game/Lara/lara_swim.cpp
@@ -54,7 +54,7 @@ void lara_as_underwater_idle(ItemInfo* item, CollisionInfo* coll)
if (IsHeld(In::Jump))
item->Animation.TargetState = LS_UNDERWATER_SWIM_FORWARD;
- item->Animation.Velocity.y -= LARA_SWIM_VELOCITY_DECEL;
+ item->Animation.Velocity.y -= g_GameFlow->GetSettings()->Physics.SwimVelocity * LARA_SWIM_VELOCITY_DECEL_COEFF;
if (item->Animation.Velocity.y < 0.0f)
item->Animation.Velocity.y = 0.0f;
@@ -96,9 +96,11 @@ void lara_as_underwater_swim_forward(ItemInfo* item, CollisionInfo* coll)
else
ModulateLaraSubsuitSwimTurnRates(item);
- item->Animation.Velocity.y += LARA_SWIM_VELOCITY_ACCEL;
- if (item->Animation.Velocity.y > LARA_SWIM_VELOCITY_MAX)
- item->Animation.Velocity.y = LARA_SWIM_VELOCITY_MAX;
+ float baseVel = g_GameFlow->GetSettings()->Physics.SwimVelocity;
+
+ item->Animation.Velocity.y += baseVel * LARA_SWIM_VELOCITY_ACCEL_COEFF;
+ if (item->Animation.Velocity.y > baseVel)
+ item->Animation.Velocity.y = baseVel;
if (!IsHeld(In::Jump))
item->Animation.TargetState = LS_UNDERWATER_INERTIA;
@@ -141,11 +143,13 @@ void lara_as_underwater_inertia(ItemInfo* item, CollisionInfo* coll)
if (IsHeld(In::Jump))
item->Animation.TargetState = LS_UNDERWATER_SWIM_FORWARD;
- item->Animation.Velocity.y -= LARA_SWIM_VELOCITY_DECEL;
+ const auto& settings = g_GameFlow->GetSettings()->Physics;
+
+ item->Animation.Velocity.y -= settings.SwimVelocity * LARA_SWIM_VELOCITY_DECEL_COEFF;
if (item->Animation.Velocity.y < 0.0f)
item->Animation.Velocity.y = 0.0f;
- if (item->Animation.Velocity.y < LARA_SWIM_INTERTIA_VELOCITY_MIN)
+ if (item->Animation.Velocity.y < (settings.SwimVelocity * LARA_SWIM_INTERTIA_VELOCITY_MIN_COEFF))
item->Animation.TargetState = LS_UNDERWATER_IDLE;
}
@@ -164,7 +168,7 @@ void lara_as_underwater_death(ItemInfo* item, CollisionInfo* coll)
lara->Control.Look.Mode = LookMode::None;
- item->Animation.Velocity.y -= LARA_SWIM_VELOCITY_DECEL;
+ item->Animation.Velocity.y -= g_GameFlow->GetSettings()->Physics.SwimVelocity * LARA_SWIM_VELOCITY_DECEL_COEFF;
if (item->Animation.Velocity.y < 0.0f)
item->Animation.Velocity.y = 0.0f;
diff --git a/TombEngine/Game/Lara/lara_tests.cpp b/TombEngine/Game/Lara/lara_tests.cpp
index 745d8d478..2875cecda 100644
--- a/TombEngine/Game/Lara/lara_tests.cpp
+++ b/TombEngine/Game/Lara/lara_tests.cpp
@@ -914,6 +914,7 @@ bool TestPlayerWaterStepOut(ItemInfo* item, CollisionInfo* coll)
bool TestLaraWaterClimbOut(ItemInfo* item, CollisionInfo* coll)
{
auto* lara = GetLaraInfo(item);
+ const auto& settings = g_GameFlow->GetSettings()->Animations;
if (coll->CollisionType != CollisionType::Front || !IsHeld(In::Action))
return false;
@@ -964,7 +965,7 @@ bool TestLaraWaterClimbOut(ItemInfo* item, CollisionInfo* coll)
{
if (headroom < LARA_HEIGHT)
{
- if (g_GameFlow->HasCrawlExtended())
+ if (settings.CrawlExtended)
SetAnimation(item, LA_ONWATER_TO_CROUCH_1_STEP);
else
return false;
@@ -976,7 +977,7 @@ bool TestLaraWaterClimbOut(ItemInfo* item, CollisionInfo* coll)
{
if (headroom < LARA_HEIGHT)
{
- if (g_GameFlow->HasCrawlExtended())
+ if (settings.CrawlExtended)
SetAnimation(item, LA_ONWATER_TO_CROUCH_M1_STEP);
else
return false;
@@ -989,7 +990,7 @@ bool TestLaraWaterClimbOut(ItemInfo* item, CollisionInfo* coll)
{
if (headroom < LARA_HEIGHT)
{
- if (g_GameFlow->HasCrawlExtended())
+ if (settings.CrawlExtended)
SetAnimation(item, LA_ONWATER_TO_CROUCH_0_STEP);
else
return false;
@@ -1449,6 +1450,7 @@ std::optional TestLaraAutoMonkeySwingJump(ItemInfo* item, Colli
std::optional TestLaraVault(ItemInfo* item, CollisionInfo* coll)
{
auto* lara = GetLaraInfo(item);
+ auto& settings = g_GameFlow->GetSettings()->Animations;
if (lara->Control.HandStatus != HandStatus::Free)
return std::nullopt;
@@ -1485,7 +1487,7 @@ std::optional TestLaraVault(ItemInfo* item, CollisionInfo* coll
// Vault to crouch up two steps.
vaultResult = TestLaraVault2StepsToCrouch(item, coll);
- if (vaultResult.has_value() && g_GameFlow->HasCrawlExtended())
+ if (vaultResult.has_value() && settings.CrawlExtended)
{
vaultResult->TargetState = LS_VAULT_2_STEPS_CROUCH;
if (!HasStateDispatch(item, vaultResult->TargetState))
@@ -1507,7 +1509,7 @@ std::optional TestLaraVault(ItemInfo* item, CollisionInfo* coll
// Vault to crouch up three steps.
vaultResult = TestLaraVault3StepsToCrouch(item, coll);
- if (vaultResult.has_value() && g_GameFlow->HasCrawlExtended())
+ if (vaultResult.has_value() && settings.CrawlExtended)
{
vaultResult->TargetState = LS_VAULT_3_STEPS_CROUCH;
if (!HasStateDispatch(item, vaultResult->TargetState))
diff --git a/TombEngine/Game/Lara/lara_two_guns.cpp b/TombEngine/Game/Lara/lara_two_guns.cpp
index bc7b4991b..303a6ba57 100644
--- a/TombEngine/Game/Lara/lara_two_guns.cpp
+++ b/TombEngine/Game/Lara/lara_two_guns.cpp
@@ -171,6 +171,7 @@ static void AnimateWeapon(ItemInfo& laraItem, LaraWeaponType weaponType, bool& h
}
SaveGame::Statistics.Game.AmmoUsed++;
+ SaveGame::Statistics.Level.AmmoUsed++;
}
}
@@ -310,14 +311,17 @@ void HandlePistols(ItemInfo& laraItem, LaraWeaponType weaponType)
if (lara.LeftArm.GunFlash || lara.RightArm.GunFlash)
{
+ const auto& settings = g_GameFlow->GetSettings()->Weapons[(int)weaponType - 1];
+
+ auto color = Color(settings.FlashColor);
+ color += Color(Random::GenerateFloat(-0.2f, 0.2f));
+
auto basePos = GetJointPosition(&laraItem, (lara.LeftArm.GunFlash != 0) ? LM_LHAND : LM_RHAND).ToVector3();
auto sphere = BoundingSphere(basePos, BLOCK(1 / 8.0f));
auto lightPos = Random::GeneratePointInSphere(sphere);
-
- TriggerDynamicLight(
- lightPos.x, lightPos.y, lightPos.z,
- Random::GenerateFloat(8.0f, 11.0f),
- (GetRandomControl() & 0x3F) + 192, (GetRandomControl() & 0x1F) + 128, GetRandomControl() & 0x3F);
+
+ int range = abs(Random::GenerateInt(settings.FlashRange - 2, settings.FlashRange + 2));
+ TriggerDynamicPointLight(lightPos, color, CLICK(range));
}
}
diff --git a/TombEngine/Game/Setup.h b/TombEngine/Game/Setup.h
index ee0413b56..2ba3a4796 100644
--- a/TombEngine/Game/Setup.h
+++ b/TombEngine/Game/Setup.h
@@ -9,8 +9,6 @@ struct CollisionInfo;
struct ItemInfo;
constexpr auto DEFAULT_RADIUS = 10;
-constexpr auto GRAVITY = 6.0f;
-constexpr auto SWAMP_GRAVITY = GRAVITY / 3.0f;
enum JointRotationFlags
{
diff --git a/TombEngine/Game/animation.cpp b/TombEngine/Game/animation.cpp
index 9949d097c..53d0a6d46 100644
--- a/TombEngine/Game/animation.cpp
+++ b/TombEngine/Game/animation.cpp
@@ -13,6 +13,7 @@
#include "Math/Math.h"
#include "Objects/Generic/Object/rope.h"
#include "Renderer/Renderer.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/level.h"
@@ -565,7 +566,7 @@ const AnimFrame& GetBestFrame(const ItemInfo& item)
float GetEffectiveGravity(float verticalVel)
{
- return ((verticalVel >= VERTICAL_VELOCITY_GRAVITY_THRESHOLD) ? 1.0f : GRAVITY);
+ return ((verticalVel >= VERTICAL_VELOCITY_GRAVITY_THRESHOLD) ? 1.0f : g_GameFlow->GetSettings()->Physics.Gravity);
}
int GetAnimNumber(const ItemInfo& item)
diff --git a/TombEngine/Game/camera.cpp b/TombEngine/Game/camera.cpp
index fbbb1b385..7067def78 100644
--- a/TombEngine/Game/camera.cpp
+++ b/TombEngine/Game/camera.cpp
@@ -970,7 +970,7 @@ void BinocularCamera(ItemInfo* item)
auto origin = Camera.pos.ToVector3i();
auto target = Camera.target.ToVector3i();
- LaraTorch(&origin, &target, player.ExtraHeadRot.y, 192);
+ LaraTorch(&origin, &target);
}
}
@@ -1489,6 +1489,9 @@ std::vector FillCollideableStaticsList()
void ItemsCollideCamera()
{
+ if (!g_GameFlow->GetSettings()->Camera.ObjectCollision)
+ return;
+
constexpr auto RADIUS = CLICK(0.5f);
auto itemList = FillCollideableItemList();
diff --git a/TombEngine/Game/camera.h b/TombEngine/Game/camera.h
index f92703ec7..0c555e439 100644
--- a/TombEngine/Game/camera.h
+++ b/TombEngine/Game/camera.h
@@ -15,8 +15,7 @@ enum class CameraType
Fixed,
Look,
Combat,
- Heavy,
- Object
+ Heavy
};
struct CAMERA_INFO
diff --git a/TombEngine/Game/control/control.cpp b/TombEngine/Game/control/control.cpp
index 8615926e2..c78a61423 100644
--- a/TombEngine/Game/control/control.cpp
+++ b/TombEngine/Game/control/control.cpp
@@ -93,7 +93,6 @@ using namespace TEN::Entities::Effects;
constexpr auto DEATH_NO_INPUT_TIMEOUT = 10 * FPS;
constexpr auto DEATH_INPUT_TIMEOUT = 3 * FPS;
-int GameTimer = 0;
int GlobalCounter = 0;
bool InitializeGame = false;
@@ -258,7 +257,8 @@ GameStatus GamePhase(bool insideMenu)
JustLoaded = false;
// Update timers.
- GameTimer++;
+ SaveGame::Statistics.Game.TimeTaken++;
+ SaveGame::Statistics.Level.TimeTaken++;
GlobalCounter++;
auto time2 = std::chrono::high_resolution_clock::now();
@@ -616,7 +616,6 @@ void InitializeOrLoadGame(bool loadGame)
{
// Clear all game info as well.
SaveGame::Statistics.Game = {};
- GameTimer = 0;
InitializeGame = false;
SaveGame::ResetHub();
diff --git a/TombEngine/Game/control/control.h b/TombEngine/Game/control/control.h
index b700595bb..742856cf8 100644
--- a/TombEngine/Game/control/control.h
+++ b/TombEngine/Game/control/control.h
@@ -53,7 +53,6 @@ constexpr int MAX_ROOMS = 1024;
constexpr auto LOOP_FRAME_COUNT = 2;
-extern int GameTimer;
extern int RumbleTimer;
extern int GlobalCounter;
diff --git a/TombEngine/Game/control/los.cpp b/TombEngine/Game/control/los.cpp
index 00db3ae6f..faea4f675 100644
--- a/TombEngine/Game/control/los.cpp
+++ b/TombEngine/Game/control/los.cpp
@@ -14,6 +14,7 @@
#include "Objects/Generic/Object/objects.h"
#include "Objects/Generic/Switches/switch.h"
#include "Renderer/Renderer.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h"
#include "Scripting/Include/ScriptInterfaceGame.h"
#include "Sound/sound.h"
@@ -345,7 +346,7 @@ bool GetTargetOnLOS(GameVector* origin, GameVector* target, bool drawTarget, boo
}
}
- HitTarget(LaraItem, item, &target2, Weapons[(int)Lara.Control.Weapon.GunType].Damage, false, bestJointIndex);
+ HitTarget(LaraItem, item, &target2, Weapons[(int)Lara.Control.Weapon.GunType].AlternateDamage, false, bestJointIndex);
hitProcessed = true;
}
else
@@ -443,11 +444,8 @@ bool GetTargetOnLOS(GameVector* origin, GameVector* target, bool drawTarget, boo
if (drawTarget && (hasHit || !result))
{
- TriggerDynamicLight(target2.x, target2.y, target2.z, 64, 255, 0, 0);
- LaserSightActive = 1;
- LaserSightX = target2.x;
- LaserSightY = target2.y;
- LaserSightZ = target2.z;
+ auto& color = g_GameFlow->GetSettings()->Camera.LasersightLightColor;
+ TriggerDynamicLight(target2.x, target2.y, target2.z, 64, color.GetR(), color.GetG(), color.GetB());
}
return hitProcessed;
diff --git a/TombEngine/Game/control/trigger.cpp b/TombEngine/Game/control/trigger.cpp
index 4c90da526..19224a96d 100644
--- a/TombEngine/Game/control/trigger.cpp
+++ b/TombEngine/Game/control/trigger.cpp
@@ -778,10 +778,11 @@ void TestTriggers(int x, int y, int z, FloorInfo* floor, Activator activator, bo
if (switchOff)
break;
- if (!(SaveGame::Statistics.Level.Secrets & (1 << value)))
+ if (!(SaveGame::Statistics.SecretBits & (1 << value)))
{
PlaySecretTrack();
- SaveGame::Statistics.Level.Secrets |= (1 << value);
+ SaveGame::Statistics.SecretBits |= (1 << value);
+ SaveGame::Statistics.Level.Secrets++;
SaveGame::Statistics.Game.Secrets++;
}
break;
diff --git a/TombEngine/Game/control/volume.cpp b/TombEngine/Game/control/volume.cpp
index 0f0188132..64f55db11 100644
--- a/TombEngine/Game/control/volume.cpp
+++ b/TombEngine/Game/control/volume.cpp
@@ -168,7 +168,7 @@ namespace TEN::Control::Volumes
if (candidate.Status == VolumeStateStatus::Leaving)
{
- if ((GameTimer - candidate.Timestamp) > VOLUME_BUSY_TIMEOUT)
+ if ((GlobalCounter - candidate.Timestamp) > VOLUME_BUSY_TIMEOUT)
candidate.Status = VolumeStateStatus::Outside;
}
else if (candidate.Status != VolumeStateStatus::Outside)
@@ -191,7 +191,7 @@ namespace TEN::Control::Volumes
{
VolumeStateStatus::Entering,
activator,
- GameTimer
+ GlobalCounter
});
HandleEvent(set.Events[(int)EventType::Enter], activator);
@@ -199,7 +199,7 @@ namespace TEN::Control::Volumes
else
{
entryPtr->Status = VolumeStateStatus::Inside;
- entryPtr->Timestamp = GameTimer;
+ entryPtr->Timestamp = GlobalCounter;
HandleEvent(set.Events[(int)EventType::Inside], activator);
}
@@ -209,10 +209,10 @@ namespace TEN::Control::Volumes
// Only fire leave event when a certain timeout has passed.
// This helps to filter out borderline cases when moving around volumes.
- if ((GameTimer - entryPtr->Timestamp) > VOLUME_LEAVE_TIMEOUT)
+ if ((GlobalCounter - entryPtr->Timestamp) > VOLUME_LEAVE_TIMEOUT)
{
entryPtr->Status = VolumeStateStatus::Leaving;
- entryPtr->Timestamp = GameTimer;
+ entryPtr->Timestamp = GlobalCounter;
HandleEvent(set.Events[(int)EventType::Leave], activator);
}
diff --git a/TombEngine/Game/effects/chaffFX.cpp b/TombEngine/Game/effects/chaffFX.cpp
index f3e511a89..373bd735e 100644
--- a/TombEngine/Game/effects/chaffFX.cpp
+++ b/TombEngine/Game/effects/chaffFX.cpp
@@ -14,6 +14,7 @@
#include "Math/Math.h"
#include "Specific/level.h"
#include "Renderer/RendererEnums.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
using namespace TEN::Effects::Bubble;
@@ -23,18 +24,20 @@ constexpr auto MAX_TRIGGER_RANGE = BLOCK(16);
void TriggerChaffEffects(int flareLife)
{
- auto pos = GetJointPosition(LaraItem, LM_LHAND, Vector3i(8, 36, 32));
- auto vect = GetJointPosition(LaraItem, LM_LHAND, Vector3i(8, 36, 1024 + Random::GenerateInt(0, 256)));
- auto vel = vect - pos;
+ auto offset = g_GameFlow->GetSettings()->Flare.Offset.ToVector3i() + Vector3i(11, 32, -4);
+ auto pos = GetJointPosition(LaraItem, LM_LHAND, offset);
+ auto vec = GetJointPosition(LaraItem, LM_LHAND, Vector3i(11, 32, BLOCK(1) + Random::GenerateInt(0, 256)));
+ auto vel = vec - pos;
TriggerChaffEffects(*LaraItem, pos, vel, LaraItem->Animation.Velocity.z, TestEnvironment(ENV_FLAG_WATER, LaraItem->RoomNumber), flareLife);
}
void TriggerChaffEffects(ItemInfo& item, int age)
{
- auto world = Matrix::CreateTranslation(-6, 6, 32) * item.Pose.Orientation.ToRotationMatrix();
+ auto offset = g_GameFlow->GetSettings()->Flare.Offset.ToVector3() + Vector3(0, 0, -4);
+ auto world = Matrix::CreateTranslation(offset) * item.Pose.Orientation.ToRotationMatrix();
auto pos = item.Pose.Position + Vector3i(world.Translation());
- world = Matrix::CreateTranslation(-6, 6, 32) *
+ world = Matrix::CreateTranslation(offset) *
Matrix::CreateTranslation((GetRandomDraw() & 127) - 64, (GetRandomDraw() & 127) - 64, (GetRandomDraw() & 511) + 512) *
item.Pose.Orientation.ToRotationMatrix();
@@ -70,12 +73,13 @@ void TriggerChaffEffects(ItemInfo& item, const Vector3i& pos, const Vector3i& ve
if (dx < -MAX_TRIGGER_RANGE || dx > MAX_TRIGGER_RANGE || dz < -MAX_TRIGGER_RANGE || dz > MAX_TRIGGER_RANGE)
return;
- auto color = Color();
- color.x = 1.0f;
- color.y = Random::GenerateFloat(0.25f, 0.75f);
- color.z = 0.75f - color.G();
+ const auto& settings = g_GameFlow->GetSettings()->Flare;
- TriggerChaffSparkles(pos, vel, color, age, item);
+ if (settings.Sparks)
+ TriggerChaffSparkles(pos, vel, settings.Color, age, item);
+
+ if (!settings.Smoke)
+ continue;
if (isUnderwater)
{
diff --git a/TombEngine/Game/effects/debris.cpp b/TombEngine/Game/effects/debris.cpp
index ba901285c..4139bb33b 100644
--- a/TombEngine/Game/effects/debris.cpp
+++ b/TombEngine/Game/effects/debris.cpp
@@ -5,8 +5,9 @@
#include "Game/collision/Sphere.h"
#include "Game/effects/tomb4fx.h"
#include "Game/Setup.h"
-#include "Specific/level.h"
#include "Math/Math.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
+#include "Specific/level.h"
using namespace TEN::Collision::Sphere;
using namespace TEN::Math;
@@ -172,7 +173,7 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num, short roomNumbe
fragment->isStatic = isStatic;
fragment->active = true;
fragment->terminalVelocity = 1024;
- fragment->gravity = Vector3(0, 7, 0);
+ fragment->gravity = Vector3(0, g_GameFlow->GetSettings()->Physics.Gravity, 0);
fragment->restitution = 0.6f;
fragment->friction = 0.6f;
fragment->linearDrag = .99f;
diff --git a/TombEngine/Game/effects/drip.cpp b/TombEngine/Game/effects/drip.cpp
index f21b06c6c..239ee86da 100644
--- a/TombEngine/Game/effects/drip.cpp
+++ b/TombEngine/Game/effects/drip.cpp
@@ -10,6 +10,7 @@
#include "Game/room.h"
#include "Game/Setup.h"
#include "Math/Math.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/clock.h"
#include "Specific/level.h"
@@ -50,10 +51,6 @@ namespace TEN::Effects::Drip
constexpr auto VERTICAL_VELOCITY_HIGH_MIN = 32.0f;
constexpr auto VERTICAL_VELOCITY_LOW_MAX = 24.0f;
constexpr auto VERTICAL_VELOCITY_LOW_MIN = 16.0f;
- constexpr auto GRAVITY_HIGH_MAX = 6.0f;
- constexpr auto GRAVITY_HIGH_MIN = 3.0f;
- constexpr auto GRAVITY_LOW_MAX = 3.0f;
- constexpr auto GRAVITY_LOW_MIN = 2.0f;
constexpr auto SPAWN_RADIUS_LARGE = BLOCK(1 / 8.0f);
constexpr auto SPAWN_RADIUS_SMALL = BLOCK(1 / 64.0f);
@@ -71,9 +68,11 @@ namespace TEN::Effects::Drip
Random::GenerateFloat(VERTICAL_VELOCITY_HIGH_MIN, VERTICAL_VELOCITY_HIGH_MAX);
auto vel = (direction * VELOCITY_BASE) + Vector3(0.0f, -verticalVel, 0.0f);
+ float systemGravity = g_GameFlow->GetSettings()->Physics.Gravity;
+
float gravity = isSmallSplash ?
- Random::GenerateFloat(GRAVITY_LOW_MIN, GRAVITY_LOW_MAX) :
- Random::GenerateFloat(GRAVITY_HIGH_MIN, GRAVITY_HIGH_MAX);
+ Random::GenerateFloat(systemGravity / 3, systemGravity / 2) :
+ Random::GenerateFloat(systemGravity / 2, systemGravity);
SpawnDrip(dripPos, roomNumber, vel, LIFE_MAX, gravity);
}
@@ -82,13 +81,12 @@ namespace TEN::Effects::Drip
void SpawnWetnessDrip(const Vector3& pos, int roomNumber)
{
constexpr auto LIFE_MAX = 1.0f;
- constexpr auto GRAVITY_MAX = 6.0f;
- constexpr auto GRAVITY_MIN = 3.0f;
constexpr auto SPAWN_RADIUS = BLOCK(1 / 32.0f);
+ auto gravity = g_GameFlow->GetSettings()->Physics.Gravity;
auto sphere = BoundingSphere(pos, SPAWN_RADIUS);
auto dripPos = Random::GeneratePointInSphere(sphere);
- SpawnDrip(dripPos, roomNumber, Vector3::Zero, LIFE_MAX, Random::GenerateFloat(GRAVITY_MIN, GRAVITY_MAX));
+ SpawnDrip(dripPos, roomNumber, Vector3::Zero, LIFE_MAX, Random::GenerateFloat(gravity / 2, gravity));
}
void UpdateDrips()
diff --git a/TombEngine/Game/effects/effects.cpp b/TombEngine/Game/effects/effects.cpp
index 80566e8da..0594939cb 100644
--- a/TombEngine/Game/effects/effects.cpp
+++ b/TombEngine/Game/effects/effects.cpp
@@ -1455,8 +1455,6 @@ void TriggerFlashSmoke(int x, int y, int z, short roomNumber)
{
auto* room = &g_Level.Rooms[roomNumber];
- bool mirror = (roomNumber == g_GameFlow->GetLevel(CurrentLevel)->GetMirrorRoom());
-
bool water = false;
if (TestEnvironment(ENV_FLAG_WATER, room))
{
@@ -1505,7 +1503,6 @@ void TriggerFlashSmoke(int x, int y, int z, short roomNumber)
spark->gravity = 0;
spark->sSize = spark->size = (GetRandomControl() & 0x1F) + 64;
spark->dSize = 2 * (spark->sSize + 4);
- spark->mirror = mirror;
}
void TriggerFireFlame(int x, int y, int z, FlameType type, const Vector3& color1, const Vector3& color2)
diff --git a/TombEngine/Game/effects/hair.cpp b/TombEngine/Game/effects/hair.cpp
index a574ac31c..8e657c204 100644
--- a/TombEngine/Game/effects/hair.cpp
+++ b/TombEngine/Game/effects/hair.cpp
@@ -22,6 +22,20 @@ namespace TEN::Effects::Hair
{
HairEffectController HairEffect = {};
+ int HairUnit::GetRootMeshID(int hairUnitID)
+ {
+ bool isYoung = (g_GameFlow->GetLevel(CurrentLevel)->GetLaraType() == LaraType::Young);
+ int meshID = g_GameFlow->GetSettings()->Hair[GetHairTypeIndex(hairUnitID, isYoung)].RootMesh;
+
+ if (meshID >= LARA_MESHES::NUM_LARA_MESHES)
+ {
+ TENLog("Incorrect root mesh index specified for hair object. Check settings file.", LogLevel::Warning);
+ return LARA_MESHES::LM_HEAD;
+ }
+
+ return meshID;
+ }
+
void HairUnit::Update(const ItemInfo& item, int hairUnitID)
{
for (auto& segment : Segments)
@@ -33,7 +47,7 @@ namespace TEN::Effects::Hair
// Get world matrix from head bone.
auto worldMatrix = Matrix::Identity;
- g_Renderer.GetBoneMatrix(item.Index, LM_HEAD, &worldMatrix);
+ g_Renderer.GetBoneMatrix(item.Index, GetRootMeshID(hairUnitID), &worldMatrix);
// Apply base offset to world matrix.
auto relOffset = GetRelBaseOffset(hairUnitID, isYoung);
@@ -108,31 +122,37 @@ namespace TEN::Effects::Hair
}
}
- Vector3 HairUnit::GetRelBaseOffset(int hairUnitID, bool isYoung)
+ int HairUnit::GetHairTypeIndex(int hairUnitID, bool isYoung)
{
- auto relOffset = Vector3::Zero;
+ int hairType = (int)PlayerHairType::Normal;
+
if (isYoung)
{
switch (hairUnitID)
{
- // Left pigtail offset.
+ // Left offset.
case 0:
- relOffset = Vector3(-48.0f, -48.0f, -50.0f);
+ hairType = (int)PlayerHairType::YoungLeft;
break;
- // Right pigtail offset.
+ // Right offset.
case 1:
- relOffset = Vector3(48.0f, -48.0f, -50.0f);
+ hairType = (int)PlayerHairType::YoungRight;
break;
}
}
else
{
- // Center braid offset.
- relOffset = Vector3(-4.0f, -4.0f, -48.0f);
+ // Center offset.
+ hairType = (int)PlayerHairType::Normal;
}
- return relOffset;
+ return hairType;
+ }
+
+ Vector3 HairUnit::GetRelBaseOffset(int hairUnitID, bool isYoung)
+ {
+ return g_GameFlow->GetSettings()->Hair[GetHairTypeIndex(hairUnitID, isYoung)].Offset;
}
Vector3 HairUnit::GetWaterProbeOffset(const ItemInfo& item)
@@ -272,7 +292,7 @@ namespace TEN::Effects::Hair
segment.Position += Weather.Wind() * 2;
// Apply gravity.
- segment.Position.y += HAIR_GRAVITY;
+ segment.Position.y += g_GameFlow->GetSettings()->Physics.Gravity * HAIR_GRAVITY_COEFF;
// Float on water surface.
if (waterHeight != NO_HEIGHT && segment.Position.y > waterHeight)
diff --git a/TombEngine/Game/effects/hair.h b/TombEngine/Game/effects/hair.h
index 5abe6acf8..3180ed755 100644
--- a/TombEngine/Game/effects/hair.h
+++ b/TombEngine/Game/effects/hair.h
@@ -6,12 +6,19 @@ struct ItemInfo;
namespace TEN::Effects::Hair
{
+ enum class PlayerHairType
+ {
+ Normal,
+ YoungLeft,
+ YoungRight
+ };
+
class HairUnit
{
private:
// Constants
- static constexpr auto HAIR_GRAVITY = 10.0f;
+ static constexpr auto HAIR_GRAVITY_COEFF = 1.66f;
struct HairSegment
{
@@ -38,6 +45,10 @@ namespace TEN::Effects::Hair
GAME_OBJECT_ID ObjectID = GAME_OBJECT_ID::ID_NO_OBJECT;
std::vector Segments = {};
+ // Getters
+
+ static int GetRootMeshID(int hairUnitID);
+
// Utilities
void Update(const ItemInfo& item, int hairUnitID);
@@ -45,6 +56,8 @@ namespace TEN::Effects::Hair
private:
// Helpers
+ static int GetHairTypeIndex(int hairUnitID, bool isYoung);
+
Vector3 GetRelBaseOffset(int hairUnitID, bool isYoung);
Vector3 GetWaterProbeOffset(const ItemInfo& item);
Quaternion GetSegmentOrientation(const Vector3& origin, const Vector3& target, const Quaternion& baseOrient);
diff --git a/TombEngine/Game/effects/item_fx.cpp b/TombEngine/Game/effects/item_fx.cpp
index 5261e6734..cbf21c2ca 100644
--- a/TombEngine/Game/effects/item_fx.cpp
+++ b/TombEngine/Game/effects/item_fx.cpp
@@ -10,7 +10,7 @@
#include "Game/items.h"
#include "Game/Lara/lara.h"
#include "Game/Lara/lara_helpers.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
#include "Specific/clock.h"
#include "Specific/level.h"
diff --git a/TombEngine/Game/effects/item_fx.h b/TombEngine/Game/effects/item_fx.h
index 20d6e1202..22cae7fcf 100644
--- a/TombEngine/Game/effects/item_fx.h
+++ b/TombEngine/Game/effects/item_fx.h
@@ -1,5 +1,6 @@
#pragma once
-#include "Scripting/Internal/TEN/Color/Color.h"
+
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
struct ItemInfo;
diff --git a/TombEngine/Game/effects/smoke.cpp b/TombEngine/Game/effects/smoke.cpp
index ed5c78535..3086f5e68 100644
--- a/TombEngine/Game/effects/smoke.cpp
+++ b/TombEngine/Game/effects/smoke.cpp
@@ -10,6 +10,7 @@
#include "Game/room.h"
#include "Game/Setup.h"
#include "Math/Math.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/level.h"
using namespace TEN::Effects::Environment;
@@ -100,7 +101,7 @@ namespace TEN::Effects::Smoke
s.velocity = direction2 * Random::GenerateFloat(7, 9);
s.gravity = -0.2f;
s.friction = Random::GenerateFloat(0.7f, 0.85f);
- s.sourceColor = Vector4(1, 131 / 255.0f, 100 / 255.0f, 1);
+ s.sourceColor = g_GameFlow->GetSettings()->Flare.Color * Vector4(0.5f);
s.destinationColor = Vector4(1, 1, 1, 0);
s.life = Random::GenerateFloat(25, 35);
s.angularVelocity = Random::GenerateFloat(-0.3f, 0.3f);
@@ -121,6 +122,9 @@ namespace TEN::Effects::Smoke
void SpawnGunSmokeParticles(const Vector3& pos, const Vector3& direction, int roomNumber, byte initial, LaraWeaponType weaponType, int count)
{
+ if (!g_GameFlow->GetSettings()->Weapons[(int)weaponType - 1].Smoke)
+ return;
+
auto& s = GetFreeSmokeParticle();
s = {};
s.active = true;
diff --git a/TombEngine/Game/effects/tomb4fx.cpp b/TombEngine/Game/effects/tomb4fx.cpp
index 46c46d2e4..8bad734c1 100644
--- a/TombEngine/Game/effects/tomb4fx.cpp
+++ b/TombEngine/Game/effects/tomb4fx.cpp
@@ -35,14 +35,8 @@ using TEN::Renderer::g_Renderer;
// NOTE: This fixes body part exploding instantly if entity is on ground.
constexpr auto BODY_PART_SPAWN_VERTICAL_OFFSET = CLICK(1);
-char LaserSightActive = 0;
-char LaserSightCol = 0;
int NextGunshell = 0;
-int LaserSightX;
-int LaserSightY;
-int LaserSightZ;
-
int NextFireSpark = 1;
int NextSmokeSpark = 0;
int NextBlood = 0;
@@ -898,53 +892,56 @@ void TriggerGunShell(short hand, short objNum, LaraWeaponType weaponType)
pos = GetJointPosition(LaraItem, LM_LHAND, Vector3i(-16, 35, 48));
}
- auto* gshell = &Gunshells[GetFreeGunshell()];
-
- gshell->pos.Position = pos;
- gshell->pos.Orientation.x = 0;
- gshell->pos.Orientation.y = 0;
- gshell->pos.Orientation.z = GetRandomControl();
- gshell->roomNumber = LaraItem->RoomNumber;
- gshell->speed = (GetRandomControl() & 0x1F) + 16;
- gshell->fallspeed = -48 - (GetRandomControl() & 7);
- gshell->objectNumber = objNum;
- gshell->counter = (GetRandomControl() & 0x1F) + 60;
-
- if (hand)
+ if (g_GameFlow->GetSettings()->Weapons[(int)weaponType - 1].Shell)
{
- if (weaponType == LaraWeaponType::Shotgun)
- {
- gshell->dirXrot =
- Lara.LeftArm.Orientation.y +
- Lara.ExtraTorsoRot.y +
- LaraItem->Pose.Orientation.y -
- (GetRandomControl() & 0xFFF) +
- 10240;
- gshell->pos.Orientation.y +=
- Lara.LeftArm.Orientation.y +
- Lara.ExtraTorsoRot.y +
- LaraItem->Pose.Orientation.y;
+ auto& gunshell = Gunshells[GetFreeGunshell()];
- if (gshell->speed < 24)
- gshell->speed += 24;
+ gunshell.pos.Position = pos;
+ gunshell.pos.Orientation.x = 0;
+ gunshell.pos.Orientation.y = 0;
+ gunshell.pos.Orientation.z = GetRandomControl();
+ gunshell.roomNumber = LaraItem->RoomNumber;
+ gunshell.speed = (GetRandomControl() & 0x1F) + 16;
+ gunshell.fallspeed = -48 - (GetRandomControl() & 7);
+ gunshell.objectNumber = objNum;
+ gunshell.counter = (GetRandomControl() & 0x1F) + 60;
+
+ if (hand)
+ {
+ if (weaponType == LaraWeaponType::Shotgun)
+ {
+ gunshell.dirXrot =
+ Lara.LeftArm.Orientation.y +
+ Lara.ExtraTorsoRot.y +
+ LaraItem->Pose.Orientation.y -
+ (GetRandomControl() & 0xFFF) +
+ 10240;
+ gunshell.pos.Orientation.y +=
+ Lara.LeftArm.Orientation.y +
+ Lara.ExtraTorsoRot.y +
+ LaraItem->Pose.Orientation.y;
+
+ if (gunshell.speed < 24)
+ gunshell.speed += 24;
+ }
+ else
+ {
+ gunshell.dirXrot =
+ Lara.LeftArm.Orientation.y +
+ LaraItem->Pose.Orientation.y -
+ (GetRandomControl() & 0xFFF) +
+ 18432;
+ }
}
else
{
- gshell->dirXrot =
+ gunshell.dirXrot =
Lara.LeftArm.Orientation.y +
- LaraItem->Pose.Orientation.y -
- (GetRandomControl() & 0xFFF) +
+ LaraItem->Pose.Orientation.y +
+ (GetRandomControl() & 0xFFF) -
18432;
}
}
- else
- {
- gshell->dirXrot =
- Lara.LeftArm.Orientation.y +
- LaraItem->Pose.Orientation.y +
- (GetRandomControl() & 0xFFF) -
- 18432;
- }
if (LaraItem->MeshBits.TestAny())
{
@@ -986,7 +983,7 @@ void UpdateGunShells()
gunshell->speed -= gunshell->speed >> 1;
}
else
- gunshell->fallspeed += 6;
+ gunshell->fallspeed += g_GameFlow->GetSettings()->Physics.Gravity;
gunshell->pos.Orientation.x += ((gunshell->speed / 2) + 7) * ANGLE(1.0f);
gunshell->pos.Orientation.y += gunshell->speed * ANGLE(1.0f);
diff --git a/TombEngine/Game/effects/tomb4fx.h b/TombEngine/Game/effects/tomb4fx.h
index 8c0d23c28..9d5f822d2 100644
--- a/TombEngine/Game/effects/tomb4fx.h
+++ b/TombEngine/Game/effects/tomb4fx.h
@@ -51,7 +51,6 @@ struct SMOKE_SPARKS
BlendMode blendMode;
byte fxObj;
byte nodeNumber;
- byte mirror;
Vector3i oldPosition;
byte oldShade;
@@ -281,12 +280,6 @@ enum class ShockwaveStyle
#define ENERGY_ARC_CIRCLE 1
#define ENERGY_ARC_NO_RANDOMIZE 1
-extern int LaserSightX;
-extern int LaserSightY;
-extern int LaserSightZ;
-extern char LaserSightActive;
-extern char LaserSightCol;
-
extern int NextFireSpark;
extern int NextSmokeSpark;
extern int NextBlood;
diff --git a/TombEngine/Game/gui.cpp b/TombEngine/Game/gui.cpp
index 807475420..ec338990f 100644
--- a/TombEngine/Game/gui.cpp
+++ b/TombEngine/Game/gui.cpp
@@ -1535,129 +1535,158 @@ namespace TEN::Gui
Ammo.CurrentGrenadeGunAmmoType = 0;
Ammo.CurrentCrossBowAmmoType = 0;
- if (g_GameFlow->GetLevel(CurrentLevel)->GetLaraType() != LaraType::Young)
+ if (player.Weapons[(int)LaraWeaponType::Pistol].Present)
{
- if (player.Weapons[(int)LaraWeaponType::Pistol].Present)
- InsertObjectIntoList(INV_OBJECT_PISTOLS);
- else if (Ammo.AmountPistolsAmmo)
- InsertObjectIntoList(INV_OBJECT_PISTOLS_AMMO);
-
- if (player.Weapons[(int)LaraWeaponType::Uzi].Present)
- InsertObjectIntoList(INV_OBJECT_UZIS);
- else if (Ammo.AmountUziAmmo)
- InsertObjectIntoList(INV_OBJECT_UZI_AMMO);
-
- if (player.Weapons[(int)LaraWeaponType::Revolver].Present)
- {
- if (player.Weapons[(int)LaraWeaponType::Revolver].HasLasersight)
- InsertObjectIntoList(INV_OBJECT_REVOLVER_LASER);
- else
- InsertObjectIntoList(INV_OBJECT_REVOLVER);
- }
- else if (Ammo.AmountRevolverAmmo)
- InsertObjectIntoList(INV_OBJECT_REVOLVER_AMMO);
-
- if (player.Weapons[(int)LaraWeaponType::Shotgun].Present)
- {
- InsertObjectIntoList(INV_OBJECT_SHOTGUN);
-
- if (player.Weapons[(int)LaraWeaponType::Shotgun].SelectedAmmo == WeaponAmmoType::Ammo2)
- Ammo.CurrentShotGunAmmoType = 1;
- }
- else
- {
- if (Ammo.AmountShotGunAmmo1)
- InsertObjectIntoList(INV_OBJECT_SHOTGUN_AMMO_1);
-
- if (Ammo.AmountShotGunAmmo2)
- InsertObjectIntoList(INV_OBJECT_SHOTGUN_AMMO_2);
- }
-
- if (player.Weapons[(int)LaraWeaponType::HK].Present)
- {
- if (player.Weapons[(int)LaraWeaponType::HK].HasLasersight)
- InsertObjectIntoList(INV_OBJECT_HK_LASERSIGHT);
- else
- InsertObjectIntoList(INV_OBJECT_HK);
-
- if (player.Weapons[(int)LaraWeaponType::HK].WeaponMode == LaraWeaponTypeCarried::WTYPE_AMMO_2)
- Ammo.CurrentHKAmmoType = 1;
-
- if (player.Weapons[(int)LaraWeaponType::HK].WeaponMode == LaraWeaponTypeCarried::WTYPE_AMMO_3)
- Ammo.CurrentHKAmmoType = 2;
- }
- else if (Ammo.AmountHKAmmo1)
- InsertObjectIntoList(INV_OBJECT_HK_AMMO);
-
- if (player.Weapons[(int)LaraWeaponType::Crossbow].Present)
- {
- if (player.Weapons[(int)LaraWeaponType::Crossbow].HasLasersight)
- InsertObjectIntoList(INV_OBJECT_CROSSBOW_LASER);
- else
- InsertObjectIntoList(INV_OBJECT_CROSSBOW);
-
- if (player.Weapons[(int)LaraWeaponType::Crossbow].SelectedAmmo == WeaponAmmoType::Ammo2)
- Ammo.CurrentCrossBowAmmoType = 1;
-
- if (player.Weapons[(int)LaraWeaponType::Crossbow].SelectedAmmo == WeaponAmmoType::Ammo3)
- Ammo.CurrentCrossBowAmmoType = 2;
- }
- else
- {
- if (Ammo.AmountCrossBowAmmo1)
- InsertObjectIntoList(INV_OBJECT_CROSSBOW_AMMO_1);
-
- if (Ammo.AmountCrossBowAmmo2)
- InsertObjectIntoList(INV_OBJECT_CROSSBOW_AMMO_2);
-
- if (Ammo.AmountCrossBowAmmo3)
- InsertObjectIntoList(INV_OBJECT_CROSSBOW_AMMO_3);
- }
-
- if (player.Weapons[(int)LaraWeaponType::GrenadeLauncher].Present)
- {
- InsertObjectIntoList(INV_OBJECT_GRENADE_LAUNCHER);
-
- if (player.Weapons[(int)LaraWeaponType::GrenadeLauncher].SelectedAmmo == WeaponAmmoType::Ammo2)
- Ammo.CurrentGrenadeGunAmmoType = 1;
-
- if (player.Weapons[(int)LaraWeaponType::GrenadeLauncher].SelectedAmmo == WeaponAmmoType::Ammo3)
- Ammo.CurrentGrenadeGunAmmoType = 2;
- }
- else
- {
- if (Ammo.AmountGrenadeAmmo1)
- InsertObjectIntoList(INV_OBJECT_GRENADE_AMMO_1);
-
- if (Ammo.AmountGrenadeAmmo2)
- InsertObjectIntoList(INV_OBJECT_GRENADE_AMMO_2);
-
- if (Ammo.AmountGrenadeAmmo3)
- InsertObjectIntoList(INV_OBJECT_GRENADE_AMMO_3);
- }
-
- if (player.Weapons[(int)LaraWeaponType::RocketLauncher].Present)
- InsertObjectIntoList(INV_OBJECT_ROCKET_LAUNCHER);
- else if (Ammo.AmountRocketsAmmo)
- InsertObjectIntoList(INV_OBJECT_ROCKET_AMMO);
-
- if (player.Weapons[(int)LaraWeaponType::HarpoonGun].Present)
- InsertObjectIntoList(INV_OBJECT_HARPOON_GUN);
- else if (Ammo.AmountHarpoonAmmo)
- InsertObjectIntoList(INV_OBJECT_HARPOON_AMMO);
-
- if (player.Inventory.HasLasersight)
- InsertObjectIntoList(INV_OBJECT_LASERSIGHT);
-
- if (player.Inventory.HasSilencer)
- InsertObjectIntoList(INV_OBJECT_SILENCER);
-
- if (player.Inventory.HasBinoculars)
- InsertObjectIntoList(INV_OBJECT_BINOCULARS);
-
- if (player.Inventory.TotalFlares)
- InsertObjectIntoList(INV_OBJECT_FLARES);
+ InsertObjectIntoList(INV_OBJECT_PISTOLS);
}
+ else if (Ammo.AmountPistolsAmmo)
+ {
+ InsertObjectIntoList(INV_OBJECT_PISTOLS_AMMO);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::Uzi].Present)
+ {
+ InsertObjectIntoList(INV_OBJECT_UZIS);
+ }
+ else if (Ammo.AmountUziAmmo)
+ {
+ InsertObjectIntoList(INV_OBJECT_UZI_AMMO);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::Revolver].Present)
+ {
+ if (player.Weapons[(int)LaraWeaponType::Revolver].HasLasersight)
+ {
+ InsertObjectIntoList(INV_OBJECT_REVOLVER_LASER);
+ }
+ else
+ {
+ InsertObjectIntoList(INV_OBJECT_REVOLVER);
+ }
+ }
+ else if (Ammo.AmountRevolverAmmo)
+ {
+ InsertObjectIntoList(INV_OBJECT_REVOLVER_AMMO);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::Shotgun].Present)
+ {
+ InsertObjectIntoList(INV_OBJECT_SHOTGUN);
+
+ if (player.Weapons[(int)LaraWeaponType::Shotgun].SelectedAmmo == WeaponAmmoType::Ammo2)
+ Ammo.CurrentShotGunAmmoType = 1;
+ }
+ else
+ {
+ if (Ammo.AmountShotGunAmmo1)
+ InsertObjectIntoList(INV_OBJECT_SHOTGUN_AMMO_1);
+
+ if (Ammo.AmountShotGunAmmo2)
+ InsertObjectIntoList(INV_OBJECT_SHOTGUN_AMMO_2);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::HK].Present)
+ {
+ if (player.Weapons[(int)LaraWeaponType::HK].HasLasersight)
+ {
+ InsertObjectIntoList(INV_OBJECT_HK_LASERSIGHT);
+ }
+ else
+ {
+ InsertObjectIntoList(INV_OBJECT_HK);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::HK].WeaponMode == LaraWeaponTypeCarried::WTYPE_AMMO_2)
+ Ammo.CurrentHKAmmoType = 1;
+
+ if (player.Weapons[(int)LaraWeaponType::HK].WeaponMode == LaraWeaponTypeCarried::WTYPE_AMMO_3)
+ Ammo.CurrentHKAmmoType = 2;
+ }
+ else if (Ammo.AmountHKAmmo1)
+ {
+ InsertObjectIntoList(INV_OBJECT_HK_AMMO);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::Crossbow].Present)
+ {
+ if (player.Weapons[(int)LaraWeaponType::Crossbow].HasLasersight)
+ {
+ InsertObjectIntoList(INV_OBJECT_CROSSBOW_LASER);
+ }
+ else
+ {
+ InsertObjectIntoList(INV_OBJECT_CROSSBOW);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::Crossbow].SelectedAmmo == WeaponAmmoType::Ammo2)
+ Ammo.CurrentCrossBowAmmoType = 1;
+
+ if (player.Weapons[(int)LaraWeaponType::Crossbow].SelectedAmmo == WeaponAmmoType::Ammo3)
+ Ammo.CurrentCrossBowAmmoType = 2;
+ }
+ else
+ {
+ if (Ammo.AmountCrossBowAmmo1)
+ InsertObjectIntoList(INV_OBJECT_CROSSBOW_AMMO_1);
+
+ if (Ammo.AmountCrossBowAmmo2)
+ InsertObjectIntoList(INV_OBJECT_CROSSBOW_AMMO_2);
+
+ if (Ammo.AmountCrossBowAmmo3)
+ InsertObjectIntoList(INV_OBJECT_CROSSBOW_AMMO_3);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::GrenadeLauncher].Present)
+ {
+ InsertObjectIntoList(INV_OBJECT_GRENADE_LAUNCHER);
+
+ if (player.Weapons[(int)LaraWeaponType::GrenadeLauncher].SelectedAmmo == WeaponAmmoType::Ammo2)
+ Ammo.CurrentGrenadeGunAmmoType = 1;
+
+ if (player.Weapons[(int)LaraWeaponType::GrenadeLauncher].SelectedAmmo == WeaponAmmoType::Ammo3)
+ Ammo.CurrentGrenadeGunAmmoType = 2;
+ }
+ else
+ {
+ if (Ammo.AmountGrenadeAmmo1)
+ InsertObjectIntoList(INV_OBJECT_GRENADE_AMMO_1);
+
+ if (Ammo.AmountGrenadeAmmo2)
+ InsertObjectIntoList(INV_OBJECT_GRENADE_AMMO_2);
+
+ if (Ammo.AmountGrenadeAmmo3)
+ InsertObjectIntoList(INV_OBJECT_GRENADE_AMMO_3);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::RocketLauncher].Present)
+ {
+ InsertObjectIntoList(INV_OBJECT_ROCKET_LAUNCHER);
+ }
+ else if (Ammo.AmountRocketsAmmo)
+ {
+ InsertObjectIntoList(INV_OBJECT_ROCKET_AMMO);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::HarpoonGun].Present)
+ {
+ InsertObjectIntoList(INV_OBJECT_HARPOON_GUN);
+ }
+ else if (Ammo.AmountHarpoonAmmo)
+ {
+ InsertObjectIntoList(INV_OBJECT_HARPOON_AMMO);
+ }
+
+ if (player.Inventory.HasLasersight)
+ InsertObjectIntoList(INV_OBJECT_LASERSIGHT);
+
+ if (player.Inventory.HasSilencer)
+ InsertObjectIntoList(INV_OBJECT_SILENCER);
+
+ if (player.Inventory.HasBinoculars)
+ InsertObjectIntoList(INV_OBJECT_BINOCULARS);
+
+ if (player.Inventory.TotalFlares)
+ InsertObjectIntoList(INV_OBJECT_FLARES);
InsertObjectIntoList(INV_OBJECT_TIMEX);//every level has the timex? what's a good way to check?!
@@ -1764,39 +1793,36 @@ namespace TEN::Gui
for (int i = 0; i < INVENTORY_TABLE_SIZE; i++)
Rings[(int)RingTypes::Ammo].CurrentObjectList[i].InventoryItem = NO_VALUE;
- if (!(g_GameFlow->GetLevel(CurrentLevel)->GetLaraType() == LaraType::Young))
+ if (player.Weapons[(int)LaraWeaponType::Revolver].Present)
{
- if (player.Weapons[(int)LaraWeaponType::Revolver].Present)
- {
- if (player.Weapons[(int)LaraWeaponType::Revolver].HasLasersight)
- InsertObjectIntoList_v2(INV_OBJECT_REVOLVER_LASER);
- else
- InsertObjectIntoList_v2(INV_OBJECT_REVOLVER);
- }
-
- if (player.Weapons[(int)LaraWeaponType::HK].Present)
- {
- if (player.Weapons[(int)LaraWeaponType::HK].HasLasersight)
- InsertObjectIntoList_v2(INV_OBJECT_HK_LASERSIGHT);
- else
- InsertObjectIntoList_v2(INV_OBJECT_HK);
- }
-
- if (player.Weapons[(int)LaraWeaponType::Crossbow].Present)
- {
- if (player.Weapons[(int)LaraWeaponType::Crossbow].HasLasersight)
- InsertObjectIntoList_v2(INV_OBJECT_CROSSBOW_LASER);
- else
- InsertObjectIntoList_v2(INV_OBJECT_CROSSBOW);
- }
-
- if (player.Inventory.HasLasersight)
- InsertObjectIntoList_v2(INV_OBJECT_LASERSIGHT);
-
- if (player.Inventory.HasSilencer)
- InsertObjectIntoList_v2(INV_OBJECT_SILENCER);
+ if (player.Weapons[(int)LaraWeaponType::Revolver].HasLasersight)
+ InsertObjectIntoList_v2(INV_OBJECT_REVOLVER_LASER);
+ else
+ InsertObjectIntoList_v2(INV_OBJECT_REVOLVER);
}
+ if (player.Weapons[(int)LaraWeaponType::HK].Present)
+ {
+ if (player.Weapons[(int)LaraWeaponType::HK].HasLasersight)
+ InsertObjectIntoList_v2(INV_OBJECT_HK_LASERSIGHT);
+ else
+ InsertObjectIntoList_v2(INV_OBJECT_HK);
+ }
+
+ if (player.Weapons[(int)LaraWeaponType::Crossbow].Present)
+ {
+ if (player.Weapons[(int)LaraWeaponType::Crossbow].HasLasersight)
+ InsertObjectIntoList_v2(INV_OBJECT_CROSSBOW_LASER);
+ else
+ InsertObjectIntoList_v2(INV_OBJECT_CROSSBOW);
+ }
+
+ if (player.Inventory.HasLasersight)
+ InsertObjectIntoList_v2(INV_OBJECT_LASERSIGHT);
+
+ if (player.Inventory.HasSilencer)
+ InsertObjectIntoList_v2(INV_OBJECT_SILENCER);
+
if (player.Inventory.BeetleComponents)
{
if (player.Inventory.BeetleComponents & 2)
@@ -3277,7 +3303,8 @@ namespace TEN::Gui
while (g_Synchronizer.Synced())
{
TimeInMenu++;
- GameTimer++;
+ SaveGame::Statistics.Game.TimeTaken++;
+ SaveGame::Statistics.Level.TimeTaken++;
UpdateInputActions(item);
@@ -3423,7 +3450,7 @@ namespace TEN::Gui
auto needleOrient = EulerAngles(0, CompassNeedleAngle, 0);
needleOrient.Lerp(EulerAngles(0, item->Pose.Orientation.y, 0), LERP_ALPHA);
- float wibble = std::sin((float(GameTimer & 0x3F) / (float)0x3F) * PI_MUL_2);
+ float wibble = std::sin((float(GlobalCounter & 0x3F) / (float)0x3F) * PI_MUL_2);
CompassNeedleAngle = needleOrient.y + ANGLE(wibble / 2);
// HACK: Needle is rotated in the draw function.
diff --git a/TombEngine/Game/items.cpp b/TombEngine/Game/items.cpp
index 75bdbed15..b761a01ae 100644
--- a/TombEngine/Game/items.cpp
+++ b/TombEngine/Game/items.cpp
@@ -829,7 +829,7 @@ bool UpdateItemRoom(short itemNumber)
return false;
}
-void DoDamage(ItemInfo* item, int damage)
+void DoDamage(ItemInfo* item, int damage, bool silent)
{
static int lastHurtTime = 0;
@@ -837,20 +837,34 @@ void DoDamage(ItemInfo* item, int damage)
return;
item->HitStatus = true;
-
item->HitPoints -= damage;
- if (item->HitPoints < 0)
+
+ if (item->HitPoints <= 0)
+ {
item->HitPoints = 0;
+ if (!item->IsLara())
+ {
+ SaveGame::Statistics.Level.Kills++;
+ SaveGame::Statistics.Game.Kills++;
+ }
+ }
+
if (item->IsLara())
{
if (damage > 0)
{
- float power = item->HitPoints ? Random::GenerateFloat(0.1f, 0.4f) : 0.5f;
- Rumble(power, 0.15f);
+ if (!silent)
+ {
+ float power = item->HitPoints ? Random::GenerateFloat(0.1f, 0.4f) : 0.5f;
+ Rumble(power, 0.15f);
+ }
+
+ SaveGame::Statistics.Game.DamageTaken += damage;
+ SaveGame::Statistics.Level.DamageTaken += damage;
}
- if ((GlobalCounter - lastHurtTime) > (FPS * 2 + Random::GenerateInt(0, FPS)))
+ if (!silent && (GlobalCounter - lastHurtTime) > (FPS * 2 + Random::GenerateInt(0, FPS)))
{
SoundEffect(SFX_TR4_LARA_INJURY, &LaraItem->Pose);
lastHurtTime = GlobalCounter;
@@ -867,6 +881,7 @@ void DoItemHit(ItemInfo* target, int damage, bool isExplosive, bool allowBurn)
{
if (target->HitPoints > 0)
{
+ SaveGame::Statistics.Game.AmmoHits++;
SaveGame::Statistics.Level.AmmoHits++;
DoDamage(target, damage);
}
diff --git a/TombEngine/Game/items.h b/TombEngine/Game/items.h
index 5d209259b..c4b4f0812 100644
--- a/TombEngine/Game/items.h
+++ b/TombEngine/Game/items.h
@@ -205,7 +205,7 @@ std::vector FindAllItems(GAME_OBJECT_ID objectID);
std::vector FindCreatedItems(GAME_OBJECT_ID objectID);
ItemInfo* FindItem(GAME_OBJECT_ID objectID);
int FindItem(ItemInfo* item);
-void DoDamage(ItemInfo* item, int damage);
+void DoDamage(ItemInfo* item, int damage, bool silent = false);
void DoItemHit(ItemInfo* target, int damage, bool isExplosive, bool allowBurn = true);
void DefaultItemHit(ItemInfo& target, ItemInfo& source, std::optional pos, int damage, bool isExplosive, int jointIndex);
short SpawnItem(const ItemInfo& item, GAME_OBJECT_ID objectID);
diff --git a/TombEngine/Game/pickup/pickup.cpp b/TombEngine/Game/pickup/pickup.cpp
index b81a1f4d0..f9e5cf5c2 100644
--- a/TombEngine/Game/pickup/pickup.cpp
+++ b/TombEngine/Game/pickup/pickup.cpp
@@ -963,7 +963,7 @@ void PickupControl(short itemNumber)
switch (triggerFlags)
{
case 5:
- item->Animation.Velocity.y += 6.0f;
+ item->Animation.Velocity.y += g_GameFlow->GetSettings()->Physics.Gravity;
item->Pose.Position.y += item->Animation.Velocity.y;
roomNumber = item->RoomNumber;
diff --git a/TombEngine/Game/pickup/pickup_ammo.cpp b/TombEngine/Game/pickup/pickup_ammo.cpp
index bd6d957da..9f9cfd8e4 100644
--- a/TombEngine/Game/pickup/pickup_ammo.cpp
+++ b/TombEngine/Game/pickup/pickup_ammo.cpp
@@ -1,8 +1,6 @@
#include "framework.h"
#include "Game/pickup/pickup_ammo.h"
-#include
-
#include "Game/Lara/lara_struct.h"
#include "Game/pickup/pickuputil.h"
#include "Objects/objectslist.h"
@@ -15,33 +13,39 @@ struct AmmoPickupInfo
int Amount;
};
-static constexpr std::array kAmmo
+static std::array Ammo
{
{
- { ID_PISTOLS_AMMO_ITEM, LaraWeaponType::Pistol, WeaponAmmoType::Ammo1, 30 },
- { ID_UZI_AMMO_ITEM, LaraWeaponType::Uzi, WeaponAmmoType::Ammo1, 30 },
- { ID_SHOTGUN_AMMO1_ITEM, LaraWeaponType::Shotgun, WeaponAmmoType::Ammo1, 6 },
- { ID_SHOTGUN_AMMO2_ITEM, LaraWeaponType::Shotgun, WeaponAmmoType::Ammo2, 6 },
- { ID_CROSSBOW_AMMO1_ITEM, LaraWeaponType::Crossbow, WeaponAmmoType::Ammo1, 10 },
- { ID_CROSSBOW_AMMO2_ITEM, LaraWeaponType::Crossbow, WeaponAmmoType::Ammo2, 10 },
- { ID_CROSSBOW_AMMO3_ITEM, LaraWeaponType::Crossbow, WeaponAmmoType::Ammo3, 10 },
- { ID_REVOLVER_AMMO_ITEM, LaraWeaponType::Revolver, WeaponAmmoType::Ammo1, 6 },
- { ID_HK_AMMO_ITEM, LaraWeaponType::HK, WeaponAmmoType::Ammo1, 30 },
- { ID_GRENADE_AMMO1_ITEM, LaraWeaponType::GrenadeLauncher, WeaponAmmoType::Ammo1, 10 },
- { ID_GRENADE_AMMO2_ITEM, LaraWeaponType::GrenadeLauncher, WeaponAmmoType::Ammo2, 10 },
- { ID_GRENADE_AMMO3_ITEM, LaraWeaponType::GrenadeLauncher, WeaponAmmoType::Ammo3, 10 },
- { ID_ROCKET_LAUNCHER_AMMO_ITEM, LaraWeaponType::RocketLauncher, WeaponAmmoType::Ammo1, 1 },
- { ID_HARPOON_AMMO_ITEM, LaraWeaponType::HarpoonGun, WeaponAmmoType::Ammo1, 10 }
+ AmmoPickupInfo{ ID_PISTOLS_AMMO_ITEM, LaraWeaponType::Pistol, WeaponAmmoType::Ammo1, 30 },
+ AmmoPickupInfo{ ID_UZI_AMMO_ITEM, LaraWeaponType::Uzi, WeaponAmmoType::Ammo1, 30 },
+ AmmoPickupInfo{ ID_SHOTGUN_AMMO1_ITEM, LaraWeaponType::Shotgun, WeaponAmmoType::Ammo1, 6 },
+ AmmoPickupInfo{ ID_SHOTGUN_AMMO2_ITEM, LaraWeaponType::Shotgun, WeaponAmmoType::Ammo2, 6 },
+ AmmoPickupInfo{ ID_CROSSBOW_AMMO1_ITEM, LaraWeaponType::Crossbow, WeaponAmmoType::Ammo1, 10 },
+ AmmoPickupInfo{ ID_CROSSBOW_AMMO2_ITEM, LaraWeaponType::Crossbow, WeaponAmmoType::Ammo2, 10 },
+ AmmoPickupInfo{ ID_CROSSBOW_AMMO3_ITEM, LaraWeaponType::Crossbow, WeaponAmmoType::Ammo3, 10 },
+ AmmoPickupInfo{ ID_REVOLVER_AMMO_ITEM, LaraWeaponType::Revolver, WeaponAmmoType::Ammo1, 6 },
+ AmmoPickupInfo{ ID_HK_AMMO_ITEM, LaraWeaponType::HK, WeaponAmmoType::Ammo1, 30 },
+ AmmoPickupInfo{ ID_GRENADE_AMMO1_ITEM, LaraWeaponType::GrenadeLauncher, WeaponAmmoType::Ammo1, 10 },
+ AmmoPickupInfo{ ID_GRENADE_AMMO2_ITEM, LaraWeaponType::GrenadeLauncher, WeaponAmmoType::Ammo2, 10 },
+ AmmoPickupInfo{ ID_GRENADE_AMMO3_ITEM, LaraWeaponType::GrenadeLauncher, WeaponAmmoType::Ammo3, 10 },
+ AmmoPickupInfo{ ID_ROCKET_LAUNCHER_AMMO_ITEM, LaraWeaponType::RocketLauncher, WeaponAmmoType::Ammo1, 1 },
+ AmmoPickupInfo{ ID_HARPOON_AMMO_ITEM, LaraWeaponType::HarpoonGun, WeaponAmmoType::Ammo1, 10 }
}
};
+void InitializeAmmo(const Settings& settings)
+{
+ for (auto& entry : Ammo)
+ entry.Amount = settings.Weapons[(int)entry.LaraWeaponType - 1].PickupCount;
+}
+
bool TryModifyingAmmo(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional amount, ModificationType modType)
{
- int arrayPos = GetArraySlot(kAmmo, objectID);
+ int arrayPos = GetArraySlot(Ammo, objectID);
if (arrayPos == NO_VALUE)
return false;
- auto ammoPickup = kAmmo[arrayPos];
+ const auto& ammoPickup = Ammo[arrayPos];
auto& currentWeapon = lara.Weapons[(int)ammoPickup.LaraWeaponType];
auto& currentAmmo = currentWeapon.Ammo[(int)ammoPickup.AmmoType];
@@ -75,21 +79,25 @@ bool TryAddingAmmo(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional a
bool TryRemovingAmmo(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional amount)
{
if (amount.has_value())
+ {
return TryModifyingAmmo(lara, objectID, -amount.value(), ModificationType::Remove);
+ }
else
+ {
return TryModifyingAmmo(lara, objectID, amount, ModificationType::Remove);
+ }
}
std::optional GetAmmoCount(LaraInfo& lara, GAME_OBJECT_ID objectID)
{
- int arrayPos = GetArraySlot(kAmmo, objectID);
+ int arrayPos = GetArraySlot(Ammo, objectID);
if (arrayPos == NO_VALUE)
return std::nullopt;
- AmmoPickupInfo info = kAmmo[arrayPos];
+ const auto& ammo = Ammo[arrayPos];
- if (!lara.Weapons[(int)info.LaraWeaponType].Ammo[(int)info.AmmoType].HasInfinite())
- return lara.Weapons[(int)info.LaraWeaponType].Ammo[(int)info.AmmoType].GetCount();
+ if (!lara.Weapons[(int)ammo.LaraWeaponType].Ammo[(int)ammo.AmmoType].HasInfinite())
+ return lara.Weapons[(int)ammo.LaraWeaponType].Ammo[(int)ammo.AmmoType].GetCount();
// NO_VALUE signifies infinite ammo.
return NO_VALUE;
@@ -97,9 +105,9 @@ std::optional GetAmmoCount(LaraInfo& lara, GAME_OBJECT_ID objectID)
int GetDefaultAmmoCount(GAME_OBJECT_ID objectID)
{
- int arrayPos = GetArraySlot(kAmmo, objectID);
+ int arrayPos = GetArraySlot(Ammo, objectID);
if (arrayPos == NO_VALUE)
return NO_VALUE;
- return kAmmo[arrayPos].Amount;
+ return Ammo[arrayPos].Amount;
}
diff --git a/TombEngine/Game/pickup/pickup_ammo.h b/TombEngine/Game/pickup/pickup_ammo.h
index 3d7565c7f..8479b7746 100644
--- a/TombEngine/Game/pickup/pickup_ammo.h
+++ b/TombEngine/Game/pickup/pickup_ammo.h
@@ -1,9 +1,12 @@
#pragma once
+#include "Scripting/Internal/TEN/Flow/Settings/Settings.h"
+
enum class ModificationType;
enum GAME_OBJECT_ID : short;
struct LaraInfo;
+void InitializeAmmo(const Settings& settings);
bool TryAddingAmmo(LaraInfo&, GAME_OBJECT_ID objectID, std::optional amount = std::nullopt);
bool TryRemovingAmmo(LaraInfo&, GAME_OBJECT_ID objectID, std::optional amount = std::nullopt);
bool TryModifyingAmmo(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional amount, ModificationType modType);
diff --git a/TombEngine/Game/pickup/pickup_consumable.cpp b/TombEngine/Game/pickup/pickup_consumable.cpp
index 0bdeccc35..a91aa082d 100644
--- a/TombEngine/Game/pickup/pickup_consumable.cpp
+++ b/TombEngine/Game/pickup/pickup_consumable.cpp
@@ -17,36 +17,41 @@ struct ConsumablePickupInfo
int Amount;
};
-static constexpr std::array kConsumables =
+static std::array Consumables =
{
{
- { ID_SMALLMEDI_ITEM, &PlayerInventoryData::TotalSmallMedipacks, 1 },
- { ID_BIGMEDI_ITEM, &PlayerInventoryData::TotalLargeMedipacks, 1 },
- { ID_FLARE_INV_ITEM, &PlayerInventoryData::TotalFlares, 12 },
- { ID_FLARE_ITEM, &PlayerInventoryData::TotalFlares, 1 }
+ ConsumablePickupInfo{ ID_SMALLMEDI_ITEM, &PlayerInventoryData::TotalSmallMedipacks, 1 },
+ ConsumablePickupInfo{ ID_BIGMEDI_ITEM, &PlayerInventoryData::TotalLargeMedipacks, 1 },
+ ConsumablePickupInfo{ ID_FLARE_INV_ITEM, &PlayerInventoryData::TotalFlares, 12 },
+ ConsumablePickupInfo{ ID_FLARE_ITEM, &PlayerInventoryData::TotalFlares, 1 }
}
};
+void InitializeConsumables(const Settings& settings)
+{
+ Consumables[GetArraySlot(Consumables, GAME_OBJECT_ID::ID_FLARE_INV_ITEM)].Amount = settings.Flare.PickupCount;
+}
+
bool TryModifyingConsumable(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional amount, ModificationType modType)
{
- int arrayPos = GetArraySlot(kConsumables, objectID);
+ int arrayPos = GetArraySlot(Consumables, objectID);
if (arrayPos == NO_VALUE)
return false;
- ConsumablePickupInfo info = kConsumables[arrayPos];
- auto & currentAmt = lara.Inventory.*(info.Count);
+ const auto& consumable = Consumables[arrayPos];
+ auto& currentAmount = lara.Inventory.*(consumable.Count);
switch (modType)
{
case ModificationType::Set:
- currentAmt = amount.value();
+ currentAmount = amount.value();
break;
default:
- if (currentAmt != NO_VALUE)
+ if (currentAmount != NO_VALUE)
{
- int defaultModify = ModificationType::Add == modType ? info.Amount : -info.Amount;
- int newVal = currentAmt + (amount.has_value() ? amount.value() : defaultModify);
- currentAmt = std::max(0, newVal);
+ int defaultModify = ModificationType::Add == modType ? consumable.Amount : -consumable.Amount;
+ int newVal = currentAmount + (amount.has_value() ? amount.value() : defaultModify);
+ currentAmount = std::max(0, newVal);
}
break;
}
@@ -62,27 +67,31 @@ bool TryAddingConsumable(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional<
bool TryRemovingConsumable(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional amount)
{
if (amount.has_value())
+ {
return TryModifyingConsumable(lara, objectID, -amount.value(), ModificationType::Remove);
+ }
else
+ {
return TryModifyingConsumable(lara, objectID, amount, ModificationType::Remove);
+ }
}
std::optional GetConsumableCount(LaraInfo& lara, GAME_OBJECT_ID objectID)
{
- int arrayPos = GetArraySlot(kConsumables, objectID);
+ int arrayPos = GetArraySlot(Consumables, objectID);
if (arrayPos == NO_VALUE)
return std::nullopt;
- ConsumablePickupInfo info = kConsumables[arrayPos];
+ const auto& consumable = Consumables[arrayPos];
- return lara.Inventory.*(info.Count);
+ return lara.Inventory.*(consumable.Count);
}
int GetDefaultConsumableCount(GAME_OBJECT_ID objectID)
{
- int arrayPos = GetArraySlot(kConsumables, objectID);
+ int arrayPos = GetArraySlot(Consumables, objectID);
if (arrayPos == NO_VALUE)
return NO_VALUE;
- return kConsumables[arrayPos].Amount;
+ return Consumables[arrayPos].Amount;
}
diff --git a/TombEngine/Game/pickup/pickup_consumable.h b/TombEngine/Game/pickup/pickup_consumable.h
index 97bf83434..40796ce07 100644
--- a/TombEngine/Game/pickup/pickup_consumable.h
+++ b/TombEngine/Game/pickup/pickup_consumable.h
@@ -1,9 +1,12 @@
#pragma once
+#include "Scripting/Internal/TEN/Flow/Settings/Settings.h"
+
enum class ModificationType;
enum GAME_OBJECT_ID : short;
struct LaraInfo;
+void InitializeConsumables(const Settings& settings);
bool TryAddingConsumable(LaraInfo&, GAME_OBJECT_ID objectID, std::optional amount = 0);
bool TryRemovingConsumable(LaraInfo&, GAME_OBJECT_ID objectID, std::optional amount = 0);
bool TryModifyingConsumable(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional amount, ModificationType modType);
diff --git a/TombEngine/Game/savegame.cpp b/TombEngine/Game/savegame.cpp
index 5d3d899cd..00153c3e0 100644
--- a/TombEngine/Game/savegame.cpp
+++ b/TombEngine/Game/savegame.cpp
@@ -262,14 +262,13 @@ const std::vector SaveGame::Build()
sghb.add_level_name(levelNameOffset);
sghb.add_level_hash(LastLevelHash);
- auto gameTime = GetGameTime(GameTimer);
- sghb.add_days(gameTime.Days);
- sghb.add_hours(gameTime.Hours);
- sghb.add_minutes(gameTime.Minutes);
- sghb.add_seconds(gameTime.Seconds);
+ const auto& gameTime = SaveGame::Statistics.Game.TimeTaken;
+ sghb.add_hours(gameTime.GetHours());
+ sghb.add_minutes(gameTime.GetMinutes());
+ sghb.add_seconds(gameTime.GetSeconds());
sghb.add_level(CurrentLevel);
- sghb.add_timer(GameTimer);
+ sghb.add_timer(GlobalCounter);
sghb.add_count(++LastSaveGame);
auto headerOffset = sghb.Finish();
@@ -278,9 +277,10 @@ const std::vector SaveGame::Build()
sgLevelStatisticsBuilder.add_ammo_used(Statistics.Level.AmmoUsed);
sgLevelStatisticsBuilder.add_kills(Statistics.Level.Kills);
sgLevelStatisticsBuilder.add_medipacks_used(Statistics.Level.HealthUsed);
+ sgLevelStatisticsBuilder.add_damage_taken(Statistics.Level.DamageTaken);
sgLevelStatisticsBuilder.add_distance(Statistics.Level.Distance);
sgLevelStatisticsBuilder.add_secrets(Statistics.Level.Secrets);
- sgLevelStatisticsBuilder.add_timer(Statistics.Level.Timer);
+ sgLevelStatisticsBuilder.add_timer(SaveGame::Statistics.Level.TimeTaken);
auto levelStatisticsOffset = sgLevelStatisticsBuilder.Finish();
Save::SaveGameStatisticsBuilder sgGameStatisticsBuilder{ fbb };
@@ -288,9 +288,10 @@ const std::vector SaveGame::Build()
sgGameStatisticsBuilder.add_ammo_used(Statistics.Game.AmmoUsed);
sgGameStatisticsBuilder.add_kills(Statistics.Game.Kills);
sgGameStatisticsBuilder.add_medipacks_used(Statistics.Game.HealthUsed);
+ sgGameStatisticsBuilder.add_damage_taken(Statistics.Game.DamageTaken);
sgGameStatisticsBuilder.add_distance(Statistics.Game.Distance);
sgGameStatisticsBuilder.add_secrets(Statistics.Game.Secrets);
- sgGameStatisticsBuilder.add_timer(Statistics.Game.Timer);
+ sgGameStatisticsBuilder.add_timer(SaveGame::Statistics.Game.TimeTaken);
auto gameStatisticsOffset = sgGameStatisticsBuilder.Finish();
// Lara
@@ -1388,6 +1389,16 @@ const std::vector SaveGame::Build()
break;
}
+ case SavedVarType::Time:
+ {
+ Save::timeTableBuilder ttb{ fbb };
+ ttb.add_scalar(std::get(s));
+ auto timeOffset = ttb.Finish();
+
+ putDataInVec(Save::VarUnion::time, timeOffset);
+ break;
+ }
+
case SavedVarType::Color:
{
Save::colorTableBuilder ctb{ fbb };
@@ -1463,6 +1474,7 @@ const std::vector SaveGame::Build()
sgb.add_header(headerOffset);
sgb.add_level(levelStatisticsOffset);
sgb.add_game(gameStatisticsOffset);
+ sgb.add_secret_map(SaveGame::Statistics.SecretBits);
sgb.add_camera(cameraOffset);
sgb.add_lara(laraOffset);
sgb.add_rooms(roomOffset);
@@ -1688,27 +1700,29 @@ bool SaveGame::Load(int slot)
static void ParseStatistics(const Save::SaveGame* s, bool isHub)
{
+ SaveGame::Statistics.SecretBits = s->secret_map();
+
SaveGame::Statistics.Level.AmmoHits = s->level()->ammo_hits();
SaveGame::Statistics.Level.AmmoUsed = s->level()->ammo_used();
SaveGame::Statistics.Level.Distance = s->level()->distance();
SaveGame::Statistics.Level.HealthUsed = s->level()->medipacks_used();
+ SaveGame::Statistics.Level.DamageTaken = s->level()->damage_taken();
SaveGame::Statistics.Level.Kills = s->level()->kills();
SaveGame::Statistics.Level.Secrets = s->level()->secrets();
- SaveGame::Statistics.Level.Timer = s->level()->timer();
+ SaveGame::Statistics.Level.TimeTaken = s->level()->timer();
// Don't touch game statistics if data is parsed in hub mode.
if (isHub)
return;
- GameTimer = s->header()->timer();
-
SaveGame::Statistics.Game.AmmoHits = s->game()->ammo_hits();
SaveGame::Statistics.Game.AmmoUsed = s->game()->ammo_used();
SaveGame::Statistics.Game.Distance = s->game()->distance();
SaveGame::Statistics.Game.HealthUsed = s->game()->medipacks_used();
+ SaveGame::Statistics.Game.DamageTaken = s->game()->damage_taken();
SaveGame::Statistics.Game.Kills = s->game()->kills();
SaveGame::Statistics.Game.Secrets = s->game()->secrets();
- SaveGame::Statistics.Game.Timer = s->game()->timer();
+ SaveGame::Statistics.Game.TimeTaken = s->game()->timer();
}
static void ParseLua(const Save::SaveGame* s, bool hubMode)
@@ -1801,6 +1815,15 @@ static void ParseLua(const Save::SaveGame* s, bool hubMode)
break;
}
+ case Save::VarUnion::time:
+ {
+ auto stored = var->u_as_time()->scalar();
+ SavedVar var;
+ var.emplace<(int)SavedVarType::Time>(stored);
+ loadedVars.push_back(var);
+ break;
+ }
+
case Save::VarUnion::color:
loadedVars.push_back((D3DCOLOR)var->u_as_color()->color());
break;
@@ -2737,7 +2760,6 @@ bool SaveGame::LoadHeader(int slot, SaveGameHeader* header)
header->Level = s->header()->level();
header->LevelName = s->header()->level_name()->str();
header->LevelHash = s->header()->level_hash();
- header->Days = s->header()->days();
header->Hours = s->header()->hours();
header->Minutes = s->header()->minutes();
header->Seconds = s->header()->seconds();
diff --git a/TombEngine/Game/savegame.h b/TombEngine/Game/savegame.h
index 067391a93..7f8363f57 100644
--- a/TombEngine/Game/savegame.h
+++ b/TombEngine/Game/savegame.h
@@ -6,31 +6,25 @@
#include "Specific/IO/ChunkWriter.h"
#include "Specific/IO/LEB128.h"
#include "Specific/IO/Streams.h"
+#include "Scripting/Internal/TEN/Types/Time/Time.h"
+#include "Scripting/Internal/TEN/Flow/Statistics/Statistics.h"
+
+using namespace TEN::Scripting;
constexpr auto SAVEGAME_MAX = 16;
-struct Stats
-{
- unsigned int Timer = 0;
- unsigned int Distance = 0;
- unsigned int AmmoHits = 0;
- unsigned int AmmoUsed = 0;
- unsigned int HealthUsed = 0;
- unsigned int Kills = 0;
- unsigned int Secrets = 0;
-};
-
struct GameStats
{
- Stats Game = {};
- Stats Level = {};
+ unsigned int SecretBits = 0;
+
+ Statistics Game = {};
+ Statistics Level = {};
};
struct SaveGameHeader
{
std::string LevelName = {};
int LevelHash = 0;
- int Days = 0;
int Hours = 0;
int Minutes = 0;
int Seconds = 0;
diff --git a/TombEngine/Objects/Effects/LensFlare.cpp b/TombEngine/Objects/Effects/LensFlare.cpp
index a159d41ea..075104459 100644
--- a/TombEngine/Objects/Effects/LensFlare.cpp
+++ b/TombEngine/Objects/Effects/LensFlare.cpp
@@ -45,7 +45,7 @@ namespace TEN::Entities::Effects
}
}
- static void SetupLensFlare(const Vector3& pos, int roomNumber, const Color& color, float& intensity, int spriteID)
+ void SetupLensFlare(const Vector3& pos, int roomNumber, const Color& color, float* intensity, int spriteID)
{
auto cameraPos = Camera.pos.ToVector3();
auto cameraTarget = Camera.target.ToVector3();
@@ -118,16 +118,19 @@ namespace TEN::Entities::Effects
isVisible = false;
}
+ float inputIntensity = (intensity != nullptr) ? *intensity : 1.0f;
+
// Fade in/out lensflares depending on their visibility.
- UpdateLensFlareIntensity(isVisible, intensity);
+ if (intensity != nullptr)
+ UpdateLensFlareIntensity(isVisible, inputIntensity);
// Lensflare is completely invisible.
- if (!isVisible && intensity == 0.0f)
+ if (!isVisible && inputIntensity == 0.0f)
return;
// Generate slight shimmer.
float shimmer = Random::GenerateFloat(-SHIMMER_STRENGTH, SHIMMER_STRENGTH);
- float finalIntensity = std::clamp(Smoothstep(intensity) + shimmer * intensity, 0.0f, MAX_INTENSITY);
+ float finalIntensity = std::clamp(Smoothstep(inputIntensity) + shimmer * inputIntensity, 0.0f, MAX_INTENSITY);
auto lensFlare = LensFlare{};
lensFlare.Position = pos;
@@ -137,6 +140,9 @@ namespace TEN::Entities::Effects
lensFlare.SpriteID = spriteID;
LensFlares.push_back(lensFlare);
+
+ if (intensity != nullptr)
+ *intensity = inputIntensity;
}
void UpdateGlobalLensFlare()
@@ -154,7 +160,7 @@ namespace TEN::Entities::Effects
auto rotMatrix = orient.ToRotationMatrix();
pos += Vector3::Transform(BASE_POS, rotMatrix);
- SetupLensFlare(pos, NO_VALUE, color, GlobalLensFlareIntensity, spriteID);
+ SetupLensFlare(pos, NO_VALUE, color, &GlobalLensFlareIntensity, spriteID);
}
void ControlLensFlare(int itemNumber)
@@ -182,9 +188,9 @@ namespace TEN::Entities::Effects
}
// Intensity value can be modified inside lensflare setup function.
- float currentIntensity = (float)item.ItemFlags[0] / 100.0f;
- SetupLensFlare(item.Pose.Position.ToVector3(), item.RoomNumber, color, currentIntensity, SPRITE_TYPES::SPR_LENS_FLARE_3);
- item.ItemFlags[0] = (short)(currentIntensity * 100.0f);
+ float currentIntensity = (float)item.ItemFlags[0] / LENSFLARE_ITEMFLAG_BRIGHTNESS_SCALE;
+ SetupLensFlare(item.Pose.Position.ToVector3(), item.RoomNumber, color, ¤tIntensity, SPRITE_TYPES::SPR_LENS_FLARE_3);
+ item.ItemFlags[0] = short(currentIntensity * LENSFLARE_ITEMFLAG_BRIGHTNESS_SCALE);
}
void ClearLensFlares()
diff --git a/TombEngine/Objects/Effects/LensFlare.h b/TombEngine/Objects/Effects/LensFlare.h
index 0f384591f..d090450a7 100644
--- a/TombEngine/Objects/Effects/LensFlare.h
+++ b/TombEngine/Objects/Effects/LensFlare.h
@@ -4,6 +4,8 @@ class EulerAngles;
namespace TEN::Entities::Effects
{
+ constexpr auto LENSFLARE_ITEMFLAG_BRIGHTNESS_SCALE = 100.0f;
+
struct LensFlare
{
int SpriteID = 0;
@@ -17,6 +19,7 @@ namespace TEN::Entities::Effects
extern std::vector LensFlares;
+ void SetupLensFlare(const Vector3& pos, int roomNumber, const Color& color, float* intensity, int spriteID);
void ControlLensFlare(int itemNumber);
void ClearLensFlares();
void UpdateGlobalLensFlare();
diff --git a/TombEngine/Objects/Generic/Object/Pushable/PushableEffects.cpp b/TombEngine/Objects/Generic/Object/Pushable/PushableEffects.cpp
index c9016f0db..354ba5004 100644
--- a/TombEngine/Objects/Generic/Object/Pushable/PushableEffects.cpp
+++ b/TombEngine/Objects/Generic/Object/Pushable/PushableEffects.cpp
@@ -23,14 +23,14 @@ namespace TEN::Entities::Generic
// TODO: Enhace the effect to make the ripples increase their size through the time.
if (pushable.WaterSurfaceHeight != NO_HEIGHT)
{
- if (fmod(GameTimer, FRAMES_BETWEEN_RIPPLES) <= 0.0f)
+ if (fmod(GlobalCounter, FRAMES_BETWEEN_RIPPLES) <= 0.0f)
SpawnRipple(
Vector3(pushableItem.Pose.Position.x, pushable.WaterSurfaceHeight, pushableItem.Pose.Position.z),
pushableItem.RoomNumber,
GameBoundingBox(&pushableItem).GetWidth() + (GetRandomControl() & 15),
(int)RippleFlags::SlowFade | (int)RippleFlags::LowOpacity);
- if (fmod(GameTimer, FRAMES_BETWEEN_RIPPLES_SOUNDS) <= 0.0f)
+ if (fmod(GlobalCounter, FRAMES_BETWEEN_RIPPLES_SOUNDS) <= 0.0f)
pushable.SoundState = PushableSoundState::Wade;
}
}
@@ -52,7 +52,7 @@ namespace TEN::Entities::Generic
{
constexpr auto FRAMES_BETWEEN_BUBBLES = 8.0f;
- if (fmod(GameTimer, FRAMES_BETWEEN_BUBBLES) <= 0.0f)
+ if (fmod(GlobalCounter, FRAMES_BETWEEN_BUBBLES) <= 0.0f)
{
for (int i = 0; i < 32; i++)
{
@@ -71,7 +71,7 @@ namespace TEN::Entities::Generic
const auto& pushable = GetPushableInfo(pushableItem);
- auto time = GameTimer + pushableItem.Animation.Velocity.y;
+ auto time = GlobalCounter + pushableItem.Animation.Velocity.y;
// Calculate bounding box volume scaling factor.
auto bounds = GameBoundingBox(&pushableItem);
@@ -92,7 +92,7 @@ namespace TEN::Entities::Generic
constexpr auto BOX_VOLUME_MIN = BLOCK(0.5f);
const auto& pushable = GetPushableInfo(pushableItem);
- auto time = GameTimer + pushableItem.Animation.Velocity.y;
+ auto time = GlobalCounter + pushableItem.Animation.Velocity.y;
// Calculate bounding box volume scaling factor.
auto bounds = GameBoundingBox(&pushableItem);
diff --git a/TombEngine/Objects/Generic/Object/burning_torch.cpp b/TombEngine/Objects/Generic/Object/burning_torch.cpp
index 4c1da0297..f12876454 100644
--- a/TombEngine/Objects/Generic/Object/burning_torch.cpp
+++ b/TombEngine/Objects/Generic/Object/burning_torch.cpp
@@ -14,6 +14,7 @@
#include "Objects/Effects/flame_emitters.h"
#include "Renderer/RendererEnums.h"
#include "Sound/sound.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/Input/Input.h"
#include "Specific/level.h"
@@ -70,7 +71,7 @@ namespace TEN::Entities::Generic
spark->size = Random::GenerateFloat(64, 150);
spark->dSize = spark->size / 8;
- int spriteOffset = GameTimer % Objects[ID_FIRE_SPRITES].nmeshes;
+ int spriteOffset = GlobalCounter % Objects[ID_FIRE_SPRITES].nmeshes;
spark->spriteIndex = Objects[ID_FIRE_SPRITES].meshIndex + spriteOffset;
}
@@ -250,7 +251,7 @@ namespace TEN::Entities::Generic
}
else
{
- item->Animation.Velocity.y += 6;
+ item->Animation.Velocity.y += g_GameFlow->GetSettings()->Physics.Gravity;
}
item->Pose.Position.y += item->Animation.Velocity.y;
@@ -295,12 +296,14 @@ namespace TEN::Entities::Generic
}
}
- void LaraTorch(Vector3i* origin, Vector3i* target, int rot, int color)
+ void LaraTorch(Vector3i* origin, Vector3i* target)
{
auto pos1 = GameVector(*origin, LaraItem->RoomNumber);
auto pos2 = GameVector(*target);
- TriggerDynamicLight(pos1.x, pos1.y, pos1.z, 12, color, color, color >> 1);
+ const auto& color = g_GameFlow->GetSettings()->Camera.BinocularLightColor;
+
+ TriggerDynamicLight(pos1.x, pos1.y, pos1.z, 12, color.GetR(), color.GetG(), color.GetB());
if (!LOS(&pos1, &pos2))
{
@@ -309,8 +312,14 @@ namespace TEN::Entities::Generic
if (l + 8 > 31)
l = 31;
- if (color - l >= 0)
- TriggerDynamicLight(pos2.x, pos2.y, pos2.z, l + 8, color - l, color - l, (color - l) * 2);
+ auto dir = pos1.ToVector3() - pos2.ToVector3();
+ dir.Normalize();
+ dir *= BLOCK(1);
+
+ byte r = std::max(0, color.GetR() - l);
+ byte g = std::max(0, color.GetG() - l);
+ byte b = std::max(0, color.GetB() - l);
+ TriggerDynamicLight(pos2.x + dir.x, pos2.y + dir.y, pos2.z + dir.z, l + 12, r, g, b);
}
}
diff --git a/TombEngine/Objects/Generic/Object/burning_torch.h b/TombEngine/Objects/Generic/Object/burning_torch.h
index 73d22eec7..be8d62f55 100644
--- a/TombEngine/Objects/Generic/Object/burning_torch.h
+++ b/TombEngine/Objects/Generic/Object/burning_torch.h
@@ -10,6 +10,6 @@ namespace TEN::Entities::Generic
void DoFlameTorch();
void GetFlameTorch();
void TorchControl(short itemNumber);
- void LaraTorch(Vector3i* origin, Vector3i* target, int rot, int color);
+ void LaraTorch(Vector3i* origin, Vector3i* target);
void FireCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll);
}
diff --git a/TombEngine/Objects/Generic/Object/rope.cpp b/TombEngine/Objects/Generic/Object/rope.cpp
index 63cd732b6..cf2b42e8e 100644
--- a/TombEngine/Objects/Generic/Object/rope.cpp
+++ b/TombEngine/Objects/Generic/Object/rope.cpp
@@ -13,6 +13,7 @@
#include "Objects/Generic/Object/rope.h"
#include "Sound/sound.h"
#include "Game/camera.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
using namespace TEN::Input;
@@ -316,7 +317,7 @@ namespace TEN::Entities::Generic
&pendulumPointer->velocity,
rope->segmentLength * pendulumPointer->node);
- pendulumPointer->velocity.y += 6 << FP_SHIFT;
+ pendulumPointer->velocity.y += (int)g_GameFlow->GetSettings()->Physics.Gravity << FP_SHIFT;
pendulumPointer->position.x += pendulumPointer->velocity.x;
pendulumPointer->position.y += pendulumPointer->velocity.y;
diff --git a/TombEngine/Objects/TR1/Trap/DamoclesSword.cpp b/TombEngine/Objects/TR1/Trap/DamoclesSword.cpp
index 1a9d9998b..a763d2567 100644
--- a/TombEngine/Objects/TR1/Trap/DamoclesSword.cpp
+++ b/TombEngine/Objects/TR1/Trap/DamoclesSword.cpp
@@ -9,6 +9,7 @@
#include "Game/Lara/lara.h"
#include "Game/Setup.h"
#include "Math/Math.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/level.h"
using namespace TEN::Collision::Point;
@@ -54,7 +55,7 @@ namespace TEN::Entities::Traps
item.Pose.Orientation.y += item.ItemFlags[0];
// Calculate vertical velocity.
- item.Animation.Velocity.y += (item.Animation.Velocity.y < DAMOCLES_SWORD_VELOCITY_MAX) ? GRAVITY : 1.0f;
+ item.Animation.Velocity.y += (item.Animation.Velocity.y < DAMOCLES_SWORD_VELOCITY_MAX) ? g_GameFlow->GetSettings()->Physics.Gravity : 1.0f;
// Translate sword.
short headingAngle = Geometry::GetOrientToPoint(item.Pose.Position.ToVector3(), laraItem.Pose.Position.ToVector3()).y;
diff --git a/TombEngine/Objects/TR2/Vehicles/skidoo.cpp b/TombEngine/Objects/TR2/Vehicles/skidoo.cpp
index d13a21f71..71cbd746b 100644
--- a/TombEngine/Objects/TR2/Vehicles/skidoo.cpp
+++ b/TombEngine/Objects/TR2/Vehicles/skidoo.cpp
@@ -19,6 +19,7 @@
#include "Specific/Input/Input.h"
#include "Specific/level.h"
#include "Math/Math.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
using namespace TEN::Collision::Point;
@@ -711,7 +712,9 @@ namespace TEN::Entities::Vehicles
verticalVelocity = 0;
}
else
- verticalVelocity += GRAVITY;
+ {
+ verticalVelocity += g_GameFlow->GetSettings()->Physics.Gravity;
+ }
}
// Airborne.
else
diff --git a/TombEngine/Objects/TR2/Vehicles/speedboat.cpp b/TombEngine/Objects/TR2/Vehicles/speedboat.cpp
index 7b7310172..21873d07a 100644
--- a/TombEngine/Objects/TR2/Vehicles/speedboat.cpp
+++ b/TombEngine/Objects/TR2/Vehicles/speedboat.cpp
@@ -14,6 +14,7 @@
#include "Objects/TR2/Vehicles/speedboat_info.h"
#include "Objects/Utils/VehicleHelpers.h"
#include "Sound/sound.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/Input/Input.h"
#include "Specific/level.h"
@@ -466,7 +467,9 @@ namespace TEN::Entities::Vehicles
verticalVelocity = 0;
}
else
- verticalVelocity += GRAVITY;
+ {
+ verticalVelocity += g_GameFlow->GetSettings()->Physics.Gravity;
+ }
}
else
{
diff --git a/TombEngine/Objects/TR3/Entity/SophiaLeigh.cpp b/TombEngine/Objects/TR3/Entity/SophiaLeigh.cpp
index ea752dae8..4b5336059 100644
--- a/TombEngine/Objects/TR3/Entity/SophiaLeigh.cpp
+++ b/TombEngine/Objects/TR3/Entity/SophiaLeigh.cpp
@@ -150,7 +150,7 @@ namespace TEN::Entities::Creatures::TR3
static void KnockbackCollision(ItemInfo& item, short headingAngle)
{
- item.HitPoints -= 200;
+ DoDamage(&item, 200);
item.HitStatus = true;
short diff = item.Pose.Orientation.y - headingAngle;
diff --git a/TombEngine/Objects/TR3/Object/corpse.cpp b/TombEngine/Objects/TR3/Object/corpse.cpp
index cba3931ea..bb301c95e 100644
--- a/TombEngine/Objects/TR3/Object/corpse.cpp
+++ b/TombEngine/Objects/TR3/Object/corpse.cpp
@@ -16,6 +16,7 @@
#include "Game/Lara/lara_helpers.h"
#include "Game/Setup.h"
#include "Math/Math.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/level.h"
@@ -125,7 +126,7 @@ namespace TEN::Entities::TR3
}
else
{
- item.Animation.Velocity.y += GRAVITY;
+ item.Animation.Velocity.y += g_GameFlow->GetSettings()->Physics.Gravity;
}
}
}
diff --git a/TombEngine/Objects/TR3/Vehicles/kayak.cpp b/TombEngine/Objects/TR3/Vehicles/kayak.cpp
index e66e1c11d..ff4086dab 100644
--- a/TombEngine/Objects/TR3/Vehicles/kayak.cpp
+++ b/TombEngine/Objects/TR3/Vehicles/kayak.cpp
@@ -16,6 +16,7 @@
#include "Objects/Sink.h"
#include "Objects/TR3/Vehicles/kayak_info.h"
#include "Objects/Utils/VehicleHelpers.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/level.h"
#include "Specific/Input/Input.h"
@@ -279,7 +280,7 @@ namespace TEN::Entities::Vehicles
verticalVelocity = 0;
}
else
- verticalVelocity += GRAVITY;
+ verticalVelocity += g_GameFlow->GetSettings()->Physics.Gravity;
}
else
{
diff --git a/TombEngine/Objects/TR3/Vehicles/quad_bike.cpp b/TombEngine/Objects/TR3/Vehicles/quad_bike.cpp
index c8ae399b1..f7198e6f0 100644
--- a/TombEngine/Objects/TR3/Vehicles/quad_bike.cpp
+++ b/TombEngine/Objects/TR3/Vehicles/quad_bike.cpp
@@ -19,6 +19,7 @@
#include "Math/Math.h"
#include "Objects/TR3/Vehicles/quad_bike_info.h"
#include "Objects/Utils/VehicleHelpers.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/level.h"
#include "Specific/Input/Input.h"
@@ -450,7 +451,9 @@ namespace TEN::Entities::Vehicles
verticalVelocity = 0;
}
else
- verticalVelocity += 6;
+ {
+ verticalVelocity += g_GameFlow->GetSettings()->Physics.Gravity;
+ }
}
else
{
diff --git a/TombEngine/Objects/TR3/Vehicles/rubber_boat.cpp b/TombEngine/Objects/TR3/Vehicles/rubber_boat.cpp
index 1b52158e4..749dfc0db 100644
--- a/TombEngine/Objects/TR3/Vehicles/rubber_boat.cpp
+++ b/TombEngine/Objects/TR3/Vehicles/rubber_boat.cpp
@@ -15,6 +15,7 @@
#include "Objects/TR3/Vehicles/upv.h"
#include "Objects/Utils/VehicleHelpers.h"
#include "Renderer/RendererEnums.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/Input/Input.h"
#include "Specific/level.h"
@@ -480,7 +481,9 @@ namespace TEN::Entities::Vehicles
verticalVelocity = 0;
}
else
- verticalVelocity += 6;
+ {
+ verticalVelocity += g_GameFlow->GetSettings()->Physics.Gravity;
+ }
}
else
{
diff --git a/TombEngine/Objects/TR4/Entity/tr4_beetle_swarm.cpp b/TombEngine/Objects/TR4/Entity/tr4_beetle_swarm.cpp
index 2d901cff1..55e3a3bb0 100644
--- a/TombEngine/Objects/TR4/Entity/tr4_beetle_swarm.cpp
+++ b/TombEngine/Objects/TR4/Entity/tr4_beetle_swarm.cpp
@@ -7,8 +7,9 @@
#include "Game/items.h"
#include "Game/Lara/lara.h"
#include "Game/Setup.h"
-#include "Specific/level.h"
#include "Math/Math.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
+#include "Specific/level.h"
using namespace TEN::Math;
@@ -152,7 +153,7 @@ namespace TEN::Entities::TR4
beetle->Pose.Position.y += beetle->VerticalVelocity;
beetle->Pose.Position.z += beetle->Velocity * phd_cos(beetle->Pose.Orientation.y);
- beetle->VerticalVelocity += GRAVITY;
+ beetle->VerticalVelocity += g_GameFlow->GetSettings()->Physics.Gravity;
int dx = LaraItem->Pose.Position.x - beetle->Pose.Position.x;
int dy = LaraItem->Pose.Position.y - beetle->Pose.Position.y;
diff --git a/TombEngine/Objects/TR4/Vehicles/jeep.cpp b/TombEngine/Objects/TR4/Vehicles/jeep.cpp
index 70258a975..159674bc9 100644
--- a/TombEngine/Objects/TR4/Vehicles/jeep.cpp
+++ b/TombEngine/Objects/TR4/Vehicles/jeep.cpp
@@ -19,6 +19,7 @@
#include "Objects/TR4/Vehicles/jeep_info.h"
#include "Objects/Utils/VehicleHelpers.h"
#include "Renderer/RendererEnums.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/Input/Input.h"
#include "Specific/level.h"
@@ -346,9 +347,13 @@ namespace TEN::Entities::Vehicles
if (*yPos <= height - 32)
{
if (flags)
+ {
verticalVelocity += flags + (flags / 2);
+ }
else
- verticalVelocity += (int)((float)GRAVITY * 1.5f);
+ {
+ verticalVelocity += (int)(g_GameFlow->GetSettings()->Physics.Gravity * 1.5f);
+ }
}
else
{
diff --git a/TombEngine/Objects/TR4/Vehicles/motorbike.cpp b/TombEngine/Objects/TR4/Vehicles/motorbike.cpp
index 8ccee05d0..8a5774676 100644
--- a/TombEngine/Objects/TR4/Vehicles/motorbike.cpp
+++ b/TombEngine/Objects/TR4/Vehicles/motorbike.cpp
@@ -20,21 +20,21 @@
#include "Game/Setup.h"
#include "Math/Random.h"
#include "Objects/Utils/VehicleHelpers.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/level.h"
-using std::vector;
using namespace TEN::Collision::Point;
using namespace TEN::Input;
using namespace TEN::Math::Random;
namespace TEN::Entities::Vehicles
{
- const vector MotorbikeJoints = { 0, 1, 2, 4, 5, 6, 7, 8, 9 };
- const vector MotorbikeBrakeLightJoints = { 10 };
- const vector MotorbikeHeadLightJoints = { 3 };
+ const std::vector MotorbikeJoints = { 0, 1, 2, 4, 5, 6, 7, 8, 9 };
+ const std::vector MotorbikeBrakeLightJoints = { 10 };
+ const std::vector MotorbikeHeadLightJoints = { 3 };
- const vector MotorbikeMountTypes =
+ const std::vector MotorbikeMountTypes =
{
VehicleMountType::LevelStart,
VehicleMountType::Right
@@ -501,9 +501,13 @@ namespace TEN::Entities::Vehicles
else
{
if (flags)
+ {
verticalVelocity += flags;
+ }
else
- verticalVelocity += GRAVITY;
+ {
+ verticalVelocity += g_GameFlow->GetSettings()->Physics.Gravity;
+ }
}
}
diff --git a/TombEngine/Objects/TR5/Emitter/tr5_rats_emitter.cpp b/TombEngine/Objects/TR5/Emitter/tr5_rats_emitter.cpp
index ceaa25115..f66bd558b 100644
--- a/TombEngine/Objects/TR5/Emitter/tr5_rats_emitter.cpp
+++ b/TombEngine/Objects/TR5/Emitter/tr5_rats_emitter.cpp
@@ -9,6 +9,7 @@
#include "Game/items.h"
#include "Game/Lara/lara.h"
#include "Game/Setup.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/level.h"
@@ -151,7 +152,7 @@ void UpdateRats()
rat->Pose.Position.y += rat->VerticalVelocity;
rat->Pose.Position.z += rat->Velocity * phd_cos(rat->Pose.Orientation.y);
- rat->VerticalVelocity += GRAVITY;
+ rat->VerticalVelocity += g_GameFlow->GetSettings()->Physics.Gravity;
int dx = LaraItem->Pose.Position.x - rat->Pose.Position.x;
int dy = LaraItem->Pose.Position.y - rat->Pose.Position.y;
diff --git a/TombEngine/Objects/TR5/Emitter/tr5_spider_emitter.cpp b/TombEngine/Objects/TR5/Emitter/tr5_spider_emitter.cpp
index 04d090de9..c22628adb 100644
--- a/TombEngine/Objects/TR5/Emitter/tr5_spider_emitter.cpp
+++ b/TombEngine/Objects/TR5/Emitter/tr5_spider_emitter.cpp
@@ -8,6 +8,7 @@
#include "Game/items.h"
#include "Game/Lara/lara.h"
#include "Game/Setup.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/level.h"
@@ -143,7 +144,7 @@ void UpdateSpiders()
spider->Pose.Position.x += spider->Velocity * phd_sin(spider->Pose.Orientation.y);
spider->Pose.Position.y += spider->VerticalVelocity;
spider->Pose.Position.z += spider->Velocity * phd_cos(spider->Pose.Orientation.y);
- spider->VerticalVelocity += GRAVITY;
+ spider->VerticalVelocity += g_GameFlow->GetSettings()->Physics.Gravity;
int dx = LaraItem->Pose.Position.x - spider->Pose.Position.x;
int dy = LaraItem->Pose.Position.y - spider->Pose.Position.y;
diff --git a/TombEngine/Objects/TR5/Entity/AutoGun.cpp b/TombEngine/Objects/TR5/Entity/AutoGun.cpp
index 32a7d6ebc..4cf4f89d8 100644
--- a/TombEngine/Objects/TR5/Entity/AutoGun.cpp
+++ b/TombEngine/Objects/TR5/Entity/AutoGun.cpp
@@ -73,7 +73,6 @@ namespace TEN::Entities::Creatures::TR5
smoke.rotAdd = Random::GenerateInt(-32, 32);
smoke.maxYvel = 0;
smoke.gravity = Random::GenerateInt(-4, -8);
- smoke.mirror = 0;
smoke.dSize = Random::GenerateInt(24, 40);
smoke.sSize = smoke.dSize / 4;
smoke.size = smoke.dSize / 4;
diff --git a/TombEngine/Objects/TR5/Entity/tr5_roman_statue.cpp b/TombEngine/Objects/TR5/Entity/tr5_roman_statue.cpp
index ef4c8e1d0..997be4ad3 100644
--- a/TombEngine/Objects/TR5/Entity/tr5_roman_statue.cpp
+++ b/TombEngine/Objects/TR5/Entity/tr5_roman_statue.cpp
@@ -129,7 +129,6 @@ namespace TEN::Entities::Creatures::TR5
spark->rotAdd = (GetRandomControl() & 0x1F) - 16;
spark->maxYvel = 0;
spark->gravity = (GetRandomControl() & 7) + 8;
- spark->mirror = 0;
spark->sSize = spark->size = (GetRandomControl() & 7) + 8;
spark->dSize = spark->size * 2;
}
diff --git a/TombEngine/Objects/TR5/Entity/tr5_submarine.cpp b/TombEngine/Objects/TR5/Entity/tr5_submarine.cpp
index 04a4b4ed3..cd102bd45 100644
--- a/TombEngine/Objects/TR5/Entity/tr5_submarine.cpp
+++ b/TombEngine/Objects/TR5/Entity/tr5_submarine.cpp
@@ -17,6 +17,7 @@
#include "Game/people.h"
#include "Game/Setup.h"
#include "Math/Math.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/level.h"
@@ -366,7 +367,9 @@ namespace TEN::Entities::Creatures::TR5
item->Animation.Velocity.z += (5.0f - item->Animation.Velocity.z) / 2.0f;
}
else
- item->Animation.Velocity.y += GRAVITY;
+ {
+ item->Animation.Velocity.y += g_GameFlow->GetSettings()->Physics.Gravity;
+ }
item->Pose.Position.y += item->Animation.Velocity.y;
diff --git a/TombEngine/Objects/TR5/Object/tr5_bodypart.cpp b/TombEngine/Objects/TR5/Object/tr5_bodypart.cpp
index e95d695c4..fe32854be 100644
--- a/TombEngine/Objects/TR5/Object/tr5_bodypart.cpp
+++ b/TombEngine/Objects/TR5/Object/tr5_bodypart.cpp
@@ -12,6 +12,7 @@
#include "Game/items.h"
#include "Game/effects/tomb4fx.h"
#include "Math/Random.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
using namespace TEN::Collision::Point;
using namespace TEN::Math::Random;
@@ -44,7 +45,7 @@ void ControlBodyPart(short fxNumber)
if (fx->speed)
fx->pos.Orientation.x += 4 * fx->fallspeed;
- fx->fallspeed += 6;
+ fx->fallspeed += g_GameFlow->GetSettings()->Physics.Gravity;
}
else
{
diff --git a/TombEngine/Objects/TR5/Object/tr5_rollingball.cpp b/TombEngine/Objects/TR5/Object/tr5_rollingball.cpp
index fe7088ff1..d05f383c3 100644
--- a/TombEngine/Objects/TR5/Object/tr5_rollingball.cpp
+++ b/TombEngine/Objects/TR5/Object/tr5_rollingball.cpp
@@ -13,6 +13,7 @@
#include "Game/Lara/lara_helpers.h"
#include "Game/Setup.h"
#include "Objects/Utils/VehicleHelpers.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/level.h"
@@ -70,7 +71,7 @@ void RollingBallControl(short itemNumber)
int smallRadius = CLICK(0.5f);
int bigRadius = CLICK(2) - 1;
- item->Animation.Velocity.y += GRAVITY;
+ item->Animation.Velocity.y += g_GameFlow->GetSettings()->Physics.Gravity;
item->Pose.Position.x += item->ItemFlags[0] / hDivider;
item->Pose.Position.y += item->Animation.Velocity.y / vDivider;
item->Pose.Position.z += item->ItemFlags[1] / hDivider;
diff --git a/TombEngine/Objects/TR5/Trap/tr5_explosion.cpp b/TombEngine/Objects/TR5/Trap/tr5_explosion.cpp
index 09bf564f0..f73ec9351 100644
--- a/TombEngine/Objects/TR5/Trap/tr5_explosion.cpp
+++ b/TombEngine/Objects/TR5/Trap/tr5_explosion.cpp
@@ -153,7 +153,7 @@ namespace TEN::Entities::Traps
else if (itemPtr->ObjectNumber != ID_SWITCH_TYPE7 && itemPtr->ObjectNumber != ID_SWITCH_TYPE8)
{
if (Objects[itemPtr->ObjectNumber].intelligent)
- DoExplosiveDamage(*LaraItem, *itemPtr, item, Weapons[(int)LaraWeaponType::GrenadeLauncher].ExplosiveDamage);
+ DoExplosiveDamage(*LaraItem, *itemPtr, item, Weapons[(int)LaraWeaponType::GrenadeLauncher].Damage);
}
else
{
diff --git a/TombEngine/Objects/TR5/Trap/tr5_wreckingball.cpp b/TombEngine/Objects/TR5/Trap/tr5_wreckingball.cpp
index 55909c4ca..418e1b565 100644
--- a/TombEngine/Objects/TR5/Trap/tr5_wreckingball.cpp
+++ b/TombEngine/Objects/TR5/Trap/tr5_wreckingball.cpp
@@ -12,6 +12,7 @@
#include "Game/Lara/lara.h"
#include "Game/room.h"
#include "Objects/TR5/Light/tr5_light.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Sound/sound.h"
#include "Specific/Input/Input.h"
#include "Specific/level.h"
@@ -282,7 +283,7 @@ namespace TEN::Entities::Traps
{
SoundEffect(SFX_TR5_BASE_CLAW_DROP, &item.Pose);
++item.ItemFlags[1];
- item.Animation.Velocity.y = 6;
+ item.Animation.Velocity.y = g_GameFlow->GetSettings()->Physics.Gravity;
item.Pose.Position.y += item.Animation.Velocity.y;
}
}
diff --git a/TombEngine/Renderer/Renderer.h b/TombEngine/Renderer/Renderer.h
index 3fb38bff1..99a621ab0 100644
--- a/TombEngine/Renderer/Renderer.h
+++ b/TombEngine/Renderer/Renderer.h
@@ -434,7 +434,7 @@ namespace TEN::Renderer
void CollectRooms(RenderView& renderView, bool onlyRooms);
void CollectItems(short roomNumber, RenderView& renderView);
void CollectStatics(short roomNumber, RenderView& renderView);
- void CollectLights(Vector3 position, float radius, int roomNumber, int prevRoomNumber, bool prioritizeShadowLight, bool useCachedRoomLights, std::vector* roomsLights, std::vector* outputLights);
+ void CollectLights(const Vector3& pos, float radius, int roomNumber, int prevRoomNumber, bool prioritizeShadowLight, bool useCachedRoomLights, std::vector* roomsLights, std::vector* outputLights);
void CollectLightsForItem(RendererItem* item);
void CollectLightsForEffect(short roomNumber, RendererEffect* effect);
void CollectLightsForRoom(short roomNumber, RenderView& renderView);
diff --git a/TombEngine/Renderer/RendererCompatibility.cpp b/TombEngine/Renderer/RendererCompatibility.cpp
index 83e4408b0..77d2970d3 100644
--- a/TombEngine/Renderer/RendererCompatibility.cpp
+++ b/TombEngine/Renderer/RendererCompatibility.cpp
@@ -6,6 +6,7 @@
#include
#include "Game/control/control.h"
+#include "Game/effects/Hair.h"
#include "Game/Lara/lara_struct.h"
#include "Game/savegame.h"
#include "Game/Setup.h"
@@ -14,6 +15,7 @@
#include "Scripting/Include/ScriptInterfaceLevel.h"
#include "Specific/level.h"
+using namespace TEN::Effects::Hair;
using namespace TEN::Renderer::Graphics;
namespace TEN::Renderer
@@ -637,56 +639,50 @@ namespace TEN::Renderer
isSkinPresent = true;
int bonesToCheck[2] = { 0, 0 };
- RendererObject& objSkin = GetRendererObject(GAME_OBJECT_ID::ID_LARA_SKIN);
+ const auto& objSkin = GetRendererObject(GAME_OBJECT_ID::ID_LARA_SKIN);
for (int j = 1; j < obj->nmeshes; j++)
{
- RendererMesh *jointMesh = moveable.ObjectMeshes[j];
- RendererBone *jointBone = moveable.LinearizedBones[j];
+ const auto* jointMesh = moveable.ObjectMeshes[j];
+ const auto* jointBone = moveable.LinearizedBones[j];
bonesToCheck[0] = jointBone->Parent->Index;
bonesToCheck[1] = j;
for (int b1 = 0; b1 < jointMesh->Buckets.size(); b1++)
{
- RendererBucket *jointBucket = &jointMesh->Buckets[b1];
+ const auto* jointBucket = &jointMesh->Buckets[b1];
for (int v1 = 0; v1 < jointBucket->NumVertices; v1++)
{
- Vertex *jointVertex = &_moveablesVertices[jointBucket->StartVertex + v1];
+ auto* jointVertex = &_moveablesVertices[jointBucket->StartVertex + v1];
bool isDone = false;
for (int k = 0; k < 2; k++)
{
- RendererMesh *skinMesh = objSkin.ObjectMeshes[bonesToCheck[k]];
- RendererBone *skinBone = objSkin.LinearizedBones[bonesToCheck[k]];
+ const auto* skinMesh = objSkin.ObjectMeshes[bonesToCheck[k]];
+ const auto* skinBone = objSkin.LinearizedBones[bonesToCheck[k]];
for (int b2 = 0; b2 < skinMesh->Buckets.size(); b2++)
{
- RendererBucket *skinBucket = &skinMesh->Buckets[b2];
+ const auto* skinBucket = &skinMesh->Buckets[b2];
for (int v2 = 0; v2 < skinBucket->NumVertices; v2++)
{
- Vertex *skinVertex = &_moveablesVertices[skinBucket->StartVertex + v2];
+ auto* skinVertex = &_moveablesVertices[skinBucket->StartVertex + v2];
- int x1 = _moveablesVertices[jointBucket->StartVertex + v1].Position.x + jointBone->GlobalTranslation.x;
- int y1 = _moveablesVertices[jointBucket->StartVertex + v1].Position.y + jointBone->GlobalTranslation.y;
- int z1 = _moveablesVertices[jointBucket->StartVertex + v1].Position.z + jointBone->GlobalTranslation.z;
+ auto vertex0 = _moveablesVertices[jointBucket->StartVertex + v1].Position + jointBone->GlobalTranslation;
+ auto vertex1 = _moveablesVertices[skinBucket->StartVertex + v2].Position + skinBone->GlobalTranslation;
- int x2 = _moveablesVertices[skinBucket->StartVertex + v2].Position.x + skinBone->GlobalTranslation.x;
- int y2 = _moveablesVertices[skinBucket->StartVertex + v2].Position.y + skinBone->GlobalTranslation.y;
- int z2 = _moveablesVertices[skinBucket->StartVertex + v2].Position.z + skinBone->GlobalTranslation.z;
+ if (Vector3::Distance(vertex0, vertex1) > 2)
+ continue;
+ jointVertex->Bone = bonesToCheck[k];
+ jointVertex->Position = skinVertex->Position;
+ jointVertex->Normal = skinVertex->Normal;
- if (abs(x1 - x2) < 2 && abs(y1 - y2) < 2 && abs(z1 - z2) < 2)
- {
- jointVertex->Bone = bonesToCheck[k];
- jointVertex->Position = skinVertex->Position;
- jointVertex->Normal = skinVertex->Normal;
-
- isDone = true;
- break;
- }
+ isDone = true;
+ break;
}
if (isDone)
@@ -700,12 +696,17 @@ namespace TEN::Renderer
}
}
}
- else if (MoveablesIds[i] == ID_HAIR_PRIMARY && isSkinPresent)
+ else if ((MoveablesIds[i] == ID_HAIR_PRIMARY || MoveablesIds[i] == ID_HAIR_SECONDARY) && isSkinPresent)
{
+ bool isYoung = (g_GameFlow->GetLevel(CurrentLevel)->GetLaraType() == LaraType::Young);
+ bool isSecond = isYoung && MoveablesIds[i] == ID_HAIR_SECONDARY;
+ const auto& skinObj = GetRendererObject(GAME_OBJECT_ID::ID_LARA_SKIN);
+ const auto& settings = g_GameFlow->GetSettings()->Hair;
+
for (int j = 0; j < obj->nmeshes; j++)
{
- auto* currentMesh = moveable.ObjectMeshes[j];
- auto* currentBone = moveable.LinearizedBones[j];
+ const auto* currentMesh = moveable.ObjectMeshes[j];
+ const auto* currentBone = moveable.LinearizedBones[j];
for (const auto& currentBucket : currentMesh->Buckets)
{
@@ -714,40 +715,39 @@ namespace TEN::Renderer
auto* currentVertex = &_moveablesVertices[currentBucket.StartVertex + v1];
currentVertex->Bone = j + 1;
- // Link mesh 0 to head.
+ // Link mesh 0 to root mesh.
if (j == 0)
{
- bool isYoung = (g_GameFlow->GetLevel(CurrentLevel)->GetLaraType() == LaraType::Young);
+ const auto& vertices0 = isYoung ? settings[(int)PlayerHairType::YoungLeft].Indices :
+ settings[(int)PlayerHairType::Normal].Indices;
- // HACK: Hardcoded hair base parent vertices.
- int parentVertices0[] = { 37, 39, 40, 38 }; // Single braid.
- int parentVertices1[] = { 79, 78, 76, 77 }; // Left pigtail.
+ const auto& vertices1 = isYoung ? settings[(int)PlayerHairType::YoungRight].Indices :
+ settings[(int)PlayerHairType::Normal].Indices;
- auto& skinObj = GetRendererObject(GAME_OBJECT_ID::ID_LARA_SKIN);
- auto* parentMesh = skinObj.ObjectMeshes[LM_HEAD];
- auto* parentBone = skinObj.LinearizedBones[LM_HEAD];
+ int rootMesh = HairUnit::GetRootMeshID(isSecond ? 1 : 0);
- // Link first 4 vertices.
- if (currentVertex->OriginalIndex < 4)
+ const auto* parentMesh = skinObj.ObjectMeshes[rootMesh];
+ const auto* parentBone = skinObj.LinearizedBones[rootMesh];
+
+ // Link listed vertices.
+ if ((!isSecond && currentVertex->OriginalIndex >= vertices0.size()) ||
+ (isSecond && currentVertex->OriginalIndex >= vertices1.size()))
{
- for (int b2 = 0; b2 < parentMesh->Buckets.size(); b2++)
+ continue;
+ }
+
+ for (int b2 = 0; b2 < parentMesh->Buckets.size(); b2++)
+ {
+ const auto* parentBucket = &parentMesh->Buckets[b2];
+ for (int v2 = 0; v2 < parentBucket->NumVertices; v2++)
{
- auto* parentBucket = &parentMesh->Buckets[b2];
- for (int v2 = 0; v2 < parentBucket->NumVertices; v2++)
+ const auto* parentVertex = &_moveablesVertices[parentBucket->StartVertex + v2];
+ if ((parentVertex->OriginalIndex == vertices1[currentVertex->OriginalIndex] && isSecond) ||
+ (parentVertex->OriginalIndex == vertices0[currentVertex->OriginalIndex] && !isSecond))
{
- auto* parentVertex = &_moveablesVertices[parentBucket->StartVertex + v2];
- if (isYoung && parentVertex->OriginalIndex == parentVertices1[currentVertex->OriginalIndex])
- {
- currentVertex->Bone = 0;
- currentVertex->Position = parentVertex->Position;
- currentVertex->Normal = parentVertex->Normal;
- }
- else if (parentVertex->OriginalIndex == parentVertices0[currentVertex->OriginalIndex])
- {
- currentVertex->Bone = 0;
- currentVertex->Position = parentVertex->Position;
- currentVertex->Normal = parentVertex->Normal;
- }
+ currentVertex->Bone = 0;
+ currentVertex->Position = parentVertex->Position;
+ currentVertex->Normal = parentVertex->Normal;
}
}
}
@@ -755,114 +755,27 @@ namespace TEN::Renderer
// Link meshes > 0 to parent meshes.
else
{
- auto* parentMesh = moveable.ObjectMeshes[j - 1];
- auto* parentBone = moveable.LinearizedBones[j - 1];
+ const auto* parentMesh = moveable.ObjectMeshes[j - 1];
+ const auto* parentBone = moveable.LinearizedBones[j - 1];
for (int b2 = 0; b2 < parentMesh->Buckets.size(); b2++)
{
- auto* parentBucket = &parentMesh->Buckets[b2];
+ const auto* parentBucket = &parentMesh->Buckets[b2];
for (int v2 = 0; v2 < parentBucket->NumVertices; v2++)
{
auto* parentVertex = &_moveablesVertices[parentBucket->StartVertex + v2];
- int x1 = _moveablesVertices[currentBucket.StartVertex + v1].Position.x + currentBone->GlobalTranslation.x;
- int y1 = _moveablesVertices[currentBucket.StartVertex + v1].Position.y + currentBone->GlobalTranslation.y;
- int z1 = _moveablesVertices[currentBucket.StartVertex + v1].Position.z + currentBone->GlobalTranslation.z;
+ auto vertex1 = _moveablesVertices[currentBucket.StartVertex + v1].Position + currentBone->GlobalTranslation;
+ auto vertex2 = _moveablesVertices[parentBucket->StartVertex + v2].Position + parentBone->GlobalTranslation;
- int x2 = _moveablesVertices[parentBucket->StartVertex + v2].Position.x + parentBone->GlobalTranslation.x;
- int y2 = _moveablesVertices[parentBucket->StartVertex + v2].Position.y + parentBone->GlobalTranslation.y;
- int z2 = _moveablesVertices[parentBucket->StartVertex + v2].Position.z + parentBone->GlobalTranslation.z;
+ // FIXME: If a tolerance is used, a strange bug occurs where certain vertices don't connect. -- Lwmte, 14.12.2024
+ if (vertex1 != vertex2)
+ continue;
- if (abs(x1 - x2) < 2 && abs(y1 - y2) < 2 && abs(z1 - z2) < 2)
- {
- currentVertex->Bone = j;
- currentVertex->Position = parentVertex->Position;
- currentVertex->Normal = parentVertex->Normal;
- currentVertex->AnimationFrameOffset = parentVertex->AnimationFrameOffset;
- currentVertex->Tangent = parentVertex->Tangent;
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- else if (MoveablesIds[i] == ID_HAIR_SECONDARY && isSkinPresent)
- {
- for (int j = 0; j < obj->nmeshes; j++)
- {
- auto* currentMesh = moveable.ObjectMeshes[j];
- auto* currentBone = moveable.LinearizedBones[j];
-
- for (const auto& currentBucket : currentMesh->Buckets)
- {
- for (int v1 = 0; v1 < currentBucket.NumVertices; v1++)
- {
- auto* currentVertex = &_moveablesVertices[currentBucket.StartVertex + v1];
- currentVertex->Bone = j + 1;
-
- // Link mesh 0 to head.
- if (j == 0)
- {
- bool isYoung = (g_GameFlow->GetLevel(CurrentLevel)->GetLaraType() == LaraType::Young);
-
- // HACK: Hardcoded hair base parent vertices.
- int parentVertices2[] = { 68, 69, 70, 71 }; // Right pigtail.
-
- auto& skinObj = GetRendererObject(GAME_OBJECT_ID::ID_LARA_SKIN);
- auto* parentMesh = skinObj.ObjectMeshes[LM_HEAD];
- auto* parentBone = skinObj.LinearizedBones[LM_HEAD];
-
- if (currentVertex->OriginalIndex < 4)
- {
- for (int b2 = 0; b2 < parentMesh->Buckets.size(); b2++)
- {
- auto* parentBucket = &parentMesh->Buckets[b2];
- for (int v2 = 0; v2 < parentBucket->NumVertices; v2++)
- {
- auto* parentVertex = &_moveablesVertices[parentBucket->StartVertex + v2];
- if (isYoung && parentVertex->OriginalIndex == parentVertices2[currentVertex->OriginalIndex])
- {
- currentVertex->Bone = 0;
- currentVertex->Position = parentVertex->Position;
- currentVertex->Normal = parentVertex->Normal;
- }
- }
- }
- }
- }
- // Link meshes > 0 to parent meshes.
- else
- {
- auto* parentMesh = moveable.ObjectMeshes[j - 1];
- auto* parentBone = moveable.LinearizedBones[j - 1];
-
- for (int b2 = 0; b2 < parentMesh->Buckets.size(); b2++)
- {
- auto* parentBucket = &parentMesh->Buckets[b2];
- for (int v2 = 0; v2 < parentBucket->NumVertices; v2++)
- {
- auto* parentVertex = &_moveablesVertices[parentBucket->StartVertex + v2];
-
- int x1 = _moveablesVertices[currentBucket.StartVertex + v1].Position.x + currentBone->GlobalTranslation.x;
- int y1 = _moveablesVertices[currentBucket.StartVertex + v1].Position.y + currentBone->GlobalTranslation.y;
- int z1 = _moveablesVertices[currentBucket.StartVertex + v1].Position.z + currentBone->GlobalTranslation.z;
-
- int x2 = _moveablesVertices[parentBucket->StartVertex + v2].Position.x + parentBone->GlobalTranslation.x;
- int y2 = _moveablesVertices[parentBucket->StartVertex + v2].Position.y + parentBone->GlobalTranslation.y;
- int z2 = _moveablesVertices[parentBucket->StartVertex + v2].Position.z + parentBone->GlobalTranslation.z;
-
- if (abs(x1 - x2) < 2 && abs(y1 - y2) < 2 && abs(z1 - z2) < 2)
- {
- currentVertex->Bone = j;
- currentVertex->Position = parentVertex->Position;
- currentVertex->Normal = parentVertex->Normal;
- currentVertex->AnimationFrameOffset = parentVertex->AnimationFrameOffset;
- currentVertex->Tangent = parentVertex->Tangent;
- break;
- }
+ currentVertex->Bone = j;
+ currentVertex->Position = parentVertex->Position;
+ currentVertex->Normal = parentVertex->Normal;
+ break;
}
}
}
diff --git a/TombEngine/Renderer/RendererDraw2D.cpp b/TombEngine/Renderer/RendererDraw2D.cpp
index 85e487c0c..93194e04e 100644
--- a/TombEngine/Renderer/RendererDraw2D.cpp
+++ b/TombEngine/Renderer/RendererDraw2D.cpp
@@ -14,6 +14,7 @@
#include "Objects/Utils/object_helper.h"
#include "Renderer/Renderer.h"
#include "Renderer/Structures/RendererHudBar.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/trutils.h"
#include "Specific/winmain.h"
@@ -181,6 +182,9 @@ namespace TEN::Renderer
void Renderer::DrawLoadingBar(float percentage)
{
+ if (!g_GameFlow->GetSettings()->Hud.LoadingBar)
+ return;
+
unsigned int strides = sizeof(Vertex);
unsigned int offset = 0;
diff --git a/TombEngine/Renderer/RendererDrawEffect.cpp b/TombEngine/Renderer/RendererDrawEffect.cpp
index c243de818..66a845e45 100644
--- a/TombEngine/Renderer/RendererDrawEffect.cpp
+++ b/TombEngine/Renderer/RendererDrawEffect.cpp
@@ -31,6 +31,7 @@
#include "Objects/Utils/object_helper.h"
#include "Renderer/Structures/RendererSprite2D.h"
#include "Renderer/Structures/RendererSprite.h"
+#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Specific/level.h"
#include "Structures/RendererSpriteBucket.h"
@@ -1011,6 +1012,16 @@ namespace TEN::Renderer
bool Renderer::DrawGunFlashes(RenderView& view)
{
+ if (!Lara.RightArm.GunFlash && !Lara.LeftArm.GunFlash)
+ return false;
+
+ if (Lara.Control.Look.OpticRange > 0)
+ return false;
+
+ const auto& settings = g_GameFlow->GetSettings()->Weapons[(int)Lara.Control.Weapon.GunType - 1];
+ if (!settings.MuzzleFlash)
+ return false;
+
_context->VSSetShader(_vsStatics.Get(), nullptr, 0);
_context->PSSetShader(_psStatics.Get(), nullptr, 0);
@@ -1021,16 +1032,11 @@ namespace TEN::Renderer
_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
_context->IASetIndexBuffer(_moveablesIndexBuffer.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0);
- if (!Lara.RightArm.GunFlash && !Lara.LeftArm.GunFlash)
- return true;
-
- if (Lara.Control.Look.OpticRange > 0)
- return true;
-
const auto& room = _rooms[LaraItem->RoomNumber];
auto* itemPtr = &_items[LaraItem->Index];
- _stStatic.Color = Vector4::One;
+ // Divide gunflash tint by 2 because tinting uses multiplication and additive color which doesn't look good with overbright color values.
+ _stStatic.Color = settings.ColorizeMuzzleFlash ? ((Vector4)settings.FlashColor / 2) : Vector4::One;
_stStatic.AmbientLight = room.AmbientLight;
_stStatic.LightMode = (int)LightMode::Static;
BindStaticLights(itemPtr->LightsToDraw);
@@ -1039,11 +1045,10 @@ namespace TEN::Renderer
short zOffset = 0;
short rotationX = 0;
- SetBlendMode(BlendMode::Additive);
SetAlphaTest(AlphaTestMode::GreatherThan, ALPHA_TEST_THRESHOLD);
+ SetBlendMode(BlendMode::Additive);
if (Lara.Control.Weapon.GunType != LaraWeaponType::Flare &&
- Lara.Control.Weapon.GunType != LaraWeaponType::Shotgun &&
Lara.Control.Weapon.GunType != LaraWeaponType::Crossbow)
{
switch (Lara.Control.Weapon.GunType)
@@ -1061,6 +1066,7 @@ namespace TEN::Renderer
break;
case LaraWeaponType::HK:
+ case LaraWeaponType::Shotgun:
length = 300;
zOffset = 92;
rotationX = -14560;
diff --git a/TombEngine/Renderer/RendererDrawMenu.cpp b/TombEngine/Renderer/RendererDrawMenu.cpp
index 10d407b43..51db4f2d3 100644
--- a/TombEngine/Renderer/RendererDrawMenu.cpp
+++ b/TombEngine/Renderer/RendererDrawMenu.cpp
@@ -656,7 +656,7 @@ namespace TEN::Renderer
AddString(MenuLoadNameLeftSide, y, (char*)save.LevelName.c_str(), PRINTSTRING_COLOR_WHITE, SF(selection == n));
// Timestamp
- sprintf(stringBuffer, g_GameFlow->GetString(STRING_SAVEGAME_TIMESTAMP), save.Days, save.Hours, save.Minutes, save.Seconds);
+ sprintf(stringBuffer, g_GameFlow->GetString(STRING_SAVEGAME_TIMESTAMP), save.Hours, save.Minutes, save.Seconds);
AddString(MenuRightSideEntry, y, stringBuffer, PRINTSTRING_COLOR_WHITE, SF(selection == n));
}
@@ -682,8 +682,8 @@ namespace TEN::Renderer
GetNextBlockPosition(&y);
// Time taken
- auto gameTime = GetGameTime(GameTimer);
- sprintf(buffer, "%02d:%02d:%02d", (gameTime.Days * DAY_UNIT) + gameTime.Hours, gameTime.Minutes, gameTime.Seconds);
+ auto& gameTime = SaveGame::Statistics.Game.TimeTaken;
+ sprintf(buffer, "%02d:%02d:%02d", gameTime.GetHours(), gameTime.GetMinutes(), gameTime.GetSeconds());
AddString(MenuRightSideEntry, y, buffer, PRINTSTRING_COLOR_WHITE, SF());
AddString(MenuLeftSideEntry, y, g_GameFlow->GetString(STRING_TIME_TAKEN), PRINTSTRING_COLOR_WHITE, SF());
GetNextLinePosition(&y);
diff --git a/TombEngine/Renderer/RendererFrame.cpp b/TombEngine/Renderer/RendererFrame.cpp
index 1af738a45..5b919f28b 100644
--- a/TombEngine/Renderer/RendererFrame.cpp
+++ b/TombEngine/Renderer/RendererFrame.cpp
@@ -528,7 +528,7 @@ namespace TEN::Renderer
}
}
- void Renderer::CollectLights(Vector3 position, float radius, int roomNumber, int prevRoomNumber, bool prioritizeShadowLight, bool useCachedRoomLights, std::vector* roomsLights, std::vector* outputLights)
+ void Renderer::CollectLights(const Vector3& pos, float radius, int roomNumber, int prevRoomNumber, bool prioritizeShadowLight, bool useCachedRoomLights, std::vector* roomsLights, std::vector* outputLights)
{
if (_rooms.size() <= roomNumber)
return;
@@ -573,7 +573,7 @@ namespace TEN::Renderer
// Dynamic lights have the priority
for (auto& light : _dynamicLights[_dynamicLightList])
{
- float distSqr = Vector3::DistanceSquared(position, light.Position);
+ float distSqr = Vector3::DistanceSquared(pos, light.Position);
processLight(light, distSqr, 1);
}
@@ -604,7 +604,7 @@ namespace TEN::Renderer
light.Type == LightType::Shadow ||
light.Type == LightType::Spot)
{
- float distSqr = Vector3::DistanceSquared(position, light.Position);
+ float distSqr = Vector3::DistanceSquared(pos, light.Position);
processLight(light, distSqr, 0);
}
else
diff --git a/TombEngine/Renderer/RendererLara.cpp b/TombEngine/Renderer/RendererLara.cpp
index 75dc4e55b..64fedd83f 100644
--- a/TombEngine/Renderer/RendererLara.cpp
+++ b/TombEngine/Renderer/RendererLara.cpp
@@ -346,7 +346,7 @@ void Renderer::DrawLaraHair(RendererItem* itemToDraw, RendererRoom* room, Render
const auto& rendererObject = *_moveableObjects[unit.ObjectID];
_stItem.World = Matrix::Identity;
- _stItem.BonesMatrices[0] = itemToDraw->InterpolatedAnimTransforms[LM_HEAD] * itemToDraw->InterpolatedWorld;
+ _stItem.BonesMatrices[0] = itemToDraw->InterpolatedAnimTransforms[HairUnit::GetRootMeshID(i)] * itemToDraw->InterpolatedWorld;
for (int i = 0; i < unit.Segments.size(); i++)
{
diff --git a/TombEngine/Scripting/Include/Flow/ScriptInterfaceFlowHandler.h b/TombEngine/Scripting/Include/Flow/ScriptInterfaceFlowHandler.h
index e09b79037..e5a96489f 100644
--- a/TombEngine/Scripting/Include/Flow/ScriptInterfaceFlowHandler.h
+++ b/TombEngine/Scripting/Include/Flow/ScriptInterfaceFlowHandler.h
@@ -36,15 +36,6 @@ public:
virtual bool IsLaraInTitleEnabled() const = 0;
virtual bool IsHomeLevelEnabled() const = 0;
virtual bool IsLoadSaveEnabled() const = 0;
- virtual bool HasCrawlExtended() const = 0;
- virtual bool HasCrouchRoll() const = 0;
- virtual bool HasCrawlspaceDive() const = 0;
- virtual bool HasAutoMonkeySwingJump() const = 0;
- virtual bool HasSprintJump() const = 0;
- virtual bool HasAFKPose() const = 0;
- virtual bool HasOverhangClimb() const = 0;
- virtual bool HasSlideExtended() const = 0;
- virtual bool HasLedgeJumps() const = 0;
virtual ScriptInterfaceLevel * GetLevel(int level) = 0;
virtual int GetLevelNumber(std::string const& fileName) = 0;
diff --git a/TombEngine/Scripting/Include/ScriptInterfaceGame.h b/TombEngine/Scripting/Include/ScriptInterfaceGame.h
index 7fd0d0025..73b0be0ee 100644
--- a/TombEngine/Scripting/Include/ScriptInterfaceGame.h
+++ b/TombEngine/Scripting/Include/ScriptInterfaceGame.h
@@ -25,6 +25,7 @@ enum class SavedVarType
Vec2,
Vec3,
Rotation,
+ Time,
Color,
FuncName,
@@ -39,6 +40,7 @@ using SavedVar = std::variant<
Vector2, // Vec2
Vector3, // Vec3
Vector3, // Rotation
+ int, // Time
D3DCOLOR, // Color
FuncName>;
diff --git a/TombEngine/Scripting/Include/ScriptInterfaceLevel.h b/TombEngine/Scripting/Include/ScriptInterfaceLevel.h
index f1c442cca..484f3a45f 100644
--- a/TombEngine/Scripting/Include/ScriptInterfaceLevel.h
+++ b/TombEngine/Scripting/Include/ScriptInterfaceLevel.h
@@ -39,7 +39,6 @@ public:
virtual float GetWeatherStrength() const = 0;
virtual WeatherType GetWeatherType() const = 0;
virtual RGBAColor8Byte GetSkyLayerColor(int index) const = 0;
- virtual short GetMirrorRoom() const = 0;
virtual bool GetFogEnabled() const = 0;
virtual RGBAColor8Byte GetFogColor() const = 0;
virtual short GetFogMinDistance() const = 0;
diff --git a/TombEngine/Scripting/Include/Strings/StringsCommon.h b/TombEngine/Scripting/Include/Strings/StringsCommon.h
index a84d7637f..24483ff6c 100644
--- a/TombEngine/Scripting/Include/Strings/StringsCommon.h
+++ b/TombEngine/Scripting/Include/Strings/StringsCommon.h
@@ -1,4 +1,4 @@
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
using CallbackDrawString = std::function<
void(
diff --git a/TombEngine/Scripting/Internal/ReservedScriptNames.h b/TombEngine/Scripting/Internal/ReservedScriptNames.h
index eccac5e63..25c798287 100644
--- a/TombEngine/Scripting/Internal/ReservedScriptNames.h
+++ b/TombEngine/Scripting/Internal/ReservedScriptNames.h
@@ -26,6 +26,18 @@ static constexpr char ScriptReserved_Color[] = "Color";
static constexpr char ScriptReserved_DisplayString[] = "DisplayString";
static constexpr char ScriptReserved_Rotation[] = "Rotation";
static constexpr char ScriptReserved_LevelFunc[] = "LevelFunc";
+static constexpr char ScriptReserved_Statistics[] = "Statistics";
+
+// Settings sections
+static constexpr char ScriptReserved_Settings[] = "Settings";
+static constexpr char ScriptReserved_SystemSettings[] = "System";
+static constexpr char ScriptReserved_FlareSettings[] = "Flare";
+static constexpr char ScriptReserved_CameraSettings[] = "Camera";
+static constexpr char ScriptReserved_AnimSettings[] = "Animations";
+static constexpr char ScriptReserved_HairSettings[] = "Hair";
+static constexpr char ScriptReserved_HudSettings[] = "Hud";
+static constexpr char ScriptReserved_PhysicsSettings[] = "Physics";
+static constexpr char ScriptReserved_WeaponSettings[] = "Weapons";
// Moveable object
static constexpr char ScriptReserved_Moveable[] = "Moveable";
@@ -215,8 +227,11 @@ static constexpr char ScriptReserved_GetNextLevel[] = "GetNextLevel";
static constexpr char ScriptReserved_SetIntroImagePath[] = "SetIntroImagePath";
static constexpr char ScriptReserved_SetTitleScreenImagePath[] = "SetTitleScreenImagePath";
static constexpr char ScriptReserved_SetFarView[] = "SetFarView";
-static constexpr char ScriptReserved_SetSettings[] = "SetSettings";
static constexpr char ScriptReserved_SetAnimations[] = "SetAnimations";
+static constexpr char ScriptReserved_GetSettings[] = "GetSettings";
+static constexpr char ScriptReserved_SetSettings[] = "SetSettings";
+static constexpr char ScriptReserved_GetStatistics[] = "GetStatistics";
+static constexpr char ScriptReserved_SetStatistics[] = "SetStatistics";
static constexpr char ScriptReserved_EndLevel[] = "EndLevel";
static constexpr char ScriptReserved_GetGameStatus[] = "GetGameStatus";
static constexpr char ScriptReserved_SetFreezeMode[] = "SetFreezeMode";
@@ -246,13 +261,13 @@ static constexpr char ScriptReserved_SetLanguageNames[] = "SetLanguageNames";
// Flow Tables
static constexpr char ScriptReserved_WeatherType[] = "WeatherType";
static constexpr char ScriptReserved_LaraType[] = "LaraType";
+static constexpr char ScriptReserved_WeaponType[] = "WeaponType";
+static constexpr char ScriptReserved_AmmoType[] = "AmmoType";
static constexpr char ScriptReserved_RotationAxis[] = "RotationAxis";
static constexpr char ScriptReserved_ItemAction[] = "ItemAction";
static constexpr char ScriptReserved_ErrorMode[] = "ErrorMode";
static constexpr char ScriptReserved_FastReload[] = "FastReload";
static constexpr char ScriptReserved_InventoryItem[] = "InventoryItem";
-static constexpr char ScriptReserved_LaraWeaponType[] = "LaraWeaponType";
-static constexpr char ScriptReserved_PlayerAmmoType[] = "PlayerAmmoType";
static constexpr char ScriptReserved_HandStatus[] = "HandStatus";
static constexpr char ScriptReserved_GameStatus[] = "GameStatus";
static constexpr char ScriptReserved_FreezeMode[] = "FreezeMode";
diff --git a/TombEngine/Scripting/Internal/ScriptAssert.h b/TombEngine/Scripting/Internal/ScriptAssert.h
index a9b9ca169..e55dc9ac6 100644
--- a/TombEngine/Scripting/Internal/ScriptAssert.h
+++ b/TombEngine/Scripting/Internal/ScriptAssert.h
@@ -14,7 +14,6 @@ void SetScriptErrorMode(ErrorMode mode);
ErrorMode GetScriptErrorMode();
void ScriptWarn(const std::string& msg);
-
bool ScriptAssert(bool cond, const std::string& msg, std::optional forceMode = std::nullopt);
template bool ScriptAssertF(bool cond, std::string_view str, Ts...args)
diff --git a/TombEngine/Scripting/Internal/ScriptUtil.h b/TombEngine/Scripting/Internal/ScriptUtil.h
index 4cbe6d97d..700aab232 100644
--- a/TombEngine/Scripting/Internal/ScriptUtil.h
+++ b/TombEngine/Scripting/Internal/ScriptUtil.h
@@ -1,4 +1,7 @@
#pragma once
+
+#include "Scripting/Internal/ScriptAssert.h"
+
#define index_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE& item, sol::object key) \
{ \
std::string err = "Attempted to read missing var \"" + key.as() + "\" from " + LUA_CLASS_NAME; \
diff --git a/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h b/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h
index f979aa772..7964702f1 100644
--- a/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h
+++ b/TombEngine/Scripting/Internal/TEN/Effects/BlendIDs.h
@@ -10,26 +10,18 @@ Constants for blend mode IDs.
@pragma nostrip
*/
-/*** Effects.BlendID constants.
+/*** Table of Effects.BlendID constants (for use with particles).
-The following constants are inside BlendID.
+ - `OPAQUE`
+ - `ALPHATEST`
+ - `ADDITIVE`
+ - `SUBTRACTIVE`
+ - `EXCLUDE`
+ - `SCREEN`
+ - `LIGHTEN`
+ - `ALPHABLEND`
- OPAQUE
- ALPHATEST
- ADDITIVE
- NOZTEST
- SUBTRACTIVE
- WIREFRAME
- EXCLUDE
- SCREEN
- LIGHTEN
- ALPHABLEND
-
-@section Effects.BlendID
-*/
-
-/*** Table of blend mode constants (for use with particles).
-@table CONSTANT_STRING_HERE
+@table Effects.BlendID
*/
static const std::unordered_map BLEND_IDS
diff --git a/TombEngine/Scripting/Internal/TEN/Effects/EffectIDs.h b/TombEngine/Scripting/Internal/TEN/Effects/EffectIDs.h
index 48cbc89b2..177943f28 100644
--- a/TombEngine/Scripting/Internal/TEN/Effects/EffectIDs.h
+++ b/TombEngine/Scripting/Internal/TEN/Effects/EffectIDs.h
@@ -10,24 +10,19 @@ Constants for effect IDs.
@pragma nostrip
*/
-/*** Effects.EffectID constants.
+/*** Table of Effects.EffectID constants.
+To be used with @{Objects.Moveable.SetEffect} and @{Objects.Moveable.GetEffect} functions.
-The following constants are inside EffectID.
+ - `NONE`
+ - `FIRE`
+ - `SPARKS`
+ - `SMOKE`
+ - `ELECTRICIGNITE`
+ - `REDIGNITE`
+ - `CADAVER`
+ - `CUSTOM`
- NONE
- FIRE
- SPARKS
- SMOKE
- ELECTRICIGNITE
- REDIGNITE
- CADAVER
- CUSTOM
-
-@section Effects.EffectID
-*/
-
-/*** Table of effect ID constants (for use Moveable:SetEffect / Moveable:GetEffect functions).
-@table CONSTANT_STRING_HERE
+@table Effects.EffectID
*/
static const std::unordered_map EFFECT_IDS
diff --git a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp
index af8b20b74..bf946e959 100644
--- a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp
@@ -16,11 +16,11 @@
#include "Scripting/Internal/LuaHandler.h"
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptUtil.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
#include "Scripting/Internal/TEN/Effects/BlendIDs.h"
#include "Scripting/Internal/TEN/Effects/EffectIDs.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
#include "Sound/sound.h"
#include "Specific/clock.h"
#include "Specific/trutils.h"
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Animations/Animations.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Animations/Animations.cpp
deleted file mode 100644
index eb820fb21..000000000
--- a/TombEngine/Scripting/Internal/TEN/Flow/Animations/Animations.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "framework.h"
-#include "Scripting/Internal/TEN/Flow/Animations/Animations.h"
-
-/***
-New custom animations which Lara can perform.
-@tenclass Flow.Animations
-@pragma nostrip
-*/
-
-void Animations::Register(sol::table& parent)
-{
- parent.new_usertype("Animations",
- sol::constructors(),
- sol::call_constructor, sol::constructors(),
- "crawlExtended", &Animations::HasCrawlExtended,
- "crouchRoll", &Animations::HasCrouchRoll,
- "crawlspaceSwandive", &Animations::HasCrawlspaceDive,
- "overhangClimb", &Animations::HasOverhangClimb,
- "slideExtended", &Animations::HasSlideExtended,
- "sprintJump", &Animations::HasSprintJump,
- "pose", &Animations::HasPose,
- "ledgeJumps", &Animations::HasLedgeJumps,
-
- // NOTE: Removed. Keep for now to maintain compatibility. -- Sezz 2024.06.06
- "monkeyAutoJump", & Animations::HasAutoMonkeySwingJump);
-}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Animations/Animations.h b/TombEngine/Scripting/Internal/TEN/Flow/Animations/Animations.h
deleted file mode 100644
index 781f62653..000000000
--- a/TombEngine/Scripting/Internal/TEN/Flow/Animations/Animations.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include
-#include "Scripting/Internal/ScriptAssert.h"
-
-namespace sol
-{
- class state;
-}
-
-struct Animations
-{
- bool HasPose; // Crossed arms AFK posing.
- bool HasSlideExtended; // Extended slope sliding functionality (not ready yet).
- bool HasSprintJump; // Sprint jump.
- bool HasCrawlspaceDive; // Dive into crawlspaces.
- bool HasCrawlExtended; // Extended crawl moveset.
- bool HasCrouchRoll; // Crouch roll.
- bool HasOverhangClimb; // Overhang functionality.
- bool HasLedgeJumps; // Jump up or back from a ledge.
-
- // NOTE: Removed. Keep for now to maintain compatibility. -- Sezz 2024.06.06
- bool HasAutoMonkeySwingJump;
-
- static void Register(sol::table&);
-};
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Enums/ErrorModes.h b/TombEngine/Scripting/Internal/TEN/Flow/Enums/ErrorModes.h
new file mode 100644
index 000000000..e30361d5a
--- /dev/null
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Enums/ErrorModes.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include "Game/control/control.h"
+#include "Scripting/Internal/ScriptAssert.h"
+
+namespace TEN::Scripting
+{
+ /// Constants for error modes.
+ // @enum Flow.ErrorMode
+ // @pragma nostrip
+
+
+ /// Table of Flow.ErrorMode constants. To be used in @{Flow.Settings.System.errorMode} setting.
+ //
+ // The following constants are inside Flow.ErrorMode:
+ //
+ // - `TERMINATE` - print to the log file and return to the title level when any script error is hit.
+ // This is the one you will want to go for if you want to know IMMEDIATELY if something has gone wrong.
+ //
+ // - `WARN` - print to the log file and continue running the application when a recoverable script error is hit.
+ // Choose this one if booting to the title level is too much for you.
+ //
+ // - `SILENT` - do nothing when a recoverable script error is hit.
+ // Think __very__ carefully before using this setting. These error modes are here to help you to keep your scripts
+ // working properly, but if you opt to ignore errors, you won't be alerted if you've misused a function or passed
+ // an invalid argument.
+ //
+ // In all of these modes, an *unrecoverable* error will boot you to the title level. If the title level itself
+ // has an unrecoverable error, the game will close.
+ //
+ // @table Flow.ErrorMode
+
+ static const auto ERROR_MODES = std::unordered_map
+ {
+ { "SILENT", ErrorMode::Silent },
+ { "WARN", ErrorMode::Warn },
+ { "TERMINATE", ErrorMode::Terminate }
+ };
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Enums/FreezeModes.h b/TombEngine/Scripting/Internal/TEN/Flow/Enums/FreezeModes.h
index 368993ce8..4a304338b 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Enums/FreezeModes.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Enums/FreezeModes.h
@@ -2,32 +2,27 @@
#include "Game/control/control.h"
-/***
-Constants for freeze modes.
-@enum Flow.FreezeMode
-@pragma nostrip
-*/
-
-/*** Flow.FreezeMode constants.
-
-The following constants are inside Flow.FreezeMode.
-
- NONE - Normal in-game operation.
- FULL - Game is completely frozen, as in pause or inventory menus.
- SPECTATOR - Game is completely frozen, but with ability to control camera.
- PLAYER - Game is completely frozen, but with ability to control player. Experimental.
-
-@section Flow.FreezeMode
-*/
-
-/*** Table of freeze modes.
-@table CONSTANT_STRING_HERE
-*/
-
-static const auto FREEZE_MODES = std::unordered_map
+namespace TEN::Scripting
{
- { "NONE", FreezeMode::None },
- { "FULL", FreezeMode::Full },
- { "SPECTATOR", FreezeMode::Spectator },
- { "PLAYER", FreezeMode::Player }
-};
+
+ /// Constants for freeze modes.
+ // @enum Flow.FreezeMode
+ // @pragma nostrip
+
+ /// Table of Flow.FreezeMode constants.
+ // To be used with @{Flow.GetFreezeMode} and @{Flow.SetFreezeMode} functions.
+ // @table FreezeMode
+ //
+ // - `NONE` - Normal in-game operation.
+ // - `FULL` - Game is completely frozen, as in pause or inventory menus.
+ // - `SPECTATOR` - Game is completely frozen, but with ability to control camera.
+ // - `PLAYER` - Game is completely frozen, but with ability to control player. Experimental.
+
+ static const auto FREEZE_MODES = std::unordered_map
+ {
+ { "NONE", FreezeMode::None },
+ { "FULL", FreezeMode::Full },
+ { "SPECTATOR", FreezeMode::Spectator },
+ { "PLAYER", FreezeMode::Player }
+ };
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Enums/GameStatuses.h b/TombEngine/Scripting/Internal/TEN/Flow/Enums/GameStatuses.h
index 8e40d8269..73073b450 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Enums/GameStatuses.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Enums/GameStatuses.h
@@ -1,41 +1,37 @@
#pragma once
-#include
-#include
#include "Game/control/control.h"
-/***
-Constants for game statuses.
-@enum Flow.GameStatus
-@pragma nostrip
-*/
-
-/*** Flow.GameStatus constants.
-
-The following constants are inside Flow.GameStatus.
-
- NORMAL
- NEW_GAME
- LOAD_GAME
- EXIT_TO_TITLE
- EXIT_GAME
- LARA_DEAD
- LEVEL_COMPLETE
-
-@section Flow.GameStatus
-*/
-
-/*** Table of game statuses.
-@table CONSTANT_STRING_HERE
-*/
-
-static const std::unordered_map GAME_STATUSES
+namespace TEN::Scripting
{
- { "NORMAL", GameStatus::Normal },
- { "NEW_GAME", GameStatus::NewGame },
- { "LOAD_GAME", GameStatus::LoadGame },
- { "EXIT_TO_TITLE", GameStatus::ExitToTitle },
- { "EXIT_GAME", GameStatus::ExitGame },
- { "LARA_DEAD", GameStatus::LaraDead },
- { "LEVEL_COMPLETE", GameStatus::LevelComplete }
-};
+ /// Constants for game statuses.
+ // @enum Flow.GameStatus
+ // @pragma nostrip
+
+
+ /// Table of Flow.GameStatus constants.
+ // To be used with @{Flow.GetGameStatus} function.
+ //
+ // The following constants are inside Flow.GameStatus.
+ //
+ // - `NORMAL`
+ // - `NEW_GAME`
+ // - `LOAD_GAME`
+ // - `EXIT_TO_TITLE`
+ // - `EXIT_GAME`
+ // - `LARA_DEAD`
+ // - `LEVEL_COMPLETE`
+ //
+ // @table Flow.GameStatus
+
+ static const auto GAME_STATUSES = std::unordered_map
+ {
+ { "NORMAL", GameStatus::Normal },
+ { "NEW_GAME", GameStatus::NewGame },
+ { "LOAD_GAME", GameStatus::LoadGame },
+ { "EXIT_TO_TITLE", GameStatus::ExitToTitle },
+ { "EXIT_GAME", GameStatus::ExitGame },
+ { "LARA_DEAD", GameStatus::LaraDead }, // TODO: Rename to PLAYER_DEAD
+ { "LEVEL_COMPLETE", GameStatus::LevelComplete }
+ };
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.cpp b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.cpp
index 70bc3f86d..3bdcf305c 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.cpp
@@ -4,19 +4,28 @@
#include
#include "Game/Gui.h"
+#include "Game/Lara/lara_fire.h"
+#include "Game/pickup/pickup_ammo.h"
+#include "Game/pickup/pickup_consumable.h"
#include "Game/savegame.h"
#include "Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h"
#include "Scripting/Include/Strings/ScriptInterfaceStringsHandler.h"
#include "Scripting/Internal/ReservedScriptNames.h"
+#include "Scripting/Internal/TEN/Flow/Enums/ErrorModes.h"
#include "Scripting/Internal/TEN/Flow/Enums/FreezeModes.h"
#include "Scripting/Internal/TEN/Flow/Enums/GameStatuses.h"
#include "Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.h"
+#include "Scripting/Internal/TEN/Flow/Settings/Settings.h"
#include "Scripting/Internal/TEN/Logic/LevelFunc.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Objects/Lara/WeaponTypes.h"
+#include "Scripting/Internal/TEN/Types/Time/Time.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Sound/sound.h"
#include "Specific/trutils.h"
+using namespace TEN::Scripting;
+
/***
Functions that (mostly) don't directly impact in-game mechanics. Used for setup
in gameflow.lua, settings.lua and strings.lua; some can be used in level
@@ -30,8 +39,7 @@ ScriptInterfaceObjectsHandler* g_GameScriptEntities;
ScriptInterfaceStringsHandler* g_GameStringsHandler;
ScriptInterfaceFlowHandler* g_GameFlow;
-FlowHandler::FlowHandler(sol::state* lua, sol::table& parent) :
- _handler(lua)
+FlowHandler::FlowHandler(sol::state* lua, sol::table& parent) : _handler(lua)
{
/*** gameflow.lua.
These functions are called in gameflow.lua, a file loosely equivalent to winroomedit's SCRIPT.DAT.
@@ -78,23 +86,26 @@ Must be true or false
*/
tableFlow.set_function(ScriptReserved_EnableLevelSelect, &FlowHandler::EnableLevelSelect, this);
- /// Enable or disable Home Level entry in the main menu.
- // @function EnableHomeLevel()
- // @tparam bool enabled True or false.
+/*** Enable or disable Home Level entry in the main menu.
+@function EnableHomeLevel()
+@tparam bool enabled True or false.
+*/
tableFlow.set_function(ScriptReserved_EnableHomeLevel, &FlowHandler::EnableHomeLevel, this);
- /// Enable or disable saving and loading of savegames.
- // @function EnableLoadSave()
- // @tparam bool enabled True or false.
+/*** Enable or disable saving and loading of savegames.
+@function EnableLoadSave()
+@tparam bool enabled True or false.
+*/
tableFlow.set_function(ScriptReserved_EnableLoadSave, &FlowHandler::EnableLoadSave, this);
/*** gameflow.lua or level scripts.
@section FlowluaOrScripts
*/
- /// Enable or disable the fly cheat.
- // @function EnableFlyCheat()
- // @tparam bool enabled True or false.
+/*** Enable or disable the fly cheat.
+@function EnableFlyCheat()
+@tparam bool enabled True or false.
+*/
tableFlow.set_function(ScriptReserved_EnableFlyCheat, &FlowHandler::EnableFlyCheat, this);
/*** Enable or disable point texture filter.
@@ -126,13 +137,13 @@ have an ID of 0, the second an ID of 1, and so on.
*/
tableFlow.set_function(ScriptReserved_GetCurrentLevel, &FlowHandler::GetCurrentLevel, this);
- /// Returns the level that is about to load. If no new level is about to load, returns current level.
- // @function GetNextLevel
- // @treturn Flow.Level incoming new level or current level, if no new level is loading
+/*** Returns the level that is about to load. If no new level is about to load, returns current level.
+@function GetNextLevel
+@treturn Flow.Level incoming new level or current level, if no new level is loading
+*/
tableFlow.set_function(ScriptReserved_GetNextLevel, &FlowHandler::GetNextLevel, this);
-/***
-Finishes the current level, with optional level index and start position index provided.
+/*** Finishes the current level, with optional level index and start position index provided.
If level index is not provided or is zero, jumps to next level. If level index is more than
level count, jumps to title. If LARA\_START\_POS objects are present in level, player will be
teleported to such object with OCB similar to provided second argument.
@@ -142,6 +153,22 @@ teleported to such object with OCB similar to provided second argument.
*/
tableFlow.set_function(ScriptReserved_EndLevel, &FlowHandler::EndLevel, this);
+/***
+Get game or level statistics. For reference about statistics class, see @{Flow.Statistics}.
+@function GetStatistics
+@tparam bool game if true, returns overall game statistics, otherwise returns current level statistics (default: false)
+@treturn Flow.Statistics statistics structure representing game or level statistics
+*/
+ tableFlow.set_function(ScriptReserved_GetStatistics, &FlowHandler::GetStatistics, this);
+
+/***
+Set game or level statistics. For reference about statistics class, see @{Flow.Statistics}.
+@function SetStatistics
+@tparam Flow.Statistics statistics statistic object to set
+@tparam bool game if true, sets overall game statistics, otherwise sets current level statistics (default: false)
+*/
+ tableFlow.set_function(ScriptReserved_SetStatistics, &FlowHandler::SetStatistics, this);
+
/***
Get current game status, such as normal game loop, exiting to title, etc.
@function GetGameStatus
@@ -161,7 +188,7 @@ Set current freeze mode, such as none, full, spectator or player.
Freeze mode specifies whether game is in normal mode or paused in a particular way to allow
custom menu creation, photo mode or time freeze.
@function SetFreezeMode
-@tparam Flow.FreezeMode new freeze mode to set.
+@tparam Flow.FreezeMode freezeMode new freeze mode to set.
*/
tableFlow.set_function(ScriptReserved_SetFreezeMode, &FlowHandler::SetFreezeMode, this);
@@ -235,29 +262,28 @@ Must be an integer value (0 means no secrets).
@treturn int Status of the flipmap group (true means on, false means off).
*/
tableFlow.set_function(ScriptReserved_GetFlipMapStatus, &FlowHandler::GetFlipMapStatus, this);
-
+
/*** settings.lua.
-These functions are called in settings.lua, a file which holds your local settings.
-settings.lua shouldn't be bundled with any finished levels/games.
+These functions are called in settings.lua, a file which holds global settings, such as system settings, flare color or animation movesets.
@section settingslua
*/
-/***
+/*** Set provided settings table to an engine.
@function SetSettings
-@tparam Flow.Settings settings a settings object
+@tparam Flow.Settings settings a settings table
*/
tableFlow.set_function(ScriptReserved_SetSettings, &FlowHandler::SetSettings, this);
-
-/***
-@function SetAnimations
-@tparam Flow.Animations animations an animations object
+/*** Get settings table from an engine.
+@function GetSettings
+@treturn Flow.Settings current settings table
*/
- tableFlow.set_function(ScriptReserved_SetAnimations, &FlowHandler::SetAnimations, this);
+ tableFlow.set_function(ScriptReserved_GetSettings, &FlowHandler::GetSettings, this);
/*** strings.lua.
These functions used in strings.lua, which is generated by TombIDE.
You will not need to call them manually.
@section stringslua
*/
+
/*** Set string variable keys and their translations.
@function SetStrings
@tparam tab table array-style table with strings
@@ -285,13 +311,13 @@ Specify which translations in the strings table correspond to which languages.
ScriptColor::Register(parent);
Rotation::Register(parent);
+ Statistics::Register(parent);
+ Time::Register(parent);
Vec2::Register(parent);
Vec3::Register(parent);
Level::Register(tableFlow);
SkyLayer::Register(tableFlow);
- Mirror::Register(tableFlow);
InventoryItem::Register(tableFlow);
- Animations::Register(tableFlow);
Settings::Register(tableFlow);
Fog::Register(tableFlow);
LensFlare::Register(tableFlow);
@@ -340,14 +366,31 @@ void FlowHandler::SetStrings(sol::nested game) const
{
- _settings = src;
+ return (game.value_or(false) ? &SaveGame::Statistics.Game : &SaveGame::Statistics.Level);
}
-void FlowHandler::SetAnimations(Animations const& src)
+void FlowHandler::SetStatistics(Statistics const& src, std::optional game)
{
- Anims = src;
+ if (game.value_or(false))
+ {
+ SaveGame::Statistics.Game = src;
+ }
+ else
+ {
+ SaveGame::Statistics.Level = src;
+ }
+}
+
+void FlowHandler::SetSettings(Settings const& src)
+{
+ _settings = src;
+
+ // Copy weapon, ammo and consumable settings to in-game structs.
+ InitializeWeaponInfo(_settings);
+ InitializeAmmo(_settings);
+ InitializeConsumables(_settings);
}
void FlowHandler::AddLevel(Level const& level)
@@ -372,12 +415,14 @@ void FlowHandler::SetTotalSecretCount(int secretsNumber)
void FlowHandler::LoadFlowScript()
{
+ TENLog("Loading gameflow script, strings, and settings...", LogLevel::Info);
+
_handler.ExecuteScript(_gameDir + "Scripts/Gameflow.lua");
_handler.ExecuteScript(_gameDir + "Scripts/SystemStrings.lua", true);
_handler.ExecuteScript(_gameDir + "Scripts/Strings.lua", true);
_handler.ExecuteScript(_gameDir + "Scripts/Settings.lua", true);
- SetScriptErrorMode(GetSettings()->ErrorMode);
+ SetScriptErrorMode(GetSettings()->System.ErrorMode);
// Check if levels exist in Gameflow.lua.
if (Levels.empty())
@@ -575,7 +620,7 @@ void FlowHandler::AddSecret(int levelSecretIndex)
return;
}
- if (SaveGame::Statistics.Level.Secrets & (1 << levelSecretIndex))
+ if (SaveGame::Statistics.SecretBits & (1 << levelSecretIndex))
return;
if (SaveGame::Statistics.Game.Secrets >= UINT_MAX)
@@ -585,7 +630,8 @@ void FlowHandler::AddSecret(int levelSecretIndex)
}
PlaySecretTrack();
- SaveGame::Statistics.Level.Secrets |= (1 << levelSecretIndex);
+ SaveGame::Statistics.SecretBits |= 1 << levelSecretIndex;
+ SaveGame::Statistics.Level.Secrets++;
SaveGame::Statistics.Game.Secrets++;
}
@@ -761,7 +807,6 @@ bool FlowHandler::DoFlow()
// Load level.
CurrentLevel = header.Level;
NextLevel = 0;
- GameTimer = header.Timer;
loadFromSavegame = true;
break;
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h
index 06f881412..e5641eaef 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/FlowHandler.h
@@ -5,18 +5,19 @@
#include "Scripting/Include/ScriptInterfaceGame.h"
#include "Scripting/Internal/LanguageScript.h"
#include "Scripting/Internal/LuaHandler.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Time/Time.h"
#include "Scripting/Internal/TEN/Logic/LogicHandler.h"
-#include "Scripting/Internal/TEN/Flow/Animations/Animations.h"
#include "Scripting/Internal/TEN/Flow/Level/FlowLevel.h"
#include "Scripting/Internal/TEN/Flow/Settings/Settings.h"
+#include "Scripting/Internal/TEN/Flow/Statistics/Statistics.h"
class FlowHandler : public ScriptInterfaceFlowHandler
{
private:
LuaHandler _handler;
+ std::string _gameDir = {};
Settings _settings = {};
- std::string _gameDir = {};
std::map _moveableMap = {};
@@ -38,9 +39,6 @@ public:
bool LaraInTitle = false;
bool DebugMode = false;
- // Table for movesets.
- Animations Anims = {};
-
std::vector Levels;
FlowHandler(sol::state* lua, sol::table& parent);
@@ -54,9 +52,6 @@ public:
bool IsStringPresent(const char* id) const;
void SetStrings(sol::nested>>&& src);
void SetLanguageNames(sol::as_table_t>&& src);
- void SetAnimations(const Animations& src);
- void SetSettings(const Settings& src);
- Settings* GetSettings();
Level* GetLevel(int id);
Level* GetCurrentLevel();
Level* GetNextLevel();
@@ -72,6 +67,8 @@ public:
void LoadGame(int slot);
void DeleteSaveGame(int slot);
bool DoesSaveGameExist(int slot);
+ Statistics* GetStatistics(std::optional game) const;
+ void SetStatistics(const Statistics& src, std::optional game);
int GetSecretCount() const;
void SetSecretCount(int secretsNum);
void AddSecret(int levelSecretIndex);
@@ -92,17 +89,9 @@ public:
void EnableHomeLevel(bool enable);
bool IsLoadSaveEnabled() const;
void EnableLoadSave(bool enable);
+
+ Settings* GetSettings();
+ void SetSettings(const Settings& src);
- bool HasCrawlExtended() const override { return Anims.HasCrawlExtended; }
- bool HasCrouchRoll() const override { return Anims.HasCrouchRoll; }
- bool HasCrawlspaceDive() const override { return Anims.HasCrawlspaceDive; }
- bool HasAFKPose() const override { return Anims.HasPose; }
- bool HasOverhangClimb() const override { return Anims.HasOverhangClimb; }
- bool HasSlideExtended() const override { return Anims.HasSlideExtended; }
- bool HasSprintJump() const override { return Anims.HasSprintJump; }
- bool HasLedgeJumps() const override { return Anims.HasLedgeJumps; }
bool DoFlow() override;
-
- // NOTE: Removed. Keep for now to maintain compatibility. -- Sezz 2024.06.06
- bool HasAutoMonkeySwingJump() const override { return Anims.HasAutoMonkeySwingJump; }
};
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp
index 7b3dfde50..8fa617c19 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp
@@ -2,9 +2,9 @@
#include "Fog.h"
/***
-Fog
+Distance fog.
-@tenclass Flow.Fog
+@tenprimitive Flow.Fog
@pragma nostrip
*/
@@ -16,21 +16,17 @@ void Fog::Register(sol::table& parent)
sol::call_constructor, ctors(),
/// (@{Color}) RGB fog color
- //@mem color
+ // @mem color
"color", sol::property(&Fog::GetColor, &Fog::SetColor),
- /*** (int) min distance.
-
- This is the distance at which the fog starts
-
- @mem minDistance*/
+ /// (int) min distance.
+ // This is the distance at which the fog starts.
+ // @mem minDistance*
"minDistance", &Fog::MinDistance,
- /*** (int) max distance.
-
- This is the distance at which the fog reaches the maximum strength
-
- @mem maxDistance*/
+ /// (int) max distance.
+ // This is the distance at which the fog reaches the maximum strength.
+ // @mem maxDistance
"maxDistance", &Fog::MaxDistance
);
}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.h b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.h
index d8de8a29f..e746a75e2 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.h
@@ -1,6 +1,6 @@
#pragma once
-#include "Scripting/Internal/TEN/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
namespace sol { class state; }
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp
index 24cffcba0..5037763ca 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp
@@ -7,7 +7,7 @@
/***
Represents the properties of an object as it appears in the inventory.
-@tenclass Flow.InventoryItem
+@tenprimitive Flow.InventoryItem
@pragma nostrip
*/
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.h b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.h
index 81e1fbdef..cedc5b0f9 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.h
@@ -1,20 +1,21 @@
#pragma once
+
#include "Game/Gui.h"
-#include "Scripting/Internal/TEN/Rotation/Rotation.h"
+#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
namespace sol { class state; }
using namespace TEN::Gui;
enum GAME_OBJECT_ID : short;
-static const std::unordered_map ROTATION_AXES
+static const auto ROTATION_AXES = std::unordered_map
{
{ "X", RotationFlags::INV_ROT_X },
{ "Y", RotationFlags::INV_ROT_Y },
{ "Z", RotationFlags::INV_ROT_Z }
};
-static const std::unordered_map ITEM_MENU_ACTIONS
+static const auto ITEM_MENU_ACTIONS = std::unordered_map
{
{ "USE", ItemOptions::OPT_USE },
{ "EQUIP", ItemOptions::OPT_EQUIP },
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp
index 8b9664593..fb4b04dbf 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp
@@ -2,12 +2,12 @@
#include "Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h"
#include "Objects/game_object_ids.h"
-#include "Scripting/Internal/TEN/Rotation/Rotation.h"
-#include "Specific\level.h"
+#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
+#include "Specific/level.h"
-/// Represents a lens flare.
+/// Represents a global lens flare (not to be confused with lensflare object).
//
-// @tenclass Flow.LensFlare
+// @tenprimitive Flow.LensFlare
// @pragma nostrip
namespace TEN::Scripting
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h
index ab450b6e1..ad146bae9 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h
@@ -1,8 +1,8 @@
#pragma once
#include "Objects/game_object_ids.h"
#include "Objects/objectslist.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
-#include "Scripting/Internal/TEN/Rotation/Rotation.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
namespace sol { class state; }
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp
index 77517676c..45c9a92a3 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp
@@ -58,12 +58,12 @@ void Level::Register(sol::table& parent)
//@mem layer2
"layer2", &Level::Layer2,
- /// (@{Flow.Starfield}) Starfield.
- // @mem starfield
+/// (@{Flow.Starfield}) Starfield.
+// @mem starfield
"starfield", &Level::Starfield,
- /// (@{Flow.LensFlare}) Global lens flare .
- // @mem lensFlare
+/// (@{Flow.LensFlare}) Global lens flare .
+// @mem lensFlare
"lensFlare", &Level::LensFlare,
/// (@{Flow.Fog}) omni fog RGB color and distance.
@@ -115,12 +115,6 @@ e.g. `myLevel.laraType = LaraType.Divesuit`
//@mem rumble
"rumble", &Level::Rumble,
-/// (@{Flow.Mirror}) Location and size of the level's mirror, if present.
-//
-// __(not yet implemented)__
-//@mem mirror
- "mirror", &Level::Mirror,
-
"farView", sol::property(&Level::SetLevelFarView),
/// (bool) Reset hub data.
@@ -246,17 +240,11 @@ WeatherType Level::GetWeatherType() const
return Weather;
}
-short Level::GetMirrorRoom() const
-{
- return Mirror.Room;
-}
-
bool Level::GetFogEnabled() const
{
return Fog.Enabled;
}
-
RGBAColor8Byte Level::GetFogColor() const
{
return Fog.GetColor();
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h
index 18d52df5b..13bcae96a 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h
@@ -2,7 +2,6 @@
#include "Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.h"
#include "Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h"
#include "Scripting/Internal/TEN/Flow/Starfield/Starfield.h"
-#include "Scripting/Internal/TEN/Flow/Mirror/Mirror.h"
#include "Scripting/Internal/TEN/Flow/Fog/Fog.h"
#include "Scripting/Include/ScriptInterfaceLevel.h"
#include "Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.h"
@@ -31,7 +30,6 @@ struct Level : public ScriptInterfaceLevel
SkyLayer Layer1 = {};
SkyLayer Layer2 = {};
Fog Fog = {};
- Mirror Mirror = {};
int LevelFarView = 0;
std::string AmbientTrack = {};
@@ -62,7 +60,6 @@ struct Level : public ScriptInterfaceLevel
void SetLevelFarView(short val);
static void Register(sol::table& parent);
WeatherType GetWeatherType() const override;
- short GetMirrorRoom() const override;
short GetFogMinDistance() const override;
short GetFogMaxDistance() const override;
short GetFarView() const override;
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Mirror/Mirror.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Mirror/Mirror.cpp
deleted file mode 100644
index 5fcceb02f..000000000
--- a/TombEngine/Scripting/Internal/TEN/Flow/Mirror/Mirror.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "framework.h"
-#include "Mirror.h"
-
-/***
-A mirror effect.
-As seen in TR4's Coastal Ruins and Sacred Lake levels.
-
-__Not currently implemented.__
-
-@tenclass Flow.Mirror
-@pragma nostrip
-*/
-
-void Mirror::Register(sol::table& parent)
-{
- using ctors = sol::constructors;
- parent.new_usertype("Mirror",
- ctors(),
- sol::call_constructor, ctors(),
- "room", &Mirror::Room,
- "startX", &Mirror::StartX,
- "endX", &Mirror::EndX,
- "startZ", &Mirror::StartZ,
- "endZ", &Mirror::EndZ
- );
-}
-
-Mirror::Mirror(short room, int startX, int endX, int startZ, int endZ)
-{
- Room = room;
- StartX = startX;
- EndX = endX;
- StartZ = startZ;
- EndZ = endZ;
-}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Mirror/Mirror.h b/TombEngine/Scripting/Internal/TEN/Flow/Mirror/Mirror.h
deleted file mode 100644
index 51e05cda4..000000000
--- a/TombEngine/Scripting/Internal/TEN/Flow/Mirror/Mirror.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-namespace sol {
- class state;
-}
-
-struct Mirror
-{
- short Room{ -1 };
- int StartX{ 0 };
- int EndX{ 0 };
- int StartZ{ 0 };
- int EndZ{ 0 };
-
- static void Register(sol::table& parent);
- Mirror() = default;
-
- Mirror(short room, int startX, int endX, int startZ, int endZ);
-};
-
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp
index af8846404..89b51b80f 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.cpp
@@ -1,44 +1,336 @@
#include "framework.h"
#include "Scripting/Internal/TEN/Flow/Settings/Settings.h"
-/// Settings that will be run on game startup.
-// @tenclass Flow.Settings
-// @pragma nostrip
+#include "Game/effects/Hair.h"
+#include "Scripting/Internal/TEN/Objects/Lara/WeaponTypes.h"
+#include "Scripting/Internal/ReservedScriptNames.h"
+#include "Scripting/Internal/ScriptUtil.h"
-void Settings::Register(sol::table& parent)
+using namespace TEN::Effects::Hair;
+
+namespace TEN::Scripting
{
- parent.new_usertype(
- "Settings",
- sol::constructors(),
- sol::call_constructor, sol::constructors(),
-/*** How should the application respond to script errors?
-
-Must be one of the following:
-`ErrorMode.TERMINATE` - print to the log file and return to the title level when any script error is hit.
-This is the one you will want to go for if you want to know IMMEDIATELY if something has gone wrong.
+ /// Global engine settings which don't fall into particular category or can't be assigned to a specific object.
+ // Can be accessed using @{Flow.SetSettings} and @{Flow.GetSettings} functions.
+ // @tenclass Flow.Settings
+ // @pragma nostrip
-`ErrorMode.WARN` - print to the log file and continue running the application when a recoverable script error is hit.
-Choose this one if booting to the title level is too much for you.
+ Settings::Settings()
+ {
+ Hair[(int)PlayerHairType::Normal] = { LM_HEAD, Vec3(-4.0f, -4.0f, -48.0f), { 37, 39, 40, 38 } };
+ Hair[(int)PlayerHairType::YoungLeft] = { LM_HEAD, Vec3(-48.0f, -48.0f, -50.0f), { 79, 78, 76, 77 } };
+ Hair[(int)PlayerHairType::YoungRight] = { LM_HEAD, Vec3(48.0f, -48.0f, -50.0f), { 68, 69, 70, 71 } };
+
+ // NOTE: Since Weapons array is bound to Lua directly and Lua accesses this array by native enum, where 0 is NONE, and 1 is PISTOLS,
+ // 0 index is omitted due to Lua indexing arrays starting from 1. 1 must be subtracted from initializer index.
+ Weapons[(int)LaraWeaponType::Pistol - 1] = { 8.0f, BLOCK(8), 9, (int)BLOCK(0.65f), 1, 1, 30, ScriptColor(192, 128, 0), 9, 3, true, true, true, false };
+ Weapons[(int)LaraWeaponType::Revolver - 1] = { 4.0f, BLOCK(8), 16, (int)BLOCK(0.65f), 21, 21, 6, ScriptColor(192, 128, 0), 9, 3, true, false, true, false };
+ Weapons[(int)LaraWeaponType::Uzi - 1] = { 8.0f, BLOCK(8), 3, (int)BLOCK(0.65f), 1, 1, 30, ScriptColor(192, 128, 0), 9, 2, true, true, true, false };
+ Weapons[(int)LaraWeaponType::Shotgun - 1] = { 10.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 3, 3, 6, ScriptColor(192, 128, 0), 12, 3, true, true, false, false };
+ Weapons[(int)LaraWeaponType::HK - 1] = { 4.0f, BLOCK(12), 0, (int)BLOCK(0.50f), 4, 4, 30, ScriptColor(192, 128, 0), 12, 2, true, true, true, false };
+ Weapons[(int)LaraWeaponType::Crossbow - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 5, 20, 10, ScriptColor(192, 128, 0), 0, 0, false, false, false, false };
+ Weapons[(int)LaraWeaponType::GrenadeLauncher - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 30, 30, 10, ScriptColor(192, 128, 0), 0, 0, true, false, false, false };
+ Weapons[(int)LaraWeaponType::RocketLauncher - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 30, 30, 1, ScriptColor(192, 128, 0), 0, 0, true, false, false, false };
+ Weapons[(int)LaraWeaponType::HarpoonGun - 1] = { 8.0f, BLOCK(8), 0, (int)BLOCK(0.50f), 6, 6, 10, ScriptColor(192, 128, 0), 0, 0, false, false, false, false };
+ }
-`ErrorMode.SILENT` - do nothing when a recoverable script error is hit.
-Think __very__ carefully before using this setting. These error modes are here to help you to keep your scripts
-working properly, but if you opt to ignore errors, you won't be alerted if you've misused a function or passed
-an invalid argument.
+ void Settings::Register(sol::table& parent)
+ {
+ AnimSettings::Register(parent);
+ CameraSettings::Register(parent);
+ FlareSettings::Register(parent);
+ HairSettings::Register(parent);
+ HudSettings::Register(parent);
+ PhysicsSettings::Register(parent);
+ SystemSettings::Register(parent);
+ WeaponSettings::Register(parent);
-In all of these modes, an *unrecoverable* error will boot you to the title level. If the title level itself
-has an unrecoverable error, the game will close.
+ parent.new_usertype(ScriptReserved_Settings,
+ sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(Settings, ScriptReserved_Settings),
+ ScriptReserved_AnimSettings, &Settings::Animations,
+ ScriptReserved_FlareSettings, &Settings::Flare,
+ ScriptReserved_CameraSettings, &Settings::Camera,
+ ScriptReserved_HairSettings, &Settings::Hair,
+ ScriptReserved_HudSettings, &Settings::Hud,
+ ScriptReserved_PhysicsSettings, &Settings::Physics,
+ ScriptReserved_SystemSettings, &Settings::System,
+ ScriptReserved_WeaponSettings, &Settings::Weapons);
+ }
-@mem errorMode
-*/
- "errorMode", &Settings::ErrorMode,
+ /// Animations
+ // @section Animations
+ // These settings determine whether a specific moveset is available in-game.
-/// Can the game utilize the fast reload feature?
-//
-// When set to `true`, the game will attempt to perform fast savegame reloading if current level is the same as
-// the level loaded from the savegame. It will not work if the level timestamp or checksum has changed
-// (i.e. level was updated). If set to `false`, this functionality is turned off.
-//
-// @mem fastReload
- "fastReload", &Settings::FastReload);
+ void AnimSettings::Register(sol::table& parent)
+ {
+ parent.create().new_usertype(
+ ScriptReserved_AnimSettings, sol::constructors(),
+ sol::call_constructor, sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(AnimSettings, ScriptReserved_AnimSettings),
+
+ /// Extended crawl moveset.
+ // @tfield bool crawlExtended when enabled, player will be able to traverse across one-click steps in crawlspaces.
+ "crawlExtended", &AnimSettings::CrawlExtended,
+
+ /// Crouch roll.
+ // @tfield bool crouchRoll when enabled, player can perform crawlspace roll by pressing sprint key.
+ "crouchRoll", &AnimSettings::CrouchRoll,
+
+ /// Crawlspace dive.
+ // @tfield bool crawlspaceSwandive when enabled, player will be able to swandive into crawlspaces.
+ "crawlspaceSwandive", &AnimSettings::CrawlspaceDive,
+
+ // Overhang climbing.
+ // @tfield bool overhangClimb enables overhang climbing feature. Currently does not work.
+ "overhangClimb", &AnimSettings::OverhangClimb,
+
+ // Extended slide mechanics.
+ // @tfield bool slideExtended if enabled, player will be able to change slide direction with controls. Currently does not work.
+ "slideExtended", &AnimSettings::SlideExtended,
+
+ /// Sprint jump.
+ // @tfield bool sprintJump if enabled, player will be able to perform extremely long jump when sprinting.
+ "sprintJump", &AnimSettings::SprintJump,
+
+ /// Ledge jumps.
+ // @tfield bool ledgeJumps if this setting is enabled, player will be able to jump upwards while hanging on the ledge.
+ "ledgeJumps", &AnimSettings::LedgeJumps,
+
+ /// Pose timeout.
+ // @tfield int poseTimeout if this setting is larger than 0, idle standing pose animation will be performed after given timeout (in seconds).
+ "poseTimeout", &AnimSettings::PoseTimeout);
+ }
+
+ /// Camera
+ // @section Camera
+ // Parameters to customize camera and everything related to it.
+
+ void CameraSettings::Register(sol::table& parent)
+ {
+ parent.create().new_usertype(ScriptReserved_CameraSettings, sol::constructors(),
+ sol::call_constructor, sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(CameraSettings, ScriptReserved_CameraSettings),
+
+ /// Determines highlight color in binocular mode.
+ // @tfield Color binocularLightColor color of highlight, when player presses action. Zero color means there will be no highlight.
+ "binocularLightColor", &CameraSettings::BinocularLightColor,
+
+ /// Determines highlight color in lasersight mode.
+ // @tfield Color lasersightLightColor lasersight highlight color. Zero color means there will be no highlight.
+ "lasersightLightColor", &CameraSettings::LasersightLightColor,
+
+ /// Specify whether camera can collide with objects.
+ // @tfield bool objectCollision when enabled, camera will collide with moveables and statics. Disable or TR4-like camera behaviour.
+ "objectCollision", &CameraSettings::ObjectCollision);
+ }
+
+ /// Flare
+ // @section Flare
+ // These settings change appearance and behaviour of a flare.
+
+ void FlareSettings::Register(sol::table& parent)
+ {
+ parent.create().new_usertype(ScriptReserved_FlareSettings, sol::constructors(),
+ sol::call_constructor, sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(FlareSettings, ScriptReserved_FlareSettings),
+
+ /// Flare color.
+ // @tfield Color color flare color. Used for sparks and lensflare coloring as well.
+ "color", &FlareSettings::Color,
+
+ /// Muzzle offset.
+ // @tfield Vec3 offset a relative muzzle offset where light and particle effects originate from.
+ "offset", &FlareSettings::Offset,
+
+ /// Light range.
+ // @tfield int range flare light radius or range. Represented in "clicks" equal to 256 world units.
+ "range", &FlareSettings::Range,
+
+ /// Burn timeout.
+ // @tfield int timeout flare burn timeout. Flare will stop working after given timeout (specified in seconds).
+ "timeout", &FlareSettings::Timeout,
+
+ /// Default flare pickup count.
+ // @tfield int pickupCount specifies amount of flares that you get when you pick up a box of flares.
+ "pickupCount", &FlareSettings::PickupCount,
+
+ /// Lens flare brightness.
+ // @tfield float lensflareBrightness brightness multiplier. Specifies how bright lens flare is in relation to light (on a range from 0 to 1).
+ "lensflareBrightness", &FlareSettings::LensflareBrightness,
+
+ /// Toggle spark effect.
+ // @tfield bool sparks spark effect. Determines whether flare generates sparks when burning.
+ "sparks", &FlareSettings::Sparks,
+
+ /// Toggle smoke effect.
+ // @tfield bool smoke smoke effect. Determines whether flare generates smoke when burning.
+ "smoke", &FlareSettings::Smoke,
+
+ /// Toggle flicker effect.
+ // @tfield bool flicker light and lensflare flickering. When turned off, flare light will be constant.
+ "flicker", &FlareSettings::Flicker);
+ }
+
+ /// Hair
+ // @section Hair
+ // This is a table of braid object settings.
+ // Table consists of three entries, with first one representing classic Lara braid, and 2 and 3 representing left and right young Lara braids respectively.
+ // Therefore, if you want to access classic Lara braid settings, use `settings.Hair[1]`, and so on.
+
+ void HairSettings::Register(sol::table& parent)
+ {
+ parent.create().new_usertype(ScriptReserved_HairSettings, sol::constructors(),
+ sol::call_constructor, sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(HairSettings, ScriptReserved_HairSettings),
+
+ /// Root mesh to which hair object will attach to.
+ // @tfield int mesh index of a root mesh to which hair will attach. Root mesh may be different for each hair object.
+ "rootMesh", &HairSettings::RootMesh,
+
+ /// Relative braid offset to a headmesh.
+ // @tfield Vec3 offset specifies how braid is positioned in relation to a headmesh.
+ "offset", &HairSettings::Offset,
+
+ /// Braid connection indices.
+ // @tfield table indices a list of headmesh's vertex connection indices. Each index corresponds to nearest braid rootmesh vertex. Amount of indices is unlimited.
+ "indices", &HairSettings::Indices);
+ }
+
+ /// Hud
+ // @section Hud
+ // These settings determine visibility of particular in-game HUD elements.
+
+ void HudSettings::Register(sol::table& parent)
+ {
+ parent.create().new_usertype(ScriptReserved_HudSettings, sol::constructors(),
+ sol::call_constructor, sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(HudSettings, ScriptReserved_HudSettings),
+
+ /// Toggle in-game status bars visibility.
+ // @tfield bool statusBars if disabled, all status bars (health, air, stamina) will be hidden.
+ "statusBars", &HudSettings::StatusBars,
+
+ /// Toggle loading bar visibility.
+ // @tfield bool loadingBar if disabled, loading bar will be invisible in game.
+ "loadingBar", &HudSettings::LoadingBar,
+
+ /// Toggle speedometer visibility.
+ // @tfield bool speedometer if disabled, speedometer will be invisible in game.
+ "speedometer", &HudSettings::Speedometer,
+
+ /// Toggle pickup notifier visibility.
+ // @tfield bool pickupNotifier if disabled, pickup notifier will be invisible in game.
+ "pickupNotifier", &HudSettings::PickupNotifier);
+ }
+
+ /// Physics
+ // @section Physics
+ // Here you will find various settings for game world physics.
+
+ void PhysicsSettings::Register(sol::table& parent)
+ {
+ parent.create().new_usertype(ScriptReserved_PhysicsSettings, sol::constructors(),
+ sol::call_constructor, sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(PhysicsSettings, ScriptReserved_PhysicsSettings),
+
+ /// Global world gravity.
+ // @tfield float gravity specifies global gravity. Mostly affects Lara and several other objects.
+ "gravity", &PhysicsSettings::Gravity,
+
+ /// Swim velocity.
+ // @tfield float swimVelocity specifies swim velocity for Lara. Affects both surface and underwater.
+ "swimVelocity", &PhysicsSettings::SwimVelocity);
+ }
+
+ /// Weapons
+ // @section Weapons
+ // This is a table of weapon settings, with several parameters available for every weapon.
+ // Access particular weapon's settings by using @{Objects.WeaponType} as an index for this table, e.g. `settings.Weapons[Flow.WeaponType.PISTOLS]`.
+
+ void WeaponSettings::Register(sol::table& parent)
+ {
+ parent.create().new_usertype(ScriptReserved_WeaponSettings, sol::constructors(),
+ sol::call_constructor, sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(WeaponSettings, ScriptReserved_WeaponSettings),
+
+ /// Shooting accuracy.
+ // @tfield float accuracy determines accuracy range in angles (smaller angles mean higher accuracy). Applicable only for firearms.
+ "accuracy", &WeaponSettings::Accuracy,
+
+ /// Targeting distance.
+ // @tfield float targetingDistance specifies maximum targeting distance in world units (1 block = 1024 world units) for a given weapon.
+ "targetingDistance", &WeaponSettings::Distance,
+
+ /// Shooting interval.
+ // @tfield float interval specifies an interval (in frames), after which Lara is able to shoot again. Not applicable for backholster weapons.
+ "interval", &WeaponSettings::Interval,
+
+ /// Damage.
+ // @tfield int damage amount of hit points taken for every hit.
+ "damage", &WeaponSettings::Damage,
+
+ /// Alternate damage.
+ // @tfield int alternateDamage for Revolver and HK, specifies damage in lasersight mode. For crossbow, specifies damage for explosive ammo.
+ "alternateDamage", &WeaponSettings::AlternateDamage,
+
+ /// Water level.
+ // @tfield int waterLevel specifies water depth, at which Lara will put weapons back into holsters, indicating it's not possible to use it in water.
+ "waterLevel", &WeaponSettings::WaterLevel,
+
+ /// Default ammo pickup count.
+ // @tfield int pickupCount amount of ammo which is given with every ammo pickup for this weapon.
+ "pickupCount", &WeaponSettings::PickupCount,
+
+ /// Gunflash color.
+ // @tfield Color flashColor specifies the color of the gunflash. Applicable only for firearms.
+ "flashColor", &WeaponSettings::FlashColor,
+
+ /// Gunflash range.
+ // @tfield Color flashRange specifies the range of the gunflash. Applicable only for firearms.
+ "flashRange", &WeaponSettings::FlashRange,
+
+ /// Gunflash duration.
+ // @tfield int flashDuration specifies the duration of a gunflash effect. Applicable only for firearms.
+ "flashDuration", &WeaponSettings::FlashDuration,
+
+ /// Gun smoke.
+ // @tfield bool smoke if set to true, indicates that weapon emits gun smoke. Not applicable for crossbow and harpoon gun.
+ "smoke", &WeaponSettings::Smoke,
+
+ /// Gun shell.
+ // @tfield bool shell if set to true, indicates that weapon emits gun shell. Applicable only for firearms.
+ "shell", &WeaponSettings::Shell,
+
+ /// Display muzzle flash.
+ // @tfield bool muzzleFlash specifies whether muzzle flash should be displayed or not. Applicable only for firearms.
+ "muzzleFlash", &WeaponSettings::MuzzleFlash,
+
+ /// Colorize muzzle flash.
+ // @tfield bool colorizeMuzzleFlash specifies whether muzzle flash should be tinted with the same color as gunflash color. Applicable only for firearms.
+ "colorizeMuzzleFlash", &WeaponSettings::ColorizeMuzzleFlash);
+ }
+
+ /// System
+ // @section System
+ // Global system settings that is not directly related to gameplay.
+
+ void SystemSettings::Register(sol::table& parent)
+ {
+ parent.create().new_usertype(ScriptReserved_SystemSettings, sol::constructors(),
+ sol::call_constructor, sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(SystemSettings, ScriptReserved_SystemSettings),
+
+ /// How should the application respond to script errors?
+ // @tfield Flow.ErrorMode errorMode error mode to use. */
+ "errorMode", &SystemSettings::ErrorMode,
+
+ /// Can the game utilize the fast reload feature?
+ // When set to `true`, the game will attempt to perform fast savegame reloading if current level is the same as
+ // the level loaded from the savegame. It will not work if the level timestamp or checksum has changed
+ // (i.e. level was updated). If set to `false`, this functionality is turned off.
+ // @tfield bool fastReload toggle fast reload on or off.
+ "fastReload", &SystemSettings::FastReload);
+ }
}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.h b/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.h
index 62dc474a8..4c70de985 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Settings/Settings.h
@@ -1,20 +1,123 @@
#pragma once
+#include "Game/Lara/lara_struct.h"
#include "Scripting/Internal/ScriptAssert.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
+#include "Specific/clock.h"
-namespace sol { class state; }
-
-static const std::unordered_map ERROR_MODES
+namespace TEN::Scripting
{
- { "SILENT", ErrorMode::Silent },
- { "WARN", ErrorMode::Warn },
- { "TERMINATE", ErrorMode::Terminate }
-};
+ struct AnimSettings
+ {
+ int PoseTimeout = 20; // AFK pose timeout.
-struct Settings
-{
- ErrorMode ErrorMode = ErrorMode::Warn;
- bool FastReload = true;
+ bool SlideExtended = false; // Extended slope sliding functionality (not ready yet).
+ bool SprintJump = false; // Sprint jump.
+ bool CrawlspaceDive = true; // Dive into crawlspaces.
+ bool CrawlExtended = true; // Extended crawl moveset.
+ bool CrouchRoll = true; // Crouch roll.
+ bool OverhangClimb = false; // Overhang functionality.
+ bool LedgeJumps = false; // Jump up or back from a ledge.
- static void Register(sol::table& parent);
-};
+ static void Register(sol::table& parent);
+ };
+
+ struct CameraSettings
+ {
+ ScriptColor BinocularLightColor = { 192, 192, 96 };
+ ScriptColor LasersightLightColor = { 255, 0, 0 };
+ bool ObjectCollision = true;
+
+ static void Register(sol::table& parent);
+ };
+
+ struct FlareSettings
+ {
+ ScriptColor Color = ScriptColor(128, 64, 0);
+ Vec3 Offset = Vec3(0, 0, 41);
+ float LensflareBrightness = 0.5f;
+ bool Sparks = true;
+ bool Smoke = true;
+ bool Flicker = true;
+ int Range = 9;
+ int Timeout = 60;
+ int PickupCount = 12;
+
+ static void Register(sol::table& parent);
+ };
+
+ struct HairSettings
+ {
+ int RootMesh = LM_HEAD;
+ Vec3 Offset = {};
+ std::vector Indices = {};
+
+ static void Register(sol::table& parent);
+ };
+
+ struct HudSettings
+ {
+ bool StatusBars = true;
+ bool LoadingBar = true;
+ bool Speedometer = true;
+ bool PickupNotifier = true;
+
+ static void Register(sol::table& parent);
+ };
+
+ struct PhysicsSettings
+ {
+ float Gravity = 6.0f;
+ float SwimVelocity = 50.0f;
+
+ static void Register(sol::table& parent);
+ };
+
+ struct SystemSettings
+ {
+ ErrorMode ErrorMode = ErrorMode::Warn;
+ bool FastReload = true;
+
+ static void Register(sol::table& parent);
+ };
+
+ struct WeaponSettings
+ {
+ float Accuracy = 0.0f;
+ float Distance = BLOCK(8);
+
+ int Interval = 0;
+ int WaterLevel = 0;
+ int Damage = 0;
+ int AlternateDamage = 0;
+ int PickupCount = 0;
+
+ ScriptColor FlashColor = ScriptColor(192, 128, 0);
+ int FlashRange = 12;
+ int FlashDuration = 0;
+
+ bool Smoke = false;
+ bool Shell = false;
+ bool MuzzleFlash = true;
+ bool ColorizeMuzzleFlash = false;
+
+ static void Register(sol::table& parent);
+ };
+
+ struct Settings
+ {
+ AnimSettings Animations = {};
+ CameraSettings Camera = {};
+ FlareSettings Flare = {};
+ std::array Hair = {};
+ HudSettings Hud = {};
+ PhysicsSettings Physics = {};
+ SystemSettings System = {};
+ std::array Weapons = {};
+
+ Settings();
+
+ static void Register(sol::table& parent);
+ };
+}
\ No newline at end of file
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp
index e37d1dbeb..a686bd988 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp
@@ -4,7 +4,7 @@
/*** Describes a layer of moving clouds.
As seen in TR4's City of the Dead.
-@tenclass Flow.SkyLayer
+@tenprimitive Flow.SkyLayer
@pragma nostrip
*/
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.h b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.h
index 9a84436de..d9231f790 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.h
@@ -1,6 +1,6 @@
#pragma once
-#include "Scripting/Internal/TEN/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
namespace sol {
class state;
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp
index 60d277a17..2194bfd78 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp
@@ -8,7 +8,7 @@ using namespace TEN::Effects::Environment;
/// Represents a starfield.
//
-// @tenclass Flow.Starfield
+// @tenprimitive Flow.Starfield
// @pragma nostrip
namespace TEN::Scripting
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp
new file mode 100644
index 000000000..fb01d325d
--- /dev/null
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.cpp
@@ -0,0 +1,63 @@
+#include "framework.h"
+#include "Scripting/Internal/TEN/Flow/Statistics/Statistics.h"
+
+#include "Scripting/Internal/ReservedScriptNames.h"
+#include "Scripting/Internal/ScriptUtil.h"
+
+/***
+A set of gameplay statistics. Can be accessed using @{Flow.GetStatistics} and @{Flow.SetStatistics} functions.
+
+@tenclass Flow.Statistics
+@pragma nostrip
+*/
+
+namespace TEN::Scripting
+{
+ void Statistics::Register(sol::table& parent)
+ {
+ parent.new_usertype(
+ ScriptReserved_Statistics, sol::constructors(),
+ sol::call_constructor, sol::constructors(),
+ sol::meta_function::new_index, newindex_error_maker(Statistics, ScriptReserved_Statistics),
+
+ /*** Ammo hits.
+ @tfield int ammoHits amount of successful enemy hits.
+ */
+ "ammoHits", &Statistics::AmmoHits,
+
+ /*** Ammo used.
+ @tfield int ammoUsed amount of used ammo.
+ */
+ "ammoUsed", &Statistics::AmmoUsed,
+
+ /*** Distance traveled.
+ @tfield int traveledDistance amount of traveled distance in world units. One meter is 420 world units.
+ */
+ "traveledDistance", &Statistics::Distance,
+
+ /*** Health packs used.
+ @tfield int healthPacksUsed amount of used medipacks.
+ */
+ "healthPacksUsed", &Statistics::HealthUsed,
+
+ /*** Damage taken.
+ @tfield int damageTaken overall amount of taken damage.
+ */
+ "damageTaken", &Statistics::DamageTaken,
+
+ /*** Kills.
+ @tfield int kills amount of killed enemies.
+ */
+ "kills", &Statistics::Kills,
+
+ /*** Secrets.
+ @tfield int secrets amount of found secrets.
+ */
+ "secrets", &Statistics::Secrets,
+
+ /*** Time taken.
+ @tfield Time timeTaken amount of time passed.
+ */
+ "timeTaken", &Statistics::TimeTaken);
+ }
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.h b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.h
new file mode 100644
index 000000000..46ce309c2
--- /dev/null
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Statistics/Statistics.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "Scripting/Internal/TEN/Types/Time/Time.h"
+
+namespace sol{ class state; }
+
+namespace TEN::Scripting
+{
+ struct Statistics
+ {
+ Time TimeTaken = {};
+ unsigned int Distance = 0;
+ unsigned int AmmoHits = 0;
+ unsigned int AmmoUsed = 0;
+ unsigned int HealthUsed = 0;
+ unsigned int DamageTaken = 0;
+ unsigned int Kills = 0;
+ unsigned int Secrets = 0;
+
+ static void Register(sol::table&);
+ };
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Input/ActionIDs.h b/TombEngine/Scripting/Internal/TEN/Input/ActionIDs.h
index 6a114ae81..93b5a5614 100644
--- a/TombEngine/Scripting/Internal/TEN/Input/ActionIDs.h
+++ b/TombEngine/Scripting/Internal/TEN/Input/ActionIDs.h
@@ -12,9 +12,8 @@ Constants for action key IDs.
@pragma nostrip
*/
-/*** Input.ActionID constants.
-
-The following constants are inside ActionID.
+/*** Table of Input.ActionID constants.
+To be used with @{Input.KeyIsHit}, @{Input.KeyIsHeld}, and similar functions.
FORWARD
BACK
@@ -61,11 +60,7 @@ The following constants are inside ActionID.
SAVE
LOAD
-@section Input.ActionID
-*/
-
-/*** Table of action ID constants (for use with KeyIsHeld / KeyIsHit / etc commands).
-@table CONSTANT_STRING_HERE
+@table Input.ActionID
*/
static const std::unordered_map ACTION_IDS
diff --git a/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp b/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp
index 803e02ec1..5db8c91f2 100644
--- a/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Input/InputHandler.cpp
@@ -6,7 +6,7 @@
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptUtil.h"
#include "Scripting/Internal/TEN/Input/ActionIDs.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
#include "Specific/Input/Input.h"
using namespace TEN::Input;
diff --git a/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp b/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp
index d34f7c21e..9bc36f302 100644
--- a/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp
@@ -1,8 +1,6 @@
#include "framework.h"
#include "LogicHandler.h"
-#include
-
#include "Game/control/volume.h"
#include "Game/effects/Electricity.h"
#include "Game/Lara/lara.h"
@@ -10,12 +8,13 @@
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/ScriptUtil.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
#include "Scripting/Internal/TEN/Logic/LevelFunc.h"
#include "Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h"
-#include "Scripting/Internal/TEN/Rotation/Rotation.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
+#include "Scripting/Internal/TEN/Types/Time/Time.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
using namespace TEN::Effects::Electricity;
@@ -149,6 +148,7 @@ void SetVariable(sol::table tab, sol::object key, sol::object value)
if (value.is() ||
value.is() ||
value.is() ||
+ value.is() ||
value.is())
{
PutVar(tab, key, value);
@@ -541,6 +541,11 @@ void LogicHandler::SetVariables(const std::vector& vars, bool onlyLeve
auto vec3 = Rotation(std::get(vars[second]));
solTables[i][vars[first]] = vec3;
}
+ else if (vars[second].index() == int(SavedVarType::Time))
+ {
+ auto time = Time(std::get(vars[second]));
+ solTables[i][vars[first]] = time;
+ }
else if (vars[second].index() == int(SavedVarType::Color))
{
auto color = D3DCOLOR(std::get(vars[second]));
@@ -765,6 +770,10 @@ void LogicHandler::GetVariables(std::vector& vars)
{
putInVars(Handle(second.as(), varsMap, numVars, vars));
}
+ else if (second.is())
+ {
+ putInVars(Handle(second.as(), varsMap, numVars, vars));
+ }
else if (second.is())
{
putInVars(Handle(second.as(), varsMap, numVars, vars));
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/AIObject/AIObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/AIObject/AIObject.cpp
index 49bfe900c..4e3c522a5 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/AIObject/AIObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/AIObject/AIObject.cpp
@@ -1,11 +1,12 @@
#pragma once
-#include "framework.h"
-#include "AIObject.h"
-#include "Scripting/Internal/ScriptAssert.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
-#include "Scripting/Internal/ScriptUtil.h"
+#include "framework.h"
+#include "Scripting/Internal/TEN/Objects/AIObject/AIObject.h"
+
#include "Scripting/Internal/ReservedScriptNames.h"
+#include "Scripting/Internal/ScriptAssert.h"
+#include "Scripting/Internal/ScriptUtil.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
/***
AI object
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Camera/CameraObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Camera/CameraObject.cpp
index 557d24bb8..b6ebb10d2 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Camera/CameraObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Camera/CameraObject.cpp
@@ -5,9 +5,9 @@
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/ScriptUtil.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Specific/LevelCameraInfo.h"
#include "Specific/level.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
/***
Basic cameras that can point at Lara or at a CAMERA_TARGET.
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Lara/AmmoTypes.h b/TombEngine/Scripting/Internal/TEN/Objects/Lara/AmmoTypes.h
index 067eae61c..70ed6d8c3 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Lara/AmmoTypes.h
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Lara/AmmoTypes.h
@@ -7,33 +7,29 @@ Constants for player weapon ammo types.
@pragma nostrip
*/
-/*** Objects.AmmoType constants.
+/*** Table of Objects.AmmoType constants.
+To be used with @{Objects.LaraObject.GetAmmoType} function.
-The following constants are inside AmmoType.
+ - `NONE`
+ - `PISTOLS`
+ - `REVOLVER`
+ - `UZI`
+ - `SHOTGUN_NORMAL`
+ - `SHOTGUN_WIDE`
+ - `HK`
+ - `CROSSBOW_BOLT_NORMAL`
+ - `CROSSBOW_BOLT_POISON`
+ - `CROSSBOW_BOLT_EXPLOSIVE`
+ - `GRENADE_NORMAL`
+ - `GRENADE_FRAG`
+ - `GRENADE_FLASH`
+ - `HARPOON`
+ - `ROCKET`
- NONE
- PISTOLS
- REVOLVER
- UZI
- SHOTGUN_NORMAL
- SHOTGUN_WIDE
- HK
- CROSSBOW_BOLT_NORMAL
- CROSSBOW_BOLT_POISON
- CROSSBOW_BOLT_EXPLOSIVE
- GRENADE_NORMAL
- GRENADE_FRAG
- GRENADE_FLASH
- HARPOON
- ROCKET
-
-@section Objects.AmmoType
+@table Objects.AmmoType
*/
-/*** AmmoType constants table.
-@table CONSTANT_STRING_HERE
-*/
-static const std::unordered_map PLAYER_AMMO_TYPES
+static const std::unordered_map AMMO_TYPES
{
{ "PISTOLS", PlayerAmmoType::Pistol },
{ "REVOLVER", PlayerAmmoType::Revolver },
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp
index c3e2cb273..709fd8cb1 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp
@@ -186,13 +186,11 @@ HandStatus LaraObject::GetHandStatus() const
return HandStatus{ lara->Control.HandStatus };
}
-//todo make these into enums - Squidshire 18/11/2022
-
/// Get actual weapon type of Lara
// @function LaraObject:GetWeaponType
// @usage
// local weaponType = Lara:GetWeaponType()
-// @treturn int weapon type 0=None, 1=Pistols, 2=Revolver, 3=Uzi, 4=Shotgun, 5=HK, 6=Crossbow, 7=Flare, 8=Torch, 9=GrenadeLauncher, 10=Harpoon, 11=RocketLauncher.
+// @treturn Flow.WeaponType current weapon type.
LaraWeaponType LaraObject::GetWeaponType() const
{
auto* lara = GetLaraInfo(m_item);
@@ -202,22 +200,9 @@ LaraWeaponType LaraObject::GetWeaponType() const
/// Set Lara weapon type
// @function LaraObject:SetWeaponType
// @usage
-// Lara:SetWeaponType(LaraWeaponType.PISTOLS, false)
-// @tparam LaraWeaponType weaponType
-// Must be one of:
-// NONE
-// PISTOLS
-// REVOLVER
-// UZI
-// SHOTGUN
-// HK
-// CROSSBOW
-// FLARE
-// TORCH
-// GRENADELAUNCHER
-// HARPOONGUN
-// ROCKETLAUNCHER
-// @tparam bool activate true = let her also draw the weapons, set torch lit. false = let Laras new weapons remain holstered until she draws them, set torch unlit.
+// Lara:SetWeaponType(WeaponType.PISTOLS, false)
+// @tparam Flow.WeaponType weaponType
+// @tparam bool activate if `true`, also draw the weapons or set torch lit. If `false`, keep weapons holstered or leave torch unlit.
void LaraObject::SetWeaponType(LaraWeaponType weaponType, bool activate)
{
auto* lara = GetLaraInfo(m_item);
@@ -242,9 +227,10 @@ void LaraObject::SetWeaponType(LaraWeaponType weaponType, bool activate)
}
}
+
/// Get player weapon ammo type.
// @function LaraObject:GetAmmoType
-// @treturn int player weapon ammo type
+// @treturn Flow.AmmoType player weapon ammo type
// @usage
// local CurrentAmmoType = Lara:GetAmmoType()
int LaraObject::GetAmmoType() const
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.h b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.h
index 752560614..a5bb6f406 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.h
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.h
@@ -2,24 +2,6 @@
#include "Game/Lara/lara_struct.h"
#include "Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h"
-static const std::unordered_map LaraWeaponTypeMap
-{
- { "NONE", LaraWeaponType::None },
- { "PISTOLS", LaraWeaponType::Pistol },
- { "REVOLVER", LaraWeaponType::Revolver },
- { "UZI", LaraWeaponType::Uzi },
- { "SHOTGUN", LaraWeaponType::Shotgun },
- { "HK", LaraWeaponType::HK },
- { "CROSSBOW", LaraWeaponType::Crossbow },
- { "FLARE", LaraWeaponType::Flare },
- { "TORCH", LaraWeaponType::Torch },
- { "GRENADELAUNCHER", LaraWeaponType::GrenadeLauncher },
- { "HARPOONGUN", LaraWeaponType::HarpoonGun },
- { "ROCKETLAUNCHER", LaraWeaponType::RocketLauncher },
- { "SNOWMOBILE", LaraWeaponType::Snowmobile },
- { "NUMWEAPONS", LaraWeaponType::NumWeapons}
-};
-
static const std::unordered_map HandStatusMap
{
{ "FREE", HandStatus::Free },
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Lara/WeaponTypes.h b/TombEngine/Scripting/Internal/TEN/Objects/Lara/WeaponTypes.h
new file mode 100644
index 000000000..ea46fc609
--- /dev/null
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Lara/WeaponTypes.h
@@ -0,0 +1,50 @@
+#pragma once
+#include "framework.h"
+
+#include "Game/control/control.h"
+#include "Game/Lara/lara_struct.h"
+
+/// Constants for weapon types.
+// @enum Objects.WeaponType
+// @pragma nostrip
+
+/// Objects.WeaponType constants. To be used with @{Objects.LaraObject.GetWeaponType} and @{Objects.LaraObject.SetWeaponType} functions.
+//
+// Note that this enumeration also contains flare and torch - these are counted as "weapon" internally by the engine, and indicate
+// an object that is currently in Lara's hands.
+//
+// - `NONE`
+// - `PISTOLS`
+// - `UZIS`
+// - `REVOLVER`
+// - `SHOTGUN`
+// - `HK`
+// - `CROSSBOW`
+// - `FLARE`
+// - `TORCH`
+// - `GRENADE_LAUNCHER`
+// - `HARPOON_GUN`
+// - `ROCKET_LAUNCHER`
+//
+// @table Objects.WeaponType
+
+namespace TEN::Scripting
+{
+ static const auto WEAPON_TYPES = std::unordered_map
+ {
+ { "NONE", LaraWeaponType::None },
+ { "PISTOL", LaraWeaponType::Pistol },
+ { "PISTOLS", LaraWeaponType::Pistol },
+ { "REVOLVER", LaraWeaponType::Revolver },
+ { "UZI", LaraWeaponType::Uzi },
+ { "UZIS", LaraWeaponType::Uzi },
+ { "SHOTGUN", LaraWeaponType::Shotgun },
+ { "HK", LaraWeaponType::HK },
+ { "CROSSBOW", LaraWeaponType::Crossbow },
+ { "FLARE", LaraWeaponType::Flare },
+ { "TORCH", LaraWeaponType::Torch },
+ { "GRENADE_LAUNCHER", LaraWeaponType::GrenadeLauncher },
+ { "HARPOON_GUN", LaraWeaponType::HarpoonGun },
+ { "ROCKET_LAUNCHER", LaraWeaponType::RocketLauncher }
+ };
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp
index a41dfdc69..37c7057a0 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp
@@ -14,11 +14,11 @@
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/ScriptUtil.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
#include "Scripting/Internal/TEN/Logic/LevelFunc.h"
#include "Scripting/Internal/TEN/Objects/ObjectsHandler.h"
-#include "Scripting/Internal/TEN/Rotation/Rotation.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Specific/level.h"
using namespace TEN::Collision::Floordata;
@@ -1263,7 +1263,7 @@ bool Moveable::GetValid() const
void Moveable::Destroy()
{
- if (m_num > NO_VALUE)
+ if (m_num > NO_VALUE)
{
dynamic_cast(g_GameScriptEntities)->RemoveMoveableFromMap(m_item, this);
s_callbackRemoveName(m_item->Name);
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h
index 2ad56a48a..3abf62860 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h
@@ -15,13 +15,15 @@ namespace sol
enum ItemStatus;
enum GAME_OBJECT_ID : short;
enum class EffectType;
-class Rotation;
class ScriptColor;
class Vec3;
struct ItemInfo;
+namespace TEN::Scripting { class Rotation; };
+
+using namespace TEN::Scripting;
using aiBitsArray = std::array;
-using aiBitsType = sol::as_table_t;
+using aiBitsType = sol::as_table_t;
class Moveable : public NamedBase
{
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableStatuses.h b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableStatuses.h
index b431315e2..e0275852b 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableStatuses.h
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableStatuses.h
@@ -10,20 +10,16 @@ Constants for moveable statuses.
@pragma nostrip
*/
-/*** Objects.MoveableStatus constants.
+/*** Table of Objects.MoveableStatus constants.
-The following constants are inside Objects.MoveableStatus.
+To be used with @{Objects.Moveable.GetStatus} and @{Objects.Moveable.SetStatus} functions.
- INACTIVE
- ACTIVE
- DEACTIVATED
- INVISIBLE
+ - `INACTIVE` - object was never activated.
+ - `ACTIVE` - object is active.
+ - `DEACTIVATED` - object was active before and was deactivated.
+ - `INVISIBLE` - object is invisible.
-@section Objects.MoveableStatus
-*/
-
-/*** Table of moveable statuses.
-@table CONSTANT_STRING_HERE
+@table Objects.MoveableStatus
*/
static const std::unordered_map MOVEABLE_STATUSES
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp b/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp
index df52b1c59..3dc237aba 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp
@@ -9,6 +9,7 @@
#include "Scripting/Internal/TEN/Objects/Camera/CameraObject.h"
#include "Scripting/Internal/TEN/Objects/Lara/AmmoTypes.h"
#include "Scripting/Internal/TEN/Objects/Lara/LaraObject.h"
+#include "Scripting/Internal/TEN/Objects/Lara/WeaponTypes.h"
#include "Scripting/Internal/TEN/Objects/Moveable/MoveableStatuses.h"
#include "Scripting/Internal/TEN/Objects/ObjectIDs.h"
#include "Scripting/Internal/TEN/Objects/Room/RoomFlags.h"
@@ -164,8 +165,8 @@ ObjectsHandler::ObjectsHandler(sol::state* lua, sol::table& parent) :
m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_ObjID, kObjIDs);
m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_RoomFlagID, ROOM_FLAG_IDS);
m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_RoomReverb, ROOM_REVERB_TYPES);
- m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_LaraWeaponType, LaraWeaponTypeMap);
- m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_PlayerAmmoType, PLAYER_AMMO_TYPES);
+ m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_WeaponType, WEAPON_TYPES);
+ m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_AmmoType, AMMO_TYPES);
m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_HandStatus, HandStatusMap);
m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_MoveableStatus, MOVEABLE_STATUSES);
}
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomFlags.h b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomFlags.h
index afebe0f45..71da196e3 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomFlags.h
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomFlags.h
@@ -10,23 +10,20 @@ Constants for room flag IDs.
@pragma nostrip
*/
-/*** Objects.RoomFlagID constants.
+/*** Table of Objects.RoomFlagID constants.
+To be used with @{Objects.Room.SetFlag} and @{Objects.Room.GetFlag} functions.
The following constants are inside RoomFlagID.
- WATER
- QUICKSAND
- SKYBOX
- WIND
- COLD
- DAMAGE
- NOLENSFLARE
+ - `WATER`
+ - `QUICKSAND`
+ - `SKYBOX`
+ - `WIND`
+ - `COLD`
+ - `DAMAGE`
+ - `NOLENSFLARE`
-@section Objects.RoomFlagID
-*/
-
-/*** Table of room flag ID constants (for use with Room:SetFlag / Room:GetFlag command).
-@table CONSTANT_STRING_HERE
+@table Objects.RoomFlagID
*/
static const std::unordered_map ROOM_FLAG_IDS
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomObject.cpp
index 3cac49f14..b7528cf6b 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomObject.cpp
@@ -5,10 +5,10 @@
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/ScriptUtil.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
#include "Scripting/Internal/TEN/Objects/Room/RoomFlags.h"
#include "Scripting/Internal/TEN/Objects/Room/RoomObject.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Sound/sound.h"
#include "Specific/level.h"
#include "Specific/trutils.h"
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomReverbTypes.h b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomReverbTypes.h
index 5c9e78bfb..6f27ccff5 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomReverbTypes.h
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomReverbTypes.h
@@ -10,21 +10,18 @@ Constants for room reverb types.
@pragma nostrip
*/
-/*** Objects.RoomReverb constants.
+/*** Table of Objects.RoomReverb constants.
+To be used with @{Objects.Room.GetReverbType} and @{Objects.Room.SetReverbType} functions.
The following constants are inside RoomReverb.
- OUTSIDE
- SMALL
- MEDIUM
- LARGE
- PIPE
+ - OUTSIDE
+ - SMALL
+ - MEDIUM
+ - LARGE
+ - PIPE
-@section Objects.RoomReverb
-*/
-
-/*** Table of room reverb constants (for use with Room:SetReverb / Room:GetReverb command).
-@table CONSTANT_STRING_HERE
+@table Objects.RoomReverb
*/
static const std::unordered_map ROOM_REVERB_TYPES
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Sink/SinkObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Sink/SinkObject.cpp
index 2c0a57d00..bd0fdd1be 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Sink/SinkObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Sink/SinkObject.cpp
@@ -5,7 +5,7 @@
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/ScriptUtil.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
/***
Sink
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/SoundSource/SoundSourceObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/SoundSource/SoundSourceObject.cpp
index 84eba0177..95347551a 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/SoundSource/SoundSourceObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/SoundSource/SoundSourceObject.cpp
@@ -5,7 +5,8 @@
#include "Sound/sound.h"
#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/ScriptUtil.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
+
/***
Sound source
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.cpp
index 2715fea57..89e46587f 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.cpp
@@ -1,14 +1,16 @@
-#pragma once
#include "framework.h"
#include "Game/effects/debris.h"
#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/TEN/Objects/Static/StaticObject.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
-#include "Scripting/Internal/TEN/Rotation/Rotation.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
#include "Scripting/Internal/ScriptUtil.h"
#include "Scripting/Internal/ReservedScriptNames.h"
+
+using namespace TEN::Scripting;
+
/***
Statics
@@ -24,8 +26,8 @@ Static::Static(MESH_INFO & ref) : m_mesh{ref}
void Static::Register(sol::table & parent)
{
- parent.new_usertype(ScriptReserved_Static,
- sol::no_constructor, // ability to spawn new ones could be added later
+ parent.new_usertype(
+ ScriptReserved_Static, sol::no_constructor, // Ability to spawn new ones could be added later.
sol::meta_function::index, IndexError,
sol::meta_function::new_index, NewIndexError,
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.h b/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.h
index 0b8e15976..1b883fd82 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.h
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Static/StaticObject.h
@@ -1,15 +1,14 @@
#pragma once
-#include "Scripting/Internal/TEN/Objects/NamedBase.h"
#include "Game/room.h"
+#include "Scripting/Internal/TEN/Objects/NamedBase.h"
-namespace sol {
- class state;
-}
-
-class Vec3;
-class Rotation;
class ScriptColor;
+class Vec3;
+namespace sol { class state; }
+namespace TEN::Scripting { class Rotation; }
+
+using namespace TEN::Scripting;
class Static : public NamedBase
{
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp
index a39198ad7..471d778a4 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp
@@ -5,8 +5,8 @@
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/ScriptUtil.h"
-#include "Scripting/Internal/TEN/Rotation/Rotation.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Specific/level.h"
/***
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.h b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.h
index 12c463632..b2ddc1187 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.h
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.h
@@ -1,11 +1,14 @@
#pragma once
+
#include "Game/Control/volume.h"
#include "Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h"
#include "Scripting/Internal/TEN/Objects/NamedBase.h"
-namespace sol { class state; }
-class Rotation;
class Vec3;
+namespace sol { class state; }
+namespace TEN::Scripting { class Rotation; }
+
+using namespace TEN::Scripting;
class Volume : public NamedBase
{
@@ -17,32 +20,38 @@ public:
static void Register(sol::table& parent);
- // Cosntructors and destructors
+ // Constructors and destructors
+
Volume(TriggerVolume& volume);
Volume(const Volume& other) = delete;
~Volume() = default;
// Getters
+
std::string GetName() const;
Vec3 GetPos() const;
Rotation GetRot() const;
Vec3 GetScale() const;
// Setters
+
void SetName(const std::string& name);
void SetRot(const Rotation& rot);
void SetPos(const Vec3& pos);
void SetScale(const Vec3& scale);
// Inquirers
+
bool GetActive() const;
bool IsMoveableInside(const Moveable& mov);
// Utilities
+
void Enable();
void Disable();
void ClearActivators();
// Operators
+
Volume& operator =(const Volume& other) = delete;
};
diff --git a/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.cpp b/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.cpp
deleted file mode 100644
index e12344984..000000000
--- a/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-#include "framework.h"
-#include "Scripting/Internal/TEN/Rotation/Rotation.h"
-
-#include "Math/Math.h"
-#include "Scripting/Internal/ReservedScriptNames.h"
-
-using namespace TEN::Math;
-
-/// Represents a degree-based 3D rotation.
-// All values are clamped to the range [0.0, 360.0].
-// @tenprimitive Rotation
-// @pragma nostrip
-
-void Rotation::Register(sol::table& parent)
-{
- using ctors = sol::constructors;
- parent.new_usertype(ScriptReserved_Rotation,
- ctors(),
- sol::call_constructor, ctors(),
- sol::meta_function::to_string, &Rotation::ToString,
- ScriptReserved_RotationDirection, &Rotation::Direction,
-
- /// (float) X angle component.
- // @mem x
- "x", &Rotation::x,
-
- /// (float) Y angle component.
- // @mem y
- "y", &Rotation::y,
-
- /// (float) Z angle component.
- // @mem z
- "z", &Rotation::z);
-}
-
-/// @tparam float x X angle component.
-// @tparam float y Y angle component.
-// @tparam float z Z angle component.
-// @treturn Rotation A Rotation.
-// @function Rotation
-Rotation::Rotation(float x, float y, float z)
-{
- this->x = x;
- this->y = y;
- this->z = z;
-}
-
-Rotation::Rotation(const EulerAngles& eulers)
-{
- x = TO_DEGREES(eulers.x);
- y = TO_DEGREES(eulers.y);
- z = TO_DEGREES(eulers.z);
-}
-
-Rotation::Rotation(const Vector3& vec)
-{
- x = vec.x;
- y = vec.y;
- z = vec.z;
-}
-
-Rotation::Rotation(const Pose& pose)
-{
- x = TO_DEGREES(pose.Orientation.x);
- y = TO_DEGREES(pose.Orientation.y);
- z = TO_DEGREES(pose.Orientation.z);
-}
-
-void Rotation::StoreInPHDPos(Pose& pose) const
-{
- pose.Orientation.x = ANGLE(x);
- pose.Orientation.y = ANGLE(y);
- pose.Orientation.z = ANGLE(z);
-}
-
-Rotation::operator Vector3() const
-{
- return Vector3(x, y, z);
-};
-
-/// Converts rotation to a direction normal.
-// @treturn Vec3 resulting normal calculated from this rotation.
-// @function Direction
-Vec3 Rotation::Direction() const
-{
- // Convert degrees to radians.
- float xRad = x * RADIAN;
- float yRad = y * RADIAN;
-
- // Calculate the direction vector.
- float dirX = sin(yRad) * cos(xRad);
- float dirY = -sin(xRad);
- float dirZ = cos(yRad) * cos(xRad);
-
- // Scale by the given distance.
- return Vec3(dirX, dirY, dirZ);
-}
-
-/// @tparam Rotation rotation this Rotation.
-// @treturn string A string showing the X, Y, and Z angle components of the Rotation.
-// @function __tostring
-std::string Rotation::ToString() const
-{
- return ("{ " + std::to_string(x) + ", " + std::to_string(y) + ", " + std::to_string(z) + " }");
-}
-
-EulerAngles Rotation::ToEulerAngles() const
-{
- return EulerAngles(ANGLE(x), ANGLE(y), ANGLE(z));
-}
diff --git a/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.h b/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.h
deleted file mode 100644
index 00ab7a96f..000000000
--- a/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#pragma once
-#include "Math/Objects/EulerAngles.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
-
-class EulerAngles;
-class Pose;
-namespace sol { class state; }
-
-class Rotation
-{
-public:
- static void Register(sol::table& parent);
-
- // Members
- float x = 0;
- float y = 0;
- float z = 0;
-
- // Constructors
- Rotation() = default;
- Rotation(float x, float y, float z);
- Rotation(const EulerAngles& eulers);
- Rotation(const Pose& pose);
- Rotation(const Vector3& vector);
-
- void StoreInPHDPos(Pose& pose) const;
-
- // Converters
- std::string ToString() const;
- EulerAngles ToEulerAngles() const;
- Vec3 Direction() const;
-
- // Operators
- operator Vector3() const;
-};
diff --git a/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp b/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp
index 7a5402cfb..b10324bfd 100644
--- a/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp
@@ -5,7 +5,7 @@
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptUtil.h"
#include "Scripting/Internal/TEN/Sound/SoundTrackTypes.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Sound/sound.h"
/// Functions for sound management.
diff --git a/TombEngine/Scripting/Internal/TEN/Sound/SoundTrackTypes.h b/TombEngine/Scripting/Internal/TEN/Sound/SoundTrackTypes.h
index 89cb55777..4ae631d98 100644
--- a/TombEngine/Scripting/Internal/TEN/Sound/SoundTrackTypes.h
+++ b/TombEngine/Scripting/Internal/TEN/Sound/SoundTrackTypes.h
@@ -7,19 +7,15 @@ Constants for the type of the audio tracks.
@pragma nostrip
*/
-/*** Sound.SoundTrackType constants.
+/*** Table of Sound.SoundTrackType constants.
+*
+To be used with sound track functions, such as @{Sound.PlayAudioTrack} and @{Sound.StopAudioTrack}.
-The following constants are inside SoundTrackType.
+ - `ONESHOT` - used for one-time music tracks.
+ - `LOOPED` - used for looped ambience or music.
+ - `VOICE` - used for dialogs. Also supports subtitles, set by @{Sound.GetCurrentSubtitle} function.
- ONESHOT
- LOOPED
- VOICE
-
-@section Sound.SoundTrackType
-*/
-
-/*** Table of sound track type constants (for use with sound track functions).
-@table CONSTANT_STRING_HERE
+@table Sound.SoundTrackType
*/
static const std::unordered_map SOUNDTRACK_TYPE
diff --git a/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.cpp b/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.cpp
index eee32ad9d..f6723e557 100644
--- a/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.cpp
@@ -1,11 +1,11 @@
#include "framework.h"
#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
-#include "Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h"
-#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/ReservedScriptNames.h"
+#include "Scripting/Internal/ScriptAssert.h"
#include "Scripting/Internal/ScriptUtil.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
/*** A string appearing on the screen.
Can be used for subtitles and "2001, somewhere in Egypt"-style messages.
diff --git a/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h b/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h
index 63e6630a8..005b9b4dd 100644
--- a/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h
+++ b/TombEngine/Scripting/Internal/TEN/Strings/DisplayString/DisplayString.h
@@ -1,8 +1,8 @@
#pragma once
#include "Game/control/control.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
/***
Constants for Display String Options.
@@ -10,16 +10,13 @@ Constants for Display String Options.
@pragma nostrip
*/
-/*** Strings.DisplayStringOption constants.
-
+/*** Strings.DisplayStringOption constants. To be used with @{Strings.DisplayString} class.
@table Strings.DisplayStringOption
- CENTER -- set the horizontal origin point to the center of the string.
- RIGHT -- set the horizontal origin point to right of the string.
- SHADOW -- gives the string a small drop shadow.
- BLINK -- blinks the string
-*/
-/***
+ - `CENTER` - set the horizontal origin point to the center of the string.
+ - `RIGHT` - set the horizontal origin point to right of the string.
+ - `SHADOW` - gives the string a small drop shadow.
+ - `BLINK` - blinks the string
*/
enum class DisplayStringOptions
diff --git a/TombEngine/Scripting/Internal/TEN/Color/Color.cpp b/TombEngine/Scripting/Internal/TEN/Types/Color/Color.cpp
similarity index 98%
rename from TombEngine/Scripting/Internal/TEN/Color/Color.cpp
rename to TombEngine/Scripting/Internal/TEN/Types/Color/Color.cpp
index 88af10b3f..6974c4bb6 100644
--- a/TombEngine/Scripting/Internal/TEN/Color/Color.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Types/Color/Color.cpp
@@ -1,5 +1,5 @@
#include "framework.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
/// Represents an RGBA or RGB color.
// Components are specified in bytes. All values are clamped to the range [0, 255].
diff --git a/TombEngine/Scripting/Internal/TEN/Color/Color.h b/TombEngine/Scripting/Internal/TEN/Types/Color/Color.h
similarity index 100%
rename from TombEngine/Scripting/Internal/TEN/Color/Color.h
rename to TombEngine/Scripting/Internal/TEN/Types/Color/Color.h
diff --git a/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.cpp b/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.cpp
new file mode 100644
index 000000000..01a4baff1
--- /dev/null
+++ b/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.cpp
@@ -0,0 +1,113 @@
+#include "framework.h"
+#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
+
+#include "Math/Math.h"
+#include "Scripting/Internal/ReservedScriptNames.h"
+
+using namespace TEN::Math;
+
+namespace TEN::Scripting
+{
+ /// Represents a degree-based 3D rotation.
+ // All values are clamped to the range [0.0, 360.0].
+ // @tenprimitive Rotation
+ // @pragma nostrip
+
+ void Rotation::Register(sol::table& parent)
+ {
+ using ctors = sol::constructors;
+ parent.new_usertype(ScriptReserved_Rotation,
+ ctors(),
+ sol::call_constructor, ctors(),
+ sol::meta_function::to_string, &Rotation::ToString,
+ ScriptReserved_RotationDirection, &Rotation::Direction,
+
+ /// (float) X angle component.
+ // @mem x
+ "x", &Rotation::x,
+
+ /// (float) Y angle component.
+ // @mem y
+ "y", &Rotation::y,
+
+ /// (float) Z angle component.
+ // @mem z
+ "z", &Rotation::z);
+ }
+
+ /// @tparam float x X angle component.
+ // @tparam float y Y angle component.
+ // @tparam float z Z angle component.
+ // @treturn Rotation A Rotation.
+ // @function Rotation
+ Rotation::Rotation(float x, float y, float z)
+ {
+ this->x = x;
+ this->y = y;
+ this->z = z;
+ }
+
+ Rotation::Rotation(const EulerAngles& eulers)
+ {
+ x = TO_DEGREES(eulers.x);
+ y = TO_DEGREES(eulers.y);
+ z = TO_DEGREES(eulers.z);
+ }
+
+ Rotation::Rotation(const Vector3& vec)
+ {
+ x = vec.x;
+ y = vec.y;
+ z = vec.z;
+ }
+
+ Rotation::Rotation(const Pose& pose)
+ {
+ x = TO_DEGREES(pose.Orientation.x);
+ y = TO_DEGREES(pose.Orientation.y);
+ z = TO_DEGREES(pose.Orientation.z);
+ }
+
+ void Rotation::StoreInPHDPos(Pose& pose) const
+ {
+ pose.Orientation.x = ANGLE(x);
+ pose.Orientation.y = ANGLE(y);
+ pose.Orientation.z = ANGLE(z);
+ }
+
+ Rotation::operator Vector3() const
+ {
+ return Vector3(x, y, z);
+ };
+
+ /// Converts rotation to a direction normal.
+ // @treturn Vec3 resulting normal calculated from this rotation.
+ // @function Direction
+ Vec3 Rotation::Direction() const
+ {
+ // Convert degrees to radians.
+ float xRad = x * RADIAN;
+ float yRad = y * RADIAN;
+
+ // Calculate the direction vector.
+ float dirX = sin(yRad) * cos(xRad);
+ float dirY = -sin(xRad);
+ float dirZ = cos(yRad) * cos(xRad);
+
+ // Scale by the given distance.
+ return Vec3(dirX, dirY, dirZ);
+ }
+
+ /// @tparam Rotation rotation this Rotation.
+ // @treturn string A string showing the X, Y, and Z angle components of the Rotation.
+ // @function __tostring
+ std::string Rotation::ToString() const
+ {
+ return ("{ " + std::to_string(x) + ", " + std::to_string(y) + ", " + std::to_string(z) + " }");
+ }
+
+ EulerAngles Rotation::ToEulerAngles() const
+ {
+ return EulerAngles(ANGLE(x), ANGLE(y), ANGLE(z));
+ }
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.h b/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.h
new file mode 100644
index 000000000..2dafecfc0
--- /dev/null
+++ b/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "Math/Objects/EulerAngles.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
+
+class EulerAngles;
+class Pose;
+
+namespace sol { class state; }
+
+namespace TEN::Scripting
+{
+ class Rotation
+ {
+ public:
+ static void Register(sol::table& parent);
+
+ // Members
+ float x = 0;
+ float y = 0;
+ float z = 0;
+
+ // Constructors
+ Rotation() = default;
+ Rotation(float x, float y, float z);
+ Rotation(const EulerAngles& eulers);
+ Rotation(const Pose& pose);
+ Rotation(const Vector3& vector);
+
+ void StoreInPHDPos(Pose& pose) const;
+
+ // Converters
+ std::string ToString() const;
+ EulerAngles ToEulerAngles() const;
+ Vec3 Direction() const;
+
+ // Operators
+ operator Vector3() const;
+ };
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Types/Time/Time.cpp b/TombEngine/Scripting/Internal/TEN/Types/Time/Time.cpp
new file mode 100644
index 000000000..6706d66e0
--- /dev/null
+++ b/TombEngine/Scripting/Internal/TEN/Types/Time/Time.cpp
@@ -0,0 +1,293 @@
+#include "framework.h"
+#include "Scripting/Internal/TEN/Types/Time/Time.h"
+
+#include "Math/Math.h"
+#include "Scripting/Internal/ReservedScriptNames.h"
+#include "Specific/clock.h"
+
+namespace TEN::Scripting
+{
+ constexpr auto TIME_UNIT = 60;
+ constexpr auto CENTISECOND = 100;
+
+ /// Represents a time value in game frames, with support for formatting to hours, minutes, seconds, and centiseconds (1/100th of a second).
+ // @tenprimitive Time
+ // @pragma nostrip
+
+ void Time::Register(sol::table& parent)
+ {
+ using ctors = sol::constructors<
+ Time(), Time(int),
+ Time(const std::string&), Time(const sol::table&)>;
+
+ parent.new_usertype(
+ "Time", ctors(),
+ sol::call_constructor, ctors(),
+
+ // Meta functions
+ sol::meta_function::to_string, &Time::ToString,
+ sol::meta_function::equal_to, &Time::operator ==,
+ sol::meta_function::less_than, &Time::operator <,
+ sol::meta_function::less_than_or_equal_to, &Time::operator <=,
+
+ sol::meta_function::addition, sol::overload(
+ [](const Time& time0, const Time& time1) { return (time0 + time1); },
+ [](const Time& time, int gameFrames) { return (time + gameFrames); }),
+ sol::meta_function::subtraction, sol::overload(
+ [](const Time& time0, const Time& time1) { return (time0 - time1); },
+ [](const Time& time, int gameFrames) { return (time - gameFrames); }),
+
+ // Methods
+ "GetTimeUnits", &Time::GetTimeUnits,
+ "GetFrameCount", &Time::GetFrameCount,
+
+ // Readable and writable fields
+ "h", sol::property(&Time::GetHours, &Time::SetHours),
+ "m", sol::property(&Time::GetMinutes, &Time::SetMinutes),
+ "s", sol::property(&Time::GetSeconds, &Time::SetSeconds),
+ "c", sol::property(&Time::GetCentiseconds, &Time::SetCentiseconds));
+ }
+
+ /// Create a Time object.
+ // @function Time
+ // @treturn Time A new Time object initialized to zero time.
+
+ /// Create a Time object from a total game frame count (1 second = 30 frames).
+ // @function Time
+ // @tparam int gameFrames Total game frame count.
+ // @treturn Time A new Time object initialized with the given frame count.
+ Time::Time(int gameFrames)
+ {
+ _frameCount = gameFrames;
+ }
+
+ /// Create a Time object from a formatted string.
+ // @function Time
+ // @tparam string formattedTime Time in the format "HH:MM:SS[.CC]", where [.CC] is centiseconds and is optional.
+ // @treturn Time A new Time object parsed from the given string.
+ Time::Time(const std::string& formattedTime)
+ {
+ SetFromFormattedString(formattedTime);
+ }
+
+ /// Create a Time object from a time unit table (hours, minutes, seconds, centiseconds).
+ // @function Time
+ // @tparam table timeUnits A time unit table in the format {HH, MM, SS, [CC]}, where [CC] is optional.
+ // @treturn Time A new Time object initialized with the given values.
+ Time::Time(const sol::table& hmsTable)
+ {
+ SetFromTable(hmsTable);
+ }
+
+ /// Get the total game frame count.
+ // @function Time:GetFrameCount
+ // @treturn int Total number of game frames.
+ int Time::GetFrameCount() const
+ {
+ return _frameCount;
+ }
+
+ /// Get the time in hours, minutes, seconds, and centiseconds as a table.
+ // @function Time:GetTimeUnits
+ // @treturn table A table in the format {HH, MM, SS, CC}.
+ sol::table Time::GetTimeUnits(sol::this_state state) const
+ {
+ auto hmsc = GetHmsc();
+ auto table = sol::state_view(state).create_table();
+
+ table.add(hmsc.Hours);
+ table.add(hmsc.Minutes);
+ table.add(hmsc.Seconds);
+ table.add(hmsc.Centiseconds);
+ return table;
+ }
+
+ /// (int) Hours component.
+ // @mem h
+ int Time::GetHours() const
+ {
+ auto [h, m, s, c] = GetHmsc();
+ return h;
+ }
+
+ /// (int) Minutes component.
+ // @mem m
+ int Time::GetMinutes() const
+ {
+ auto [h, m, s, c] = GetHmsc();
+ return m;
+ }
+
+ /// (int) Seconds component.
+ // @mem s
+ int Time::GetSeconds() const
+ {
+ auto [h, m, s, c] = GetHmsc();
+ return s;
+ }
+
+ /// (int) Centiseconds component.
+ // @mem c
+ int Time::GetCentiseconds() const
+ {
+ auto [h, m, s, c] = GetHmsc();
+ return c;
+ }
+
+ void Time::SetHours(int value)
+ {
+ auto [h, m, s, f] = GetHmsc();
+ SetFromHMSC(value, m, s, f);
+ }
+
+ void Time::SetMinutes(int value)
+ {
+ auto [h, m, s, f] = GetHmsc();
+ SetFromHMSC(h, value, s, f);
+ }
+
+ void Time::SetSeconds(int value)
+ {
+ auto [h, m, s, c] = GetHmsc();
+ SetFromHMSC(h, m, value, c);
+ }
+
+ void Time::SetCentiseconds(int value)
+ {
+ auto [h, m, s, c] = GetHmsc();
+ SetFromHMSC(h, m, s, value);
+ }
+
+ /// Convert this Time object to a formatted string.
+ // @function tostring
+ // @tparam Time this Time object.
+ // @treturn string A string showing time in "HH:MM:SS.CC" format.
+ std::string Time::ToString() const
+ {
+ auto hmsc = GetHmsc();
+
+ auto stream = std::ostringstream();
+ stream << std::setw(2) << std::setfill('0') << hmsc.Hours << ":"
+ << std::setw(2) << std::setfill('0') << hmsc.Minutes << ":"
+ << std::setw(2) << std::setfill('0') << hmsc.Seconds << "."
+ << std::setw(2) << std::setfill('0') << hmsc.Centiseconds;
+ return stream.str();
+ }
+
+ Time& Time::operator ++()
+ {
+ _frameCount++;
+ return *this;
+ }
+
+ Time& Time::operator ++(int)
+ {
+ _frameCount++;
+ return *this;
+ }
+
+ Time& Time::operator +=(const Time& time)
+ {
+ _frameCount += time._frameCount;
+ return *this;
+ }
+
+ Time& Time::operator -=(const Time& time)
+ {
+ _frameCount -= time._frameCount;
+ return *this;
+ }
+
+ Time Time::operator +(int frameCount) const
+ {
+ return Time(frameCount + _frameCount);
+ }
+
+ Time Time::operator -(int frameCount) const
+ {
+ return Time(frameCount - _frameCount);
+ }
+
+ Time Time::operator +(const Time& time) const
+ {
+ return Time(_frameCount + time._frameCount);
+ }
+
+ Time Time::operator -(const Time& time) const
+ {
+ return Time(_frameCount - time._frameCount);
+ }
+
+ Time Time::operator <(const Time& time) const
+ {
+ return Time(_frameCount < time._frameCount);
+ }
+
+ Time Time::operator <=(const Time& time) const
+ {
+ return Time(_frameCount <= time._frameCount);
+ }
+
+ bool Time::operator ==(const Time& time) const
+ {
+ return _frameCount == time._frameCount;
+ }
+
+ Time::Hmsc Time::GetHmsc() const
+ {
+ int totalSeconds = _frameCount / FPS;
+
+ return Hmsc
+ {
+ totalSeconds / SQUARE(TIME_UNIT),
+ (totalSeconds % SQUARE(TIME_UNIT)) / TIME_UNIT,
+ totalSeconds % TIME_UNIT,
+ (_frameCount * 100 / FPS) % CENTISECOND
+ };
+ }
+
+ Time::Hmsc Time::ParseFormattedString(const std::string& formattedTime)
+ {
+ std::regex timeFormat(R"((\d{2}):(\d{2}):(\d{2})\.(\d{2}))");
+ std::smatch match;
+
+ if (!std::regex_match(formattedTime, match, timeFormat))
+ {
+ TENLog("Invalid time format. Expected HH:MM:SS or HH:MM:SS.CC", LogLevel::Warning);
+ return Time::Hmsc();
+ }
+
+ return
+ {
+ std::stoi(match[1].str()),
+ std::stoi(match[2].str()),
+ std::stoi(match[3].str()),
+ match[4].matched ? std::stoi(match[4].str()) : 0
+ };
+ }
+
+ void Time::SetFromHMSC(int hours, int minutes, int seconds, int cents)
+ {
+ _frameCount = (hours * SQUARE(TIME_UNIT) + minutes * TIME_UNIT + seconds) * FPS +
+ round((float)cents / ((float)CENTISECOND / (float)FPS));
+ }
+
+ void Time::SetFromFormattedString(const std::string& formattedTime)
+ {
+ auto hmsc = ParseFormattedString(formattedTime);
+ SetFromHMSC(hmsc.Hours, hmsc.Minutes, hmsc.Seconds, hmsc.Centiseconds);
+ }
+
+ void Time::SetFromTable(const sol::table& hmsTable)
+ {
+ if (!hmsTable.valid() || hmsTable.size() < 1 || hmsTable.size() > 4)
+ throw std::invalid_argument("Invalid time unit table. Expected {HH, MM, SS, [CC]}");
+
+ int hours = hmsTable.get_or(1, 0);
+ int minutes = hmsTable.get_or(2, 0);
+ int seconds = hmsTable.get_or(3, 0);
+ int cents = hmsTable.get_or(4, 0);
+
+ SetFromHMSC(hours, minutes, seconds, cents);
+ }
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Types/Time/Time.h b/TombEngine/Scripting/Internal/TEN/Types/Time/Time.h
new file mode 100644
index 000000000..171b18d58
--- /dev/null
+++ b/TombEngine/Scripting/Internal/TEN/Types/Time/Time.h
@@ -0,0 +1,76 @@
+#pragma once
+
+namespace TEN::Scripting
+{
+ class Time
+ {
+ private:
+ // Members
+
+ int _frameCount = 0;
+
+ public:
+ static void Register(sol::table& parent);
+
+ // Constructors
+
+ Time() = default;
+ Time(int gameFrames);
+ Time(const std::string& formattedTime);
+ Time(const sol::table& hmsTable);
+
+ // Getters
+
+ int GetFrameCount() const;
+ sol::table GetTimeUnits(sol::this_state state) const;
+
+ int GetHours() const;
+ int GetMinutes() const;
+ int GetSeconds() const;
+ int GetCentiseconds() const;
+
+ // Setters
+
+ void SetHours(int value);
+ void SetMinutes(int value);
+ void SetSeconds(int value);
+ void SetCentiseconds(int value);
+
+ // Utilities
+
+ std::string ToString() const;
+
+ // Operators
+
+ Time operator +(int frameCount) const;
+ Time operator -(int frameCount) const;
+ Time operator +(const Time& time) const;
+ Time operator -(const Time& time) const;
+ Time operator <(const Time& time) const;
+ Time operator <=(const Time& time) const;
+ bool operator ==(const Time& time) const;
+ Time& operator +=(const Time& time);
+ Time& operator -=(const Time& time);
+ Time& Time::operator ++();
+ Time& Time::operator ++(int);
+ operator int() const { return _frameCount; }
+
+ private:
+ struct Hmsc
+ {
+ int Hours = 0;
+ int Minutes = 0;
+ int Seconds = 0;
+ int Centiseconds = 0;
+ };
+
+ // Helpers
+
+ Hmsc GetHmsc() const;
+ static Hmsc ParseFormattedString(const std::string& formattedTime);
+
+ void SetFromHMSC(int hours, int minutes = 0, int seconds = 0, int cents = 0);
+ void SetFromFormattedString(const std::string& formattedTime);
+ void SetFromTable(const sol::table& hmscTable);
+ };
+}
diff --git a/TombEngine/Scripting/Internal/TEN/Vec2/Vec2.cpp b/TombEngine/Scripting/Internal/TEN/Types/Vec2/Vec2.cpp
similarity index 94%
rename from TombEngine/Scripting/Internal/TEN/Vec2/Vec2.cpp
rename to TombEngine/Scripting/Internal/TEN/Types/Vec2/Vec2.cpp
index 38e403fc2..0a25b1b20 100644
--- a/TombEngine/Scripting/Internal/TEN/Vec2/Vec2.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Types/Vec2/Vec2.cpp
@@ -1,5 +1,5 @@
#include "framework.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
#include "Math/Math.h"
#include "Scripting/Internal/ReservedScriptNames.h"
@@ -48,7 +48,7 @@ void Vec2::Register(sol::table& parent)
}
/// Create a Vec2 object.
-// @function Vec2(x, y)
+// @function Vec2
// @tparam float x X component.
// @tparam float y Y component.
// @treturn Vec2 A new Vec2 object.
@@ -59,7 +59,7 @@ Vec2::Vec2(float x, float y)
}
/// Create a Vec2 object.
-// @function Vec(value)
+// @function Vec
// @tparam float value X and Z component.
// @treturn Vec2 A new Vec2 object.
Vec2::Vec2(float value)
@@ -90,7 +90,7 @@ std::string Vec2::ToString() const
}
/// Get a copy of this Vec2 normalized to length 1.
-// @function Vec2:Normalize()
+// @function Vec2:Normalize
// @treturn Vec2 Normalized vector.
Vec2 Vec2::Normalize() const
{
@@ -101,7 +101,7 @@ Vec2 Vec2::Normalize() const
}
/// Get a copy of this Vec2 rotated by the input rotation in degrees.
-// @function Vec2:Rotate(rot)
+// @function Vec2:Rotate
// @tparam float rot Rotation in degrees.
// @treturn Vec2 Rotated Vec2.
Vec2 Vec2::Rotate(float rot) const
@@ -113,7 +113,7 @@ Vec2 Vec2::Rotate(float rot) const
}
/// Get the linearly interpolated Vec2 between this Vec2 and the input Vec2 according to the input interpolation alpha.
-// @function Vec2:Lerp(vector)
+// @function Vec2:Lerp
// @tparam Vec2 vector Target interpolation vector.
// @tparam float alpha Interpolation alpha in the range [0, 1].
// @treturn Vec2 Linearly interpolated vector
@@ -126,7 +126,7 @@ Vec2 Vec2::Lerp(const Vec2& vector, float alpha) const
}
/// Get the cross product of this Vec2 and the input Vec2.
-// @function Vec2:Cross(vector)
+// @function Vec2:Cross
// @tparam Vec2 vector Input vector.
// @treturn Vec2 Cross product.
Vec2 Vec2::Cross(const Vec2& vector) const
@@ -138,7 +138,7 @@ Vec2 Vec2::Cross(const Vec2& vector) const
}
/// Get the dot product of this Vec2 and the input Vec2.
-// @function Vec2:Dot(vector)
+// @function Vec2:Dot
// @tparam Vec2 vector Input vector.
// @treturn float Dot product.
float Vec2::Dot(const Vec2& vector) const
@@ -150,7 +150,7 @@ float Vec2::Dot(const Vec2& vector) const
}
/// Get the distance between this Vec2 and the input Vec2.
-// @function Vec2:Distance(vector)
+// @function Vec2:Distance
// @tparam Vec2 vector Input vector.
// @treturn float Distance.
float Vec2::Distance(const Vec2& vector) const
@@ -162,7 +162,7 @@ float Vec2::Distance(const Vec2& vector) const
}
/// Get the length of this Vec2.
-// @function Vec2:Length()
+// @function Vec2:Length
// @treturn float Length.
float Vec2::Length() const
{
diff --git a/TombEngine/Scripting/Internal/TEN/Vec2/Vec2.h b/TombEngine/Scripting/Internal/TEN/Types/Vec2/Vec2.h
similarity index 100%
rename from TombEngine/Scripting/Internal/TEN/Vec2/Vec2.h
rename to TombEngine/Scripting/Internal/TEN/Types/Vec2/Vec2.h
diff --git a/TombEngine/Scripting/Internal/TEN/Vec3/Vec3.cpp b/TombEngine/Scripting/Internal/TEN/Types/Vec3/Vec3.cpp
similarity index 93%
rename from TombEngine/Scripting/Internal/TEN/Vec3/Vec3.cpp
rename to TombEngine/Scripting/Internal/TEN/Types/Vec3/Vec3.cpp
index 656a56bf9..5b53e4a88 100644
--- a/TombEngine/Scripting/Internal/TEN/Vec3/Vec3.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Types/Vec3/Vec3.cpp
@@ -1,9 +1,9 @@
#include "framework.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Math/Math.h"
#include "Scripting/Internal/ReservedScriptNames.h"
-#include "Scripting/Internal/TEN/Rotation/Rotation.h"
+#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
using namespace TEN::Math;
@@ -53,7 +53,7 @@ void Vec3::Register(sol::table& parent)
}
/// Create a Vec3 object.
-// @function Vec3(x, y, z)
+// @function Vec3
// @tparam float x X component.
// @tparam float y Y component.
// @tparam float z Z component.
@@ -66,7 +66,7 @@ Vec3::Vec3(float x, float y, float z)
}
/// Create a Vec3 object.
-// @function Vec3(value)
+// @function Vec3
// @tparam float value X, Y, and Z component.
// @treturn Vec3 A new Vec3 object.
Vec3::Vec3(float value)
@@ -91,7 +91,7 @@ Vec3::Vec3(const Vector3i& vector)
}
/// Get a copy of this Vec3 normalized to length 1.
-// @function Vec3:Normalize()
+// @function Vec3:Normalize
// @treturn Vec3 Normalized vector.
Vec3 Vec3::Normalize() const
{
@@ -102,7 +102,7 @@ Vec3 Vec3::Normalize() const
}
/// Get a copy of this Vec3 rotated by the input Rotation object.
-// @function Vec3:Rotate(rot)
+// @function Vec3:Rotate
// @tparam Rotation rot Rotation object.
// @treturn Vec3 Rotated Vec3.
Vec3 Vec3::Rotate(const Rotation& rot) const
@@ -115,7 +115,7 @@ Vec3 Vec3::Rotate(const Rotation& rot) const
}
/// Get the linearly interpolated Vec3 between this Vec3 and the input Vec3 according to the input interpolation alpha.
-// @function Vec3:Lerp(vector)
+// @function Vec3:Lerp
// @tparam Vec3 vector Target interpolation vector.
// @tparam float alpha Interpolation alpha in the range [0, 1].
// @treturn Vec3 Linearly interpolated vector
@@ -128,7 +128,7 @@ Vec3 Vec3::Lerp(const Vec3& vector, float alpha) const
}
/// Get the cross product of this Vec3 and the input Vec3.
-// @function Vec3:Cross(vector)
+// @function Vec3:Cross
// @tparam Vec3 vector Input vector.
// @treturn Vec3 Cross product.
Vec3 Vec3::Cross(const Vec3& vector) const
@@ -140,7 +140,7 @@ Vec3 Vec3::Cross(const Vec3& vector) const
}
/// Get the dot product of this Vec3 and the input Vec3.
-// @function Vec3:Dot(vector)
+// @function Vec3:Dot
// @tparam Vec3 vector Input vector.
// @treturn float Dot product.
float Vec3::Dot(const Vec3& vector) const
@@ -152,7 +152,7 @@ float Vec3::Dot(const Vec3& vector) const
}
/// Get the distance between this Vec3 and the input Vec3.
-// @function Vec3:Distance(vector)
+// @function Vec3:Distance
// @tparam Vec3 vector Input vector.
// @treturn float Distance.
float Vec3::Distance(const Vec3& vector) const
@@ -164,7 +164,7 @@ float Vec3::Distance(const Vec3& vector) const
}
/// Get the length of this Vec3.
-// @function Vec3:Length()
+// @function Vec3:Length
// @treturn float Length.
float Vec3::Length() const
{
diff --git a/TombEngine/Scripting/Internal/TEN/Vec3/Vec3.h b/TombEngine/Scripting/Internal/TEN/Types/Vec3/Vec3.h
similarity index 94%
rename from TombEngine/Scripting/Internal/TEN/Vec3/Vec3.h
rename to TombEngine/Scripting/Internal/TEN/Types/Vec3/Vec3.h
index de2d95365..7a981722a 100644
--- a/TombEngine/Scripting/Internal/TEN/Vec3/Vec3.h
+++ b/TombEngine/Scripting/Internal/TEN/Types/Vec3/Vec3.h
@@ -1,10 +1,12 @@
#pragma once
-namespace sol { class state; }
class GameVector;
class Pose;
-class Rotation;
class Vector3i;
+namespace sol { class state; }
+namespace TEN::Scripting { class Rotation; };
+
+using namespace TEN::Scripting;
class Vec3
{
diff --git a/TombEngine/Scripting/Internal/TEN/Util/LevelLog.h b/TombEngine/Scripting/Internal/TEN/Util/LevelLog.h
index 554dde516..f40fad533 100644
--- a/TombEngine/Scripting/Internal/TEN/Util/LevelLog.h
+++ b/TombEngine/Scripting/Internal/TEN/Util/LevelLog.h
@@ -11,18 +11,13 @@ Constants for LogLevel IDs.
@pragma nostrip
*/
-/*** Util.LogLevel constants.
-The following constants are inside LogLevel.
+/*** Table of Util.LogLevel constants. To be used with @{Util.PrintLog} function.
- INFO
- WARNING
- ERROR
+ - `INFO`
+ - `WARNING`
+ - `ERROR`
-@section Util.LogLevel
-*/
-
-/*** Table of LogLevel ID constants (for use with PrintLog() command).
-@table CONSTANT_STRING_HERE
+@table Util.LogLevel
*/
static const std::unordered_map LOG_LEVEL
diff --git a/TombEngine/Scripting/Internal/TEN/Util/Util.cpp b/TombEngine/Scripting/Internal/TEN/Util/Util.cpp
index db2890408..d29ebec0f 100644
--- a/TombEngine/Scripting/Internal/TEN/Util/Util.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Util/Util.cpp
@@ -12,9 +12,9 @@
#include "Scripting/Internal/ScriptUtil.h"
#include "Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h"
#include "Scripting/Internal/TEN/Objects/Static/StaticObject.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Scripting/Internal/TEN/Util/LevelLog.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
#include "Specific/configuration.h"
#include "Specific/level.h"
@@ -177,7 +177,7 @@ namespace TEN::Scripting::Util
//debug.traceback
//@function PrintLog
//@tparam string message to be displayed within the Log
- //@tparam Misc.LogLevel logLevel log level to be displayed
+ //@tparam Util.LogLevel logLevel log level to be displayed
//@tparam[opt] bool allowSpam true allows spamming of the message
//
//@usage
diff --git a/TombEngine/Scripting/Internal/TEN/View/AlignModes.h b/TombEngine/Scripting/Internal/TEN/View/AlignModes.h
index 97a7c07bb..af0139711 100644
--- a/TombEngine/Scripting/Internal/TEN/View/AlignModes.h
+++ b/TombEngine/Scripting/Internal/TEN/View/AlignModes.h
@@ -8,32 +8,25 @@ using namespace TEN::Effects::DisplaySprite;
namespace TEN::Scripting::View
{
- /***
- Constants for sprite align modes.
- @enum View.AlignMode
- @pragma nostrip
- */
+ /// Constants for sprite align modes.
+ // @enum View.AlignMode
+ // @pragma nostrip
- /*** View.AlignMode constants.
-
- The following constants are inside View.AlignMode.
-
- CENTER
- CENTER_TOP
- CENTER_BOTTOM
- CENTER_LEFT
- CENTER_RIGHT
- TOP_LEFT
- TOP_RIGHT
- BOTTOM_LEFT
- BOTTOM_RIGHT
-
- @section View.AlignMode
- */
-
- /*** Table of align modes.
- @table CONSTANT_STRING_HERE
- */
+ /// Table of View.AlignMode constants.
+ //
+ // The following constants are inside View.AlignMode. To be used with @{Strings.DisplayString} class.
+ //
+ // - `CENTER`
+ // - `CENTER_TOP`
+ // - `CENTER_BOTTOM`
+ // - `CENTER_LEFT`
+ // - `CENTER_RIGHT`
+ // - `TOP_LEFT`
+ // - `TOP_RIGHT`
+ // - `BOTTOM_LEFT`
+ // - `BOTTOM_RIGHT`
+ //
+ // @table View.AlignMode
static const std::unordered_map ALIGN_MODES
{
diff --git a/TombEngine/Scripting/Internal/TEN/View/CameraTypes.h b/TombEngine/Scripting/Internal/TEN/View/CameraTypes.h
index 4a5ad3ebe..abeb58748 100644
--- a/TombEngine/Scripting/Internal/TEN/View/CameraTypes.h
+++ b/TombEngine/Scripting/Internal/TEN/View/CameraTypes.h
@@ -7,30 +7,38 @@ Constants for the type of the Camera.
@pragma nostrip
*/
-/*** View.CameraType constants.
-
-The following constants are inside CameraType.
-
- CHASE
- FIXED
- LOOK
- COMBAT
- HEAVY
- OBJECT
-
-@section View.CameraType
-*/
-
-/*** Table of camera type constants (for use with GetCameraType() function).
-@table CONSTANT_STRING_HERE
-*/
-
-static const std::unordered_map CAMERA_TYPE
+enum class ScriptCameraType
{
- { "CHASE", CameraType::Chase },
- { "FIXED", CameraType::Fixed },
- { "LOOK", CameraType::Look },
- { "COMBAT", CameraType::Combat },
- { "HEAVY", CameraType::Heavy },
- { "OBJECT", CameraType::Object }
+ Normal,
+ Fixed,
+ Look,
+ Combat,
+ Flyby,
+ Binoculars,
+ Lasersight
+};
+
+/*** Table of View.CameraType constants. To be used with @{View.GetCameraType} function.
+@table CameraType
+
+ - `NORMAL` - standard in-game camera when weapons are holstered.
+ - `COMBAT` - in-game camera when weapons are unholstered.
+ - `FIXED` - classic fixed camera.
+ - `LOOK` - look camera.
+ - `FLYBY` - flyby or tracking camera.
+ - `BINOCULARS` - binoculars is active.
+ - `LASERSIGHT` - lasersight is active.
+*/
+
+static const std::unordered_map CAMERA_TYPE
+{
+ { "CHASE", ScriptCameraType::Normal }, // DEPRECATED
+ { "NORMAL", ScriptCameraType::Normal },
+ { "COMBAT", ScriptCameraType::Combat },
+ { "FIXED", ScriptCameraType::Fixed },
+ { "HEAVY", ScriptCameraType::Fixed }, // DEPRECATED
+ { "LOOK", ScriptCameraType::Look },
+ { "FLYBY", ScriptCameraType::Flyby },
+ { "BINOCULARS", ScriptCameraType::Binoculars },
+ { "LASERSIGHT", ScriptCameraType::Lasersight }
};
diff --git a/TombEngine/Scripting/Internal/TEN/DisplaySprite/ScriptDisplaySprite.cpp b/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.cpp
similarity index 97%
rename from TombEngine/Scripting/Internal/TEN/DisplaySprite/ScriptDisplaySprite.cpp
rename to TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.cpp
index 285a3a9ad..3e46b5b0d 100644
--- a/TombEngine/Scripting/Internal/TEN/DisplaySprite/ScriptDisplaySprite.cpp
+++ b/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.cpp
@@ -1,5 +1,5 @@
#include "framework.h"
-#include "Scripting/Internal/TEN/DisplaySprite/ScriptDisplaySprite.h"
+#include "Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.h"
#include "Game/effects/DisplaySprite.h"
#include "Game/Setup.h"
@@ -7,8 +7,8 @@
#include "Renderer/Renderer.h"
#include "Scripting/Internal/LuaHandler.h"
#include "Scripting/Internal/ReservedScriptNames.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
using TEN::Renderer::g_Renderer;
diff --git a/TombEngine/Scripting/Internal/TEN/DisplaySprite/ScriptDisplaySprite.h b/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.h
similarity index 93%
rename from TombEngine/Scripting/Internal/TEN/DisplaySprite/ScriptDisplaySprite.h
rename to TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.h
index 63d0dc9b0..b58ec7ac9 100644
--- a/TombEngine/Scripting/Internal/TEN/DisplaySprite/ScriptDisplaySprite.h
+++ b/TombEngine/Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.h
@@ -1,8 +1,8 @@
#pragma once
#include "Game/effects/DisplaySprite.h"
#include "Objects/game_object_ids.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
-#include "Scripting/Internal/TEN/Vec2/Vec2.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Vec2/Vec2.h"
using namespace TEN::Effects::DisplaySprite;
diff --git a/TombEngine/Scripting/Internal/TEN/View/PostProcessEffects.h b/TombEngine/Scripting/Internal/TEN/View/PostProcessEffects.h
index 4ea880aed..e3cc1b331 100644
--- a/TombEngine/Scripting/Internal/TEN/View/PostProcessEffects.h
+++ b/TombEngine/Scripting/Internal/TEN/View/PostProcessEffects.h
@@ -8,20 +8,18 @@ Constants for the post-process effects to apply.
@pragma nostrip
*/
-/*** View.PostProcessMode constants.
+/*** Table of View.PostProcessMode effect constants. To be used with @{View.SetPostProcessMode} function.
-The following constants are inside PostProcessMode.
+ - `NONE` - No postprocess effect.
+ - `MONOCHROME` - Black & white effect.
+ - `NEGATIVE` - Negative image effect.
+ - `EXCLUSION` - Similar to negative effect, but with different color operation.
- NONE
- MONOCHROME
- NEGATIVE
- EXCLUSION
-
-@section View.PostProcessMode
+@table View.PostProcessMode
*/
-/*** Table of post-process effect constants (for use with SetPostProcessMode() function).
-@table CONSTANT_STRING_HERE
+/*** (for use with SetPostProcessMode() function).
+@ PostProcessMode
*/
static const std::unordered_map POSTPROCESS_MODES
diff --git a/TombEngine/Scripting/Internal/TEN/View/ScaleModes.h b/TombEngine/Scripting/Internal/TEN/View/ScaleModes.h
index 22da4ff96..605002855 100644
--- a/TombEngine/Scripting/Internal/TEN/View/ScaleModes.h
+++ b/TombEngine/Scripting/Internal/TEN/View/ScaleModes.h
@@ -8,26 +8,18 @@ using namespace TEN::Effects::DisplaySprite;
namespace TEN::Scripting::View
{
- /***
- Constants for scale modes.
- @enum View.ScaleMode
- @pragma nostrip
- */
- /*** View.ScaleMode constants.
+ /// Constants for display sprite scale modes.
+ // @enum View.ScaleMode
+ // @pragma nostrip
- The following constants are inside View.ScaleMode.
-
- FIT
- FILL
- STRETCH
-
- @section View.ScaleMode
- */
-
- /*** Table of display sprite scale modes.
- @table CONSTANT_STRING_HERE
- */
+ /// Table of View.ScaleMode constants. To be used with @{View.DisplaySprite} class.
+ //
+ // - `FIT`
+ // - `FILL`
+ // - `STRETCH`
+ //
+ // @table View.ScaleMode
static const std::unordered_map SCALE_MODES
{
diff --git a/TombEngine/Scripting/Internal/TEN/View/ViewHandler.cpp b/TombEngine/Scripting/Internal/TEN/View/ViewHandler.cpp
index a5f8b1cf8..facaf59f4 100644
--- a/TombEngine/Scripting/Internal/TEN/View/ViewHandler.cpp
+++ b/TombEngine/Scripting/Internal/TEN/View/ViewHandler.cpp
@@ -9,12 +9,12 @@
#include "Scripting/Internal/LuaHandler.h"
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptUtil.h"
-#include "Scripting/Internal/TEN/Color/Color.h"
-#include "Scripting/Internal/TEN/DisplaySprite/ScriptDisplaySprite.h"
#include "Scripting/Internal/TEN/Objects/Room/RoomObject.h"
-#include "Scripting/Internal/TEN/Vec3/Vec3.h"
+#include "Scripting/Internal/TEN/Types/Color/Color.h"
+#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
#include "Scripting/Internal/TEN/View/AlignModes.h"
#include "Scripting/Internal/TEN/View/CameraTypes.h"
+#include "Scripting/Internal/TEN/View/DisplaySprite/ScriptDisplaySprite.h"
#include "Scripting/Internal/TEN/View/ScaleModes.h"
#include "Scripting/Internal/TEN/View/PostProcessEffects.h"
#include "Specific/clock.h"
@@ -67,9 +67,21 @@ namespace TEN::Scripting::View
return TO_DEGREES(GetCurrentFOV());
}
- static CameraType GetCameraType()
+ static ScriptCameraType GetCameraType()
{
- return Camera.oldType;
+ if (UseSpotCam)
+ return ScriptCameraType::Flyby;
+
+ if (Lara.Control.Look.IsUsingLasersight)
+ return ScriptCameraType::Lasersight;
+
+ if (Lara.Control.Look.IsUsingBinoculars)
+ return ScriptCameraType::Binoculars;
+
+ if (Camera.oldType == CameraType::Heavy)
+ return ScriptCameraType::Fixed;
+
+ return (ScriptCameraType)Camera.oldType;
}
static Vec3 GetCameraPosition()
@@ -172,12 +184,22 @@ namespace TEN::Scripting::View
//@treturn View.CameraType value used by the Main Camera.
//@usage
//LevelFuncs.OnLoop = function()
- // if (View.GetCameraType() == CameraType.Combat) then
+ // if (View.GetCameraType() == CameraType.COMBAT) then
// --Do your Actions here.
// end
//end
tableView.set_function(ScriptReserved_GetCameraType, &GetCameraType);
+ ///Gets current camera position.
+ //@function GetCameraPosition
+ //@treturn Vec3 current camera position
+ tableView.set_function(ScriptReserved_GetCameraPosition, &GetCameraPosition);
+
+ ///Gets current camera target.
+ //@function GetCameraTarget
+ //@treturn Vec3 current camera target
+ tableView.set_function(ScriptReserved_GetCameraTarget, &GetCameraTarget);
+
///Gets current room where camera is positioned.
//@function GetCameraRoom
//@treturn Objects.Room current room of the camera
@@ -198,16 +220,6 @@ namespace TEN::Scripting::View
//@tparam Color tint value to use.
tableView.set_function(ScriptReserved_SetPostProcessTint, &SetPostProcessTint);
- ///Gets current camera position.
- //@function GetCameraPosition
- //@treturn Vec3 current camera position
- tableView.set_function(ScriptReserved_GetCameraPosition, &GetCameraPosition);
-
- ///Gets current camera target.
- //@function GetCameraTarget
- //@treturn Vec3 current camera target
- tableView.set_function(ScriptReserved_GetCameraTarget, &GetCameraTarget);
-
///Enable FlyBy with specific ID
//@function PlayFlyBy
//@tparam short flyby (ID of flyby)
diff --git a/TombEngine/Specific/BitField.cpp b/TombEngine/Specific/BitField.cpp
index adfcd5ef2..650c19df2 100644
--- a/TombEngine/Specific/BitField.cpp
+++ b/TombEngine/Specific/BitField.cpp
@@ -38,17 +38,6 @@ namespace TEN::Utils
_bits.push_back(bit == '1');
}
- bool BitField::IndexIsCorrect(unsigned int index) const
- {
- if (index >= _bits.size())
- {
- TENLog(std::string("BitField attempted to access bit at invalid index."), LogLevel::Warning);
- return false;
- }
-
- return true;
- }
-
unsigned int BitField::GetSize() const
{
return (unsigned int)_bits.size();
@@ -70,7 +59,7 @@ namespace TEN::Utils
{
for (const unsigned int& index : indices)
{
- if (!IndexIsCorrect(index))
+ if (!IsIndexCorrect(index))
continue;
_bits[index] = true;
@@ -91,7 +80,7 @@ namespace TEN::Utils
{
for (const unsigned int& index : indices)
{
- if (!IndexIsCorrect(index))
+ if (!IsIndexCorrect(index))
continue;
_bits[index] = false;
@@ -112,7 +101,7 @@ namespace TEN::Utils
{
for (const unsigned int& index : indices)
{
- if (!IndexIsCorrect(index))
+ if (!IsIndexCorrect(index))
continue;
_bits[index].flip();
@@ -133,7 +122,7 @@ namespace TEN::Utils
{
for (const unsigned int& index : indices)
{
- if (!IndexIsCorrect(index))
+ if (!IsIndexCorrect(index))
continue;
// Test if any bits at input indices are set.
@@ -155,7 +144,7 @@ namespace TEN::Utils
bool BitField::Test(unsigned int index) const
{
- if (!IndexIsCorrect(index))
+ if (!IsIndexCorrect(index))
return false;
return _bits[index];
@@ -275,4 +264,15 @@ namespace TEN::Utils
{
std::fill(_bits.begin(), _bits.end(), value);
}
+
+ bool BitField::IsIndexCorrect(unsigned int index) const
+ {
+ if (index >= _bits.size())
+ {
+ TENLog(std::string("BitField attempted to access bit at invalid index."), LogLevel::Warning);
+ return false;
+ }
+
+ return true;
+ }
}
diff --git a/TombEngine/Specific/BitField.h b/TombEngine/Specific/BitField.h
index ecab1819b..76a0704cc 100644
--- a/TombEngine/Specific/BitField.h
+++ b/TombEngine/Specific/BitField.h
@@ -2,7 +2,6 @@
namespace TEN::Utils
{
- // TODO: Switch to std::span container type as parameter whenever we update to C++20.
// TODO: When all conversions are complete, remove the size cap and use unsigned long long for packedBits input.
class BitField
@@ -11,24 +10,27 @@ namespace TEN::Utils
static constexpr auto SIZE_DEFAULT = 32;
std::vector _bits = {};
- bool IndexIsCorrect(unsigned int index) const;
public:
// Presets
+
static const BitField Empty;
static const BitField Default;
// Constructors
+
BitField();
BitField(unsigned int size);
BitField(unsigned int size, unsigned int packedBits);
BitField(const std::string& bitString);
// Getters
+
unsigned int GetSize() const;
unsigned int GetCount() const;
// Setters
+
void Set(const std::vector& indices);
void Set(unsigned int index);
void SetAll();
@@ -40,12 +42,14 @@ namespace TEN::Utils
void FlipAll();
// Inquirers
+
bool Test(const std::vector& indices, bool testAny = true) const;
bool Test(unsigned int index) const;
bool TestAny() const;
bool TestAll() const;
// Converters
+
unsigned int ToPackedBits() const;
std::string ToString() const;
@@ -64,5 +68,6 @@ namespace TEN::Utils
// Helpers
void Fill(bool value);
+ bool IsIndexCorrect(unsigned int index) const;
};
}
diff --git a/TombEngine/Specific/clock.cpp b/TombEngine/Specific/clock.cpp
index f2fa0a3d3..73849cbff 100644
--- a/TombEngine/Specific/clock.cpp
+++ b/TombEngine/Specific/clock.cpp
@@ -104,18 +104,6 @@ bool TimeInit()
return true;
}
-GameTime GetGameTime(int ticks)
-{
- auto gameTime = GameTime{};
- int seconds = ticks / FPS;
-
- gameTime.Days = (seconds / (DAY_UNIT * SQUARE(TIME_UNIT)));
- gameTime.Hours = (seconds % (DAY_UNIT * SQUARE(TIME_UNIT))) / SQUARE(TIME_UNIT);
- gameTime.Minutes = (seconds / TIME_UNIT) % TIME_UNIT;
- gameTime.Seconds = seconds % TIME_UNIT;
- return gameTime;
-}
-
bool TestGlobalTimeInterval(float intervalSecs, float offsetSecs)
{
int intervalGameFrames = (int)round(intervalSecs * FPS);
diff --git a/TombEngine/Specific/clock.h b/TombEngine/Specific/clock.h
index 5d59e3856..dfc281a94 100644
--- a/TombEngine/Specific/clock.h
+++ b/TombEngine/Specific/clock.h
@@ -6,16 +6,6 @@
// which assumes 30 iterations per second.
constexpr auto FPS = 30;
constexpr auto DELTA_TIME = 1.0f / FPS;
-constexpr auto TIME_UNIT = 60;
-constexpr auto DAY_UNIT = 24;
-
-struct GameTime
-{
- int Days = 0;
- int Hours = 0;
- int Minutes = 0;
- int Seconds = 0;
-};
class HighFramerateSynchronizer
{
@@ -38,8 +28,6 @@ int TimeSync();
bool TimeInit();
bool TimeReset();
-GameTime GetGameTime(int ticks);
-
bool TestGlobalTimeInterval(float intervalSecs, float offsetSecs = 0.0f);
-extern HighFramerateSynchronizer g_Synchronizer;
\ No newline at end of file
+extern HighFramerateSynchronizer g_Synchronizer;
diff --git a/TombEngine/Specific/level.cpp b/TombEngine/Specific/level.cpp
index 101ff3bb7..544dd248e 100644
--- a/TombEngine/Specific/level.cpp
+++ b/TombEngine/Specific/level.cpp
@@ -1546,7 +1546,8 @@ bool LoadLevelFile(int levelIndex)
TENLog("Loading level file: " + levelPath, LogLevel::Info);
auto timestamp = std::filesystem::last_write_time(levelPath);
- bool fastReload = (g_GameFlow->GetSettings()->FastReload && levelIndex == CurrentLevel && timestamp == LastLevelTimestamp && levelPath == LastLevelFilePath);
+ bool fastReload = (g_GameFlow->GetSettings()->System.FastReload &&
+ levelIndex == CurrentLevel && timestamp == LastLevelTimestamp && levelPath == LastLevelFilePath);
// If fast reload is in action, draw last game frame instead of loading screen.
auto loadingScreenPath = TEN::Utils::ToWString(assetDir + level.LoadScreenFileName);
diff --git a/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h b/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h
index 37087531a..c91a3c0ac 100644
--- a/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h
+++ b/TombEngine/Specific/savegame/flatbuffers/ten_savegame_generated.h
@@ -183,6 +183,10 @@ struct boolTable;
struct boolTableBuilder;
struct boolTableT;
+struct timeTable;
+struct timeTableBuilder;
+struct timeTableT;
+
struct vec2Table;
struct vec2TableBuilder;
struct vec2TableT;
@@ -265,22 +269,24 @@ enum class VarUnion : uint8_t {
tab = 2,
num = 3,
boolean = 4,
- vec2 = 5,
- vec3 = 6,
- rotation = 7,
- color = 8,
- funcName = 9,
+ time = 5,
+ vec2 = 6,
+ vec3 = 7,
+ rotation = 8,
+ color = 9,
+ funcName = 10,
MIN = NONE,
MAX = funcName
};
-inline const VarUnion (&EnumValuesVarUnion())[10] {
+inline const VarUnion (&EnumValuesVarUnion())[11] {
static const VarUnion values[] = {
VarUnion::NONE,
VarUnion::str,
VarUnion::tab,
VarUnion::num,
VarUnion::boolean,
+ VarUnion::time,
VarUnion::vec2,
VarUnion::vec3,
VarUnion::rotation,
@@ -291,12 +297,13 @@ inline const VarUnion (&EnumValuesVarUnion())[10] {
}
inline const char * const *EnumNamesVarUnion() {
- static const char * const names[11] = {
+ static const char * const names[12] = {
"NONE",
"str",
"tab",
"num",
"boolean",
+ "time",
"vec2",
"vec3",
"rotation",
@@ -333,6 +340,10 @@ template<> struct VarUnionTraits {
static const VarUnion enum_value = VarUnion::boolean;
};
+template<> struct VarUnionTraits {
+ static const VarUnion enum_value = VarUnion::time;
+};
+
template<> struct VarUnionTraits {
static const VarUnion enum_value = VarUnion::vec2;
};
@@ -417,6 +428,14 @@ struct VarUnionUnion {
return type == VarUnion::boolean ?
reinterpret_cast(value) : nullptr;
}
+ TEN::Save::timeTableT *Astime() {
+ return type == VarUnion::time ?
+ reinterpret_cast(value) : nullptr;
+ }
+ const TEN::Save::timeTableT *Astime() const {
+ return type == VarUnion::time ?
+ reinterpret_cast(value) : nullptr;
+ }
TEN::Save::vec2TableT *Asvec2() {
return type == VarUnion::vec2 ?
reinterpret_cast(value) : nullptr;
@@ -6527,6 +6546,64 @@ struct boolTable::Traits {
flatbuffers::Offset CreateboolTable(flatbuffers::FlatBufferBuilder &_fbb, const boolTableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+struct timeTableT : public flatbuffers::NativeTable {
+ typedef timeTable TableType;
+ int32_t scalar = 0;
+};
+
+struct timeTable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
+ typedef timeTableT NativeTableType;
+ typedef timeTableBuilder Builder;
+ struct Traits;
+ enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
+ VT_SCALAR = 4
+ };
+ int32_t scalar() const {
+ return GetField(VT_SCALAR, 0);
+ }
+ bool Verify(flatbuffers::Verifier &verifier) const {
+ return VerifyTableStart(verifier) &&
+ VerifyField(verifier, VT_SCALAR) &&
+ verifier.EndTable();
+ }
+ timeTableT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ void UnPackTo(timeTableT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
+ static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const timeTableT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+};
+
+struct timeTableBuilder {
+ typedef timeTable Table;
+ flatbuffers::FlatBufferBuilder &fbb_;
+ flatbuffers::uoffset_t start_;
+ void add_scalar(int32_t scalar) {
+ fbb_.AddElement(timeTable::VT_SCALAR, scalar, 0);
+ }
+ explicit timeTableBuilder(flatbuffers::FlatBufferBuilder &_fbb)
+ : fbb_(_fbb) {
+ start_ = fbb_.StartTable();
+ }
+ flatbuffers::Offset Finish() {
+ const auto end = fbb_.EndTable(start_);
+ auto o = flatbuffers::Offset(end);
+ return o;
+ }
+};
+
+inline flatbuffers::Offset CreatetimeTable(
+ flatbuffers::FlatBufferBuilder &_fbb,
+ int32_t scalar = 0) {
+ timeTableBuilder builder_(_fbb);
+ builder_.add_scalar(scalar);
+ return builder_.Finish();
+}
+
+struct timeTable::Traits {
+ using type = timeTable;
+ static auto constexpr Create = CreatetimeTable;
+};
+
+flatbuffers::Offset CreatetimeTable(flatbuffers::FlatBufferBuilder &_fbb, const timeTableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
+
struct vec2TableT : public flatbuffers::NativeTable {
typedef vec2Table TableType;
std::unique_ptr vec{};
@@ -6859,6 +6936,9 @@ struct UnionTable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const TEN::Save::boolTable *u_as_boolean() const {
return u_type() == TEN::Save::VarUnion::boolean ? static_cast(u()) : nullptr;
}
+ const TEN::Save::timeTable *u_as_time() const {
+ return u_type() == TEN::Save::VarUnion::time ? static_cast(u()) : nullptr;
+ }
const TEN::Save::vec2Table *u_as_vec2() const {
return u_type() == TEN::Save::VarUnion::vec2 ? static_cast(u()) : nullptr;
}
@@ -6902,6 +6982,10 @@ template<> inline const TEN::Save::boolTable *UnionTable::u_as inline const TEN::Save::timeTable *UnionTable::u_as() const {
+ return u_as_time();
+}
+
template<> inline const TEN::Save::vec2Table *UnionTable::u_as() const {
return u_as_vec2();
}
@@ -7033,7 +7117,6 @@ struct SaveGameHeaderT : public flatbuffers::NativeTable {
typedef SaveGameHeader TableType;
std::string level_name{};
int32_t level_hash = 0;
- int32_t days = 0;
int32_t hours = 0;
int32_t minutes = 0;
int32_t seconds = 0;
@@ -7049,13 +7132,12 @@ struct SaveGameHeader FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_LEVEL_NAME = 4,
VT_LEVEL_HASH = 6,
- VT_DAYS = 8,
- VT_HOURS = 10,
- VT_MINUTES = 12,
- VT_SECONDS = 14,
- VT_LEVEL = 16,
- VT_TIMER = 18,
- VT_COUNT = 20
+ VT_HOURS = 8,
+ VT_MINUTES = 10,
+ VT_SECONDS = 12,
+ VT_LEVEL = 14,
+ VT_TIMER = 16,
+ VT_COUNT = 18
};
const flatbuffers::String *level_name() const {
return GetPointer(VT_LEVEL_NAME);
@@ -7063,9 +7145,6 @@ struct SaveGameHeader FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
int32_t level_hash() const {
return GetField(VT_LEVEL_HASH, 0);
}
- int32_t days() const {
- return GetField(VT_DAYS, 0);
- }
int32_t hours() const {
return GetField(VT_HOURS, 0);
}
@@ -7089,7 +7168,6 @@ struct SaveGameHeader FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VerifyOffset(verifier, VT_LEVEL_NAME) &&
verifier.VerifyString(level_name()) &&
VerifyField(verifier, VT_LEVEL_HASH) &&
- VerifyField(verifier, VT_DAYS) &&
VerifyField(verifier, VT_HOURS) &&
VerifyField(verifier, VT_MINUTES) &&
VerifyField(verifier, VT_SECONDS) &&
@@ -7113,9 +7191,6 @@ struct SaveGameHeaderBuilder {
void add_level_hash(int32_t level_hash) {
fbb_.AddElement(SaveGameHeader::VT_LEVEL_HASH, level_hash, 0);
}
- void add_days(int32_t days) {
- fbb_.AddElement(SaveGameHeader::VT_DAYS, days, 0);
- }
void add_hours(int32_t hours) {
fbb_.AddElement(SaveGameHeader::VT_HOURS, hours, 0);
}
@@ -7149,7 +7224,6 @@ inline flatbuffers::Offset CreateSaveGameHeader(
flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset level_name = 0,
int32_t level_hash = 0,
- int32_t days = 0,
int32_t hours = 0,
int32_t minutes = 0,
int32_t seconds = 0,
@@ -7163,7 +7237,6 @@ inline flatbuffers::Offset CreateSaveGameHeader(
builder_.add_seconds(seconds);
builder_.add_minutes(minutes);
builder_.add_hours(hours);
- builder_.add_days(days);
builder_.add_level_hash(level_hash);
builder_.add_level_name(level_name);
return builder_.Finish();
@@ -7178,7 +7251,6 @@ inline flatbuffers::Offset CreateSaveGameHeaderDirect(
flatbuffers::FlatBufferBuilder &_fbb,
const char *level_name = nullptr,
int32_t level_hash = 0,
- int32_t days = 0,
int32_t hours = 0,
int32_t minutes = 0,
int32_t seconds = 0,
@@ -7190,7 +7262,6 @@ inline flatbuffers::Offset CreateSaveGameHeaderDirect(
_fbb,
level_name__,
level_hash,
- days,
hours,
minutes,
seconds,
@@ -7206,6 +7277,7 @@ struct SaveGameStatisticsT : public flatbuffers::NativeTable {
int32_t ammo_hits = 0;
int32_t ammo_used = 0;
int32_t medipacks_used = 0;
+ int32_t damage_taken = 0;
int32_t distance = 0;
int32_t kills = 0;
int32_t secrets = 0;
@@ -7220,10 +7292,11 @@ struct SaveGameStatistics FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_AMMO_HITS = 4,
VT_AMMO_USED = 6,
VT_MEDIPACKS_USED = 8,
- VT_DISTANCE = 10,
- VT_KILLS = 12,
- VT_SECRETS = 14,
- VT_TIMER = 16
+ VT_DAMAGE_TAKEN = 10,
+ VT_DISTANCE = 12,
+ VT_KILLS = 14,
+ VT_SECRETS = 16,
+ VT_TIMER = 18
};
int32_t ammo_hits() const {
return GetField(VT_AMMO_HITS, 0);
@@ -7234,6 +7307,9 @@ struct SaveGameStatistics FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
int32_t medipacks_used() const {
return GetField(VT_MEDIPACKS_USED, 0);
}
+ int32_t damage_taken() const {
+ return GetField(VT_DAMAGE_TAKEN, 0);
+ }
int32_t distance() const {
return GetField(VT_DISTANCE, 0);
}
@@ -7251,6 +7327,7 @@ struct SaveGameStatistics FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VerifyField(verifier, VT_AMMO_HITS) &&
VerifyField(verifier, VT_AMMO_USED) &&
VerifyField(verifier, VT_MEDIPACKS_USED) &&
+ VerifyField(verifier, VT_DAMAGE_TAKEN) &&
VerifyField(verifier, VT_DISTANCE) &&
VerifyField(verifier, VT_KILLS) &&
VerifyField(verifier, VT_SECRETS) &&
@@ -7275,6 +7352,9 @@ struct SaveGameStatisticsBuilder {
void add_medipacks_used(int32_t medipacks_used) {
fbb_.AddElement(SaveGameStatistics::VT_MEDIPACKS_USED, medipacks_used, 0);
}
+ void add_damage_taken(int32_t damage_taken) {
+ fbb_.AddElement(SaveGameStatistics::VT_DAMAGE_TAKEN, damage_taken, 0);
+ }
void add_distance(int32_t distance) {
fbb_.AddElement(SaveGameStatistics::VT_DISTANCE, distance, 0);
}
@@ -7303,6 +7383,7 @@ inline flatbuffers::Offset CreateSaveGameStatistics(
int32_t ammo_hits = 0,
int32_t ammo_used = 0,
int32_t medipacks_used = 0,
+ int32_t damage_taken = 0,
int32_t distance = 0,
int32_t kills = 0,
int32_t secrets = 0,
@@ -7312,6 +7393,7 @@ inline flatbuffers::Offset CreateSaveGameStatistics(
builder_.add_secrets(secrets);
builder_.add_kills(kills);
builder_.add_distance(distance);
+ builder_.add_damage_taken(damage_taken);
builder_.add_medipacks_used(medipacks_used);
builder_.add_ammo_used(ammo_used);
builder_.add_ammo_hits(ammo_hits);
@@ -7330,6 +7412,7 @@ struct SaveGameT : public flatbuffers::NativeTable {
std::unique_ptr header{};
std::unique_ptr game{};
std::unique_ptr level{};
+ int32_t secret_map = 0;
std::unique_ptr camera{};
std::unique_ptr lara{};
std::vector> rooms{};
@@ -7394,60 +7477,61 @@ struct SaveGame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_HEADER = 4,
VT_GAME = 6,
VT_LEVEL = 8,
- VT_CAMERA = 10,
- VT_LARA = 12,
- VT_ROOMS = 14,
- VT_ITEMS = 16,
- VT_NEXT_ITEM_FREE = 18,
- VT_NEXT_ITEM_ACTIVE = 20,
- VT_ROOM_ITEMS = 22,
- VT_FISH_SWARM = 24,
- VT_FXINFOS = 26,
- VT_NEXT_FX_FREE = 28,
- VT_NEXT_FX_ACTIVE = 30,
- VT_FIXED_CAMERAS = 32,
- VT_SINKS = 34,
- VT_STATIC_MESHES = 36,
- VT_FLYBY_CAMERAS = 38,
- VT_PARTICLES = 40,
- VT_RATS = 42,
- VT_SPIDERS = 44,
- VT_SCARABS = 46,
- VT_BATS = 48,
- VT_FLIP_MAPS = 50,
- VT_FLIP_STATS = 52,
- VT_FLIP_EFFECT = 54,
- VT_FLIP_TIMER = 56,
- VT_FLIP_STATUS = 58,
- VT_CURRENT_FOV = 60,
- VT_LAST_INV_ITEM = 62,
- VT_ACTION_QUEUE = 64,
- VT_SOUNDTRACKS = 66,
- VT_CD_FLAGS = 68,
- VT_POSTPROCESS_MODE = 70,
- VT_POSTPROCESS_STRENGTH = 72,
- VT_POSTPROCESS_TINT = 74,
- VT_ROPE = 76,
- VT_PENDULUM = 78,
- VT_ALTERNATE_PENDULUM = 80,
- VT_VOLUMES = 82,
- VT_GLOBAL_EVENT_SETS = 84,
- VT_VOLUME_EVENT_SETS = 86,
- VT_SCRIPT_VARS = 88,
- VT_CALLBACKS_PRE_START = 90,
- VT_CALLBACKS_POST_START = 92,
- VT_CALLBACKS_PRE_END = 94,
- VT_CALLBACKS_POST_END = 96,
- VT_CALLBACKS_PRE_SAVE = 98,
- VT_CALLBACKS_POST_SAVE = 100,
- VT_CALLBACKS_PRE_LOAD = 102,
- VT_CALLBACKS_POST_LOAD = 104,
- VT_CALLBACKS_PRE_LOOP = 106,
- VT_CALLBACKS_POST_LOOP = 108,
- VT_CALLBACKS_PRE_USEITEM = 110,
- VT_CALLBACKS_POST_USEITEM = 112,
- VT_CALLBACKS_PRE_FREEZE = 114,
- VT_CALLBACKS_POST_FREEZE = 116
+ VT_SECRET_MAP = 10,
+ VT_CAMERA = 12,
+ VT_LARA = 14,
+ VT_ROOMS = 16,
+ VT_ITEMS = 18,
+ VT_NEXT_ITEM_FREE = 20,
+ VT_NEXT_ITEM_ACTIVE = 22,
+ VT_ROOM_ITEMS = 24,
+ VT_FISH_SWARM = 26,
+ VT_FXINFOS = 28,
+ VT_NEXT_FX_FREE = 30,
+ VT_NEXT_FX_ACTIVE = 32,
+ VT_FIXED_CAMERAS = 34,
+ VT_SINKS = 36,
+ VT_STATIC_MESHES = 38,
+ VT_FLYBY_CAMERAS = 40,
+ VT_PARTICLES = 42,
+ VT_RATS = 44,
+ VT_SPIDERS = 46,
+ VT_SCARABS = 48,
+ VT_BATS = 50,
+ VT_FLIP_MAPS = 52,
+ VT_FLIP_STATS = 54,
+ VT_FLIP_EFFECT = 56,
+ VT_FLIP_TIMER = 58,
+ VT_FLIP_STATUS = 60,
+ VT_CURRENT_FOV = 62,
+ VT_LAST_INV_ITEM = 64,
+ VT_ACTION_QUEUE = 66,
+ VT_SOUNDTRACKS = 68,
+ VT_CD_FLAGS = 70,
+ VT_POSTPROCESS_MODE = 72,
+ VT_POSTPROCESS_STRENGTH = 74,
+ VT_POSTPROCESS_TINT = 76,
+ VT_ROPE = 78,
+ VT_PENDULUM = 80,
+ VT_ALTERNATE_PENDULUM = 82,
+ VT_VOLUMES = 84,
+ VT_GLOBAL_EVENT_SETS = 86,
+ VT_VOLUME_EVENT_SETS = 88,
+ VT_SCRIPT_VARS = 90,
+ VT_CALLBACKS_PRE_START = 92,
+ VT_CALLBACKS_POST_START = 94,
+ VT_CALLBACKS_PRE_END = 96,
+ VT_CALLBACKS_POST_END = 98,
+ VT_CALLBACKS_PRE_SAVE = 100,
+ VT_CALLBACKS_POST_SAVE = 102,
+ VT_CALLBACKS_PRE_LOAD = 104,
+ VT_CALLBACKS_POST_LOAD = 106,
+ VT_CALLBACKS_PRE_LOOP = 108,
+ VT_CALLBACKS_POST_LOOP = 110,
+ VT_CALLBACKS_PRE_USEITEM = 112,
+ VT_CALLBACKS_POST_USEITEM = 114,
+ VT_CALLBACKS_PRE_FREEZE = 116,
+ VT_CALLBACKS_POST_FREEZE = 118
};
const TEN::Save::SaveGameHeader *header() const {
return GetPointer(VT_HEADER);
@@ -7458,6 +7542,9 @@ struct SaveGame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const TEN::Save::SaveGameStatistics *level() const {
return GetPointer(VT_LEVEL);
}
+ int32_t secret_map() const {
+ return GetField(VT_SECRET_MAP, 0);
+ }
const TEN::Save::Camera *camera() const {
return GetPointer(VT_CAMERA);
}
@@ -7628,6 +7715,7 @@ struct SaveGame FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
verifier.VerifyTable(game()) &&
VerifyOffset(verifier, VT_LEVEL) &&
verifier.VerifyTable(level()) &&
+ VerifyField(verifier, VT_SECRET_MAP) &&
VerifyOffset(verifier, VT_CAMERA) &&
verifier.VerifyTable(camera()) &&
VerifyOffset(verifier, VT_LARA) &&
@@ -7775,6 +7863,9 @@ struct SaveGameBuilder {
void add_level(flatbuffers::Offset level) {
fbb_.AddOffset(SaveGame::VT_LEVEL, level);
}
+ void add_secret_map(int32_t secret_map) {
+ fbb_.AddElement(SaveGame::VT_SECRET_MAP, secret_map, 0);
+ }
void add_camera(flatbuffers::Offset camera) {
fbb_.AddOffset(SaveGame::VT_CAMERA, camera);
}
@@ -7953,6 +8044,7 @@ inline flatbuffers::Offset CreateSaveGame(
flatbuffers::Offset