Beispiel #1
0
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);
}
/* 
 * Better EarthObj Placement. Besides many new parameters it also does the following:
 * - Leaves at least 10 pixels distance between each placed object
 * - Makes sure they are *really* stuck in the material
 * Parameters:
 *
 * objectid:  Object to be placed
 * quantity: Quantity to be planted
 * rect: Target rect as array [x,y,wdt,hgt], Offset in local calls
 * materials: array of materials it should be placed in. If not set, the objects will be placed in Materials with Soil=1
 * nearbymaterials: material the object has to be somewhat close to
 *
 * Returns:
 * Amount of actually placed objects (algo gives up after 10.000 iterations) 
 *
 * Examples:
 *
 * PlaceObjects2(FLNT, 20, 0, LandscapeHeight()/3, LandscapeWidth(), LandscapeHeight()/3, ["Rock", "Granite"])
 * - Places 20 flints inside rock and granite between 33% and 66% landscape height 
 */
global func PlaceObjects2(id objectid, int quantity, array rect, array inmaterials, int nearbymaterial) {
	var x = rect[0], y = rect[1], wdt = rect[2], hgt = rect[3];
	
	var haveinmaterials = GetType(inmaterials) == C4V_Array;
	
	
	// Failsafe
	var attempts = 0;
	var placed = 0;
	
	// Create a dozen random places and try there
	var rndx, rndy, valid, obj, matatpos;
	var objhgt = GetDefHeight(objectid);
	
		
	if (nearbymaterial) {
		while (quantity > 0 && attempts++ < 20000) {
			rndx = x + Random(wdt);
			rndy = y + Random(hgt);
			
			matatpos = GetMaterial(rndx,rndy);
	
			if (matatpos == nearbymaterial) {
				for (var i = 0; i < 8; i++) {
					// Generate a random number between -10 to -4 or 4 to 10
					rndx += RandomX(10, 20) * (Random(2)*2-1);
					rndy += RandomX(10, 20) * (Random(2)*2-1);
					matatpos = GetMaterial(rndx,rndy);
					
					valid = false;
					if (haveinmaterials) {
						for (var mat in inmaterials) {
							if (mat == matatpos && mat != nearbymaterial) { 
								valid = true;
								break;
							}
						}
					} else {
						valid = isMaterialSoil(rndx, rndy);
					}
					
					if (valid) {
						obj = CreateObject(objectid, rndx, rndy + objhgt / 2, -1);
						obj->SetR(Random(360));
					}

					if (Stuck(obj)) {
						placed++;
						quantity--;
						break;
					} else {
						RemoveObject(obj);
					}
				}
			}
		}
	} else {
Beispiel #3
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);
  }
}
Beispiel #4
0
protected func Initialize()
{
  if (Stuck()) SetPosition(GetX(), GetY() - 2);
  return(1);
}
Beispiel #5
0
protected func FlyProcess() {
	Smoke(0, 0, 7 + Random(5));
	if (Stuck() || (GetActTime() > 150))
		return(Hit());
}
Beispiel #6
0
public func FlyProcess () {
	if (Stuck() || (GetActTime() > (30 + Random(10)))) {
		Xplode();
	}
}