コード例 #1
0
ファイル: Script.c プロジェクト: maxmitti/SGGP
func InitializePlayer(int iPlayer)
{
	_inherited();
	var pClonk;
	if(GetPlayerTeam(iPlayer) == 1)
	{
		pClonk = CreateObject(JAFA,0,0,iPlayer);
		pClonk -> Enter(FindObject(GOEB,0,0,LandscapeWidth(),LandscapeHeight()/2));
		MakeCrewMember(pClonk,iPlayer);
		CreateContents(FLAG,pClonk);
		SetCursor(iPlayer,pClonk);
		pClonk = CreateObject(JAFA,0,0,iPlayer);
		pClonk -> Enter(FindObject(GOEB,0,0,LandscapeWidth(),LandscapeHeight()/2));
		MakeCrewMember(pClonk,iPlayer);
	}
	if(GetPlayerTeam(iPlayer) == 2)
	{
		pClonk = CreateObject(WRAT,0,0,iPlayer);
		pClonk -> Enter(FindObject(GOEB,0,LandscapeHeight()/2,LandscapeWidth(),LandscapeHeight()/2));
		MakeCrewMember(pClonk,iPlayer);
		CreateContents(FLAG,pClonk);
		SetCursor(iPlayer,pClonk);
		pClonk = CreateObject(WRAT,0,0,iPlayer);
		pClonk -> Enter(FindObject(GOEB,0,LandscapeHeight()/2,LandscapeWidth(),LandscapeHeight()/2));
		MakeCrewMember(pClonk,iPlayer);
	}
}
コード例 #2
0
ファイル: Script.c プロジェクト: ckanibal/clonk-content
func Initialize()
{
  var iTimeout,pWipf;
  SetGamma(RGB(15,15,15),RGB(118,118,118),RGB(215,215,215));
  SetSkyParallax(0,15,17,0,0,0,0); 
  //Handgemacht... ;)
  Meeresrauschen(170);
  Meeresrauschen(1100);
  Meeresrauschen(2060);
  Meeresrauschen(2900);
  Meeresrauschen(3800);
  Meeresrauschen(4800);
  Meeresrauschen(5700);
  Moewen(900);
  Moewen(2300);
  Moewen(3900);
  Moewen(5000);
  //Nebel platzieren
  for(var i;i<260;++i) 
    CreateParticle("Fog",Random(LandscapeWidth()),Random(LandscapeHeight()*2/3),RandomX(3,9),0,RandomX(1000,1500));
  //Wipfe platzieren
  while(pWipf=FindObject(WIPF,0,0,0,0,0,0,0,0,pWipf)) {
    iTimeout=0;
    while(Stuck(pWipf)||GetMaterial(GetX(pWipf),GetY(pWipf))!=Material("Tunnel")) {
      SetPosition(Random(LandscapeWidth()),RandomX(LandscapeHeight()*2/3,LandscapeHeight()),pWipf);
      if(iTimeout++ > 50000) { RemoveObject(pWipf); break; }
    }
  }  
  ScriptGo(1);
}
コード例 #3
0
ファイル: Script.c プロジェクト: tyronx/gze
func Initialize() {
	MusicLevel(50);
	
	// We place some extra in-earth objects nearby certain materials for awesome looks
	PlaceObjects2(COAL, 250, [0,0,LandscapeWidth(),LandscapeHeight()], 0, Material("Coal")); // Coal nearby coal 
	PlaceObjects2(FLNT, 80, [0,0,LandscapeWidth(),LandscapeHeight()], 0, Material("Flint"));
	PlaceObjects2(LOAM, 100, [0,0,LandscapeWidth(),LandscapeHeight()], 0, Material("Loam"));
	PlaceObjects2(ORE1, 150, [0,0,LandscapeWidth(),LandscapeHeight()], 0, Material("Ore"));

	return(1);
}
コード例 #4
0
ファイル: Script.c プロジェクト: TheThow/OpenClonk-Stuff
global func FxDefManaTimer()
{
	for(var o in FindObjects(Find_ID(Clonk)))
	{
		var plr = o->GetOwner();
		if(GetPlayerTeam(plr) == 1 && o->GetX() < LandscapeWidth()/2)
			o->DoMagicEnergy(1);
			
		if(GetPlayerTeam(plr) == 2 && o->GetX() > LandscapeWidth()/2)
			o->DoMagicEnergy(1);
	}
コード例 #5
0
ファイル: Script.c プロジェクト: lluchs/ClonkMars
func Initialize() {
  MarsSky();
  SetSkyAdjust(RGBa(255,255,255,160), RGB(70,30,15));
  //Hintergrund
  CreateObject(BG_1,-0,0,-1);
  CreateObject(DUSK,0,0,-1);
  ScriptGo(1);

  // Spielziel setzen
  var goal = FindObject(RCOB);
  goal->AddType(DBSE);
  goal->AddType(DLAB);
  goal->AddType(DSOL);
  
  //Forschungsstation
  PlaceObjects(DBSE,1,"Durolava",950,1200,150,150);
  PlaceObjects(DLAB,1,"Durolava",950,1200,150,150);
  PlaceObjects(BONE,9,"Durolava",950,1200,150,150);
  PlaceObjects(SKUL,3,"Durolava",950,1200,150,150);    
  PlaceObjects(DSOL,3,"Durolava",950,1200,150,150);   
  PlaceObjects(METL,2,"Durolava",950,1200,150,150);   
  PlaceObjects(CELL,1,"Durolava",950,1200,150,150);   
  PlaceObjects(SATD,1,"Durolava",950,1200,150,150);
  PlaceObjects(ORE1,8,"Durolava",950,1200,150,150);  
  
  // Spouter
  PlaceObjects(OILS, RandomX(1,3), "Oil", 0, 1300, LandscapeWidth(), 300);  
  
  // Kristalle
  PlaceCrystals(5, 20);
  
  return(1);
}
コード例 #6
0
ファイル: Script.c プロジェクト: ckanibal/clonk-content
global func DrawIslands(iX, iY, iWidth, iHeight)
{
 DrawMap(iX, iY, iWidth, iHeight, "map new { overlay { algo=bozo; turbulence=100; loosebounds=1; a=10; } & overlay { algo=rndchecker; turbulence=1000; a=1; mat=Earth; tex=Rough; overlay { algo=random; mat=Earth; tex=Smooth; }; overlay InEarth { grp=1; invert=1;overlay { algo=bozo; a=6; turbulence=1000; } & overlay { algo=rndchecker; a=2;turbulence=1000; mat=Rock; tex=Rough; };}; InEarth & overlay { mat=Gold; tex=Rough; }; InEarth & overlay { mat=Coal; tex=Swirl; };};overlay { algo=poly;point { x=0px; y=0px; };point { x=1px; y=0px; };point { x=1px; y=100%; };point { x=0px; y=100%; };}; overlay { algo=poly;point { x=99%; y=0px; };point { x=100%; y=0px; };point { x=100%; y=100%; };point { x=99%; y=100%; };}; overlay { algo=poly;point { x=0%; y=0px; };point { x=100%; y=0px; };point { x=100%; y=1%; };point { x=0%; y=1%; };};overlay { algo=poly;point { x=0%; y=99%; };point { x=100%; y=99%; };point { x=100%; y=100%; };point { x=0%; y=100%; };}; };");
 for(var x=0; x < iWidth; x++)
   for(var y=0; y < iHeight; y++)
     DrawMaterialQuad (MaterialName(GetMaterial(x+iX, y+iY)), LandscapeWidth()-x-iX, y+iY, LandscapeWidth()-x-iX, y+iY+1, LandscapeWidth()-x-iX+1, y+iY+1, LandscapeWidth()-x-iX+1, y+iY);
}
コード例 #7
0
ファイル: Script.c プロジェクト: 772/openclonk
func InitializePlayer(int iPlr, int iX, int iY, object pBase, int iTeam)
{
	SetFoW(false,iPlr);
	JoinPlayer(iPlr);
	GetHiRank(iPlr)->SetPosition(LandscapeWidth()/2, LandscapeHeight()/2);
	return;
}
コード例 #8
0
ファイル: Script.c プロジェクト: Fulgen301/openclonk
global func FxRandomMeteorTimer()
{
	if (!Random(GetPlayerCount() + 2)) 
		return FX_OK;
	LaunchMeteor(50 + Random(LandscapeWidth() - 100), -10, 40 + Random(40), RandomX(-20, 20), 0);
	return FX_OK;
}
コード例 #9
0
ファイル: Script.c プロジェクト: ckanibal/clonk-content
global func DoPlaceObjects(idID, iAmount, szMat)
{
  var obj;
  for(var i=0; i<iAmount; i++)
  {
    obj = PlaceInMaterial(idID, Material(szMat));
    if(obj) CreateObject(idID, LandscapeWidth()-GetX(obj), GetY(obj));
  }
}
コード例 #10
0
ファイル: Script.c プロジェクト: 772/openclonk
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));
}
コード例 #11
0
ファイル: Script.c プロジェクト: clonkspot/ClonkFest.ocs
func StartGame(array players)
{
	time = 0;
	AddTimer(this.Timer, 30);
	var wdt = LandscapeWidth(), hgt = LandscapeHeight();
	var m = 15; // border margin
	borders = [
		{ x=m,       xl=wdt-2*m, y=0,       yl=0,       d=+1, nx=0,  ny=+1 }, // top
		{ x=wdt-1,   xl=0,       y=m,       yl=hgt-2*m, d=+1, nx=-1, ny=0  }, // right
コード例 #12
0
ファイル: Appendto.c プロジェクト: TheBlackJokerDevil/Graete
protected func Hit()
{
	if((GetY()+GetDefHeight(GetID())/2) >= 530) {
	SetXDir(150);
	SetYDir(-2);
	}
	if(GetX() >= LandscapeWidth()-15)	{ RemoveObject(); }
	_inherited();
}
コード例 #13
0
ファイル: Script.c プロジェクト: TheThow/OpenClonk-Stuff
func InitClouds()
{
	for(var i = 0; i < 8; i++)
	{
		var cloud = CreateObject(DecoCloud, Random(LandscapeWidth() + 400) - 200, Random(LandscapeHeight()), -1);
		cloud->SetClrModulation(RGBa(255, 128, 0, 40));
		cloud->SetXDir(RandomX(1, 3));
	}
}
コード例 #14
0
ファイル: Script.c プロジェクト: ckanibal/clonk-content
global func DoPlaceAnimal(idID, iAmount)
{
  var obj;
  for(var i=0; i<iAmount; i++)
  {
    obj = PlaceAnimal(idID);
    if(obj) CreateObject(idID, LandscapeWidth()-GetX(obj), GetY(obj));
  }
}
コード例 #15
0
ファイル: SeqIntro.c プロジェクト: Fulgen301/openclonk
public func Intro_Init(int difficulty)
{
	// Set wind to the left, so that less lava is on the starting place.
	SetWind(-50 - Random(50));
	
	// Determine crater lava height.
	var lava_y = 0;
	while (!GBackLiquid(LandscapeWidth() / 2, lava_y) && lava_y < LandscapeHeight())
		lava_y++;
	
	// Create an airplane with pilot and fly it towards the peak.
	this.airplane = CreateObjectAbove(Airplane, LandscapeWidth() / 2 - 564, lava_y - 176);
	this.pilot = CreateObjectAbove(Clonk, LandscapeWidth() / 2 - 564, lava_y - 176);
	this.pilot->SetName("$PilotName$");
	this.pilot->SetSkin(2);
	this.pilot->Enter(this.airplane);
	this.pilot->SetAction("Walk");
	this.pilot->SetDir(DIR_Right);
	this.pilot->SetColor(0xff0000aa);
	this.airplane->PlaneMount(this.pilot);
	this.airplane->FaceRight();
	this.airplane->StartInstantFlight(90, 15);
	this.airplane->SetXDir(12);
	this.airplane->SetYDir(-1);
	this.airplane->MakeInvincible();
	this.airplane.intro_seq = this;
	// Fill the airplane with some materials.
	this.difficulty = difficulty;
	if (difficulty <= 2)
	{
		this.airplane->CreateContents(Loam, 5);
		this.airplane->CreateContents(Bread, 5);
		this.airplane->CreateContents(Wood, 8);
		this.airplane->CreateContents(Rock, 4);
		this.airplane->CreateContents(Metal, 4);
		if (difficulty <= 1)
		{
			this.airplane->CreateContents(Pickaxe, 2);
			for (var i = 0; i < 5; i++)
				this.airplane->CreateContents(Barrel)->PutLiquid("Water", 300);
		}	
	}
	return;
}
コード例 #16
0
ファイル: Script.c プロジェクト: tyronx/gze
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);
}
コード例 #17
0
ファイル: Script.c プロジェクト: ckanibal/clonk-content
func Initialize()
{
  DrawIslands(0,353,415,369);
  DrawIslands(0,722,559,651);
  for(var i=0; i < 60; i++)
    PlaceVegetation(TRE1, 0, 0, LandscapeWidth(), LandscapeHeight(), -1);
  for(var i=0; i < 60; i++)
    PlaceVegetation(TRE2, 0, 0, LandscapeWidth(), LandscapeHeight(), -1);
  for(var i=0; i < 60; i++)
    PlaceVegetation(TRE3, 0, 0, LandscapeWidth(), LandscapeHeight(), -1);
  DoPlaceObjects(LOAM,60,"Earth");
  DoPlaceObjects(CNKT,20,"Earth");
  DoPlaceObjects(WOOD,50,"Earth");
  DoPlaceObjects(ROCK,60,"Earth");
  DoPlaceObjects(FLNT,60,"Earth");
  DoPlaceObjects(METL,50,"Earth");
  DoPlaceAnimal(BIRD, 14);
  return();
}
コード例 #18
0
ファイル: Script.c プロジェクト: ckanibal/clonk-content
// Spielerbeitritt
func InitializePlayer(iPlr)
{
  // Anwählen und in Position bringen
  SetCursor(iPlr,GetHiRank(iPlr));
  SelectCrew(iPlr, GetHiRank(iPlr), 1);
  if(GetPlayerTeam(iPlr)==1)
    SetPosition(10,1609, GetHiRank(iPlr));
  else
    SetPosition(LandscapeWidth()-10,1609, GetHiRank(iPlr));
}
コード例 #19
0
ファイル: Script.c プロジェクト: 772/openclonk
func Initialize()
{
	Log("Difficulty = %d", SCENPAR_Difficulty);
	num_to_collect = SCENPAR_Difficulty;
	for (var i=0; i<num_to_collect; ++i)
	{
		var ng = CreateObjectAbove(Nugget, Random(LandscapeWidth()-100) + 50, LandscapeHeight()/2 + Random(LandscapeHeight()/2-40));
		ng.Entrance = Scenario.GotNugget;
	}
	return true;
}
コード例 #20
0
ファイル: Script.c プロジェクト: ckanibal/clonk-content
func Initialize() 
{
  SetSkyParallax(0,14,30);
  for(var i=Random(3)+1; i>0; --i)
  {
    var iX=Random(LandscapeWidth()), iY=0;
    while(1)
    {
      ++iY;
      if(GBackSemiSolid(iX, iY)) break;
    }
    if(!FindObject(MWKS, iX, iY))
      AddEffect("PotionSupply", CreateObject(MWKS, iX, iY, -1), 1, 650);
  }  
}
コード例 #21
0
ファイル: Script.c プロジェクト: 772/openclonk
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;
	}
}
コード例 #22
0
ファイル: Script.c プロジェクト: ckanibal/clonk-content
func InitializePlayer(iPlr) {
  var iX=Random(LandscapeWidth());
  var iY;
  while(1)
  {
    ++iY;
    if(GBackSemiSolid(iX, iY)) break;
  }
  SetPosition(iX, iY-10, GetCrew(iPlr));
  DoMagicEnergy(50, GetCrew(iPlr));
  
  Sound("PlayerJoin");
  PlacementEffects(GetCrew(iPlr)->GetX(), GetCrew(iPlr)->GetY());
  
  return(1);
}
コード例 #23
0
ファイル: Script.c プロジェクト: Fulgen301/openclonk
protected func Initialize()
{
	// Environment 
	CreateObject(Rule_ObjectFade)->DoFadeTime(10 * 36);
	
	GetRelaunchRule()->SetLastWeaponUse(false);
	
	var time=CreateObject(Time);
	time->SetTime();
	time->SetCycleSpeed();
	FindObject(Find_ID(Moon))->SetMoonPhase(3);
	FindObject(Find_ID(Moon))->SetCon(150);
	FindObject(Find_ID(Moon))->SetPosition(LandscapeWidth()/2,150);

	// Goal: Capture the flag, with bases in both hideouts.
	var goal = CreateObject(Goal_CaptureTheFlag, 0, 0, NO_OWNER);
	goal->SetFlagBase(1, 135, 266);
	goal->SetFlagBase(2, LandscapeWidth() - 135, 266);
	CreateObject(Rule_KillLogs);	
	
	var gate = CreateObjectAbove(StoneDoor, 345, 272, NO_OWNER);
	gate->SetClrModulation(RGB(140,185,255));
	gate->SetAutoControl(1);
	var gate = CreateObjectAbove(StoneDoor, LandscapeWidth()-344, 272, NO_OWNER);
	gate->SetClrModulation(RGB(140,185,255));
	gate->SetAutoControl(2);

	// Chests with weapons.
	var chest;
	chest = CreateObjectAbove(Chest, 60, 220, NO_OWNER);
	chest->MakeInvincible();
	AddEffect("FillBaseChest", chest, 100, 7 * 36,nil,nil,false);
	chest = CreateObjectAbove(Chest, 150, 370, NO_OWNER);
	chest->MakeInvincible();
	AddEffect("FillBaseChest", chest, 100, 7 * 36,nil,nil,true);
	chest = CreateObjectAbove(Chest, LandscapeWidth() - 60, 220, NO_OWNER);
	chest->MakeInvincible();
	AddEffect("FillBaseChest", chest, 100, 7 * 36,nil,nil,false);
	chest = CreateObjectAbove(Chest, LandscapeWidth() - 150, 370, NO_OWNER);
	chest->MakeInvincible();
	AddEffect("FillBaseChest", chest, 100, 7 * 36,nil,nil,true);

	
	chest = CreateObjectAbove(Chest, LandscapeWidth()/2, 320, NO_OWNER);
	chest->MakeInvincible();
	AddEffect("FillOtherChest", chest, 100, 5 * 36);
	
	AddEffect("SnowyWinter", nil, 100, 1);
	Sound("Environment::WindLoop",true,20,nil,+1);
	AddEffect("GeysirExplosion", nil, 100, 1);
	// Brick edges, notice the symmetric landscape.
	PlaceEdges();
	return;
}
コード例 #24
0
ファイル: Script.c プロジェクト: chrisweidya/openclonk
public func ControlUse(object clonk, int x, int y)
{
	x = LandscapeWidth() / 2 + 100;
	y = baseHeight - 20;	
	DrawParticleLine("Flash", 0,0,-GetX()+x,-GetY()+y, 3, 0, 0, 8, {Prototype = Particles_Flash(), Size = 20, R = 50, G = 50, B = 255});

	// Make sure the clonk loses the attach procedure.
	var action = clonk->GetAction();
	if (action && clonk.ActMap[action].Procedure == DFA_ATTACH)
		clonk->SetAction("Jump");
	clonk->SetPosition(x, y);
	clonk->SetXDir(0);
	clonk->SetYDir(-5);

	RemoveObject();	
	return 1;
}
コード例 #25
0
ファイル: Script.c プロジェクト: Fulgen301/SGGP
func Timer()
{
	if(pBeamer && GetCursor(GetOwner()) != this()) return RemoveObject();
	Frame++;
	if(Frame > 10)
	{
		Frame = 0;
		if(GetAction() eq "1")
		{
			SetAction("2");
		}
		else
		{
			SetAction("1");
		}
	}
	/*if(GetR() < 360)
	{
		SetR(GetR() + 1);
	}
	else
	{
		SetR(0);
	}*/
	if(ObjectDistance(pBeamer) > LandscapeWidth() / 2 && !FindObject(ENRG)) 
	{
		if(GetX() > GetX(pBeamer))
		{
			SetXDir(-30);
		}
		else
		{
			SetXDir(30);
		}
		if(GetY() > GetY(pBeamer))
		{
			SetYDir(-30);
		}
		else
		{
			SetYDir(30);
		}
	}
	SetRDir(3);
}	
コード例 #26
0
ファイル: Script.c プロジェクト: ev1313/Widening-III
protected func CheckBorders()
{
	// Prüfen ob ein Objekt gerade aus dem Spielfeld fliegt
	var mapwdt = LandscapeWidth();
	var xdir, xoff, x;
	for (var obj in FindObjects(Find_Func("GetXDir"))) {
		xdir = GetXDir(obj)/10; xoff = obj->GetDefOffset();
		if (xdir < 0) { // Linker Rand
			x = (GetX(obj)+xoff)+xdir;
			if (x <= 0)
				SetPosition(BoundBy(mapwdt+x-xoff, 0, mapwdt+xoff), GetY(obj)+GetYDir(obj)/10, obj, 1);
		}
		else { // Rechter Rand
			x = (GetX(obj)-xoff)+xdir-mapwdt;
			if (x >= 0)
				SetPosition(BoundBy(x+xoff, -xoff, mapwdt), GetY(obj)+GetYDir(obj)/10, obj, 1);
		}
	}
	return 1;
}
コード例 #27
0
ファイル: Script.c プロジェクト: tyronx/gze
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 [];
}
コード例 #28
0
ファイル: Script.c プロジェクト: 772/openclonk
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--;
	}
