forked from Mirrors/openclonk
defense goal: improve scoreboard, description and enemies
parent
f3626469b2
commit
0086f236c1
|
@ -88,6 +88,13 @@ public func ExecuteBomber(effect fx)
|
|||
fx.weapon->Explode(fx.weapon->GetExplosionStrength());
|
||||
fx.Target->Kill();
|
||||
}
|
||||
// Are we stuck?
|
||||
else if (fx.Target->Stuck())
|
||||
{
|
||||
// Also perform suicide, because we can safely assume the player somehow trapped this AI.
|
||||
fx.weapon->Explode(fx.weapon->GetExplosionStrength());
|
||||
fx.Target->Kill();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not in range. Walk there.
|
||||
|
|
|
@ -137,7 +137,7 @@ local FxFlight = new Effect
|
|||
// At this distance, fly horizontally. When getting closer, gradually turn to direct flight into target.
|
||||
if (!this.current_waypoint)
|
||||
{
|
||||
var aim_dist = 600;
|
||||
var aim_dist = 600;
|
||||
dy = dy * (aim_dist - Abs(dx)) / aim_dist;
|
||||
}
|
||||
}
|
||||
|
@ -147,10 +147,11 @@ local FxFlight = new Effect
|
|||
angle_rocket += 360;
|
||||
// Gradually update the angle.
|
||||
var angle_delta = angle_rocket - angle_to_target;
|
||||
var angle_step = BoundBy(Target.FlySpeed / 25, 4, 8);
|
||||
if (Inside(angle_delta, 0, 180) || Inside(angle_delta, -360, -180))
|
||||
Target->SetR(Target->GetR() - Min(4, Abs(angle_delta)));
|
||||
Target->SetR(Target->GetR() - Min(angle_step, Abs(angle_delta)));
|
||||
else if (Inside(angle_delta, -180, 0) || Inside(angle_delta, 180, 360))
|
||||
Target->SetR(Target->GetR() + Min(4, Abs(angle_delta)));
|
||||
Target->SetR(Target->GetR() + Min(angle_step, Abs(angle_delta)));
|
||||
|
||||
// Update velocity according to angle.
|
||||
Target->SetXDir(Sin(Target->GetR(), Target.FlySpeed), 100);
|
||||
|
@ -158,7 +159,7 @@ local FxFlight = new Effect
|
|||
|
||||
// Create exhaust fire.
|
||||
var x = -Sin(Target->GetR(), 15);
|
||||
var y = +Cos(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);
|
||||
|
@ -294,7 +295,7 @@ public func Destruction()
|
|||
public func HasNoNeedForAI() { return true; }
|
||||
|
||||
|
||||
/* Enemy spawn registration */
|
||||
/*-- Enemy spawn registration --*/
|
||||
|
||||
public func Definition(def)
|
||||
{
|
||||
|
@ -320,7 +321,7 @@ private func SpawnBoomAttack(array pos, proplist enemy_data, proplist enemy_def,
|
|||
// Boomattack settings
|
||||
boom.FlySpeed = enemy_data.FlySpeed;
|
||||
var wp0 = attack_path[0];
|
||||
boom->SetR(Angle(0, 0, wp0.X - pos[0], wp0.Y - pos[1]) + Random(11)-5);
|
||||
boom->SetR(Angle(0, 0, wp0.X - pos[0], wp0.Y - pos[1]) + Random(11) - 5);
|
||||
boom->SetWaypoints(attack_path);
|
||||
// Rider?
|
||||
var clonk = EnemySpawn->SpawnAICreature(enemy_data.Rider, pos, enemy_def, [attack_path[-1]], spawner);
|
||||
|
|
|
@ -134,7 +134,10 @@ private func LaunchEnemyAt(proplist prop_enemy, int wave_nr, int enemy_plr, prop
|
|||
{
|
||||
for (var inv in ForceVal2Array(prop_enemy.Inventory))
|
||||
{
|
||||
// Action hacking to instantly pick up carry heavy objects.
|
||||
enemy->SetAction("Jump");
|
||||
var inv_obj = enemy->CreateContents(inv);
|
||||
enemy->SetAction("Walk");
|
||||
// Infinite ammo.
|
||||
if (inv_obj)
|
||||
inv_obj->~SetInfiniteStackCount();
|
||||
|
@ -268,7 +271,7 @@ local Spearman = new DefaultEnemy
|
|||
Skin = CSKIN_Steampunk
|
||||
};
|
||||
|
||||
// A clonk with javelins.
|
||||
// A clonk with a grenade launcher.
|
||||
local Grenadier = new DefaultEnemy
|
||||
{
|
||||
Name = "$EnemyGrenadier$",
|
||||
|
|
|
@ -28,7 +28,7 @@ local shared_wealth_remainder;
|
|||
local observer_container;
|
||||
local plrs_active;
|
||||
local plrs_bonus;
|
||||
local plrs_score;
|
||||
local plrs_kills;
|
||||
|
||||
|
||||
public func Construction()
|
||||
|
@ -46,11 +46,12 @@ public func Construction()
|
|||
// Init player tracking.
|
||||
plrs_active = [];
|
||||
plrs_bonus = [];
|
||||
plrs_score = [];
|
||||
plrs_kills = [];
|
||||
// Initialize scoreboard.
|
||||
Scoreboard->SetTitle(Format("$MsgScoreboard$", GetScore()));
|
||||
Scoreboard->Init([
|
||||
{key = "bonus", title = Icon_Wealth, sorted = true, desc = true, default = "0", priority = 100}
|
||||
{key = "bonus", title = Icon_Wealth, sorted = true, desc = true, default = "0", priority = 100},
|
||||
{key = "kills", title = Scoreboard_Kill, sorted = true, desc = true, default = "0", priority = 50}
|
||||
]);
|
||||
// Create the enemy script player, the script player should be in the attackers team (id = 2).
|
||||
CreateScriptPlayer("$PlayerAttackers$", nil, 2, CSPF_NoEliminationCheck | CSPF_NoScenarioInit | CSPF_NoScenarioSave, GetID());
|
||||
|
@ -72,7 +73,9 @@ public func InitializePlayer(int plr)
|
|||
// Initialize scoreboard.
|
||||
Scoreboard->NewPlayerEntry(plr);
|
||||
plrs_bonus[plrid] = 0;
|
||||
plrs_kills[plrid] = 0;
|
||||
Scoreboard->SetPlayerData(plr, "bonus", plrs_bonus[plrid]);
|
||||
Scoreboard->SetPlayerData(plr, "kills", plrs_kills[plrid]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -287,6 +290,12 @@ local FxWaveControl = new Effect
|
|||
return FX_OK;
|
||||
},
|
||||
|
||||
Destruction = func()
|
||||
{
|
||||
// Remove clock, since not needed any more.
|
||||
GUI_Clock->RemoveCountdown();
|
||||
},
|
||||
|
||||
OnWaveCompleted = func(int wave_nr)
|
||||
{
|
||||
// Set current wave to nil if it has been completed and has no duration in order to start new one.
|
||||
|
@ -444,7 +453,9 @@ public func OnClonkDeath(object clonk, int killed_by)
|
|||
{
|
||||
DoWealth(killed_by, clonk.Bounty);
|
||||
plrs_bonus[plrid] += clonk.Bounty;
|
||||
plrs_kills[plrid] += 1;
|
||||
Scoreboard->SetPlayerData(killed_by, "bonus", plrs_bonus[plrid]);
|
||||
Scoreboard->SetPlayerData(killed_by, "kills", plrs_kills[plrid]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -495,16 +506,22 @@ public func CheckAchievement()
|
|||
return;
|
||||
}
|
||||
|
||||
public func ConvertWaveToAchievement(int wave_nr)
|
||||
public func GetWaveToAchievement()
|
||||
{
|
||||
// Get the number of waves needed for achieving stars.
|
||||
var data = GameCall("GetWaveToAchievement");
|
||||
var achievement_data = GameCall("GetWaveToAchievement");
|
||||
// By default the stars are awarded for 5, 10 and 25 completed waves.
|
||||
if (!data)
|
||||
data = [5, 10, 25];
|
||||
SortArray(data);
|
||||
for (var index = GetLength(data); index >= 1; index--)
|
||||
if (wave_nr >= data[index - 1])
|
||||
if (!achievement_data || GetLength(achievement_data) != 3)
|
||||
achievement_data = [5, 10, 25];
|
||||
SortArray(achievement_data);
|
||||
return achievement_data;
|
||||
}
|
||||
|
||||
public func ConvertWaveToAchievement(int wave_nr)
|
||||
{
|
||||
var achievement_data = GetWaveToAchievement();
|
||||
for (var index = GetLength(achievement_data); index >= 1; index--)
|
||||
if (wave_nr >= achievement_data[index - 1])
|
||||
return index;
|
||||
return 0;
|
||||
}
|
||||
|
@ -559,7 +576,10 @@ public func GetDescription(int plr)
|
|||
// Add wave and score.
|
||||
wave_msg = Format("%s\n%s", wave_msg, Format("$MsgFinishedWave$", completed_waves, GetBestWave(plr)));
|
||||
wave_msg = Format("%s\n%s", wave_msg, Format("$MsgCurrentScore$", GetScore(), GetBestScore(plr)));
|
||||
return Format("%s\n\n%s", "$Description$", wave_msg);
|
||||
// Get basic description and achievement information.
|
||||
var achievement_data = GetWaveToAchievement();
|
||||
var desc_msg = Format("$Description$", achievement_data[0], achievement_data[1], achievement_data[2]);
|
||||
return Format("%s\n\n%s", desc_msg, wave_msg);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Name=Verteidigung
|
||||
Description=Survive as many attack waves as possible, each wave and enemy eliminated earns you points.
|
||||
Description=Survive as many attack waves as possible, each wave and enemy eliminated earns you points. You need to survive %d waves (<c cd7f32>bronze</c>), %d waves (<c c0c0c0>silver</c>) or %d waves (<c ffd700>gold</c>) for the star achievement.
|
||||
|
||||
PlayerAttackers=Angreifer
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Name=Defense
|
||||
Description=Survive as many attack waves as possible, each wave and enemy eliminated earns you points.
|
||||
Description=Survive as many attack waves as possible, each wave and enemy eliminated earns you points. You need to survive %d waves (<c cd7f32>bronze</c>), %d waves (<c c0c0c0>silver</c>) or %d waves (<c ffd700>gold</c>) for the star achievement.
|
||||
|
||||
PlayerAttackers=Attackers
|
||||
|
||||
|
|
Loading…
Reference in New Issue