Пример #1
0
func ShroomCaveCheck()
{
	var intruder = FindObject(Find_InRect(1252,1342,320,138), Find_OCF(OCF_CrewMember));
	if (!intruder) return true;
	ClearScheduleCall(nil, Scenario.ShroomCaveCheck);
	return true;
}
Пример #2
0
func ShroomCaveCheck()
{
	var intruder = FindObject(Find_InRect(1252,1342,320,138), Find_OCF(OCF_CrewMember));
	if (!intruder) return true;
	Dialogue->MessageBoxAll("$MsgEncounterShrooms$", intruder, true);
	ClearScheduleCall(nil, Scenario.ShroomCaveCheck);
	return true;
}
Пример #3
0
func Timer()
{
	if(!Enabled) return();
	DrawParticleLine("MSpark", -10, 0, -10,LandscapeHeight(), 10, 100, RGBa(255,50,50,50), RGBa(255,255,50,100), -10);
	DrawParticleLine("MSpark", 10, 0, 10,LandscapeHeight(), 10, 100, RGBa(255,50,50,50), RGBa(255,255,50,100), -10);
	var pObj;
	for(pObj in FindObjects(Find_InRect(-10,-500,20,LandscapeHeight() + 1000)))
	{
		SetXDir(GetXDir(pObj) * -2,pObj);
		SetYDir(GetYDir(pObj) * -2,pObj);
	}
}
Пример #4
0
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;
}
Пример #5
0
func Initialize()
{
	// Setup testing environment: one object for context, a second object at the context object, one object at 0,0
	var ctx = CreateObject(Dummy, 100, 100, NO_OWNER);
	ctx->SetName("ctx");
	var at_origin = CreateObject(Dummy, 0, 0, NO_OWNER);
	at_origin->SetName("at_origin");
	var at_object = CreateObject(Dummy, ctx->GetX(), ctx->GetY(), NO_OWNER);
	at_object->SetName("at_object");

	TEST("object context Find_Distance");
	EXPECT_EQ(at_object, ctx->FindObject(Find_Exclude(ctx), Find_Distance(1)));

	TEST("global context Find_Distance");
	EXPECT_EQ(at_origin,      FindObject(Find_Exclude(ctx), Find_Distance(1, at_origin->GetX(), at_origin->GetY())));
	EXPECT_EQ(at_object,      FindObject(Find_Exclude(ctx), Find_Distance(1, at_object->GetX(), at_object->GetY())));

	TEST("object context Find_InRect");
	EXPECT_EQ(at_object, ctx->FindObject(Find_Exclude(ctx), Find_InRect(0, 0, 1, 1)));
	EXPECT_EQ(at_origin, ctx->FindObject(Find_Exclude(ctx), Find_InRect(-ctx->GetX(), -ctx->GetY(), 1, 1)));

	TEST("global context Find_InRect");
	EXPECT_EQ(at_origin,      FindObject(Find_Exclude(ctx), Find_InRect(at_origin->GetX(), at_origin->GetY(), 1, 1)));
	EXPECT_EQ(at_object,      FindObject(Find_Exclude(ctx), Find_InRect(at_object->GetX(), at_object->GetY(), 1, 1)));

	TEST("object context Sort_Distance");
	EXPECT_EQ(at_object, ctx->FindObject(Find_Exclude(ctx),              Sort_Distance() ));
	EXPECT_EQ(at_origin, ctx->FindObject(Find_Exclude(ctx), Sort_Reverse(Sort_Distance())));

	TEST("global context Sort_Distance");
	EXPECT_EQ(at_object,      FindObject(Find_Exclude(ctx),              Sort_Distance(at_object->GetX(), at_object->GetY()) ));
	EXPECT_EQ(at_origin,      FindObject(Find_Exclude(ctx),              Sort_Distance(at_origin->GetX(), at_origin->GetY()) ));
	EXPECT_EQ(at_object,      FindObject(Find_Exclude(ctx), Sort_Reverse(Sort_Distance(at_origin->GetX(), at_origin->GetY()))));

	END_TEST();
	GameOver();
}
Пример #6
0
private func CheckStuck()
{
  var pClonk,iYChange,iX,iY;
  // Alle feststeckenden Clonks in der Nähe suchen
  for (pClonk in FindObjects(Find_InRect(-20,-20,40,40), Find_OCF(OCF_CrewMember),Find_NoContainer()))
  {
    iX=GetX(pClonk);
    iY=GetY(pClonk);
    while(Stuck(pClonk) && Inside(GetY(pClonk)-GetY(),-20,20))
    {
      if(!(iYChange=BoundBy(GetY(pClonk)-GetY(),-1,1))) iYChange=1;
      // Zur Sicherheit...
      if(!Inside(GetY(pClonk)+iYChange,-100,LandscapeHeight())) break;
      SetPosition(GetX(pClonk),GetY(pClonk)+iYChange,pClonk);
    }
    // verschieben fehlgeschlagen: rückgängig machen
    if(Stuck(pClonk)) SetPosition(iX,iY,pClonk);
  }
}
Пример #7
0
func InitializePlayer(player) {
	var x = 20 + Random(LandscapeWidth() - 40);
	
	while(FindObject2(Find_InRect(x-30, 0, 60, LandscapeHeight()), Find_Category (C4D_Structure))) {
		x = Random(LandscapeWidth());
	}
	
	// Find a goot spot
	var miny = (4*LandscapeHeight())/10;
	var spawnpoint = findSpawnPoint(miny);
	
	// Place player and hut there
	var hut = CreateConstruction(HUT2, spawnpoint[0], spawnpoint[1],player,100,1);
	SetPosition(spawnpoint[0] - 5, spawnpoint[1]-8, GetCrew(player,0));
	
	// Amboss drüberklatschen
	hut->CreateObject(ANVL, 17, 23);
	hut->CreateContents(FLAG);
}
Пример #8
0
func findSpawnPoint(miny) {
	var x,y;
	
	while (true) {
		x = 20 + Random(LandscapeWidth() - 40);
		y = miny;
		
		while (GBackSolid(x, y) && y < LandscapeHeight()) {
			y++;
		}
		y = GetYSolid(x, y);
		
		if (LandscapeHeight() - y < 10) continue;
		if (FindObject2(Find_InRect(x-30, y - 80, 60, 160), Find_Category (C4D_Structure))) continue;
		if (GBackLiquid(x, y-3)) continue;
		
		return [x,y];
	}
	return [];
}
Пример #9
0
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"));
	var hives = CreateArray(), hive;
	while (amount)
	{
		hive = nil;
		ShuffleArray(trees);
		for (var tree in trees)
		{
			hive = tree->CreateObjectInTreetop(this);
			if (hive) break;
		}
		if (hive)
			hives[GetLength(hives)] = hive;
		amount--;
	}
