diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/Barrel.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Tools.ocd/Barrel.ocd/Script.c index 3c75ff37c..cdeb865f6 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/Barrel.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/Barrel.ocd/Script.c @@ -15,6 +15,7 @@ func Initialize() { AddTimer("Check", 5); + UpdateLiquidContainer(); } func RejectCollect(id def, object new_contents) diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/Script.c index f725fa818..0c744e54d 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/Script.c @@ -9,6 +9,7 @@ local count; local TimeToExplode = 90; // Number of frames to pass until keg explodes +local MaxContentsCount = 12; public func GetCarryTransform(clonk) { @@ -19,20 +20,11 @@ public func GetCarryTransform(clonk) } public func GetCarryPhase() { return 900; } -protected func Initialize() -{ - UpdatePicture(); -} - protected func Construction() { - count = 12; - var effect = AddEffect("Update",this,1,1,this); - effect.oldcount = count; + SetPowderCount(MaxContentsCount); } -local MaxContentsCount = 12; - public func GetPowderCount() { return count; @@ -41,6 +33,9 @@ public func GetPowderCount() public func SetPowderCount(newcount) { count = newcount; + this.Description = Format("%s||$RemainingPowder$: %d", this.Prototype.Description, this.count); + if (count == 0) + ScheduleCall(this, "CheckEmpty", 1, 0); return; } @@ -51,46 +46,47 @@ public func DoPowderCount(int change) return SetPowderCount(GetPowderCount() + change); } -public func FxUpdateTimer(object target, effect, int timer) +private func CheckEmpty() { - if(count != effect.oldcount) - UpdatePicture(); - if(count == 0) + if (count == 0) { ChangeDef(Barrel); - return -1; + this.Description = this.Prototype.Description; + this->~Initialize(); } - effect.oldcount = count; - return 1; } -public func UpdatePicture() +// Do not put differently filled kegs on top of each other. +public func CanBeStackedWith(object other) { - var s = 400; - var yoffs = 14000; - var xoffs = 22000; - var spacing = 14000; + if (this.count != other.count) return false; + return inherited(other, ...); +} + +// Display the powder as a bar over the keg icon. +public func GetInventoryIconOverlay() +{ + if (this.count >= MaxContentsCount) return nil; + + var percentage = 100 - 100 * this.count / this.MaxContentsCount; - if (count == nil) + // Overlay a usage bar. + var overlay = { - SetGraphics(nil, nil, 11); - SetGraphics("Inf", Icon_Number, 12, GFXOV_MODE_Picture); - SetObjDrawTransform(s, 0, xoffs, 0, s, yoffs, 12); - return; - } + Bottom = "0.75em", Margin = ["0.1em", "0.25em"], + BackgroundColor = RGB(0, 0, 0), + margin = + { + Margin = "0.05em", + bar = + { + BackgroundColor = RGB(150, 50, 50), + Right = Format("%d%%", percentage), + } + } + }; - var one = count % 10; - var ten = (count / 10) % 10; - if (ten > 0) - { - SetGraphics(Format("%d", ten), Icon_Number, 11, GFXOV_MODE_Picture); - SetObjDrawTransform(s, 0, xoffs - spacing, 0, s, yoffs, 11); - } - else - SetGraphics(nil, nil, 11); - - SetGraphics(Format("%d", one), Icon_Number, 12, GFXOV_MODE_Picture); - SetObjDrawTransform(s, 0, xoffs, 0, s, yoffs, 12); + return overlay; } public func Incineration(int caused_by) @@ -168,7 +164,7 @@ public func SaveScenarioObject(props) { if (!inherited(props, ...)) return false; var v = GetPowderCount(); - if (v != 12) props->AddCall("Powder", this, "SetPowderCount", v); + if (v != MaxContentsCount) props->AddCall("Powder", this, "SetPowderCount", v); return true; } diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/StringTblDE.txt b/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/StringTblDE.txt index d80651bc6..fffc929be 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/StringTblDE.txt +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/StringTblDE.txt @@ -1,2 +1,3 @@ Name=Pulverfass -Description=Munition für die Kanone. \ No newline at end of file +Description=Munition für die Kanone. +RemainingPowder=Verbleibendes Pulver diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/StringTblUS.txt b/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/StringTblUS.txt index 1aefa5679..d9d005370 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/StringTblUS.txt +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/PowderKeg.ocd/StringTblUS.txt @@ -1,2 +1,3 @@ Name=Powder Keg -Description=Ammunition for the cannon. \ No newline at end of file +Description=Ammunition for the cannon. +RemainingPowder=Remaining powder