コード例 #29
0
ファイル: Script.c プロジェクト: TheThow/OpenClonk-Stuff
func GetItemCratePos()
{
	return [100 + Random(LandscapeWidth() - 200), 50];
}
コード例 #30
0
ファイル: Creation.c プロジェクト: 772/openclonk
// Creates amount objects of type id inside the indicated rectangle(optional) in the indicated material.
// Returns the number of iterations needed, or -1 when the placement failed.
global func PlaceObjects(id id, int amount, string mat_str, int x, int y, int wdt, int hgt, bool onsf, bool nostuck)
{
	var i, j;
	var rndx, rndy, obj;
	var mat;
	var objhgt = id->GetDefCoreVal("Height", "DefCore");
	
	mat = Material(mat_str);
	// Some failsavety.
	if (mat == -1)
		if (mat_str != "GBackSolid" && mat_str != "GBackSemiSolid" && mat_str != "GBackLiquid" && mat_str != "GBackSky")
			return -1;
	
	// Optional parameters wdt and hgt.
	if (!wdt)
		wdt = LandscapeWidth() - x - GetX();
	if (!hgt)
		hgt = LandscapeHeight() - y - GetY();

	// Cycle-saving method.
	if (mat != -1)
		while (i < amount)
		{
			// If there's isn't any or not enough of the given material, break before it gets an endless loop.
			if (j++ > 20000)
				return -1;
			// Destinated rectangle.
			rndx = x + Random(wdt);
			rndy = y + Random(hgt);
			// Positioning.
			if (GetMaterial(rndx, rndy) == mat)
			{
				// On-surface option.
				if (onsf)
					while (GBackSemiSolid(rndx, rndy) && rndy >= y)
						rndy--;
				if (rndy < y)
					continue;
				// Create and verify stuckness.
				obj = CreateObjectAbove(id, rndx, rndy + objhgt / 2, NO_OWNER);
				obj->SetR(Random(360));
				if (obj->Stuck() || nostuck)
					i++;
				else
					obj->RemoveObject();
			}
		}

	if (mat == -1)
		while (i < amount)
		{
			// If there's isn't any or not enough of the given material, break before it gets an endless loop.
			if (j++ > 20000)
				return -1;
			// Destinated rectangle.
			rndx = x + Random(wdt);
			rndy = y + Random(hgt);
			// Positioning.
			if (eval(Format("%s(%d,%d)", mat_str, rndx, rndy)))
			{
				// On-surface Option.
				if (onsf)
					while (GBackSemiSolid(rndx, rndy) && rndy >= y)
						rndy--;
				if (rndy < y)
					continue;
				// Create and verify stuckness.
				obj = CreateObjectAbove(id, rndx, rndy + objhgt / 2, NO_OWNER);
				obj->SetR(Random(360));
				if (obj->Stuck() || nostuck)
					i++;
				else
					obj->RemoveObject();
			}
		}

	return j;
}