From d411f07fda64ad3c0f540e24263b78b05a60621d Mon Sep 17 00:00:00 2001 From: Maikel de Vries Date: Sun, 21 Jan 2018 09:44:12 +0100 Subject: [PATCH] carry heavy: add option for scripters to skip pick up animation This is probably not the cleanest solution but I needed one and could not think of a better option. --- .../Goals.ocd/Defense.ocd/DefenseEnemy.ocd/Script.c | 9 +++++---- .../Libraries.ocd/CarryHeavyControl.ocd/Script.c | 12 +++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/planet/Objects.ocd/Goals.ocd/Defense.ocd/DefenseEnemy.ocd/Script.c b/planet/Objects.ocd/Goals.ocd/Defense.ocd/DefenseEnemy.ocd/Script.c index df79dcb51..6ff01e832 100644 --- a/planet/Objects.ocd/Goals.ocd/Defense.ocd/DefenseEnemy.ocd/Script.c +++ b/planet/Objects.ocd/Goals.ocd/Defense.ocd/DefenseEnemy.ocd/Script.c @@ -158,10 +158,11 @@ private func LaunchEnemyAt(proplist prop_enemy, int wave_nr, int enemy_plr, prop { for (var inv in ForceToInventoryArray(prop_enemy.Inventory)) { - // Action hacking to instantly pick up carry heavy objects. - enemy->SetAction("Jump"); - var inv_obj = enemy->CreateContents(inv); - enemy->SetAction("Walk"); + // Special way to pick up carry heavy objects instantly. + if (inv->~IsCarryHeavy() && (enemy->GetOCF() & OCF_CrewMember)) + inv_obj = enemy->CreateCarryHeavyContents(inv); + else + inv_obj = enemy->CreateContents(inv); // Infinite ammo. if (inv_obj) inv_obj->~SetInfiniteStackCount(); diff --git a/planet/Objects.ocd/Libraries.ocd/CarryHeavyControl.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/CarryHeavyControl.ocd/Script.c index 93863bc08..0c70ad3de 100644 --- a/planet/Objects.ocd/Libraries.ocd/CarryHeavyControl.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/CarryHeavyControl.ocd/Script.c @@ -10,6 +10,16 @@ local lib_carryheavy_obj; // object beeing carried with carryheavy public func GetCarryHeavy() { return lib_carryheavy_obj; } public func IsCarryingHeavy() { return lib_carryheavy_obj != nil; } + +// Helper function to create carry heavy contents without doing the pick up animation. +public func CreateCarryHeavyContents(id obj_id, int amount) +{ + this.BlockCarryHeavyPickUpAnimation = true; + var res = CreateContents(obj_id, amount); + this.BlockCarryHeavyPickUpAnimation = false; + return res; +} + /* Overloads for Inventory */ // Check if we can carry a carry heavy object @@ -173,7 +183,7 @@ private func DoLiftCarryHeavy(object obj) if (obj->Contained() != this) return; // If inside something or not walking, skip the animation - if (Contained() || GetAction() != "Walk") + if (Contained() || GetAction() != "Walk" || this.BlockCarryHeavyPickUpAnimation) return; AddEffect("IntLiftHeavy", this, 1, 1, this, nil, obj); }