func DoInit(int first_player) { // Message when first player enters shroom area ScheduleCall(nil, Scenario.ShroomCaveCheck, 21, 0xffffff); // Scorching village g_ruin1->AddScorch(-20,-10, -45, 50, 1500); g_ruin2->AddScorch(-15,42, 90, 50, 1200); g_ruin3->AddScorch(-12,18, 130, 80, 1300); // Horax g_king.JumpSpeed = 200; // Update AI stuff var fx; for (var enemy in FindObjects(Find_ID(Clonk), Find_Owner(NO_OWNER))) if (fx = S2AI->GetAI(enemy)) { fx.weapon = fx.target = nil; S2AI->BindInventory(enemy); enemy->DoEnergy(10000); enemy->AddEnergyBar(); } g_farmer.portrait = { Source=DialogueCastle }; // Start intro if not yet started StartSequence("Intro", 0, GetCrew(first_player)); return true; }
public func Interact(object clonk) { if (!dlg_interact || !dlg_name) return inherited(clonk, ...); var guide = FindObject(Find_ID(TutorialGuide), Find_Owner(clonk->GetOwner())); if (!guide) return inherited(clonk, ...); if (dlg_status == DLG_Status_Stop) { if (this.guide_was_shown) { this.guide_was_shown = false; guide->ShowGuide(); } } else if (dlg_status != DLG_Status_Remove && dlg_status != DLG_Status_Wait) { if (!guide->IsHidden()) { this.guide_was_shown = true; guide->HideGuide(); } } return inherited(clonk, ...); }
global func DoBaseProduction(int plr, id def, int change) { var base = FindObject(Find_ID(BaseMaterial), Find_Owner(plr)); if (!base) base = CreateObjectAbove(BaseMaterial, AbsX(10), AbsY(10), plr); if (base) return base->DoBaseProd(def, change); }
global func GetBaseProduction(int plr, id def, int index, int category) { var base = FindObject(Find_ID(BaseMaterial), Find_Owner(plr)); if (!base) base = CreateObjectAbove(BaseMaterial, AbsX(10), AbsY(10), plr); if (base) return base->GetBaseProd(def, index, category); }
global func SetBaseMaterial(int plr, id def, int cnt) { var base = FindObject(Find_ID(BaseMaterial), Find_Owner(plr)); if (!base) base = CreateObjectAbove(BaseMaterial, AbsX(10), AbsY(10), plr); if (base) return base->SetBaseMat(def, cnt); }
func RemovePlayer(int iPlr) { for(var obj in FindObjects(Find_Owner(iPlr))) { if(obj) obj->RemoveObject(); } }
func RelaunchPlayer(int plr) { var clonk = CreateObjectAbove(Clonk, LandscapeWidth()/2, 600, plr); clonk->MakeCrewMember(plr); SetCursor(plr, clonk); JoinPlayer(plr); var gui_arrow = FindObject(Find_ID(GUI_GoalArrow), Find_Owner(plr)); gui_arrow->SetAction("Show", GetCursor(plr)); }
func Outro_Start(object plane) { // Player closest to plane becomes outro protagonist this.plane = plane; this.hero = plane->FindObject(Find_ID(Clonk), Find_Not(Find_Owner(NO_OWNER)), plane->Sort_Distance()); SetPlayerZoomByViewRange(NO_OWNER, 200,100, PLRZOOM_Set | PLRZOOM_LimitMax); SetViewTarget(this.hero); npc_pyrit.has_sequence = true; // Pyrit stops hammering return ScheduleNext(5); }
func Outro_Start(object goal, object plane) { this.goal = goal; this.plane = plane; this.hero = plane->FindObject(Find_Not(Find_Owner(NO_OWNER)), Find_ID(Clonk), plane->Sort_Distance()); SetViewTarget(this.plane); MessageBoxAll("$Outro1$", this.hero, true); return ScheduleNext(150); }
func Initialize(...) { // (first) plane built? Story advances. // only after attack, so enemy planes don't count if (g_attack_done && !g_plane_built) { g_plane_built = true; var closest_clonk = FindObject(Find_ID(Clonk), Find_Not(Find_Owner(NO_OWNER)), Sort_Distance()); SetColor(0xa04000); // Make sure it has the same color in all missions Dialogue->MessageBoxAll("$PlaneBuilt$", closest_clonk, true); } return _inherited(...); }
func Special2(object clonk, int x, int y, bool released, bool mouseclick, bool abletocast, bool cooldown) { if (released || mouseclick || cooldown) return; var existing = FindObjects(Find_ID(StickyBomb), Find_Owner(clonk->GetOwner())); if (existing) { SoundAt("UI::Click"); for (var bomb in existing) bomb->BlowUp(); return; } }
global func CyclopsFindTarget(fx) { // Consider hostile clonks, or all clonks if the AI does not have an owner. var hostile_criteria = Find_Hostile(fx.cyclops->GetOwner()); if (fx.cyclops->GetOwner() == NO_OWNER) hostile_criteria = Find_Not(Find_Owner(fx.cyclops->GetOwner())); for (var target in FindObjects(Find_InRect(fx.guard_range.x,fx.guard_range.y,fx.guard_range.wdt,fx.guard_range.hgt), Find_OCF(OCF_CrewMember), hostile_criteria, Find_NoContainer(), Sort_Random())) if (PathFree(fx.cyclops->GetX(),fx.cyclops->GetY(),target->GetX(),target->GetY())) return target; // Nothing found. return; }
func DoInit(int first_player) { // Message when first player enters shroom area ScheduleCall(nil, Scenario.ShroomCaveCheck, 21, 0xffffff); // Scorching village g_ruin1->AddScorch(-20,-10, -45, 50, 1500); g_ruin2->AddScorch(-15,42, 90, 50, 1200); g_ruin3->AddScorch(-12,18, 130, 80, 1300); // Update AI stuff var fx; for (var enemy in FindObjects(Find_ID(Clonk), Find_Owner(NO_OWNER))) if (fx = AI->GetAI(enemy)) { fx.weapon = fx.target = nil; AI->BindInventory(enemy); enemy->DoEnergy(10000); enemy->AddEnergyBar(); } return true; }
func InitializePlayer (plr,x,y,bas,team) { // Gebäude in den Besitz for (var obj in FindObjects(Find_Category(C4D_Structure), Find_Owner(NO_OWNER), Find_Distance(300, x,y))) SetOwner(plr, obj); // Hörx ist ein König! if (team == 2) { var obj = GetHiRank (plr); obj->CLNK::Redefine2 (_HRX); SetPortrait ("random", obj, _HRX); SetName ("$Herx$", obj); } // Alle ins Haus! var home; if (team == 2) home = FindObject2(Find_ID(CST3)); else home = FindObject2(Find_ID(HUT3)); for (var mat in FindObjects(Find_Category(C4D_Object | C4D_Vehicle | C4D_Living), Find_Not(Find_ID(CSTE)), Find_Owner(plr))) Enter(home, mat); // Den besten Clonks auswählen und vor die Tür SetCursor(plr, GetHiRank(plr)); SetCommand(GetCursor(plr), "Exit"); // Und auf den Gegner schauen SetDir(2-team, GetCursor(plr)); }
global func CreateAttackWave(int angle, int rockets, int anglespread) { var radius = Min(LandscapeWidth()/2, LandscapeHeight()/2); var rocket_id = Boomattack; // boss if(rockets == -1) { rockets = 1; rocket_id = BigBoomattack; } for(var i=0; i<rockets; ++i) { var rocket_angle = angle + Random(anglespread) - anglespread/2; var rocket_radius = radius * RandomX(80,100) / 100; var x = Sin(rocket_angle, rocket_radius)+LandscapeWidth()/2; var y = -Cos(rocket_angle, rocket_radius)+LandscapeHeight()/2; CreateObjectAbove(rocket_id, x, y)->Launch(rocket_angle + 180); } for(var i=0; i<GetPlayerCount(); ++i) { var owner = GetPlayerByIndex(i); var gui_arrow = FindObject(Find_ID(GUI_GoalArrow), Find_Owner(owner)); if(!gui_arrow) { gui_arrow = CreateObjectAbove(GUI_GoalArrow,0,0,owner); gui_arrow->SetAction("Show", GetCursor(owner)); gui_arrow->SetClrModulation(RGB(255,0,0)); gui_arrow->SetObjectBlitMode(GFX_BLIT_Mod2); } gui_arrow->SetR(angle); gui_arrow.Plane = 500; } }
global func GetMarkerForIndex(index, plr) { return FindObject(Find_ID(Marker), Find_Owner(plr), Find_Func("IsIndex", index)); }
// Open for all players func Find_Allied(plr) { return Find_Not(Find_Owner(NO_OWNER)); }
func Outro_5() { if (npc_pyrit->Contained() != this.plane) return ScheduleSame(5); // After Pyrit is inside, rest enters freely this.plane->SetEntrance(true); for (var clonk in this.plane->FindObjects(this.plane->Find_AtRect(-60,-30,120,60), Find_ID(Clonk), Find_Not(Find_Owner(NO_OWNER)))) clonk->SetCommand("Enter", this.plane); return ScheduleNext(100); }
func CleanUp(object clonk) { for (var bomb in FindObjects(Find_ID(StickyBomb), Find_Owner(clonk->GetOwner()))) bomb->Remove(); }