Example #1
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));
}
Example #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;
}
Example #3
0
func ContactBottom()
{
	if (!Random(3))
		SetXDir(GetXDir() / 2);
	SetYDir(GetYDir() / -2);
	return BouncePhysics();
}
Example #4
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;
}
Example #5
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;
}
Example #6
0
func InitEffect()
{
	Sound("Objects::Weapons::WeaponSwing1", false, 100);
	SetLightRange(30, 70);
	SetLightColor(RGB(150, 150, 150));

	trailparticles =
	{
		Size = 5,
		R = pR,
		G = pG,
		B = pB,
		Attach=ATTACH_Front
	};
	
	var angle = Angle(0, 0, GetXDir(), GetYDir());
	
	hookprt = 
	{
		Size = 8,
		R = pR,
		G = pG,
		B = pB,
		Attach=ATTACH_Front|ATTACH_MoveRelative,
		Rotation = angle
	};
	
	
	AddEffect("Life", this, 1, LifeTime, this);
	hit = false;
}
Example #7
0
global func FxAttachTimer(object pTarget, int iEffectNumber) {
	var pObj = EffectVar(0, pTarget, iEffectNumber);
	if(!pObj)
		return -1;
	pTarget -> SetPosition(GetX(pObj), GetY(pObj));
	pTarget -> SetXDir(GetXDir(pObj));
	pTarget -> SetYDir(GetYDir(pObj));
}
Example #8
0
func TravelEffect(int time)
{
	if(!shooter)
		return RemoveObject();
	var obj = FindObject(Find_ID(SawBlade), Find_AtPoint());
	if(obj)
	{
		obj->HitByHook(this);
		DestroyEffect();
		Destroy();
		return;
	}
	
	ClearParticles();
	CreateParticle("Hook", GetXDir()/15, GetYDir()/15, 0, 0, 0, hookprt, 1);
	DrawParticleLine("Shockwave2", GetXDir()/15, GetYDir()/15, shooter->GetX() - GetX() + shooter->GetXDir()/10, shooter->GetY() - GetY() + shooter->GetYDir()/10, 5, 0, 0, 1, trailparticles);
}
Example #9
0
func CatchBlow(int iLevel, object pObj) {
	if (GetCategory(pObj) & C4D_Object && GetOCF(pObj) & OCF_Collectible && ObjectDistance(pObj)*10 < 8*Sqrt(GetDefWidth(GetID())*GetDefHeight(GetID())) ) {
		pObj->~Hit();
		// Reduces object speed by 90%
		if (pObj) {
			pObj->SetXDir(GetXDir()*5, 0, 100);
			pObj->SetYDir(GetYDir()*5, 0, 100);
		}
	}
	return _inherited(iLevel, pObj);
}
Example #10
0
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;
}
Example #11
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);
	}
}
Example #12
0
protected func SmokeTrail() {
  Smoke(0, 0, 2);
  Smoke(0, -5, Random(3));
  var i = Random(20);
  while (i--) {
    var c = (20+Random(41))/2;
    CreateParticle("PxSpark", Random(11)-5, Random(11)-5, 0, 0, c,
      RGBa(255, Random(100), c*4, 128));
  }
  CreateParticle("PxSpark", 0, 0, 0, 0, 20,
    RGBa(255, 155, 0, 128));
  //Bitte hier Schaden für Wipfe setzen
  //*99/100 = Grenzwertig stark, *98/100=Meistens 0 Schaden
  SetYDir(GetYDir(this, 1000)*982/1000, this, 1000);
}
Example #13
0
global func SemiExplode(int iLevel, int incidence)
{
  for(var i = 0; i < incidence; i++)
  {
    var rock = CreateObject(ROCK, 0, 0, GetOwner());
    if(this)
    {
      rock->SetXDir(GetXDir(this));
      rock->SetYDir(GetYDir(this));
    }
    Explode(iLevel,rock); 
  }
  RemoveObject();
  return 1;
}
Example #14
0
func InitEffect()
{
	Sound("Fire::Fireball", false, 100);
	Sound("Fire::FuseLoop", false, 50, nil, 1);
	SetLightRange(30, 70);
	SetLightColor(RGB(255, 100, 0));
	
	if (shooter.ChampType == ComboMan)
	{
		Speed = 75;
		ParticleSize = 13;
		SpellDamage = 25;
		SetVelocity(Angle(0,0,GetXDir(), GetYDir(), 10), Speed, 10);
	}

	var lightparticle =
	{
		R = 255,
		G = 100,
		B = 0,
		Alpha = 40,
		Size = 50,
		BlitMode = GFX_BLIT_Additive,
		Rotation = PV_Step(30, 0, 1),
		Attach = ATTACH_Back | ATTACH_MoveRelative
		
	};
	CreateParticle("Shockwave", 0, 0, 0, 0, 0, lightparticle);
	
	firetrailparticles =
	{
		Prototype = Particles_FireTrail(),
		Size = PV_Linear(ParticleSize,0),
		BlitMode = GFX_BLIT_Additive,
	};
}
Example #15
0
func ContactTop()
{
	SetYDir(GetYDir() / -2);
	return BouncePhysics();
}
Example #16
0
// Example func to determine when to relay clonk controls to the held vehicle
func CanRelayControl(controltype, pClonk) {
    if (controltype == "ControlUp" || controltype == "ControlDown") {
        return (GetAction() == "WaterLand" || GetAction() == "FloatIdle") && GetYDir() <= 2 && GetXDir()==0;
    }
    return 1;
}
Example #17
0
func FxTrailTimer()
{
	TravelEffect();
	if(!GetXDir() && !GetYDir() && !GetEffect("Idle", this))
		AddEffect("Idle", this, 1, 15, this);
}
Example #18
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;
	}
}
Example #19
0
// Returns the speed of an object.
global func GetSpeed(int prec)
{
	return Sqrt(GetXDir(prec)**2 + GetYDir(prec)**2);
}
Example #20
0
global func Explode(int iLevel, object pObj, id idEffect, string szEffect)
{
  if(!pObj)
    if(!(pObj=this))
      return;
  
  var x = AbsX(pObj->GetX()),
  	  y = AbsY(pObj->GetY());
			
  var boom = FindObject(BOOM);
  if(!boom) boom = CreateObject(BOOM,0,0,-1);
			
	var xdir = GetXDir(pObj) + GetWind(GetX(pObj),GetY(pObj))/20;
	var ydir = GetYDir(pObj);
	
	var opt_angle = Angle(xdir,ydir);
	var speed = BoundBy(Distance(xdir,ydir),0,60);
  
	
	///Feuer-, Funken- und Dirt-Effekte...
  var i=0, count = 3+iLevel/8, angle = Random(360);
  while((count > 0) && (++i < count*10))
  {
    angle += RandomX(40,80);
    
    angle = Interpolate4K(angle,opt_angle,0,60,speed);
    angle -= 180;
        
    //Rauch
    var smokex = +Sin(angle,RandomX(iLevel/4,iLevel/2));
    var smokey = -Cos(angle,RandomX(iLevel/4,iLevel/2));
    if(GBackSolid(x+smokex,y+smokey))
      continue;
     var level = iLevel + Random(iLevel/5);

		var a = angle+RandomX(-15,+15);
		for(var i = 7; i > 0; i--)
		  CreateParticle("BlastSpark1", smokex, smokey, +Sin(a,level+RandomX(-5,+5)), -Cos(a,level+RandomX(-5,+5)), 25+Random(50)); 
    CreateParticle("BlastFlame", smokex, smokey, +Sin(angle,level/2), -Cos(angle,level/2), level*5);
    for(var i = Random(3)+1; i > 0; i--)
		{
		  a = angle+RandomX(-30,+30);
		  CreateParticle("BlastDirt", smokex, smokey, +Sin(a,level+RandomX(-20,+20)), -Cos(a,level+RandomX(-20,+20)), level*RandomX(7,12));
		}
		//CreateSmokeTrail(level,angle,smokex,smokey,pObj);
    count--;
  }

	///Brandspuren...
  // Wir haben keine Effekteinstellungen oä., daher immer an
  //if(EffectLevel() > EM4K_Low)
    CreateBurnMark(x,y,iLevel,20+iLevel/2);

  ///Lichteffekte bei Dunkelheit...
  if(IsDark())
  {
    var iSize = iLevel*100;
    if(iLevel < 20)
      iSize /= 2;
    AddLightFlash(iSize/3, x, y, RGBa(255,220,64,15));
  }
	
	///Feuer-Effekt..
	/*angle = Interpolate4K(0,opt_angle,0,120,speed);
	angle -= 180;
	CreateParticle("BlastBg",0,0,+Sin(angle,100),-Cos(angle,100),iLevel*20);
	//CreateParticle("BlastBg",0,0,0,-1,iLevel*20);
	*/
	
	///Der eigentliche Blast-Partikel...
	CreateParticle("Blast",x,y,0,0,iLevel*11);

	///Standart-Verhalten...
  return inherited(iLevel, pObj, idEffect, szEffect);
}
Example #21
0
func FxJumpingSpeedAdjustmentTimer()
{
	if (GetYDir() < 0) return FX_OK;
	return FX_Execute_Kill;
}