Пример #10
0
global func DoInitialize() {
    if(fInitialized) return();
    fInitialized = 1;
    fUseHungerThirst = 1;

    if(!FindObject(NOPC)) CreateObject(NOPC);

    if(fUseHungerThirst) if (!ObjectCount(NDWA)) CreateObject(NDWA, 50,50, -1); // Durst
    if(fUseHungerThirst) if (!ObjectCount(NDFO)) CreateObject(NDFO, 50,50, -1); // Hunger

    if(FindObject(_ETG)) RemoveObject(FindObject(_ETG));
    if(FindObject(REPR)) RemoveObject(FindObject(REPR));
    CreateObject(REPR, 50,50, -1); // Nachwuchs
    if(FindObject(TREP)) RemoveObject(FindObject(TREP));
    CreateObject(TREP, 50,50, -1); // Baumnachwuchs

    // NPC's sollen Position halten
    var i, pObj;
    while(pObj = FindObjectOwner(0,-1,0,0,0,0,OCF_CrewMember,0,0,pObj))
        AddEffect("StayThere",pObj,1,35,pObj);

//  if (!GetPlayerCount()) return();
    // Banditen erstellen
    pObj = CreateObject(BNDT, 3917, 570, -1);
    pObj->SetAI("BanditNoMove", 3);
    pObj->SetColorDw(RGB(150));
    pObj = CreateObject(BNDT, 4120, 560, -1);
    pObj->SetAI("BanditNoMove", 3);
    pObj->SetColorDw(RGB(150));
    pObj = CreateObject(BNDT, 4175, 520, -1);
    pObj->SetAI("BanditNoMove", 3);
    pObj->SetColorDw(RGB(150));
    pObj = CreateObject(BNDT, 4044, 477, -1);
    pObj->SetAI("BanditNoMove", 3);
    pObj->SetColorDw(RGB(150));
    pObj = CreateObject(BNDT, 4309, 471, -1);
    pObj->SetAI("BanditBoss", 3);
    pObj->SetColorDw(RGB(150));
    pObj->MakeBoss();
    pObj->Enter(FindObject(MTNT, 4309, 471, -1, -1));
    // Startmaterial erstellen
    pWagon = CreateObject(COAC, 28, 270, -1);
    pHorse = CreateObject(HORS, 77, 270, -1);
    pHorse->ConnectWagon(pWagon);
    SetDir(1, pWagon);
    SetDir(1, pHorse);

    // Startmaterial
    CreateContents(MEAC,pWagon,6);
    CreateContents(WHKY,pWagon,3);
    for(i=0; i<2; i++) {
        pObj = CreateContents(WSKI, pWagon);
        LocalN("iWater", pObj) = 90;
        pObj->~UpdateGraphics();
    }
    CreateContents(MLLT,pWagon);
    CreateContents(KNFE,pWagon);
    CreateContents(IGNB,pWagon);
    CreateContents(DYNB,pWagon,2);
    CreateContents(METL,pWagon,7);
    CreateContents(WOOD,pWagon,21);
    CreateContents(CNKT,pWagon,4);
    CreateContents(LNKT,pWagon);

    // Höhle muss immer vom  Indianer zu betreten sein!
    FreeRect(1970,589,40,9);

    // Brauchbare Gebäude mit unzerstörbarkeit belegen
    for(pObj in FindObjects(Find_Category(C4D_StaticBack|C4D_Structure|C4D_Vehicle),Find_Not(Find_Category(32768)),Find_InRect(1130,190,300,140)))
        AddEffect("NoDmg",pObj,200);
    for(pObj in FindObjects(Find_Category(C4D_StaticBack|C4D_Structure|C4D_Vehicle),Find_Func("IsIndianHandcraft"),
                            Find_Or(Find_InRect(1830,230,560,340),Find_InRect(3190,160,670,360))))
        AddEffect("NoDmg",pObj,200);

    // Weil die Kanone hier bearbeitet worden ist
    if(pObj = FindObject(CCAN)) pObj->~Initialize();

    if(fTestSection==1) return(ChangeSection("AshCity"));
    if(fTestSection==2) return(ChangeSection("Caves"));

    // ... und los!
    if(!fTesting) ScriptGo(1);
    return(1);
}