1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
/**
Crash
First attempt at a nontrivial settlement scenario
@authors Sven2, Maikel, ck
*/
static g_is_initialized, g_has_bought_plans, npc_pyrit;
public func Initialize()
{
// Show wealth in HUD.
GUI_Controller->ShowWealth();
return true;
}
func DoInit(int first_player)
{
CreateObjectAbove(Windmill, 152, 825+48, 0);
// Set time of day to evening and create some clouds and celestials.
Cloud->Place(20);
var time = CreateObject(Time);
time->SetTime(600);
time->SetCycleSpeed(20);
// Waterfall
AddEffect("IntWaterfall", nil, 1, 1);
// Windmill owner
var windmill = FindObject(Find_ID(Windmill));
if (windmill) windmill->SetOwner(first_player);
// Goal
CreateObject(Goal_Airplane);
// Rules
CreateObject(Rule_TeamAccount, 50, 50);
// NPC: Merchant.
var merchant = CreateObjectAbove(Clonk, 76, 870);
merchant->MakeInvincible();
merchant->SetColor(RGB(55, 65, 75)); // currently overridden by skin
merchant->SetAlternativeSkin("Leather");
merchant->SetName("$NameMerchant$");
merchant->SetDir(DIR_Left);
merchant->SetObjectLayer(merchant);
merchant->SetDialogue("Merchant", true);
// Newbies like to kill off all trees
var tree_area = Shape->Rectangle(166, 774, 300, 170);
ScheduleCall(nil, Scenario.EnsureTrees, 100, 99999999, tree_area);
// Start intro if not yet started
StartSequence("Intro", 0, GetCrew(first_player));
GetRelaunchRule()
->SetInventoryTransfer(true)
->SetLastClonkRespawn(true)
->SetFreeCrew(true)
->SetAllowPlayerRestart(true)
->SetBaseRespawn(true)
->SetRespawnDelay(0);
return true;
}
func EnsureTrees(proplist area)
{
var nr_trees = ObjectCount(Find_Func("IsTree"), area->Find_In());
if (nr_trees < 2)
PlaceVegetation(Tree_Coniferous, 0, 0, LandscapeWidth(), LandscapeHeight(), 10, area);
return true;
}
global func FxIntWaterfallTimer(object obj, proplist eff)
{
InsertMaterial(Material("Water"), 1560,840);
ExtractLiquid(1314,901);
}
func InitializePlayer(int plr)
{
var crew;
// Scenario init
if (!g_is_initialized) g_is_initialized = DoInit(plr);
// Late joining players just start in the village
var index;
for(index = 0; crew = GetCrew(plr, index); ++index)
{
if (!crew->Contained()) // if not put into plane by intro
{
var x = 50 + Random(50);
var y = 850;
crew->SetPosition(x , y);
}
}
// Extra plans from merchant to newly joined players
if (g_has_bought_plans) GiveExtraPlans(plr);
// Give clonks initial tools
for(var index = 0; crew = GetCrew(plr, index); ++index)
{
crew->CreateContents(Shovel);
// First Clonk can construct and mine.
if (!index)
{
crew->CreateContents(Hammer);
crew->CreateContents(Axe);
}
}
return true;
}
func OnGoalsFulfilled()
{
SetNextMission("Missions.ocf/DeepSeaMining.ocs");
GainScenarioAchievement("Done");
GainMissionAccess("S2Crash");
return false;
}
func GiveExtraPlans(int plr)
{
SetPlrKnowledge(plr, Pump);
SetPlrKnowledge(plr, Pipe);
SetPlrKnowledge(plr, Catapult);
SetPlrKnowledge(plr, Cannon);
return true;
}
|