forked from Mirrors/openclonk
parent
bd5e127b22
commit
6bcdfa3525
|
@ -5,14 +5,13 @@
|
|||
A small annoying being.
|
||||
*/
|
||||
|
||||
#include Library_Insect
|
||||
#include Library_InsectSwarm
|
||||
|
||||
local lib_swarm_standard = 20;
|
||||
local lib_insect_max_dist = 50;
|
||||
local lib_insect_nocturnal = true;
|
||||
|
||||
protected func Initialize()
|
||||
private func Initialize()
|
||||
{
|
||||
SetAction("Fly");
|
||||
SetPhase(Random(3));
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
|
@ -0,0 +1,13 @@
|
|||
[DefCore]
|
||||
id=Zaphive
|
||||
Version=6,1
|
||||
Category=C4D_StaticBack
|
||||
Width=6
|
||||
Height=8
|
||||
Offset=-3,-4
|
||||
Value=5
|
||||
Mass=2
|
||||
Vertices=4
|
||||
VertexX=0,0,-2,2
|
||||
VertexY=-3,3,0,0
|
||||
VertexFriction=100,100,100,100
|
|
@ -0,0 +1,18 @@
|
|||
// Materials for Graphics
|
||||
|
||||
material Bee_Hive
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
diffuse 1.0 1.0 1.0
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture BeeHive.png
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
Zaphive
|
||||
|
||||
Author: Clonkonaut
|
||||
*/
|
||||
|
||||
/* Placement */
|
||||
|
||||
public func Place(int amount, proplist rectangle)
|
||||
{
|
||||
// No calls to objects, only definitions
|
||||
if (GetType(this) == C4V_C4Object) return;
|
||||
// Default parameters
|
||||
if (!amount) amount = 1;
|
||||
if (!rectangle) rectangle = Rectangle(0,0, LandscapeWidth(), LandscapeHeight());
|
||||
|
||||
var trees = FindObjects(Find_InRect(rectangle.x, rectangle.y, rectangle.w, rectangle.h), Find_OCF(OCF_Fullcon), Find_Func("IsTree"), Find_Func("IsStanding"), Sort_Random());
|
||||
var hives = CreateArray(), hive;
|
||||
while (amount)
|
||||
{
|
||||
hive = nil;
|
||||
for (var tree in trees)
|
||||
{
|
||||
hive = tree->CreateObjectInTreetop(this);
|
||||
if (hive) break;
|
||||
}
|
||||
if (hive)
|
||||
hives[GetLength(hives)] = hive;
|
||||
amount--;
|
||||
}
|
||||
return hives;
|
||||
}
|
||||
|
||||
local tree;
|
||||
|
||||
// Called by trees
|
||||
public func AttachToTree(object to_attach)
|
||||
{
|
||||
tree = to_attach;
|
||||
// Move down (this might break placement by the tree but...yeah!)
|
||||
SetPosition(GetX(), GetY()+4);
|
||||
}
|
||||
|
||||
// Called by trees
|
||||
public func DeattachFromTree()
|
||||
{
|
||||
// Fall down
|
||||
SetCategory(GetCategory() & ~C4D_StaticBack);
|
||||
}
|
||||
|
||||
/* Creation */
|
||||
|
||||
private func Initialize()
|
||||
{
|
||||
SetProperty("MeshTransformation", Trans_Rotate(RandomX(-50,50),0,1,0));
|
||||
// Create a little swarm
|
||||
var zap = CreateObject(Zap);
|
||||
// Could be instantly dead
|
||||
if (zap)
|
||||
zap->SetHome(this);
|
||||
}
|
||||
|
||||
/* Destruction */
|
||||
|
||||
private func Hit2()
|
||||
{
|
||||
// Create an enraged swarm
|
||||
var zap = CreateObject(Zap,0, -3);
|
||||
// Could be instantly dead
|
||||
if (zap)
|
||||
zap->SetEnraged();
|
||||
RemoveObject();
|
||||
}
|
||||
|
||||
local Name = "$Name$";
|
|
@ -0,0 +1 @@
|
|||
Name=Zapnest
|
|
@ -0,0 +1 @@
|
|||
Name=Zaphive
|
|
@ -0,0 +1,16 @@
|
|||
[DefCore]
|
||||
id=Zap
|
||||
Version=6,1
|
||||
Category=C4D_Living
|
||||
ContactCalls=1
|
||||
Width=2
|
||||
Height=2
|
||||
Offset=-1,-1
|
||||
Mass=1
|
||||
Vertices=4
|
||||
VertexX=0,0,-1,1
|
||||
VertexY=-1,1,0,0
|
||||
VertexCNAT=4,8,1,2
|
||||
VertexFriction=100,100,100,100
|
||||
Float=1
|
||||
BorderBound=7
|
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
Zap
|
||||
|
||||
Author: Clonkonaut
|
||||
|
||||
Protects its hive!
|
||||
*/
|
||||
|
||||
#include Library_InsectSwarm
|
||||
|
||||
local lib_swarm_standard = 5;
|
||||
local swarm_enraged = 20;
|
||||
local lib_swarm_density = 5;
|
||||
local lib_insect_max_dist = 100;
|
||||
|
||||
local home;
|
||||
local enraged;
|
||||
local enrage_target;
|
||||
local sting_damage = 2;
|
||||
|
||||
// Called by the zaphive
|
||||
public func SetHome(object my_castle)
|
||||
{
|
||||
home = my_castle;
|
||||
this->CreateSwarm(lib_swarm_standard);
|
||||
}
|
||||
|
||||
// Called by the zaphive
|
||||
public func SetEnraged()
|
||||
{
|
||||
this->CreateSwarm(swarm_enraged);
|
||||
SwarmCall("SetEnragedSwarm");
|
||||
}
|
||||
|
||||
// Called by swarm helper
|
||||
public func SetEnragedSwarm()
|
||||
{
|
||||
enraged = true;
|
||||
SetAction("Attack");
|
||||
}
|
||||
|
||||
private func Initialize()
|
||||
{
|
||||
SetAction("Fly");
|
||||
SetPhase(Random(3));
|
||||
|
||||
_inherited();
|
||||
}
|
||||
|
||||
private func Death()
|
||||
{
|
||||
_inherited();
|
||||
RemoveObject();
|
||||
}
|
||||
|
||||
private func MissionComplete()
|
||||
{
|
||||
if (enraged)
|
||||
MoveToTarget();
|
||||
else
|
||||
_inherited();
|
||||
}
|
||||
|
||||
private func Sleep()
|
||||
{
|
||||
if (enraged) return MoveToTarget();
|
||||
if (lib_insect_sleeping) return;
|
||||
|
||||
if (lib_insect_going2sleep)
|
||||
{
|
||||
SetAction("Sleep");
|
||||
lib_insect_sleeping = true;
|
||||
return;
|
||||
}
|
||||
// One last trip, then become invisible
|
||||
MoveToTarget();
|
||||
lib_insect_going2sleep = true;
|
||||
}
|
||||
|
||||
private func SleepComplete()
|
||||
{
|
||||
SetAction("Sleep");
|
||||
_inherited();
|
||||
}
|
||||
|
||||
private func WakeUp()
|
||||
{
|
||||
SetAction("Fly");
|
||||
_inherited();
|
||||
}
|
||||
|
||||
private func GetAttraction(proplist coordinates)
|
||||
{
|
||||
if (enraged) return Enrage(coordinates);
|
||||
if (!home)
|
||||
{
|
||||
HomeIsLost();
|
||||
return false;
|
||||
}
|
||||
// GetAttraction will only be called for the swarm master, perfect to have just one being make sound
|
||||
if(!Random(20))
|
||||
Sound("Zap?", nil,nil,nil,nil, 200);
|
||||
|
||||
coordinates.x = home->GetX() + Random(20)-10;
|
||||
coordinates.y = home->GetY() + Random(20)-10;
|
||||
return true;
|
||||
}
|
||||
|
||||
private func HomeIsLost()
|
||||
{
|
||||
if (!Random(2)) Kill();
|
||||
}
|
||||
|
||||
private func Enrage(proplist coordinates)
|
||||
{
|
||||
if (!enrage_target)
|
||||
CheckTarget();
|
||||
if (!enrage_target)
|
||||
return false;
|
||||
if (ObjectDistance(enrage_target) < 10)
|
||||
return Sting();
|
||||
|
||||
if (!(enrage_target->GetAlive())) return Kill();
|
||||
if (enrage_target->Contained())
|
||||
{
|
||||
if (!Random(25)) return Kill();
|
||||
return false;
|
||||
}
|
||||
if (!Random(50)) return Kill();
|
||||
if (!GBackSky() && !Random(25)) return Kill();
|
||||
|
||||
coordinates.x = enrage_target->GetX();
|
||||
coordinates.y = enrage_target->GetY();
|
||||
return true;
|
||||
}
|
||||
|
||||
private func Sting()
|
||||
{
|
||||
if (!enrage_target) return false;
|
||||
|
||||
Punch(enrage_target, sting_damage);
|
||||
Kill();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Look for a target to attack
|
||||
private func CheckTarget()
|
||||
{
|
||||
var clonk = FindObject(Find_Distance(200), Find_OCF(OCF_CrewMember), Find_OCF(OCF_Alive), Find_NoContainer(), Find_PathFree(), Sort_Distance());
|
||||
if (clonk)
|
||||
{
|
||||
SwarmCall("DoAttack", clonk);
|
||||
return;
|
||||
}
|
||||
if (!Random(10)) Kill();
|
||||
}
|
||||
|
||||
public func DoAttack(object to_kill)
|
||||
{
|
||||
enrage_target = to_kill;
|
||||
}
|
||||
|
||||
private func CheckTurn()
|
||||
{
|
||||
if (GetXDir() < 0)
|
||||
SetDir(DIR_Left);
|
||||
if (GetXDir() > 0)
|
||||
SetDir(DIR_Right);
|
||||
}
|
||||
|
||||
private func AngryBuzz()
|
||||
{
|
||||
Sound("Zap?");
|
||||
}
|
||||
|
||||
/*-- Saving --*/
|
||||
|
||||
public func SaveScenarioObject(proplist props)
|
||||
{
|
||||
if (!inherited(props, ...)) return false;
|
||||
// Ignore some fast-changing stuff
|
||||
props->Remove("XDir");
|
||||
props->Remove("YDir");
|
||||
props->Remove("Command");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Definition */
|
||||
|
||||
local ActMap = {
|
||||
Fly = {
|
||||
Prototype = Action,
|
||||
Name = "Fly",
|
||||
Procedure = DFA_FLOAT,
|
||||
Speed = 100,
|
||||
Accel = 5,
|
||||
Decel = 5,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 3,
|
||||
Delay = 2,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Wdt = 2,
|
||||
Hgt = 2,
|
||||
NextAction = "Fly",
|
||||
EndCall = "CheckTurn",
|
||||
},
|
||||
Attack = {
|
||||
Prototype = Action,
|
||||
Name = "Attack",
|
||||
Procedure = DFA_FLOAT,
|
||||
Speed = 200,
|
||||
Accel = 30,
|
||||
Decel = 30,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 3,
|
||||
Delay = 2,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Wdt = 2,
|
||||
Hgt = 2,
|
||||
NextAction = "Attack",
|
||||
StartCall = "AngryBuzz",
|
||||
EndCall = "CheckTurn",
|
||||
},
|
||||
Sleep = {
|
||||
Prototype = Action,
|
||||
Name = "Sleep",
|
||||
Procedure = DFA_FLOAT,
|
||||
Speed = 0,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 1,
|
||||
Delay = 1,
|
||||
X = 6,
|
||||
Y = 0,
|
||||
Wdt = 2,
|
||||
Hgt = 2,
|
||||
NextAction = "Hold",
|
||||
},
|
||||
};
|
||||
|
||||
local Name = "$Name$";
|
||||
local MaxEnergy = 30000;
|
||||
local MaxBreath = 250;
|
||||
local Placement = 2;
|
||||
local NoBurnDecay = 1;
|
|
@ -0,0 +1 @@
|
|||
Name=Zap
|
|
@ -0,0 +1 @@
|
|||
Name=Zap
|
|
@ -19,6 +19,14 @@ public func Place(int amount, int swarm_members, proplist area)
|
|||
insect->CreateSwarm(swarm_members - 1); // -1 because one insect already exists
|
||||
}
|
||||
|
||||
/** Call something for every swarm member
|
||||
*/
|
||||
public func SwarmCall(string func, par1, par2, par3, par4, par5, par6, par7, par8, par9)
|
||||
{
|
||||
if(!lib_swarm_helper) return;
|
||||
lib_swarm_helper->SwarmCall(func, par1, par2, par3, par4, par5, par6, par7, par8, par9);
|
||||
}
|
||||
|
||||
/** Standard swarm size (utilised in Place()). Default 10.
|
||||
*/
|
||||
local lib_swarm_standard = 10;
|
||||
|
@ -41,7 +49,7 @@ public func CreateSwarm(int amount)
|
|||
if (!amount) return;
|
||||
|
||||
// Create a swarm helper
|
||||
lib_swarm_helper = CreateObject(Library_Swarm_Helper,0,0,NO_OWNER);
|
||||
lib_swarm_helper = CreateObject(Library_Swarm_Helper, AbsX(0), AbsY(0), NO_OWNER);
|
||||
lib_swarm_helper->SetMaster(this);
|
||||
lib_swarm_helper->SetSwarmCount(amount);
|
||||
|
||||
|
@ -56,6 +64,8 @@ public func CreateSwarm(int amount)
|
|||
last_created = insect;
|
||||
amount--;
|
||||
}
|
||||
|
||||
return lib_swarm_helper;
|
||||
}
|
||||
|
||||
public func SetNextInLine(object next)
|
||||
|
@ -71,6 +81,7 @@ public func SetPreviousInLine(object next)
|
|||
public func SetSwarmHelper(object helper)
|
||||
{
|
||||
lib_swarm_helper = helper;
|
||||
lib_swarm_helper->AddSwarmMember(this);
|
||||
}
|
||||
|
||||
// Swarm insect need randomized activities to not look odd
|
||||
|
|
|
@ -7,12 +7,20 @@
|
|||
|
||||
local swarm_master;
|
||||
local swarm_count;
|
||||
local swarm;
|
||||
|
||||
private func Initialize()
|
||||
{
|
||||
SetPosition(0,0);
|
||||
}
|
||||
|
||||
public func SwarmCall(string func, par1, par2, par3, par4, par5, par6, par7, par8, par9)
|
||||
{
|
||||
for (var insect in swarm)
|
||||
if (insect)
|
||||
insect->Call(func, par1, par2, par3, par4, par5, par6, par7, par8, par9);
|
||||
}
|
||||
|
||||
public func SetMaster(object new_master)
|
||||
{
|
||||
if (!new_master) return;
|
||||
|
@ -45,6 +53,12 @@ public func GetSwarmCenter(proplist coordinates)
|
|||
coordinates.y = swarm_master->GetY();
|
||||
}
|
||||
|
||||
public func AddSwarmMember(object insect)
|
||||
{
|
||||
if (!swarm) swarm = CreateArray();
|
||||
swarm[GetLength(swarm)] = insect;
|
||||
}
|
||||
|
||||
/* Saving */
|
||||
|
||||
public func SaveScenarioObject(proplist props)
|
||||
|
@ -64,5 +78,4 @@ public func SaveScenarioObject(proplist props)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
local Name = "$Name$";
|
||||
local Name = "$Name$";
|
|
@ -226,6 +226,9 @@ private func MoveToTarget()
|
|||
// Priority is always to move to an interesting spot
|
||||
if (!GetAttraction(coordinates))
|
||||
{
|
||||
// Insect may have died
|
||||
if (!this || !GetAlive()) return;
|
||||
|
||||
if (!lib_insect_max_dist)
|
||||
coordinates.x = Random(LandscapeWidth());
|
||||
else
|
||||
|
@ -239,6 +242,9 @@ private func MoveToTarget()
|
|||
}
|
||||
coordinates.y = GetHorizonHeight(coordinates.x)- 30 - Random(60);
|
||||
}
|
||||
// Insect may have died
|
||||
if (!this || !GetAlive()) return;
|
||||
|
||||
SetCommand("MoveTo", nil, coordinates.x, coordinates.y, nil, true);
|
||||
AppendCommand("Call", this, nil,nil,nil,nil, "MissionComplete");
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -7,6 +7,7 @@ Author Work(s)
|
|||
Ringwaul - MonsterGrowl*, MonsterDie, Snuff*, WipfAroof, WipfWhine
|
||||
Clonkonaut - Confirm*, FDie
|
||||
Checkmaty - ProjectileHitLiving*
|
||||
ala - Zap1-4, GlassBreak
|
||||
dobroide - BirdsLoop (http://www.freesound.org/people/dobroide/sounds/54746/)
|
||||
Benboncan - Blast*/BlastMetal (http://www.freesound.org/people/Benboncan/sounds/73005/)
|
||||
Stickinthemud - Clonk (http://www.freesound.org/people/Stickinthemud/sounds/27526/)
|
||||
|
|
Loading…
Reference in New Issue