Skip to content

Commit c01cdf4

Browse files
authored
Merge pull request #453 from cortex-command-community/arm-refactor-and-animations
Arm refactor and animations
2 parents 7f556ad + f1825a8 commit c01cdf4

18 files changed

+1554
-1502
lines changed

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,28 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
495495
- Added Lua convenience function `RoundToNearestMultiple(num, multiple)` which returns a number rounded to the nearest specified multiple.
496496
Note that this operates on integers, so fractional parts will be truncated towards zero by type conversion.
497497

498+
- Added `AHuman` INI and Lua (R/W) property `DeviceArmSwayRate`, that defines how much `HeldDevices` will sway when walking. 0 is no sway, 1 directly couples sway with leg movement, >1 may be funny. Defaults to 0.75.
499+
500+
- Added `AHuman` INI and Lua (R/W) property `ReloadOffset`, that defines where `Hands` should move to when reloading, if they're not holding a supported `HeldDevice`. A non-zero value is reqiured for `OneHandedReloadAngle` to be used.
501+
502+
- Added `AHuman` INI and Lua (R/W) property `OneHandedReloadAngle`, that defines the angle in radians which `HeldDevices` are rotated to when reloading with only one hand (i.e. the `HeldDevice` is one-handed, or the `AHuman` no longer has their bg`Arm`) and the `AHuman` has a non-zero `ReloadOffset`.
503+
504+
- Added `AHuman` Lua function `FirearmsAreReloading(onlyIfAllFirearmsAreReloading)` which returns whether or not this `AHuman`'s `HeldDevices` are currently reloading. If the parameter is set to true and the `AHuman` is holding multiple `HeldDevices`, this will only return true if all of them are reloading.
505+
506+
- Added `AHuman` Lua function `ReloadFirearms(onlyReloadEmptyFirearms)`. This behaves the same as the pre-existing `ReloadFirearms` function, but if the parameter is set to true, only `HDFirearms` that are empty will be reloaded.
507+
498508
- Added `AHuman` Lua property (R/W) `UpperBodyState`, that lets you get and set the `AHuman`'s `UpperBodyState`. If you don't know what this does, you probably don't need or want it.
499509

