Beispiel #1
0
func Hit(int oldx, int oldy)
{
	if (IsJumping())
	{
		if (GetContact(-1, CNAT_Right))
		{
			SetXDir(-10);
			SetYDir(oldy, 100);
			AddEffect("CheckComDir", this, 1, 1, this);
		}
		else if (GetContact(-1, CNAT_Left))
		{
			SetXDir(10);
			SetYDir(oldy, 100);
			AddEffect("CheckComDir", this, 1, 1, this);
		}
		else if (GetContact(-1, CNAT_Top) && (oldy < 0))
		{
			SetXDir(oldx, 100);
			SetYDir(+5);
		}
	}
	
	return inherited(oldx, oldy, ...);
}
Beispiel #2
0
func BouncePhysics()
{
	SetRDir(GetRDir() * -2);
	if (GBackSolid(5, 0) || GBackSolid(-5, 0))
		SetXDir(GetXDir() / -2);
	if (GBackSolid(0, 5) || GBackSolid(0, -5))
		SetYDir(GetYDir() / -2);
	if (GBackSolid(10, 0) || GBackSolid(-10, 0))
		SetXDir(GetXDir() / -2);
	if (GBackSolid(0, 10) || GBackSolid(0, -10))
		SetYDir(GetYDir() / -2);
	return true;
}
Beispiel #3
0
// Player pressed da button.
func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release)
{
	if (release) return true;
	var xdir=0, ydir=0, comd;
	if (ctrl == CON_Up)
		{ ydir = -1; comd = COMD_Up; }
	else if (ctrl == CON_Down)
		{ ydir = +1; comd = COMD_Down; }
	else if (ctrl == CON_Left)
		{ xdir = -1; comd = COMD_Left; }
	else if (ctrl == CON_Right)
		{ xdir = +1; comd = COMD_Right; }
	else
		return true; // block anything else
	var is_drawing = (GetAction() == "Draw");
	// No direct turnaround
	if (is_drawing && xdir * GetXDir() + ydir * GetYDir() < 0) { Sound("GIDL_Clonk::GIDLTurnError", true, 100, plr); return true; }
	Sound("GIDL_Clonk::GIDLTurn");
	var speed = ActMap.Draw.Speed / 10;
	if (is_drawing) Drawing();
	SetComDir(comd);
	if (is_drawing) { SetXDir(xdir*speed); SetYDir(ydir*speed); }
	SetR(Angle(0,0,xdir, ydir));
	return true;
}
Beispiel #4
0
func ContactBottom()
{
	if (!Random(3))
		SetXDir(GetXDir() / 2);
	SetYDir(GetYDir() / -2);
	return BouncePhysics();
}
Beispiel #5
0
func MoveToPos(x, y, add)
{
	var angle = Angle(GetX(), GetY(), x, y, 10);
	var txdir = Sin(angle, Speed + add, 10);
	var tydir = -Cos(angle, Speed + add, 10);
	SetXDir((GetXDir() + (txdir - GetXDir())/10));
	SetYDir((GetYDir() + (tydir - GetYDir())/10));
}
Beispiel #6
0
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);
}	
Beispiel #7
0
protected func Hit()
{
	if((GetY()+GetDefHeight(GetID())/2) >= 530) {
	SetXDir(150);
	SetYDir(-2);
	}
	if(GetX() >= LandscapeWidth()-15)	{ RemoveObject(); }
	_inherited();
}
Beispiel #8
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);
	}
}
Beispiel #9
0
func Bounce(int xdir, int ydir)
{
	var angle = Angle(0, 0, xdir, ydir);
	
	var surface = GetSurfaceVector(0, 0);
	var surface_angle = Angle(0, 0, surface[0], surface[1]);
	var angle_diff = GetTurnDirection(angle - 180, surface_angle);
	var new_angle = surface_angle + angle_diff;
	
	SetXDir(Sin(new_angle, Speed*10), 100);
	SetYDir(-Cos(new_angle, Speed*10), 100);
}
Beispiel #10
0
func Discharge()
{
	ClearEffects();
	SetXDir(0);
	SetYDir(0);
	
	ox=GetX();
	oy=GetY();
	
	AddEffect("Discharge", this, 1, 1 ,this);
	
	Sound("Ball::ball_start_discharge", false, 20);
}
Beispiel #11
0
func FxBlockedStop(object target, proplist effect, int reason, bool temporary)
{
	if(temporary)
		return;
		
	SetXDir(0);
	SetYDir(0);
	
	ox=GetX();
	oy=GetY();
	SetRDir(10);
	
	Sound("Ball::ball_resume", false, 20);
}
Beispiel #12
0
// Sets an objects's speed and its direction, doesn't it?
// Can set either speed or angle of velocity, or both
global func SetVelocity(int angle, int speed, int precAng, int precSpd)
{
	if(!precSpd) precSpd = 10;
	if(!precAng) precAng = 1;
	if(!speed)
		speed = Distance(0,0, GetXDir(precSpd), GetYDir(precSpd));
	if(!angle)
		angle = Angle(0,0, GetXDir(precSpd), GetYDir(precSpd), precAng);
		
	var x_dir = Sin(angle, speed, precAng);
	var y_dir = -Cos(angle, speed, precAng);

	SetXDir(x_dir, precSpd);
	SetYDir(y_dir, precSpd);
	return;
}
Beispiel #13
0
func FxMoveToTimer(object target, proplist fx, int time)
{
	if(!master)
	{
		KillBall();
		return;
	}
		
	if(GetEffect("Blocked", this))
	{
		ox=GetX();
		oy=GetY();
		return;
	}
	
	DrawParticleLine("Flash", 0, 0, ox-GetX(), oy-GetY(), 1, 0, 0, 15, movetrailparticles);

	if(time%7 == 0)
	{
		for(var i = 0; i < 360; i+=5)
		{
			CreateParticle("Flash", Sin(i, 3), -Cos(i, 5), 0, 0, 10, moveparticle2, 2);
		}
	}

	MoveToPos(fx.x, fx.y);
	
	ox=GetX();
	oy=GetY();
	
	var dst = Distance(GetX(), GetY(), fx.x, fx.y);
	if(dst < 5)
	{
		SetXDir(0);
		SetYDir(0);
		CheckForEnemies(AttackSize);
		Idle();
		
		CreateParticle("StarSpark", 0, 0, 0, 0, 10, moveparticle, 5);
		
		return -1;
	}
}
Beispiel #14
0
func Hit(xdir, ydir)
{
	if(!snapped)
	{
		Sound("hooksnap", false, 50, nil, nil, nil, 70);
		var fx = AddEffect("Travel", this, 1, 1, this);
		if(xdir)
			fx.dir = xdir / Abs(xdir);
		else
			fx.dir = 1;
			
		var rfx = GetEffect("Rotate", this);
			rfx.dir = fx.dir;
			
		fx.v = 0;
		fx.angle = 0;
		if(fx.dir == -1)
			fx.angle = 180;
		
		if	(ydir < 0)
			fx.angle -= 45 * fx.dir;
		else if(ydir > 0)
			fx.angle += 45 * fx.dir;
		
		snapped = true;
		SetAction("Travel");
		SetXDir(0);
		SetYDir(0);
		
		if(!GBackSolid())
		{
			if(GBackSolid(-1,0))
				SetPosition(GetX()-1, GetY());
			else if(GBackSolid(0,-1))
				SetPosition(GetX(), GetY()-1);
			else if(GBackSolid(1,0))
				SetPosition(GetX()+1, GetY());
			else
				SetPosition(GetX(), GetY()+1);
		}
	}
}
Beispiel #15
0
public func Activate(caster, real_caster) {
  // Zaubernden Clonk ermitteln
  var clonk = caster;
  if (real_caster) clonk = real_caster;

  // Richtungsvorzeichen ermitteln
  var dir_sign = -1;
  if (GetDir(caster) == DIR_Right()) dir_sign = +1;

  // Evtl. mit Flint kombinieren
  var obj;
  if (obj = FindContents(FLNT, clonk)) {
    // Holz erzeugen, anzünden und in Guckrichtung schleudern
    var wood = CreateObject(WOOD, 5*dir_sign, 0, -1);
    Incinerate(wood);
    // Richtigen Controller setzen
    SetController(GetController(clonk),wood);
    SetXDir(40*dir_sign, wood);
    SetYDir(-10, wood);
    // Flint verbrauchen
    RemoveObject(obj);
  }
  // Evtl. mit Pfeil kombinieren
  else
  {
    obj = FindContents(ARRW, clonk);
    if(!obj) if(FindContents(ARWP, clonk))
      obj = FindContents(ARWP, clonk)->GetItem();
    if(obj) {
      // Ein paar Objekte schleudern
      var fling_cnt = RandomX(4, 10);
      var fling_obj;
      while (fling_obj = FindObject(0, 0, 0, -1, -1, OCF_InFree(), 0, 0, NoContainer(), fling_obj)) {
        // Zu weit weg vom Clonk?
        if (ObjectDistance(clonk, fling_obj) > 5*GetDefCoreVal("Width", "DefCore", GetID(caster)))
          break;
        // Der Wolf konnte keine Steinhütten wegblasen - Clonks können keine Hütten mit Fundament wegblasen
        if (!LocalN("basement", fling_obj))
          {
          var pBasement = Local(9, fling_obj);
          if (GetType(pBasement) != C4V_C4Object()) pBasement=0;
          if (pBasement) if (!PrivateCall(pBasement, "BasementID")) pBasement=0;
          if (!pBasement)
            {
            SetXDir(dir_sign*Min(80, 80*350/GetMass(fling_obj)), fling_obj);
            SetYDir(-Min(20, 20/GetMass(fling_obj)), fling_obj);
            // Bei Objekten noch den Controller anpassen
            if(GetCategory(fling_obj) & C4D_Object())
              SetController(GetController(clonk),fling_obj);
            }
          }
        // Schon genügend Objekte geschleudert?
        if (!fling_cnt--) break;
      }
      if (!Contained(clonk)) {
        Fling(clonk, 8*dir_sign, -2);
      }
      // Pfeil verbrauchen
      RemoveObject(obj);
    }
    // Sonst normale Wirkung
    else {
      AddEffect("WindUSpell", 0, 104, 50, 0, GetID(), GetDir(caster));
      Sound("Wind2");
    }
  }
  
  RemoveObject();
  return(1);
}
Beispiel #16
0
// Does not set the speed of an object. But you can set two components of the velocity vector with this function.
global func SetSpeed(int x_dir, int y_dir, int prec)
{
	SetXDir(x_dir, prec);
	SetYDir(y_dir, prec);
	return;
}
Beispiel #17
0
func ContactRight()
{
	SetXDir(GetXDir() / -2);
	return BouncePhysics();
}
Beispiel #18
0
func ControlLeftDouble()
{
	SetXDir(-80);
	SetYDir();
}
Beispiel #19
0
func ControlRight()
{
	SetXDir(30);
}
Beispiel #20
0
func ControlUpDouble()
{
	SetYDir(-80);
	SetXDir();
}
Beispiel #21
0
func ControlRightDouble()
{
	SetXDir(80);
	SetYDir();
}
Beispiel #22
0
func ControlDownDouble()
{
	SetYDir(80);
	SetXDir();
}
Beispiel #23
0
func ControlDig()
{
	SetXDir();
	SetYDir();
}
Beispiel #24
0
func FxHomeCallTimer(object target, proplist fx, int time)
{
	if(!master)
	{
		KillBall();
		return -1;
	}	
	
	if(GetEffect("Blocked", this))
	{
		ox=GetX();
		oy=GetY();
		return;
	}
	
	DrawParticleLine("Flash", 0, 0, ox-GetX(), oy-GetY(), 1, 0, 0, 15, hometrailparticles);
	
	if(time%7 == 0)
	{
		for(var i = 0; i < 360; i+=5)
		{
			CreateParticle("Flash", Sin(i, 3), -Cos(i, 5), 0, 0, 10, hometrailparticles2, 2);
		}
	}

	fx.x = master->GetX();
	fx.y = master->GetY();
	var angle = Angle(GetX(), GetY(), fx.x, fx.y, 10);
	var txdir = Sin(angle, Speed + 12, 10);
	var tydir = -Cos(angle, Speed + 12, 10);
	SetXDir((GetXDir() + (txdir - GetXDir())/2));
	SetYDir((GetYDir() + (tydir - GetYDir())/2));
	
	CheckForEnemies(HomeCallSize);
	
	ox=GetX();
	oy=GetY();
	
	var dst = Distance(GetX(), GetY(), fx.x, fx.y);
	if(dst < 8)
	{
		AddShield(master);
		Sound("Ball::ball_shield", false, 20);
		
		var particles =
		{
			Prototype = Particles_Glimmer(),
			R = pR,
			G = pG,
			B = pB,
			Alpha = 255,
			Size = PV_Linear(10, 0),
			OnCollision = PC_Bounce(),
		};
		CreateParticle("StarSpark", 0, 0, PV_Random(-60,60), PV_Random(-60, 60), 25, particles, 5);
		
		var particle =
		{
			Alpha = PV_Linear(255, 0),
			Size = 50,
			R = pR,
			G = pG,
			B = pB,
			BlitMode = GFX_BLIT_Additive,
		};
		master->CreateParticle("StarSpark", 0, 0, 0, 0, 7, particle, 4);
		
		FollowMaster();
		return -1;
	}
}
Beispiel #25
0
func ControlLeft()
{
	SetXDir(-30);
}
Beispiel #26
0
protected func Shiver()
{
    // Bewegung
    SetXDir(Random(21) - 10);
    return(1);
}