Example #1
0
void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj) {
  // Splash only if there is free space above
  if (GBackSemiSolid(tx, ty - 15))
    return;
  // get back mat
  int32_t iMat = GBackMat(tx, ty);
  // check liquid
  if (MatValid(iMat))
    if (DensityLiquid(Game.Material.Map[iMat].Density) &&
        Game.Material.Map[iMat].Instable) {
      int32_t sy = ty;
      while (GBackLiquid(tx, sy) && sy > ty - 20 && sy >= 0)
        sy--;
      // Splash bubbles and liquid
      for (int32_t cnt = 0; cnt < amt; cnt++) {
        BubbleOut(tx + Random(16) - 8, ty + Random(16) - 6);
        if (GBackLiquid(tx, ty) && !GBackSemiSolid(tx, sy))
          Game.PXS.Create(Game.Landscape.ExtractMaterial(tx, ty), itofix(tx),
                          itofix(sy), FIXED100(Random(151) - 75),
                          FIXED100(-Random(200)));
      }
    }
  // Splash sound
  if (amt >= 20)
    StartSoundEffect("Splash2", false, 100, pByObj);
  else if (amt > 1)
    StartSoundEffect("Splash1", false, 100, pByObj);
}
Example #2
0
void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj)
{
	// Splash only if there is free space above
	if (GBackSemiSolid(tx, ty - 15)) return;
	// get back mat
	int32_t iMat = GBackMat(tx, ty);
	// check liquid
	if (MatValid(iMat))
		if (DensityLiquid(::MaterialMap.Map[iMat].Density) && ::MaterialMap.Map[iMat].Instable)
		{
			int32_t sy = ty;
			while (GBackLiquid(tx, sy) && sy > ty - 20 && sy >= 0) sy--;
			// Splash bubbles and liquid
			for (int32_t cnt=0; cnt<amt; cnt++)
			{
				int32_t bubble_x = tx+Random(16)-8;
				int32_t bubble_y = ty+Random(16)-6;
				BubbleOut(bubble_x,bubble_y);
				if (GBackLiquid(tx,ty) && !GBackSemiSolid(tx, sy))
				{
					C4Real xdir = C4REAL100(Random(151)-75);
					C4Real ydir = C4REAL100(-Random(200));
					::PXS.Create(::Landscape.ExtractMaterial(tx,ty,false),
					             itofix(tx),itofix(sy),
					             xdir,
					             ydir);
				}
			}
		}
	// Splash sound
	if (amt>=20)
		StartSoundEffect("Splash2",false,100,pByObj);
	else if (amt>1) StartSoundEffect("Splash1",false,100,pByObj);
}
Example #3
0
public func Advance()
{
    // Letzten Vertex ermitteln
    var iLastVertex = GetVertexNum() - 1;
    // Einschlag im Boden
    if (GBackSemiSolid(GetVertex(iLastVertex, 0) - GetX(), GetVertex(iLastVertex, 1) - GetY()))
        return(Remove());
    // Schon über fünf Schritte fortgeschritten: Schaden an Objekten verursachen
    if (iLastVertex > 5)
        BlastObjects(GetVertex(iLastVertex, 0), GetVertex(iLastVertex, 1), 3);
    // Neuen Schritt durchführen
    if (Not(AddVertex(GetVertex(iLastVertex, 0) + Local(0) + Random(Local(1)),
                      GetVertex(iLastVertex, 1) + Local(2) + Random(Local(3)) )))
        return(Remove());
    // Anziehung an ein Zielobjekt prüfen
    var pTarget;
    iLastVertex = GetVertexNum() - 1;
    if (iLastVertex > 7)
        if (pTarget = FindObject( 0,
                                  GetVertex(iLastVertex, 0) - GetX() - 50,
                                  GetVertex(iLastVertex, 1) - GetY() - 50,
                                  100,
                                  100,
                                  OCF_AttractLightning() ))
            Attraction(pTarget);
}
Example #4
0
void BubbleOut(int32_t tx, int32_t ty) {
  // No bubbles from nowhere
  if (!GBackSemiSolid(tx, ty)) return;
  // User-defined smoke level
  int32_t SmokeLevel = GetSmokeLevel();
  // Enough bubbles out there already
  if (Game.Objects.ObjectCount(C4Id("FXU1")) >= SmokeLevel) return;
  // Create bubble
  Game.CreateObject(C4Id("FXU1"), NULL, NO_OWNER, tx, ty);
}
Example #5
0
// Returns the number of stuck vertices. (of this)
global func VerticesStuckSemi()
{
	var vertices = 0;
	// Loop through vertices.
	for (var i = -1; i < GetVertexNum(); i++)
		// Solid?
		if (GBackSemiSolid(GetVertex(i, VTX_X), GetVertex(i, VTX_Y)))
			// Count vertices.
			vertices++;
	return vertices;
}
Example #6
0
public func RejectUse(object clonk)
{
	// General inability?
	if(clonk->GetProcedure() != "WALK") return true;
	if (GBackSemiSolid(0, 0)) return true;
	/*
	This check might make sense, so that you can just hold the button and walk over the ground until the soil is fitting.
	However, you would never get the $NoSuitableGround$ message in that case.
	// Check soil below the Clonk's feet
	var ground_y = clonk->GetDefBottom() - clonk->GetY() + 1;
	if (GetMaterialVal("Soil", "Material", GetMaterial(0, ground_y)) == 0) return true;
	*/
	return false;
}
Example #7
0
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);
  }  
}
Example #8
0
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);
}
Example #9
0
global func FxSmokeTrailTimer(object pTarget, int iEffectNumber, int iEffectTime)
{
  var iStrength = EffectVar(0, pTarget, iEffectNumber);
  var iAStr = EffectVar(1, pTarget, iEffectNumber);
  var iX = EffectVar(2, pTarget, iEffectNumber);
  var iY = EffectVar(3, pTarget, iEffectNumber);
  var iXDir = EffectVar(4, pTarget, iEffectNumber);
  var iYDir = EffectVar(5, pTarget, iEffectNumber);

  iAStr = Max(1,iAStr-iAStr/10+Random(2));
  iAStr--;
  iYDir += GetGravity()*2/3;
  iYDir += GetWind(iX,iY)/20;

  var xdir = iXDir*iAStr/iStrength;
  var ydir = iYDir*iAStr/iStrength;

  // Neu: Random
  iX += RandomX(-3,3);
  iY += RandomX(-3,3);
  
  // zuerst zeichnen
  CreateParticle("Smoke3",iX,iY,RandomX(-2,2),RandomX(-2,2)-3,20+iAStr*8,RGBa(128,128,128,55+35*iAStr/iStrength));
  CreateParticle("Blast",iX,iY,0,0,10+iAStr*8,RGBa(250,100+Random(100),100,160));

  // dann nächste position berechnen
  iX += xdir/100;
  iY += ydir/100;
  
  if(GBackSemiSolid(iX,iY))
    return -1;
  if(iAStr <= 1)
    return -1;
    
  EffectVar(1, pTarget, iEffectNumber) = iAStr;
  EffectVar(2, pTarget, iEffectNumber) = iX;
  EffectVar(3, pTarget, iEffectNumber) = iY;
  EffectVar(5, pTarget, iEffectNumber) = iYDir;
}
Example #10
0
protected func Construction()
{
	if (GBackSemiSolid())
		SetGraphics("Old");
}
Example #11
0
// 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;
}