1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/**
Flame
Spreads fire.
@author Maikel
*/
public func Initialize()
{
Incinerate(100, GetController());
AddTimer("Burning", RandomX(24, 26));
return;
}
public func Burning()
{
if (!OnFire())
return RemoveObject();
// Consume inflammable material and make the flame a little bigger.
if (FlameConsumeMaterial() && GetCon() <= 80)
{
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 && !this.NoBurnDecay && !Random(4))
{
var x = Random(15);
var new_flame = CreateObjectAbove(GetID());
new_flame->SetSpeed(x, -7);
new_flame->SetCon(GetCon() / 2);
SetSpeed(-x, -7);
SetCon(GetCon() / 2);
}
return;
}
public func DoCon(...)
{
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;
|