forked from Mirrors/openclonk
add option to gravestone rule to fade them out
parent
5b796dd6d0
commit
8cc30baf02
|
@ -160,7 +160,9 @@ private func DoFireworks(int killed_by)
|
||||||
SetRider(nil);
|
SetRider(nil);
|
||||||
}
|
}
|
||||||
// Notify defense goal for reward and score.
|
// Notify defense goal for reward and score.
|
||||||
GameCallEx("OnClonkDeath", this, killed_by);
|
var defense = FindObject(Find_ID(Goal_Defense));
|
||||||
|
if (defense)
|
||||||
|
defense->~OnClonkDeath(this, killed_by);
|
||||||
Fireworks();
|
Fireworks();
|
||||||
Explode(40);
|
Explode(40);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
/*-- Gravestones --*/
|
/**
|
||||||
|
Gravestone Rule
|
||||||
|
Dead clonks are replaced by gravestones.
|
||||||
|
|
||||||
|
@author Ringwaul
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
local fade_out;
|
||||||
|
|
||||||
|
|
||||||
protected func Initialize()
|
protected func Initialize()
|
||||||
|
@ -6,59 +14,81 @@ protected func Initialize()
|
||||||
// Under no circumstance there may by multiple copies of this rule.
|
// Under no circumstance there may by multiple copies of this rule.
|
||||||
if (ObjectCount(Find_ID(Rule_Gravestones)) > 1)
|
if (ObjectCount(Find_ID(Rule_Gravestones)) > 1)
|
||||||
return RemoveObject();
|
return RemoveObject();
|
||||||
|
fade_out = nil;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func SetFadeOut(int time)
|
||||||
|
{
|
||||||
|
fade_out = time;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public func OnClonkDeath(object clonk)
|
public func OnClonkDeath(object clonk)
|
||||||
{
|
{
|
||||||
|
// Add a gravestone if the clonk died.
|
||||||
if (!clonk->GetAlive())
|
if (!clonk->GetAlive())
|
||||||
AddEffect("AddGravestone", clonk, 1, 1, this);
|
clonk->CreateEffect(FxAddGravestone, 100, 1, fade_out);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public func FxAddGravestoneTimer(object target, proplist effect, int timer)
|
local FxAddGravestone = new Effect
|
||||||
{
|
{
|
||||||
// Wait for the death animation to be over.
|
Construction = func(int fade_out)
|
||||||
if (timer >= 20)
|
|
||||||
{
|
{
|
||||||
AddEffect("IntGravestone", target, 1, nil, this);
|
this.fade_out = fade_out;
|
||||||
return -1;
|
},
|
||||||
|
Timer = func(int time)
|
||||||
|
{
|
||||||
|
// Wait for the death animation to be over.
|
||||||
|
if (time >= 20)
|
||||||
|
return FX_Execute_Kill;
|
||||||
|
return FX_OK;
|
||||||
|
},
|
||||||
|
Destruction = func(int reason)
|
||||||
|
{
|
||||||
|
// Don't do anything if the clonk has been removed.
|
||||||
|
if (reason == FX_Call_RemoveClear)
|
||||||
|
return;
|
||||||
|
// Create the grave and remove the clonk.
|
||||||
|
this.grave = Target->CreateObjectAbove(Clonk_Grave, 0, 0, Target->GetController());
|
||||||
|
this.grave->SetInscription(Target);
|
||||||
|
if (this.fade_out > 0)
|
||||||
|
this.grave->FadeOut(this.fade_out, true);
|
||||||
|
Target->RemoveObject();
|
||||||
|
// Smoke effect.
|
||||||
|
var particles =
|
||||||
|
{
|
||||||
|
Prototype = Particles_Dust(),
|
||||||
|
R = 200,
|
||||||
|
G = 100,
|
||||||
|
B = 50,
|
||||||
|
Size = PV_KeyFrames(0, 0, 0, 300, 40, 1000, 15)
|
||||||
|
};
|
||||||
|
this.grave->CreateParticle("Dust", 0, 0, PV_Random(-3, 3), PV_Random(-3, 3), PV_Random(18, 1 * 36), particles, 6);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
public func FxIntGravestoneStart(object clonk, proplist effect)
|
protected func Activate(int by_plr)
|
||||||
{
|
{
|
||||||
effect.grave = clonk->CreateObjectAbove(Clonk_Grave, 0, 0, clonk->GetController());
|
MessageWindow(GetProperty("Description"), by_plr);
|
||||||
effect.grave->SetInscription(clonk);
|
|
||||||
clonk->RemoveObject();
|
|
||||||
//smoke effect
|
|
||||||
var particles =
|
|
||||||
{
|
|
||||||
Prototype = Particles_Dust(),
|
|
||||||
R = 200,
|
|
||||||
G = 100,
|
|
||||||
B = 50,
|
|
||||||
Size = PV_KeyFrames(0, 0, 0, 300, 40, 1000, 15)
|
|
||||||
};
|
|
||||||
effect.grave->CreateParticle("Dust", 0, 0, PV_Random(-3, 3), PV_Random(-3, 3), PV_Random(18, 1 * 36), particles, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
public func FxIntGravestoneStop(object clonk, proplist effect, int reason)
|
|
||||||
{
|
|
||||||
if (reason != FX_Call_RemoveClear)
|
|
||||||
{
|
|
||||||
clonk->Exit();
|
|
||||||
effect.grave->RemoveObject();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected func Activate(int iByPlayer)
|
|
||||||
{
|
|
||||||
MessageWindow(GetProperty("Description"), iByPlayer);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-- Scenario Saving -- */
|
||||||
|
|
||||||
|
public func SaveScenarioObject(props)
|
||||||
|
{
|
||||||
|
if (!inherited(props, ...)) return false;
|
||||||
|
if (fade_out != nil)
|
||||||
|
props->AddCall("FadeOut", this, "SetFadeOut", fade_out);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-- Properties --*/
|
||||||
|
|
||||||
local Name = "$Name$";
|
local Name = "$Name$";
|
||||||
local Description = "$Description$";
|
local Description = "$Description$";
|
||||||
local Visibility = VIS_Editor;
|
local Visibility = VIS_Editor;
|
||||||
|
|
Loading…
Reference in New Issue