510+
- Added `HeldDevice` INI and Lua (R/W) property `DualReloadable`, that determines whether or not a one-handed `HeldDevice` can be dual-reloaded (i.e. old reload behaviour). Note that for dual-reload to happen, both equipped `HDFirearms` must have this flag enabled.
511+
512+
- Added `HeldDevice` INI and Lua (R/W) property `OneHandedReloadTimeMultiplier`, that determines how much faster or slower an `HeldDevice` is when reloading one-handed (i.e. if it's one-handed and the other `Arm` is missing, or is holding something).
513+
514+
- Added `HeldDevice` INI and Lua (R/W) property `Supportable`, that determines whether or not a `HeldDevice` can be supported by a background `Arm`.
515+
516+
- Added `Timer` Lua function `GetSimTimeLimitMS()` that gets the sim time limit of the `Timer` in milliseconds.
517+
518+
- Added `Timer` Lua function `GetSimTimeLimitS()` that gets the sim time limit of the `Timer` in seconds.
519+
500520
</details>
501521

502522
<details><summary><b>Changed</b></summary>
@@ -636,6 +656,38 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
636656
- `BitmapPrimitive` drawing functions now accept `MOSprite` instead of `Entity` for the object they get the bitmap to draw from.
637657
This changes nothing regarding the bindings, but will now print an error to the console when attempting to draw a non-`MOSprite` based object (e.g. `MOPixel`), instead of silently skipping it.
638658

659+
- Unless set to dual-reload, one-handed `HDFirearms` will now reload one-at-a-time. To maintain this behaviour in Lua scripts, it is recommend to use `AHuman:ReloadFirearms()` instead of reloading `HeldDevices` directly, as the latter will ignore restrictions.
660+
661+
- Made a lot of changes to `Arms` - they can now only hold `HeldDevices` (and subclasses like `HDFirearms` and `ThrownDevices`), and `AHumans` have a lot of `Arm` animations, including sway when walking and holding something, smoother `Arm` movement and reload animations.
662+
They now have the following INI properties:
663+
```
664+
MaxLength - The max length of the Arm in pixels.
665+
MoveSpeed - How quickly the Arm moves between targets. 0 means no movement, 1 means instant movement.
666+
HandDefaultIdleOffset - The idle offset this Arm will move to if it has no targets, and nothing else affecting its idle offset (e.g. it's not holding or supporting a HeldDevice). IdleOffset is also allowed for compatibility.
667+
HandSprite - The sprite file for this Arm's hand. Hand is also allowed for compatibility.
668+
GripStrength - The Arm's grip strength when holding HeldDevices. Further described below, in the entry where it was added.
669+
ThrowStrength - The Arm's throw strength when throwing ThrownDevices. Further described below, in the entry where it was added.
670+
HeldDevice - Allows you to set the HeldDevice attached to this Arm.
671+
```
672+
They now have the following Lua properties and functions:
673+
**`MaxLength`** (R) - Allows getting the `Arm`'s maximum length.
674+
**`MoveSpeed`** (R/W) - Allows getting and setting the `Arm`'s movement speed. 0 means no movement, 1 means instant movement.
675+
**`HandDefaultIdleOffset`** (R/W) - Allows getting and setting the `Arm`'s default idle hand offset, i.e. where the hand will go when it has no targets and isn't holding or supporting anything.
676+
**`HandCurrentPos`** (R/W) - Gets and sets the current position of the hand. Note that this will override any animations and move the hand to the position instantly, so it's generally not recommended.
677+
**`HasAnyHandTargets`** (R) - Gets whether or not this `Arm` has any hand targets, i.e. any positions the `Arm` is supposed to try to move its hand to.
678+
**`NumberOfHandTargets`** (R) - Gets the number of hand targets this `Arm` has.
679+
**`NextHandTargetDescription`** (R/W) - Gets the description of the next target this `Arm`'s hand is moving to, or an empty string if there are no targets.
680+
**`NextHandTargetPosition`** (R/W) - Gets the position of the next target this `Arm`'s hand is moving to, or `Vector(0, 0)` if there are no targets.
681+
**`HandHasReachedCurrentTarget`** (R) - Gets whether or not this `Arm`'s hand has reached its current target. This may not be reliably accessible from Lua since it can often get reset before being read from Lua, if the target has no delay. Note that this will be true if there are no targets but that hand has reached its appropriate idle offset.
682+
**`GripStrength`** (R/W) - Gets and sets the `Arm`'s grip strength when holding `HeldDevices`. Further described below, in the entry where it was added.
683+
**`ThrowStrength`** (R/W) - Gets and sets the `Arm`'s throw strength when throwing `ThrownDevices`. Further described below, in the entry where it was added.
684+
**`HeldDevice`** (R/W) - Gets and sets the `HeldDevice` held by this `Arm`.
685+
**`SupportedHeldDevice`** (R) - Gets the `HeldDevice` this `Arm` is supporting. For obvious reasons, this will be empty if this is not the BG `Arm` or if it has a `HeldDevice` of its own.
686+
**`AddHandTarget(description, positionOnScene)`** - Adds a target for this `Arm`'s hand to move to. The target goes to the back of the queue, allowing for multiple animations to be added in succession. The description is arbitrary, but useful for identification, and if the target being added has the same description as the target at the end of the queue, they will be merged to avoid duplication.
687+
**`AddHandTarget(description, positionOnScene, delayAtTarget)`** - Adds a target for this `Arm`'s hand to move to as above, but the hand will wait at the target for the specified amount of time.
688+
**`RemoveNextHandTarget()`** - Removes the next hand target from the queue, if there are any.
689+
**`ClearHandTargets()`** - Empties the queue of hand targets. Once the queue is empty, the hand will move towards its appropriate idle offset.
690+
639691
- The following `SceneMan` functions have been moved to `CameraMan`:
640692
```lua
641693
SetOffset(offsetVector, screenId);

Entities/ACraft.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,9 @@ void ACraft::CloseHatch()
601601
m_HatchTimer.Reset();
602602

603603
// When closing, move all newly added inventory to the regular inventory list so it'll be ejected next time doors open
604-
for (std::deque<MovableObject *>::const_iterator niItr = m_CollectedInventory.begin(); niItr != m_CollectedInventory.end(); ++niItr)
605-
m_Inventory.push_back(*niItr);
604+
for (std::deque<MovableObject *>::const_iterator niItr = m_CollectedInventory.begin(); niItr != m_CollectedInventory.end(); ++niItr) {
605+
AddToInventoryBack(*niItr);
606+
}
606607

607608
// Clear the new inventory hold, it's all been moved to the regular inventory
608609
m_CollectedInventory.clear();
@@ -630,7 +631,7 @@ void ACraft::AddInventoryItem(MovableObject *pItemToAdd)
630631
m_CollectedInventory.push_back(pItemToAdd);
631632
// If doors are already closed, it's safe to put the item directly the regular inventory
632633
else
633-
m_Inventory.push_back(pItemToAdd);
634+
AddToInventoryBack(pItemToAdd);
634635
}
635636
}
636637

0 commit comments

Comments
 (0)