forked from Mirrors/openclonk
animals: added chippie
parent
ce3d7e4227
commit
d4154ab1eb
|
@ -0,0 +1,21 @@
|
|||
material Chippie
|
||||
{
|
||||
receive_shadows on
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.5 0.5 0.5 1.0 12.5
|
||||
emissive 0.0 0.0 0.0 1.0
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture chippie.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,21 @@
|
|||
[DefCore]
|
||||
id=Chippie
|
||||
Version=6,1
|
||||
Category=C4D_Living
|
||||
Width=8
|
||||
Height=8
|
||||
Offset=-4,-4
|
||||
Vertices=7
|
||||
VertexX=0,0,0,-3,3,-2,2
|
||||
VertexY=-1,-3,3,-0,-0,-3,-3
|
||||
VertexCNAT=0,4,8,1,2,1,2
|
||||
VertexFriction=300,300,100,300,300,300,300
|
||||
Mass=30
|
||||
ContactCalls=1
|
||||
NoGet=1
|
||||
Float=0
|
||||
BorderBound=1
|
||||
StretchGrowth=1
|
||||
IncompleteActivity=1
|
||||
Oversize=1
|
||||
Pathfinder=1
|
|
@ -0,0 +1,21 @@
|
|||
material ChippieEgg
|
||||
{
|
||||
receive_shadows on
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.19999998807907104 0.19999998807907104 0.19999998807907104 1.0 12.5
|
||||
emissive 0.0 0.0 0.0 1.0
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture chippieegg.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
[DefCore]
|
||||
id=Chippie_Egg
|
||||
Version=6,1
|
||||
Category=C4D_Object
|
||||
Width=6
|
||||
Height=6
|
||||
Offset=-3,-3
|
||||
Vertices=4
|
||||
VertexX=0, 0, 2, -2
|
||||
VertexY=0, 2, -2, -2
|
||||
VertexFriction=20, 20, 20, 20
|
||||
VertexCNAT=0, 15, 15, 15
|
||||
Value=1
|
||||
Mass=10
|
||||
Components=Chippie_Egg=1
|
||||
Projectile=1
|
||||
Rotate=1
|
||||
IncompleteActivity=1
|
||||
StretchGrowth=1
|
||||
|
Binary file not shown.
|
@ -0,0 +1,163 @@
|
|||
/**
|
||||
Egg
|
||||
New chippies hatch from here.
|
||||
*/
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local Collectible = 1;
|
||||
|
||||
// Default random transform of this egg.
|
||||
local transform;
|
||||
|
||||
local age;
|
||||
|
||||
public func Place(int amount)
|
||||
{
|
||||
var owner = GetCreaturePlayer();
|
||||
while(amount > 0)
|
||||
{
|
||||
var p = nil;
|
||||
if(Random(2)) p = GetInEarthPosition(nil, Material("Tunnel"));
|
||||
if(p == nil)
|
||||
p = GetInEarthPosition();
|
||||
if(p == nil)
|
||||
{
|
||||
--amount;
|
||||
continue;
|
||||
}
|
||||
|
||||
// small circle
|
||||
for(var r = 0; (r < 360) && (amount > 0); r += 40+Random(40))
|
||||
{
|
||||
var o = CreateObject(Chippie_Egg, p.x + Sin(r, 10 + RandomX(-2, 2)), p.y - Cos(r, 10 + RandomX(-2, 2)), owner);
|
||||
if(owner == nil)
|
||||
o->SetCreatureControlled();
|
||||
o->SetCon(RandomX(90, 100));
|
||||
--amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func Entrance()
|
||||
{
|
||||
SetVertex(0, VTX_X, 0, 2);
|
||||
SetVertex(0, VTX_Y, 0, 2);
|
||||
}
|
||||
|
||||
public func Construction()
|
||||
{
|
||||
AddTimer("RndHatch", 100);
|
||||
transform = Trans_Mul(Trans_Rotate(RandomX(-90, 90), 0, 0, 1), Trans_Rotate(RandomX(-90, 90), 1, 0, 0));
|
||||
this.MeshTransformation = transform;
|
||||
}
|
||||
|
||||
public func Initialize()
|
||||
{
|
||||
age = FrameCounter();
|
||||
Yoink();
|
||||
return true;
|
||||
}
|
||||
|
||||
private func GetLifeTime()
|
||||
{
|
||||
return FrameCounter() - age;
|
||||
}
|
||||
|
||||
public func Hit(int x, int y)
|
||||
{
|
||||
if(Hatch()) return;
|
||||
|
||||
// Put one vertex into wall so that the egg sticks.
|
||||
var angle = Angle(0, 0, x, y);
|
||||
var x_capped = +Sin(angle, 5);
|
||||
var y_capped = -Cos(angle, 5);
|
||||
if (GBackSolid(x_capped, y_capped))
|
||||
{
|
||||
// Need to offset the rotation.
|
||||
var x_rotation = Sin(angle - GetR(), 5);
|
||||
var y_rotation = -Cos(angle - GetR(), 5);
|
||||
SetVertex(0, VTX_X, x_rotation, 2);
|
||||
SetVertex(0, VTX_Y, y_rotation, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetVertex(0, VTX_X, 0, 2);
|
||||
SetVertex(0, VTX_Y, 0, 2);
|
||||
}
|
||||
|
||||
SetRDir(0);
|
||||
Sound("SoftHit*");
|
||||
|
||||
var particles =
|
||||
{
|
||||
Prototype = Particles_Material(RGB(50, 200, 50)),
|
||||
DampingX = 950, DampingY = 950,
|
||||
};
|
||||
CreateParticle("WoodChip", PV_Random(-5, 5), PV_Random(-5, 5),
|
||||
PV_Random(-10, 10), PV_Random(-10, 10),
|
||||
PV_Random(10, 20), particles, 30);
|
||||
|
||||
Yoink();
|
||||
}
|
||||
|
||||
private func Yoink()
|
||||
{
|
||||
AddEffect("Wiggle", this, 1, 1, this);
|
||||
}
|
||||
|
||||
private func FxWiggleStart(target, effect, temp)
|
||||
{
|
||||
if(temp) return;
|
||||
effect.start = Random(360);
|
||||
}
|
||||
|
||||
private func FxWiggleTimer(target, effect, time)
|
||||
{
|
||||
var magnitude = Abs(Sin(6 * time, 1000));
|
||||
var x = Sin(effect.start + 4 * time, magnitude);
|
||||
var y = -Cos(effect.start + 5 * time, magnitude);
|
||||
this.MeshTransformation = Trans_Mul(transform, Trans_Scale(1000 + x/4, 1000+y/4, 1000 + Max(x, y)/4));
|
||||
|
||||
if(magnitude <= 1 && Random(2))
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private func FxWiggleStop(target, effect, cause, temp)
|
||||
{
|
||||
if(temp) return;
|
||||
this.MeshTransformation = transform;
|
||||
}
|
||||
|
||||
private func RndHatch()
|
||||
{
|
||||
if(!Random(30))
|
||||
Hatch();
|
||||
}
|
||||
|
||||
private func Hatch()
|
||||
{
|
||||
if(GetLifeTime() < 36 * 120) return false;
|
||||
if(Stuck()) return false;
|
||||
if(Contained()) return false;
|
||||
if(GBackSemiSolid(0, -1)) return false;
|
||||
var cnt = ObjectCount(Find_Distance(50), Find_ID(Chippie));
|
||||
if(cnt >= 5) return false;
|
||||
|
||||
var c = CreateObject(Chippie, 0, 0, GetOwner());
|
||||
c->SetCon(50);
|
||||
c->Sound("ChippieChirp*", false, 25);
|
||||
|
||||
var particles =
|
||||
{
|
||||
Prototype = Particles_Material(RGB(50, 200, 50)),
|
||||
DampingX = 800, DampingY = 800,
|
||||
ForceY = -GetGravity() / 10,
|
||||
};
|
||||
CreateParticle("SmokeDirty", PV_Random(-5, 5), PV_Random(-5, 5),
|
||||
PV_Random(-10, 10), PV_Random(-10, 10),
|
||||
PV_Random(10, 20), particles, 60);
|
||||
RemoveObject();
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Name=Egg
|
||||
Description=New chippies hatch from here.
|
|
@ -0,0 +1,2 @@
|
|||
Name=Egg
|
||||
Description=New chippies hatch from here.
|
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
Binary file not shown.
|
@ -0,0 +1,380 @@
|
|||
/**
|
||||
Chippy
|
||||
Small, lovely creatures.
|
||||
*/
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
|
||||
// Remember the attachee to be able to detach again.
|
||||
local attach_object, attached_mesh;
|
||||
// Remember the energy sucked to frequently spawn offsprings.
|
||||
local energy_sucked;
|
||||
|
||||
public func Construction()
|
||||
{
|
||||
AddEffect("Activity", this, 1, 10, this);
|
||||
SetAction("Walk");
|
||||
SetCreatureControlled();
|
||||
energy_sucked = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
public func Destruction()
|
||||
{
|
||||
if (GetAction() == "Clawing")
|
||||
StopClawing();
|
||||
}
|
||||
|
||||
public func Death()
|
||||
{
|
||||
var particles =
|
||||
{
|
||||
Prototype = Particles_Material(RGB(50, 200, 50)),
|
||||
OnCollision = nil,
|
||||
DampingX = 900, DampingY = 900,
|
||||
};
|
||||
CreateParticle("SmokeDirty", PV_Random(-5, 5), PV_Random(-5, 5),
|
||||
PV_Random(-20, 20), PV_Random(-20, 20),
|
||||
PV_Random(20, 60), particles, 120);
|
||||
Sound("ChippieChirp*", false, 50);
|
||||
RemoveObject();
|
||||
}
|
||||
|
||||
public func AttachTargetLost()
|
||||
{
|
||||
SetAction("Jump");
|
||||
}
|
||||
|
||||
private func StartClawing()
|
||||
{
|
||||
AddEffect("Clawing", this, 1, 30, this);
|
||||
}
|
||||
|
||||
private func StopClawing()
|
||||
{
|
||||
if (attach_object && attached_mesh != nil)
|
||||
attach_object->DetachMesh(attached_mesh);
|
||||
this.Visibility = VIS_All;
|
||||
RemoveEffect("Clawing", this);
|
||||
SetVertexXY(0, 0, -1);
|
||||
}
|
||||
|
||||
private func FxClawingTimer(target, effect, time)
|
||||
{
|
||||
var e = GetActionTarget();
|
||||
if(!e) return SetAction("Jump");
|
||||
|
||||
if((!e->GetAlive()) || GBackSemiSolid())
|
||||
{
|
||||
SetAction("Jump");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Random(3))
|
||||
{
|
||||
var damage = GetCon() * 10;
|
||||
e->DoEnergy(-damage, true, FX_Call_EngGetPunched, GetOwner());
|
||||
energy_sucked += damage;
|
||||
|
||||
if (energy_sucked > 10 * 1000)
|
||||
{
|
||||
LayEgg();
|
||||
energy_sucked -= 10 * 1000;
|
||||
}
|
||||
|
||||
// Grow and prosper.
|
||||
if (GetCon() < 100 && !Random(10))
|
||||
{
|
||||
DoCon(1);
|
||||
DoEnergy(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func StartJump()
|
||||
{
|
||||
RotateGraphics(0, false);
|
||||
if(!GetEffect("DmgShock", this) && !GetEffect("JumpCheck", this))
|
||||
AddEffect("JumpCheck", this, 1, 4, this);
|
||||
}
|
||||
|
||||
private func FxJumpCheckTimer(target, effect, time)
|
||||
{
|
||||
var e = FindObject(Find_AtPoint(), Find_OCF(OCF_Alive), Find_Hostile(GetOwner()));
|
||||
if(e)
|
||||
{
|
||||
ClawTo(e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private func ClawTo(object obj)
|
||||
{
|
||||
// Play the sound on the object, because the chippie turns invisible.
|
||||
obj->Sound("ChippieBite*", false, 50);
|
||||
|
||||
energy_sucked += 5 * 1000;
|
||||
obj->DoEnergy(-5, false, FX_Call_EngGetPunched, GetOwner());
|
||||
// Woops, I broke it.
|
||||
if (!obj || !obj->GetAlive()) return;
|
||||
|
||||
SetAction("Claw", obj);
|
||||
SetVertexXY(0, obj->GetX() - GetX(), obj->GetY() - GetY());
|
||||
|
||||
// Special handling for the Clonk - attach directly to a random bone.
|
||||
if (obj->~IsClonk())
|
||||
{
|
||||
var bone_name = ["skeleton_leg_upper.R", "skeleton_leg_upper.L",
|
||||
"skeleton_arm_upper.R", "skeleton_arm_upper.L",
|
||||
"pos_back2"][Random(5)];
|
||||
attach_object = obj;
|
||||
var scale = GetCon() * 1000 / 100;
|
||||
attached_mesh = attach_object->AttachMesh(this, bone_name, "back",
|
||||
Trans_Mul(Trans_Scale(scale, scale, scale), Trans_Rotate(Random(360), 0, 1, 0)));
|
||||
// Hide the attached object.
|
||||
this.Visibility = VIS_None;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.MeshTransformation = Trans_Mul(Trans_Rotate(90, 0, 1, 0), Trans_Rotate(Random(360), 0, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private func EndJump()
|
||||
{
|
||||
RemoveEffect("JumpCheck", this);
|
||||
}
|
||||
|
||||
private func StartWalk()
|
||||
{
|
||||
RotateGraphics(0, false);
|
||||
}
|
||||
|
||||
private func StartScale()
|
||||
{
|
||||
RotateGraphics(90, false);
|
||||
}
|
||||
|
||||
private func RotateGraphics(int r, bool mirror)
|
||||
{
|
||||
var transform = Trans_Rotate(r, 0, 0, 1);
|
||||
if (mirror) transform = Trans_Mul(transform, Trans_Scale(-1000, 1000, 1000));
|
||||
this.MeshTransformation = transform;
|
||||
}
|
||||
|
||||
private func StartHangle()
|
||||
{
|
||||
RotateGraphics(180, true);
|
||||
}
|
||||
|
||||
private func Jump()
|
||||
{
|
||||
SetAction("Jump");
|
||||
SetSpeed(GetXDir(), -10 - GetXDir());
|
||||
}
|
||||
|
||||
private func FxActivityTimer(target, effect, time)
|
||||
{
|
||||
if((GetAction() == "Jump") || (GetAction() == "Claw"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(GetComDir() != COMD_Stop)
|
||||
if(!Random(5)) Jump();
|
||||
|
||||
if(!GetEffect("DmgShock", this))
|
||||
{
|
||||
for(var enemy in FindObjects(Find_Distance(100), Find_OCF(OCF_Alive), Find_Hostile(GetOwner()), Sort_Distance()))
|
||||
{
|
||||
if(!PathFree(GetX(), GetY(), enemy->GetX(), enemy->GetY())) continue;
|
||||
|
||||
if(enemy->GetX() < GetX())
|
||||
SetComDir(COMD_Left);
|
||||
else SetComDir(COMD_Right);
|
||||
|
||||
if(ObjectDistance(this, enemy) < 20)
|
||||
{
|
||||
SetAction("Jump");
|
||||
var a = Angle(GetX(), GetY(), enemy->GetX(), enemy->GetY());
|
||||
SetSpeed(Sin(a, 20), -Cos(a, 20) - 2);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(GetEffect("DoDance", this))
|
||||
{
|
||||
if(GetAction() == "Walk")
|
||||
{
|
||||
SetComDir(COMD_Stop);
|
||||
Jump();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(!Random(20) && !GetEffect("DanceCooldown", this))
|
||||
{
|
||||
Sound("ChippieTalk*");
|
||||
|
||||
var cnt = 0;
|
||||
for(var obj in FindObjects(Find_Distance(100), Find_ID(GetID()), Find_Allied(GetOwner()), Sort_Distance()))
|
||||
{
|
||||
if(++cnt > 5) break;
|
||||
obj->AddEffect("DoDance", obj, 1, 35*5, obj);
|
||||
obj->AddEffect("DanceCooldown", obj, 1, 35*10, obj);
|
||||
}
|
||||
|
||||
if(!GetEffect("EggCooldown", this))
|
||||
{
|
||||
if(!Random(2))
|
||||
{
|
||||
LayEgg();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!Random(5))
|
||||
{
|
||||
if(Random(2))
|
||||
SetComDir(COMD_Right);
|
||||
else SetComDir(COMD_Left);
|
||||
} else SetComDir(COMD_Stop);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private func FxActivityDamage(target, effect, dmg)
|
||||
{
|
||||
if(dmg > 0) return dmg;
|
||||
AddEffect("DmgShock", this, 1, 35*5, this);
|
||||
return dmg;
|
||||
}
|
||||
|
||||
private func LayEgg()
|
||||
{
|
||||
if(GetEffect("DmgShock", this)) return;
|
||||
var o = CreateObject(Chippie_Egg, 0, 0, GetOwner());
|
||||
o->SetSpeed(-GetXDir(), -GetYDir());
|
||||
o->SetCon(50);
|
||||
o->StartGrowth(10);
|
||||
AddEffect("EggCooldown", this, 1, 35*30, this);
|
||||
}
|
||||
|
||||
local MaxEnergy = 10000;
|
||||
local MaxBreath = 10000;
|
||||
local NoBurnDecay = 1;
|
||||
|
||||
local ActMap = {
|
||||
Walk = {
|
||||
Prototype = Action,
|
||||
Name = "Walk",
|
||||
Procedure = DFA_WALK,
|
||||
Accel = 16,
|
||||
Decel = 22,
|
||||
Speed = 100,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 20,
|
||||
Delay = 1,
|
||||
Animation = "Move",
|
||||
StartCall = "StartWalk"
|
||||
},
|
||||
Swim = {
|
||||
Prototype = Action,
|
||||
Name = "Swim",
|
||||
Procedure = DFA_SWIM,
|
||||
Accel = 16,
|
||||
Decel = 22,
|
||||
Speed = 100,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 20,
|
||||
Delay = 1,
|
||||
Animation = "Move",
|
||||
StartCall = "StartWalk"
|
||||
},
|
||||
Scale = {
|
||||
Prototype = Action,
|
||||
Name = "Scale",
|
||||
Procedure = DFA_SCALE,
|
||||
Accel = 16,
|
||||
Decel = 22,
|
||||
Speed = 50,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 20,
|
||||
Delay = 2,
|
||||
Animation = "Move",
|
||||
StartCall = "StartScale"
|
||||
},
|
||||
Hangle = {
|
||||
Prototype = Action,
|
||||
Name = "Hangle",
|
||||
Procedure = DFA_HANGLE,
|
||||
Accel = 16,
|
||||
Decel = 22,
|
||||
Speed = 50,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 20,
|
||||
Delay = 2,
|
||||
Animation = "Move",
|
||||
StartCall = "StartHangle"
|
||||
},
|
||||
Kneel = {
|
||||
Prototype = Action,
|
||||
Name = "Kneel",
|
||||
Procedure = DFA_KNEEL,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 20,
|
||||
Delay = 2,
|
||||
Animation = "Move",
|
||||
NextAction = "Walk",
|
||||
},
|
||||
Jump = {
|
||||
Prototype = Action,
|
||||
Name = "Jump",
|
||||
Procedure = DFA_FLIGHT,
|
||||
Speed = 200,
|
||||
Accel = 14,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 20,
|
||||
Delay = 2,
|
||||
Animation = "Move",
|
||||
PhaseCall = "CheckStuck",
|
||||
StartCall = "StartJump",
|
||||
EndCall = "EndJump",
|
||||
AbortCall = "EndJump"
|
||||
},
|
||||
Dead = {
|
||||
Prototype = Action,
|
||||
Name = "Dead",
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 10,
|
||||
Delay = 3,
|
||||
Animation = "Move",
|
||||
NextAction = "Hold",
|
||||
NoOtherAction = 1,
|
||||
ObjectDisabled = 1,
|
||||
},
|
||||
Claw = {
|
||||
Prototype = Action,
|
||||
Name = "Claw",
|
||||
Procedure = DFA_ATTACH,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 1,
|
||||
Delay = 0,
|
||||
Animation = "Move",
|
||||
NextAction = "Hold",
|
||||
StartCall = "StartClawing",
|
||||
EndCall = "StopClawing",
|
||||
AbortCall = "StopClawing",
|
||||
},
|
||||
};
|
|
@ -0,0 +1,2 @@
|
|||
Name=Chippie
|
||||
Description=Small, lovely creatures.
|
|
@ -0,0 +1,2 @@
|
|||
Name=Chippie
|
||||
Description=Small, lovely creatures.
|
|
@ -0,0 +1,6 @@
|
|||
Sounds by ala.
|
||||
CC Attribution 3.0 license (http://creativecommons.org/licenses/by/3.0/).
|
||||
|
||||
ChippieChirp1-3
|
||||
ChippieTalk1-2
|
||||
ChippieBite1-2
|
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
Loading…
Reference in New Issue