Skip to content
Permalink
Browse files

club respects Rule_NoFriendFire and IsProjectileTarget (#1993)

Not recommended for 8.1, because there are semantic changes: The club can now also hit targets (IsProjectileTarget) while before it could only hit OCF_Alive and C4D_Object. It's similar to the sword now.
Oh, and before it could also not hit livings that were stuck.
  • Loading branch information...
walachey committed Mar 11, 2018
1 parent 99ef4ce commit 29a1a21526741e6928a73649e4f59b3fb89970b7
Showing with 13 additions and 13 deletions.
  1. +13 −13 planet/Objects.ocd/Items.ocd/Weapons.ocd/Club.ocd/Script.c
@@ -176,32 +176,27 @@ func DoStrike(clonk, angle)
var x = Sin(angle, 7);
var y = -Cos(angle, 7);
var found = false;
for (var obj in FindObjects(Find_Distance(15, 0, 0), Find_Or(Find_OCF(OCF_Alive), Find_Category(C4D_Object), Find_Category(C4D_Vehicle)), Find_Exclude(clonk), Find_NoContainer(), Find_Layer(GetObjectLayer()), Sort_Distance()))
var already_hit_effect_name = Format("CannotBeHitTwiceBy%d", this->ObjectNumber());
for (var obj in FindObjects(Find_Distance(15, 0, 0), Find_Exclude(clonk), Find_NoContainer(), Find_Layer(GetObjectLayer()), Sort_Distance()))
{
if (obj->Stuck()) continue;

// don't hit objects behind the Clonk
if (x < 0)
{
if (obj->GetX() > GetX()) continue;
}
else if (obj->GetX() < GetX()) continue;

// vehicles are only hit if they are pseudo vehicles. Bad system - has to be changed in the future
if (obj->GetCategory() & C4D_Vehicle)
if (!GetEffect("HitCheck", obj)) continue;

var en = Format("CannotBeHitTwiceBy%d", this->ObjectNumber());
if (GetEffect(en, obj)) continue;
if (GetEffect(already_hit_effect_name, obj)) continue;

if (obj->GetOCF() & OCF_Alive)
if (obj->~IsProjectileTarget(this, Contained()))
{
var damage = ClubDamage();
ApplyWeaponBash(obj, 400, angle, clonk);
obj->DoEnergy(-damage, true, FX_Call_EngGetPunched, clonk->GetOwner());
WeaponDamage(obj, damage, FX_Call_EngGetPunched, true);
}
else
else if (obj->GetCategory() & C4D_Object)
{
if (obj->Stuck()) continue;
var div = ClubVelocityPrecision();
if(obj->GetContact(-1)) div*=10;

@@ -218,7 +213,12 @@ func DoStrike(clonk, angle)
obj->SetYDir((obj->GetYDir(100) - Cos(angle, speed)) / 2, div);
obj->SetController(clonk->GetController());
}
AddEffect(en, obj, 1, 15, nil);
else
{
continue;
}

AddEffect(already_hit_effect_name, obj, 1, 15, nil);
found=true;
break;
}

0 comments on commit 29a1a21

Please sign in to comment.
You can’t perform that action at this time.