コード例 #1
0
ファイル: HitCheck.c プロジェクト: pkern/openclonk
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;
}
コード例 #2
0
ファイル: DlgLara.c プロジェクト: Fulgen301/openclonk
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;
コード例 #3
0
ファイル: Script.c プロジェクト: TheThow/OpenClonk-Stuff
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;
	}
	
}