2015-12-28 13:43:21 +00:00
|
|
|
#appendto Airship
|
|
|
|
|
2016-01-05 17:20:33 +00:00
|
|
|
local HitPoints = 500;
|
2015-12-28 13:43:21 +00:00
|
|
|
|
|
|
|
public func AllStop()
|
|
|
|
{
|
|
|
|
if (GetType(this) != C4V_Def) return;
|
|
|
|
|
|
|
|
for (var airship in FindObjects(Find_ID(Airship)))
|
|
|
|
{
|
2015-12-30 02:25:51 +00:00
|
|
|
airship->SetCommand("None");
|
2015-12-28 13:43:21 +00:00
|
|
|
airship->SetXDir();
|
|
|
|
airship->SetYDir();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-03 00:53:55 +00:00
|
|
|
public func IsInsideGondola(object clonk)
|
|
|
|
{
|
|
|
|
if (!clonk) return false;
|
|
|
|
|
|
|
|
if (Inside(clonk->GetX() - GetX(), this.gondola[0], this.gondola[2]))
|
|
|
|
if (Inside(clonk->GetY() - GetY(), this.gondola[1], this.gondola[3]))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-28 13:43:21 +00:00
|
|
|
public func PromoteNewCaptain()
|
|
|
|
{
|
|
|
|
var crew = GetCrewMembers();
|
|
|
|
if (!GetLength(crew)) return Sink();
|
|
|
|
var captain = RandomElement(crew);
|
|
|
|
var fx = GetEffect("AI", captain);
|
|
|
|
if (!fx) return Sink(); // shouldn't happen
|
|
|
|
fx.weapon = this;
|
|
|
|
fx.vehicle = this;
|
|
|
|
fx.strategy = CustomAI.ExecutePilot;
|
|
|
|
}
|
|
|
|
|
|
|
|
public func PrepareToBoard(object cpt)
|
|
|
|
{
|
|
|
|
var crew = GetCrewMembers();
|
|
|
|
var count = 0;
|
|
|
|
for (var member in crew)
|
|
|
|
{
|
|
|
|
var fx = GetEffect("AI", member);
|
|
|
|
if (!fx) continue;
|
|
|
|
fx.weapon = nil;
|
|
|
|
fx.strategy = nil;
|
|
|
|
fx.vehicle = nil;
|
|
|
|
fx.carrier = nil;
|
|
|
|
if (member->GetProcedure() == "PUSH") member->SetAction("Walk");
|
|
|
|
count++;
|
|
|
|
}
|
2015-12-30 02:25:51 +00:00
|
|
|
// Suitable crew
|
2015-12-28 13:43:21 +00:00
|
|
|
if (count >= 5)
|
2017-01-03 17:09:42 +00:00
|
|
|
Sound("Clonk::Action::GroupAttack");
|
2015-12-28 13:43:21 +00:00
|
|
|
// Let the captain yell something
|
|
|
|
if (!Random(3) && cpt)
|
|
|
|
cpt->Message(Translate(Format("MsgAttack%d", Random(4))));
|
|
|
|
}
|
|
|
|
|
|
|
|
private func Sink()
|
|
|
|
{
|
|
|
|
Incinerate();
|
|
|
|
}
|
|
|
|
|
|
|
|
private func GetCrewMembers()
|
|
|
|
{
|
|
|
|
return FindObjects(Find_InRect(this.gondola[0], this.gondola[1], this.gondola[2], this.gondola[3]), Find_Owner(GetOwner()), Find_OCF(OCF_Alive));
|
2015-12-31 11:45:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// When fading out the airship, the fade out rule does not check for position changes
|
2016-01-03 00:53:55 +00:00
|
|
|
public func FadeOutForced() { return true; }
|