From 6efb292fa7c383b22fad0c5992ede7d302787dd2 Mon Sep 17 00:00:00 2001 From: Maikel de Vries Date: Wed, 14 Mar 2018 16:50:57 +0100 Subject: [PATCH] flame: option to make eternal for editor mode --- .../Effects.ocd/Flame.ocd/Script.c | 64 ++++++++++++++++--- .../Effects.ocd/Flame.ocd/StringTblDE.txt | 6 +- .../Effects.ocd/Flame.ocd/StringTblUS.txt | 6 +- 3 files changed, 65 insertions(+), 11 deletions(-) diff --git a/planet/Objects.ocd/Effects.ocd/Flame.ocd/Script.c b/planet/Objects.ocd/Effects.ocd/Flame.ocd/Script.c index f2bbe1bfc..8232dff32 100644 --- a/planet/Objects.ocd/Effects.ocd/Flame.ocd/Script.c +++ b/planet/Objects.ocd/Effects.ocd/Flame.ocd/Script.c @@ -6,7 +6,7 @@ */ -protected func Initialize() +public func Initialize() { Incinerate(100, GetController()); AddTimer("Burning", RandomX(24, 26)); @@ -15,16 +15,20 @@ protected func Initialize() public func Burning() { - if (!OnFire()) return RemoveObject(); + if (!OnFire()) + return RemoveObject(); // Consume inflammable material and make the flame a little bigger. if (FlameConsumeMaterial() && GetCon() <= 80) { - DoCon(6); - SetXDir(RandomX(-8, 8)); + if (!this.NoBurnDecay) + { + DoCon(6); + SetXDir(RandomX(-8, 8)); + } } // Split the flame if it is large enough and not too many flames are nearby. var amount = ObjectCount(Find_ID(GetID()), Find_Distance(10)); - if (amount < 5 && GetCon() > 50 && !Random(4)) + if (amount < 5 && GetCon() > 50 && !this.NoBurnDecay && !Random(4)) { var x = Random(15); var new_flame = CreateObjectAbove(GetID()); @@ -36,17 +40,59 @@ public func Burning() return; } -// Don't incinerate twice in saved scenarios. -func SaveScenarioObject(props) +public func DoCon(...) { - if (!inherited(props, ...)) return false; + var res = _inherited(...); + // Update any existing fire effect, because it does not do it internally when NoBurnDecay is active. + var fire_fx = GetEffect("Fire", this); + if (fire_fx) + EffectCall(this, fire_fx, "UpdateEffectProperties"); + return res; +} + +public func SetCon(...) +{ + var res = _inherited(...); + // Update any existing fire effect, because it does not do it internally when NoBurnDecay is active. + var fire_fx = GetEffect("Fire", this); + if (fire_fx) + EffectCall(this, fire_fx, "UpdateEffectProperties"); + return res; +} + + +/*-- Saving --*/ + +public func SaveScenarioObject(proplist props) +{ + if (!inherited(props, ...)) + return false; + // Don't incinerate twice in saved scenarios. props->Remove("Fire"); return true; } +/*-- Editor --*/ + +public func EditorInitialize() +{ + // Assume the flame is eternal when placed in the editor + this.NoBurnDecay = true; + return; +} + +public func Definition(proplist def) +{ + if (!def.EditorProps) + def.EditorProps = {}; + def.EditorProps.NoBurnDecay = { Name = "$EditorEternal$", EditorHelp = "$EditorEternalHelp$", Type = "enum", Options = [{ Name = "$EditorEternalOff$", Value = false }, { Name = "$EditorEternalOn$", Value = true }] }; + return; +} + + /*-- Properties --*/ local Name = "$Name$"; local Description = "$Description$"; -local Plane = 500; \ No newline at end of file +local Plane = 500; diff --git a/planet/Objects.ocd/Effects.ocd/Flame.ocd/StringTblDE.txt b/planet/Objects.ocd/Effects.ocd/Flame.ocd/StringTblDE.txt index feaa1b1fe..9dea08e4a 100644 --- a/planet/Objects.ocd/Effects.ocd/Flame.ocd/StringTblDE.txt +++ b/planet/Objects.ocd/Effects.ocd/Flame.ocd/StringTblDE.txt @@ -1,2 +1,6 @@ Name=Flamme -Description=Brennt. \ No newline at end of file +Description=Brennt. +EditorEternal=Eternal +EditorEternalHelp=When active this flame burns eternally. +EditorEternalOn=Eternal +EditorEternalOff=Finite \ No newline at end of file diff --git a/planet/Objects.ocd/Effects.ocd/Flame.ocd/StringTblUS.txt b/planet/Objects.ocd/Effects.ocd/Flame.ocd/StringTblUS.txt index 12616b7fc..824281de5 100644 --- a/planet/Objects.ocd/Effects.ocd/Flame.ocd/StringTblUS.txt +++ b/planet/Objects.ocd/Effects.ocd/Flame.ocd/StringTblUS.txt @@ -1,2 +1,6 @@ Name=Flame -Description=Burning. \ No newline at end of file +Description=Burning. +EditorEternal=Eternal +EditorEternalHelp=When active this flame burns eternally. +EditorEternalOn=Eternal +EditorEternalOff=Finite \ No newline at end of file