Example #1
0
func FxFireDashStop(object target, proplist effect, int reason, bool temporary)
{
	if(temporary)
		return;
	
	target->Unstuck();
	target->SetObjectLayer(nil);
	
	target->SetAction("Jump");
	ExplosionEffect(effect.Size2, target->GetX(), target->GetY(),0,0,0);
	
	for(var o in FindObjects(Find_Distance(effect.Size2, target->GetX(), target->GetY()), Find_Func("CanBeHit", target)))
	{
		if(o->GetOwner() == target->GetOwner())
			continue;
			
		var angle = Angle(target->GetX(), target->GetY(), o->GetX(), o->GetY());
		
		o->AddFireHitEffect();
		o->Fling(Sin(angle, 8), -Cos(angle, 8) - 2);
		target->WeaponDamage(o, effect.SpellDamage2);
	}
	
	target->CastObjects(Flame, RandomX(6,8), RandomX(10,25));
	//effect.marker->RemoveObject();
	//effect.clonk->MakeHitable(true);

}
Example #2
0
global func FxHitCheckDoCheck(object target, proplist effect)
{
    var obj;
    // rather search in front of the projectile, since a hit might delete the effect,
    // and clonks can effectively hide in front of walls.
    var oldx = target->GetX();
    var oldy = target->GetY();
    var newx = target->GetX() + target->GetXDir() / 10;
    var newy = target->GetY() + target->GetYDir() / 10;
    var dist = Distance(oldx, oldy, newx, newy);
    var is_human = GetPlayerType(target->GetController()) == C4PT_User;

    var shooter = effect.shooter;
    var live = effect.live;

    if (live)
        shooter = target;

    if (dist <= Max(1, Max(Abs(target->GetXDir()), Abs(target->GetYDir()))) * 2)
    {
        // We search for objects along the line on which we moved since the last check
        // and sort by distance (closer first).
        for (obj in FindObjects(Find_OnLine(oldx, oldy, newx, newy),
                                Find_NoContainer(),
                                Find_Layer(target->GetObjectLayer()),
                                Find_PathFree(target),
                                Sort_Distance(oldx, oldy)))
        {
            // Excludes
            if (!obj) continue; // hit callback of one object might have removed other objects
            if(obj == target) continue;
            if(obj == shooter) continue;
            if (is_human) {
                if (obj == g_windgen1) continue;
                if (obj == g_windgen2) continue;
                if (obj == g_windgen3) continue;
                if (obj == g_windmill) continue;
            }

            // Unlike in hazard, there is no NOFF rule (yet)
            // CheckEnemy
            //if(!CheckEnemy(obj,target)) continue;

            // IsProjectileTarget or Alive will be hit
            if (obj->~IsProjectileTarget(target, shooter) || obj->GetOCF() & OCF_Alive)
            {
                target->~HitObject(obj);
                if (!target)
                    return;
            }
        }
    }
    return;
}
Example #3
0
global func SetArrowToObj(object obj)
{
	if (arrow_target == obj) return 0;
  RemoveObject(FindObject(_AR1));
  CreateObject(_AR1, obj->GetX() + obj->GetDefCoreVal("Width") / 4, obj->GetY() - obj->GetDefCoreVal("Height") / 2 - 10, -1);
  arrow_target = obj;
}
Example #4
0
global func AddCyclopsAI(object clonk) // somewhat hacky, but it works
{
	var effect_name = "IntCyclopsAI";
	var fx = GetEffect(effect_name, clonk);
	if (!fx) fx = AddEffect(effect_name, clonk, 1, 2);
	if (!fx || !clonk) return nil;
	
	clonk.ai = fx;

	// bin inventory
	var cnt = clonk->ContentsCount();
	fx.bound_weapons = CreateArray(cnt);
	for (var i=0; i<cnt; ++i) fx.bound_weapons[i] = clonk->Contents(i);

	// set home
	fx.home_x = clonk->GetX();
	fx.home_y = clonk->GetY();
	fx.home_dir = DIR_Left;

	// set guard range
	fx.guard_range = {
                      x = fx.home_x-AI_DefGuardRangeX,
                      y = fx.home_y-AI_DefGuardRangeY,
                      wdt = AI_DefGuardRangeX*2,
                      hgt =  AI_DefGuardRangeY*2};
                      

	fx.spray_old = {time = 0, v0 = 0, v1 = 0, reach = 0};
	fx.spray_cur = {time = 0, v0 = 0, v1 = 0, reach = 0};

	AI->SetMaxAggroDistance(clonk, AI_DefMaxAggroDistance);
	return fx;
}
Example #5
0
func SetRight2(object host)
{
	SetGraphics("Right");
	SetAction("Right", host);
	SetShape(0,0,4,32);
	SetPosition(host->GetX()+15, host->GetY()-48);
	SetSolidMask(0,0,2,32,2,0);
	SetVertexXY(0,-27-3,1+32);
	return true;
}
Example #6
0
func SetBottom2(object host)
{
	SetGraphics("Bottom");
	SetAction("Bottom", host);
	SetShape(0,0,32,4);
	SetPosition(host->GetX()+13, host->GetY()+12);
	SetSolidMask(0,0,32,4);
	SetVertexXY(0,1-29,-27);
	return true;
}
Example #7
0
func SetLeft(object host)
{
	SetGraphics("Left");
	SetAction("Left", host);
	SetShape(0,0,4,32);
	SetPosition(host->GetX()-16, host->GetY()-16);
	SetSolidMask(0,0,2,32);
	SetVertexXY(0,1,1);
	return true;
}
Example #8
0
func SetTop(object host)
{
	SetGraphics("Top");
	SetAction("Top", host);
	SetShape(0,0,32,4);
	SetPosition(host->GetX()-16, host->GetY()-16);
	SetSolidMask(0,0,32,4);
	SetVertexXY(0,1,1);
	return true;
}
Example #9
0
func Blocked(object clonk)
{
	AddEffect("Blocked", this, 1, 1, this);
	Sound("Ball::ball_blocked", false, 20);
	SetRDir(20);
	var objectangle = Angle(clonk->GetX(), clonk->GetY(), GetX(), GetY());
	
	//var tangle = 2* ( (objectangle + 90)%360 - entryangle) + entryangle;
	SetVelocity(objectangle, Speed);
	Idle();
}
Example #10
0
// Set the home position the Clonk returns to if he has no target
func SetHome(object clonk, int x, int y, int dir)
{
	var fx = GetEffect("S2AI", clonk);
	if (!fx || !clonk) return false;
	// nil/nil defaults to current position
	if (!GetType(x)) x=clonk->GetX();
	if (!GetType(y)) y=clonk->GetY();
	if (!GetType(dir)) dir=clonk->GetDir();
	fx.home_x = x; fx.home_y = y;
	fx.home_dir = dir;
	return true;
}
Example #11
0
func Launch(object clonk, int x, int y)
{
	if(clonk.TimeTravelMark == nil)
	{
		clonk.TimeTravelMark = [clonk->GetX(), clonk->GetY()];
		clonk.timeposfx = AddEffect("TravelPos", clonk, 1, 1, nil, GetID(), Size);
		clonk.timeposfx.size = Size;
		clonk.timeposfx.dur = Dur;
		clonk->Sound("travel_pos", false, 30, clonk->GetOwner());
		RemoveObject();
		return 1;
	}
Example #12
0
func FxPyritHammeringTimer(object c, proplist fx, int time)
{
	if (FrameCounter() < this.anim_continue_frame || c.has_sequence) return FX_OK;
	this.anim = 0;
	if (!fx.catapult) if (!(fx.catapult = FindObject(Find_ID(Catapult), Sort_Distance()))) return FX_OK;
	if ((!Random(20) && GetPlayerCount()) || this.was_walk_interrupted)
	{
		// Move between two places (only if players are joined so Pyrit stays in place for object saving)
		var new_pos = [fx.catapult->GetX()-24, fx.catapult->GetX()+26][c->GetX() < fx.catapult->GetX()];
		c->SetCommand("MoveTo", nil, new_pos, fx.catapult->GetY());
		this.anim_continue_frame = FrameCounter() + 50;
		this.was_walk_interrupted = false;
	}
Example #13
0
func FxAttack_PanicTimer(object c, proplist fx, int time)
{
	// Run around in random directions
	var x = c->GetX();
	if (x < 400)
		x += 200;
	else if (x > 600)
		x -= 200;
	else
		x += Random(2)*400 - 200;
	c->SetCommand("MoveTo", nil, x, 300);
	return FX_OK;
}
Example #14
0
func JumpEffect(object clonk, dir)
{
	var from;
	var to;

	if (dir == "Up")
	{
		from = 50; 
		to = 130;
	}
	if (dir == "Left")
	{
		from = -30; 
		to = 50;
	}
	if (dir == "Right")
	{
		from = 130; 
		to = 210;
	}
	if (dir == "Down")
	{
		from = 230; 
		to = 310;
	}

	clonk->Sound("time_hit", false, 30);

	for(var i = from; i < to; i+=5)
	{
		var r = 10;
		var x = clonk->GetX() + Cos(i, r);
		var y = clonk->GetY() + Sin(i, r);
		
		var angle = Angle(0,0,Cos(i, r),Sin(i, r));
		
		var trailparticles =
		{
			Prototype = Particles_ElectroSpark2(),
			Size = PV_Linear(10,0),
			Rotation = angle,
			R = 255,
			G = 165,
			B = 50,
			OnCollision = PC_Bounce(),
		};
	
		CreateParticle("Lightning", x, y, Cos(i, r), Sin(i, r), 10, trailparticles);
	}
}
Example #15
0
func JumpEffect(object clonk, dir)
{
	var from;
	var to;

	if (dir == "Up")
	{
		from = 50; 
		to = 130;
	}
	if (dir == "Left")
	{
		from = -30; 
		to = 50;
	}
	if (dir == "Right")
	{
		from = 130; 
		to = 210;
	}
	if (dir == "Down")
	{
		from = 230; 
		to = 310;
	}

	Sound("hookjump", false, 30);

	for(var i = from; i < to; i+=5)
	{
		var r = 10;
		var x = clonk->GetX() + Cos(i, r);
		var y = clonk->GetY() + Sin(i, r);
		
		var angle = Angle(0,0,Cos(i, r),Sin(i, r));
		
		var trailparticles =
		{
			//Prototype = Particles_ElectroSpark2(),
			Size = PV_Linear(10,0),
			Rotation = angle,
			R = 150,
			G = 150,
			B = 150,
			OnCollision = PC_Bounce(),
		};
	
		CreateParticle("Shockwave", x, y, Cos(i, r + RandomX(-1,1)), Sin(i, r + RandomX(-1, 1)), 10, trailparticles);
	}
}
Example #16
0
func ControlUse(object clonk, x, y)
{
	var objdef = clonk.ObjectSpawnDefinition;
	
	
	if (objdef == Marker)
	{
		var marker = clonk->PlaceNewMarker();
		if (marker) marker->SetPosition(clonk->GetX() + x, clonk->GetY() + y);
	}
	else
	{
		clonk->CreateObject(objdef, x, y);
	}
	
	Sound("UI::Click", true, nil, clonk->GetOwner());
}
Example #17
0
func FxLaraWalkingTimer(object c, proplist fx, int time)
{
	var speed_factor = 50;
	// Interrupted by dialogue?
	if (FrameCounter() < this.anim_continue_frame) return FX_OK;
	// No player joined? Stay in place for proper scenario saving.
	if (!GetPlayerCount()) return FX_OK;
	// Busy lifting/dropping?
	if (GetEffect("IntLiftHeavy", c)) return FX_OK;
	if (GetEffect("IntDropHeavy", c)) return FX_OK;
	// Do we have something to carry?
	if (!fx.carry_obj)
	{
		// Relax for a random time...
		if (!Random(10))
			// ...and search new work after
			fx.carry_obj = fx.last_barrel = Lara_FindCarryObj(c, fx);
	}
	if (fx.carry_obj)
	{
		// need to pick it up?
		if (fx.carry_obj->Contained() != c)
		{
			// need to walk there?
			var dist = Abs(fx.carry_obj->GetX() - c->GetX());
			if (dist < 10)
			{
				// pick up!
				c->SetCommand("None");
				c->SetComDir(COMD_Stop);
				// short break - then pick up.
				if (c->GetXDir()) return FX_OK;
				c->SetXDir();
				fx.carry_obj->Enter(c);
				// find a target
				fx.target_pos = [[220+Random(11), 311], [495+Random(51),358]][fx.carry_obj->GetX() < 350];
			}
			else 
			{
				// we're close. slow down.
				if (dist < 40) speed_factor = 30;
Example #18
0
func FxBallShieldStart(object target, proplist effect, int temporary)
{
	effect.dummy = CreateObject(Dummy, target->GetX(), target->GetY(), target->GetOwner());
	effect.dummy.Visibility = VIS_All;
	effect.dummy->SetAction("HangOnto", target);
	effect.shield = ShieldAmount;
	effect.cancel = false;
	
	var props =
		{
			R = 0,
			G = 0,
			B = 255,
			Alpha = 255,
			Size = 40,
			BlitMode = GFX_BLIT_Additive,
			Rotation = PV_Step(10, 0, 1),
			Attach = ATTACH_Back | ATTACH_MoveRelative
			
	};
	effect.dummy->CreateParticle("Shockwave", 0, 0, 0, 0, 0, props);
}
Example #19
0
func BlockEffect(object clonk, range)
{
	for(var i = 0; i < 360; i+=10)
	{
		var r = range;
		var x = clonk->GetX() + Cos(i, r);
		var y = clonk->GetY() + Sin(i, r);
		
		var angle = Angle(0,0,Cos(i, r),Sin(i, r)) + 90;
		
		var trailparticles =
		{
			Size = PV_Linear(15,0),
			Rotation = angle,
			R = 150,
			G = 150,
			B = 150,
		};
	
		CreateParticle("Shockwave", x, y, 0, 0, 10, trailparticles);
	}
	
}
Example #20
0
func BlockEffect(object clonk, range)
{
	for(var i = 0; i < 360; i+=10)
	{
		var r = range;
		var x = clonk->GetX() + Cos(i, r);
		var y = clonk->GetY() + Sin(i, r);
		
		var angle = Angle(0,0,Cos(i, r),Sin(i, r)) + 90;
		
		var trailparticles =
		{
			Prototype = Particles_ElectroSpark2(),
			Size = PV_Linear(15,0),
			Rotation = angle,
			R = 255,
			G = 165,
			B = 50,
		};
	
		CreateParticle("Lightning", x, y, 0, 0, 10, trailparticles);
	}
	
}
Example #21
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 #22
0
public func ControlUse(object pClonk, int ix, int iy)
{
	AddEffect("HardeningSpell", nil, 100, 1, nil, GetID(), Angle(0,0,ix,iy),pClonk->GetX(), pClonk->GetY());
	RemoveObject();
	return 1;
}
Example #23
0
public func ControlUse(object pClonk, int ix, int iy)
{
	AddEffect("Frostbolt", nil, 100, 1, nil, GetID(), pClonk->GetOwner(), Angle(0,0,ix,iy),pClonk->GetX(), pClonk->GetY());
	Sound("Fireball");
	Sound("Fireball");
	RemoveObject();
	return 1;
}
Example #24
0
func FxFireDashTimer(object target, proplist effect, int time)
{
	var a = effect.angle;
		
	var x = target->GetX();
	var y = target->GetY();
	
	target->SetPosition(target->GetX() + Sin(a, 6, effect.angle_prec), target->GetY() + -Cos(a, 6, effect.angle_prec));

	for(var o in FindObjects(Find_Distance(effect.Size1, x, y), Find_Func("CanBeHit", target)))
	{
		if(o->GetOwner() == target->GetOwner())
			continue;
		if(!GetEffect("DashCD", o))
		{
			o->Fling(0, -5);
			AddEffect("DashCD", o, 20, 10);
			o->AddFireHitEffect();
			target->WeaponDamage(o, effect.SpellDamage1);
		}
		
	}
	
	var chaoticspark =
	{
		Size = PV_Linear(1, 0),
		ForceX = PV_KeyFrames(10, 0, PV_Random(-6, 6), 333, PV_Random(-6, -6), 666, PV_Random(6, 6), 1000, PV_Random(-6, 6)),
		ForceY = PV_KeyFrames(10, 0, PV_Random(-8, 5), 333, PV_Random(-8, 5), 666, PV_Random(-10, 10), 1000, PV_Random(-10, 15)),
		Stretch = PV_Speed(1000, 500),
		Rotation = PV_Direction(),
		CollisionVertex = 0,
		OnCollision = PC_Die(),
		R = 255,
		G = PV_Linear(255,100),
		B = PV_Random(0, 100),
		DampingX=950,
		DampingY=950,
		Alpha = PV_Random(100,180),
		BlitMode = GFX_BLIT_Additive
	};
	CreateParticle("Magic", x + RandomX(-5, 5), y + RandomX(-10, 10), RandomX(25, -25) + target->GetXDir(), RandomX(-25, 12) + target->GetYDir(), 50, chaoticspark, 4);


	var firetrailparticles =
	{
		Prototype = Particles_FireTrail(),
		Size = PV_Linear(effect.Size1,0),
		BlitMode = GFX_BLIT_Additive,
		OnCollision=nil,
	};
	CreateParticle("Fire", x, y, PV_Random(-7,7), PV_Random(-7,7), 20, firetrailparticles, 3);
	
	var dist = Distance(x, y, effect.startx + effect.tx, effect.starty + effect.ty);
	if(dist < 10 || (dist > effect.dist + 1 && time > 10))
	{
		effect.clonk->SetObjectLayer(nil);
		return -1;
	}
	else
	{
		//Log("%d %d", dist, effect.dist);
		effect.dist = dist;
	}
	
}
Example #25
0
public func ControlUse(object pClonk, int ix, int iy)
{
	AddEffect("WindScrollStorm", nil, 100, 1, nil, GetID(), Angle(0,0,ix,iy),pClonk->GetX(), pClonk->GetY());
	RemoveObject();
	return 1;
}