flame: option to make eternal for editor mode

master
Maikel de Vries 2018-03-14 16:50:57 +01:00
parent f81d41ba84
commit 6efb292fa7
3 changed files with 65 additions and 11 deletions

View File

@ -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;
local Plane = 500;

View File

@ -1,2 +1,6 @@
Name=Flamme
Description=Brennt.
Description=Brennt.
EditorEternal=Eternal
EditorEternalHelp=When active this flame burns eternally.
EditorEternalOn=Eternal
EditorEternalOff=Finite

View File

@ -1,2 +1,6 @@
Name=Flame
Description=Burning.
Description=Burning.
EditorEternal=Eternal
EditorEternalHelp=When active this flame burns eternally.
EditorEternalOn=Eternal
EditorEternalOff=Finite