forked from Mirrors/openclonk
add defense boom attack object
This is the standard wave attack weapon and is part of the goal in some sense.alut-include-path
parent
a03c67a7a2
commit
eec8127e8a
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
[DefCore]
|
||||
id=DefenseBoomAttack
|
||||
Version=8,0
|
||||
Category=C4D_Vehicle
|
||||
Width=15
|
||||
Height=27
|
||||
Offset=-7,-13
|
||||
Vertices=4
|
||||
VertexX=0,0,-6,6
|
||||
VertexY=13,-13,-5,-5
|
||||
VertexCNAT=8,4,1,2
|
||||
VertexFriction=80,60,60,60
|
||||
Rotate=1
|
||||
IncompleteActivity=1
|
Binary file not shown.
|
@ -0,0 +1,21 @@
|
|||
material Boomattack
|
||||
{
|
||||
receive_shadows on
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 0.500000 0.500000 0.500000 1.000000
|
||||
diffuse 0.640000 0.640000 0.640000 1.000000
|
||||
specular 0.000000 0.000000 0.000000 1.000000 12.500000
|
||||
emissive 0.000000 0.000000 0.000000 1.000000
|
||||
texture_unit
|
||||
{
|
||||
texture boomattack.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
colour_op alpha_blend
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
/**
|
||||
Boom Attack
|
||||
An evil rocket which attacks you, can be ridden as well.
|
||||
|
||||
@authors Randrian, Newton, Sven2
|
||||
*/
|
||||
|
||||
|
||||
public func Construction()
|
||||
{
|
||||
SetAction("Fly");
|
||||
SetComDir(COMD_None);
|
||||
// Add flight effects.
|
||||
CreateEffect(FxFlight, 100, 10);
|
||||
CreateEffect(FxFlightRotation, 100, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*-- Flight --*/
|
||||
|
||||
local FxFlightRotation = new Effect
|
||||
{
|
||||
Construction = func()
|
||||
{
|
||||
this.rotation = 0;
|
||||
},
|
||||
Timer = func(int time)
|
||||
{
|
||||
if (Target->GetRider())
|
||||
return FX_Execute_Kill;
|
||||
|
||||
this.rotation += 2;
|
||||
if (this.rotation >= 360)
|
||||
this.rotation = 0;
|
||||
|
||||
Target.MeshTransformation = Trans_Rotate(this.rotation, 0, 1, 0);
|
||||
return FX_OK;
|
||||
}
|
||||
};
|
||||
|
||||
local FxFlight = new Effect
|
||||
{
|
||||
Construction = func()
|
||||
{
|
||||
this.target = GetRandomAttackTarget(Target);
|
||||
this->Timer(0);
|
||||
},
|
||||
Timer = func(int time)
|
||||
{
|
||||
// Find target and if not explode.
|
||||
if (!this.target)
|
||||
{
|
||||
this.target = GetRandomAttackTarget(Target);
|
||||
if (!this.target)
|
||||
{
|
||||
Target->DoFireworks(NO_OWNER);
|
||||
return FX_Execute_Kill;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust angle every 10 frames.
|
||||
if (!(time % 10))
|
||||
{
|
||||
var dx = this.target->GetX() - Target->GetX();
|
||||
var dy = this.target->GetY() + 50 - Target->GetY();
|
||||
// At this distance, fly horizontally. When getting closer, gradually turn to direct flight into target.
|
||||
var aim_dist = 600;
|
||||
var aim_dy = dy * (aim_dist - Abs(dx)) / aim_dist;
|
||||
var angle = Angle(0, 0, dx, aim_dy);
|
||||
Target->SetXDir(Sin(angle, Target.FlySpeed), 100);
|
||||
Target->SetYDir(-Cos(angle, Target.FlySpeed), 100);
|
||||
Target->SetR(angle);
|
||||
}
|
||||
|
||||
// Create exhaust fire.
|
||||
var x = -Sin(Target->GetR(), 15);
|
||||
var y = +Cos(Target->GetR(), 15);
|
||||
|
||||
var xdir = Target->GetXDir() / 2;
|
||||
var ydir = Target->GetYDir() / 2;
|
||||
Target->CreateParticle("FireDense", x, y, PV_Random(xdir - 4, xdir + 4), PV_Random(ydir - 4, ydir + 4), PV_Random(16, 38), Particles_Thrust(), 5);
|
||||
return FX_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*-- Riding --*/
|
||||
|
||||
local riderattach;
|
||||
local rider;
|
||||
|
||||
public func SetRider(object to)
|
||||
{
|
||||
rider = to;
|
||||
return;
|
||||
}
|
||||
|
||||
public func GetRider() { return rider; }
|
||||
|
||||
public func OnMount(object clonk)
|
||||
{
|
||||
SetRider(clonk);
|
||||
var dir = -1;
|
||||
if (GetX() > LandscapeWidth() / 2)
|
||||
dir = 1;
|
||||
clonk->PlayAnimation("PosRocket", CLONK_ANIM_SLOT_Arms, Anim_Const(0));
|
||||
riderattach = AttachMesh(clonk, "main", "pos_tool1", Trans_Translate(-1000, 2000 * dir, 2000));
|
||||
return true;
|
||||
}
|
||||
|
||||
public func OnUnmount(object clonk)
|
||||
{
|
||||
clonk->StopAnimation(clonk->GetRootAnimation(10));
|
||||
DetachMesh(riderattach);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*-- Explosion --*/
|
||||
|
||||
public func IsProjectileTarget(target,shooter) { return true; }
|
||||
public func OnProjectileHit(object shot) { return DoFireworks(shot->GetController()); }
|
||||
|
||||
public func ContactBottom() { return Hit(); }
|
||||
public func ContactTop() { return Hit(); }
|
||||
public func ContactLeft() { return Hit(); }
|
||||
public func ContactRight() { return Hit(); }
|
||||
|
||||
public func Hit() { return DoFireworks(NO_OWNER); }
|
||||
public func HitObject() { return DoFireworks(NO_OWNER); }
|
||||
|
||||
private func DoFireworks(int killed_by)
|
||||
{
|
||||
if (rider)
|
||||
{
|
||||
rider->Fling(RandomX(-5, 5), -5);
|
||||
rider->SetAction("Walk");
|
||||
SetRider(nil);
|
||||
}
|
||||
// Notify defense goal for reward and score.
|
||||
GameCallEx("OnClonkDeath", this, killed_by);
|
||||
Fireworks();
|
||||
Explode(40);
|
||||
return;
|
||||
}
|
||||
|
||||
public func HasNoNeedForAI() { return true; }
|
||||
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local ActMap = {
|
||||
Fly = {
|
||||
Prototype = Action,
|
||||
Name = "Fly",
|
||||
Procedure = DFA_FLOAT,
|
||||
Length = 1,
|
||||
Delay = 0,
|
||||
Wdt = 15,
|
||||
Hgt = 27,
|
||||
}
|
||||
};
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local ContactCalls = true;
|
||||
local FlySpeed = 100;
|
|
@ -0,0 +1,2 @@
|
|||
Name=Boom-Angriff
|
||||
Description=Böse Rakete die einen angreift! Könnte auch von Gegnern geritten werden.
|
|
@ -0,0 +1,2 @@
|
|||
Name=Boom Attack
|
||||
Description=Angry rocket that attacks you! Might be ridden by enemies as well.
|
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
Loading…
Reference in New Issue