forked from Mirrors/openclonk
fixed shield exploit: limited the maximum damage of the sword on one target to 9 damage every 15 frames
parent
a78d8a1858
commit
99638db4c9
|
@ -6,100 +6,9 @@ public func MakeKingSize() { king_size = true; SetMeshMaterial("KingSword2",0);
|
||||||
public func MakeNormalSize() { king_size = false; SetMeshMaterial("Sword2",0); }
|
public func MakeNormalSize() { king_size = false; SetMeshMaterial("Sword2",0); }
|
||||||
public func Departure() { MakeNormalSize(); }
|
public func Departure() { MakeNormalSize(); }
|
||||||
|
|
||||||
|
func SwordDamage(int shield)
|
||||||
func CheckStrike(iTime)
|
|
||||||
{
|
{
|
||||||
|
var damage = _inherited(shield, ...);
|
||||||
|
if(king_size) damage+=3000+Random(3000);
|
||||||
//if(iTime < 20) return;
|
return damage;
|
||||||
var offset_x=7;
|
|
||||||
var offset_y=0;
|
|
||||||
if(Contained()->GetDir() == DIR_Left) offset_x*=-1;
|
|
||||||
|
|
||||||
if(!(Contained()->GetContact(-1) & CNAT_Bottom))
|
|
||||||
offset_y=10;
|
|
||||||
|
|
||||||
var width=10;
|
|
||||||
var height=20;
|
|
||||||
var angle=0;
|
|
||||||
|
|
||||||
var doBash=Abs(Contained()->GetXDir()) > 5 || Abs(Contained()->GetYDir()) > 5;
|
|
||||||
if(!doBash) doBash=Contained()->GetContact(-1) & CNAT_Bottom;
|
|
||||||
|
|
||||||
if(doBash)
|
|
||||||
{
|
|
||||||
if(Contained()->GetDir() == DIR_Left)
|
|
||||||
angle=-(Max(5, Abs(Contained()->GetXDir())));
|
|
||||||
else angle=(Max(5, Abs(Contained()->GetXDir())));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(var obj in FindObjects(Find_AtRect(offset_x - width/2, offset_y - height/2, width, height),
|
|
||||||
Find_NoContainer(),
|
|
||||||
Find_Exclude(Contained()),
|
|
||||||
Find_Layer(GetObjectLayer())))
|
|
||||||
{
|
|
||||||
if (obj->~IsProjectileTarget(this, Contained()) || obj->GetOCF() & OCF_Alive)
|
|
||||||
{
|
|
||||||
var effect_name=Format("HasBeenHitBySwordEffect%d", magic_number);
|
|
||||||
var sword_name=Format("HasBeenHitBySword%d", this->ObjectNumber());
|
|
||||||
var first=true;
|
|
||||||
// don't hit objects twice
|
|
||||||
if(!GetEffect(effect_name, obj))
|
|
||||||
{
|
|
||||||
AddEffect(effect_name, obj, 1, 60 /* arbitrary */, 0, 0);
|
|
||||||
|
|
||||||
if(GetEffect(sword_name, obj))
|
|
||||||
{
|
|
||||||
//Log("successive hit");
|
|
||||||
first=false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Log("first hit overall");
|
|
||||||
AddEffect(sword_name, obj, 1, 40, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!king_size)
|
|
||||||
{
|
|
||||||
// Reduce damage by shield
|
|
||||||
var shield=ApplyShieldFactor(Contained(), obj, 0); // damage out of scope?
|
|
||||||
if(shield == 100)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// fixed damage (10)
|
|
||||||
var damage=((100-shield)*10*1000 / 100);
|
|
||||||
if(king_size) damage+=3000+Random(3000);
|
|
||||||
ProjectileHit(obj, damage, ProjectileHit_no_query_catch_blow_callback | ProjectileHit_exact_damage | ProjectileHit_no_on_projectile_hit_callback, FX_Call_EngGetPunched);
|
|
||||||
|
|
||||||
// object has not been deleted?
|
|
||||||
if(obj)
|
|
||||||
{
|
|
||||||
if(offset_y)
|
|
||||||
ApplyWeaponBash(obj, 100, 0);
|
|
||||||
else
|
|
||||||
if(!first)
|
|
||||||
ApplyWeaponBash(obj, damage/50, Angle(0, 0, angle, -10));
|
|
||||||
else
|
|
||||||
if(!offset_y)
|
|
||||||
DoWeaponSlow(obj, 300);
|
|
||||||
|
|
||||||
// Particle effect
|
|
||||||
var x=-1;
|
|
||||||
var p="Slice2";
|
|
||||||
if(Contained()->GetDir() == DIR_Right)
|
|
||||||
{
|
|
||||||
x=1;
|
|
||||||
p="Slice1";
|
|
||||||
}
|
|
||||||
CreateParticle(p, AbsX(obj->GetX())+RandomX(-1,1), AbsY(obj->GetY())+RandomX(-1,1), 0, 0, 100, RGB(255,255,255), obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
// sound and done. We can only hit one target
|
|
||||||
Sound(Format("WeaponHit%d.ogg", 1+Random(3)), false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include Library_MeleeWeapon
|
#include Library_MeleeWeapon
|
||||||
|
|
||||||
|
static const Sword_Standard_StrikingLength = 15; // in frames
|
||||||
|
|
||||||
func Hit()
|
func Hit()
|
||||||
{
|
{
|
||||||
Sound("LightMetalHit?");
|
Sound("LightMetalHit?");
|
||||||
|
@ -51,12 +53,9 @@ public func ControlUse(object clonk, int x, int y)
|
||||||
var downwards_stab = false;
|
var downwards_stab = false;
|
||||||
|
|
||||||
// figure out the kind of attack to use
|
// figure out the kind of attack to use
|
||||||
var length=15;
|
var length = Sword_Standard_StrikingLength;
|
||||||
if(clonk->IsWalking())
|
if(clonk->IsWalking())
|
||||||
{
|
{
|
||||||
//length=20;
|
|
||||||
/*if(!GetEffect("SwordStrikeSpeedUp", clonk) && !slow)
|
|
||||||
AddEffect("SwordStrikeSpeedUp", clonk, 1, 5, this);*/
|
|
||||||
if(!GetEffect("SwordStrikeStop", clonk))
|
if(!GetEffect("SwordStrikeStop", clonk))
|
||||||
AddEffect("SwordStrikeStop", clonk, 2, length, this);
|
AddEffect("SwordStrikeStop", clonk, 2, length, this);
|
||||||
} else
|
} else
|
||||||
|
@ -68,7 +67,7 @@ public func ControlUse(object clonk, int x, int y)
|
||||||
|
|
||||||
if(!slow && !GetEffect("DelayTranslateVelocity", clonk))
|
if(!slow && !GetEffect("DelayTranslateVelocity", clonk))
|
||||||
{
|
{
|
||||||
//TranslateVelocity(clonk, Angle(0, 0, x,y), 0, 300, 1);
|
// check whether the player aims below the Clonk
|
||||||
var a=Angle(0, 0, x,y);
|
var a=Angle(0, 0, x,y);
|
||||||
if(Inside(a, 35+90, 35+180))
|
if(Inside(a, 35+90, 35+180))
|
||||||
{
|
{
|
||||||
|
@ -99,14 +98,13 @@ public func ControlUse(object clonk, int x, int y)
|
||||||
}
|
}
|
||||||
clonk->UpdateAttach();
|
clonk->UpdateAttach();
|
||||||
|
|
||||||
magic_number=((magic_number+1)%10) + (ObjectNumber()*10);
|
// this means that the sword can only hit an object every X frames
|
||||||
|
// change it to something that changes every strike if you want the sword to be able to hit the same enemy with different
|
||||||
|
// strikes regardless of the time in between
|
||||||
|
magic_number = ObjectNumber();
|
||||||
StartWeaponHitCheckEffect(clonk, length, 1);
|
StartWeaponHitCheckEffect(clonk, length, 1);
|
||||||
|
|
||||||
this->Sound("WeaponSwing?", false, nil, nil, nil);
|
this->Sound("WeaponSwing?", false, nil, nil, nil);
|
||||||
// Cooldown
|
|
||||||
// Prevent clonk from striking too often if the animation is interrupted
|
|
||||||
AddEffect("SwordWeaponCooldown", clonk, 1, length, this);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,22 +114,28 @@ func OnWeaponHitCheckStop(clonk)
|
||||||
clonk->UpdateAttach();
|
clonk->UpdateAttach();
|
||||||
if(GetEffect("SwordStrikeSpeedUp", clonk))
|
if(GetEffect("SwordStrikeSpeedUp", clonk))
|
||||||
RemoveEffect("SwordStrikeSpeedUp", clonk);
|
RemoveEffect("SwordStrikeSpeedUp", clonk);
|
||||||
//if(GetEffect("DelayTranslateVelocity", clonk))
|
|
||||||
// RemoveEffect("DelayTranslateVelocity", clonk);
|
|
||||||
if(clonk->IsJumping())
|
if(clonk->IsJumping())
|
||||||
{
|
{
|
||||||
if(!GetEffect("Fall", clonk))
|
if(!GetEffect("Fall", clonk))
|
||||||
AddEffect("Fall",clonk,1,1,clonk);
|
AddEffect("Fall",clonk,1,1,clonk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(GetEffect("SwordStrikeStop", clonk))
|
||||||
|
RemoveEffect("SwordStrikeStop", clonk);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// called when the strike expired before end of length (aborted)
|
||||||
func WeaponStrikeExpired()
|
func WeaponStrikeExpired()
|
||||||
{
|
{
|
||||||
//if(Contained())
|
|
||||||
// this->ScheduleCall(this, "ControlUseStart", 1, 0, Contained(), 0, 0);
|
}
|
||||||
if(GetEffect("SwordStrikeStop", Contained()))
|
|
||||||
RemoveEffect("SwordStrikeStop", Contained());
|
func SwordDamage(int shield)
|
||||||
|
{
|
||||||
|
return ((100-shield)*9*1000 / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckStrike(iTime)
|
func CheckStrike(iTime)
|
||||||
|
@ -171,7 +175,7 @@ func CheckStrike(iTime)
|
||||||
// don't hit objects twice
|
// don't hit objects twice
|
||||||
if(!GetEffect(effect_name, obj))
|
if(!GetEffect(effect_name, obj))
|
||||||
{
|
{
|
||||||
AddEffect(effect_name, obj, 1, 60 /* arbitrary */, 0, 0);
|
AddEffect(effect_name, obj, 1, Sword_Standard_StrikingLength, 0, 0);
|
||||||
|
|
||||||
if(GetEffect(sword_name, obj))
|
if(GetEffect(sword_name, obj))
|
||||||
{
|
{
|
||||||
|
@ -191,7 +195,7 @@ func CheckStrike(iTime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// fixed damage (9)
|
// fixed damage (9)
|
||||||
var damage=((100-shield)*9*1000 / 100);
|
var damage = SwordDamage(shield);
|
||||||
ProjectileHit(obj, damage, ProjectileHit_no_query_catch_blow_callback | ProjectileHit_exact_damage | ProjectileHit_no_on_projectile_hit_callback, FX_Call_EngGetPunched);
|
ProjectileHit(obj, damage, ProjectileHit_no_query_catch_blow_callback | ProjectileHit_exact_damage | ProjectileHit_no_on_projectile_hit_callback, FX_Call_EngGetPunched);
|
||||||
|
|
||||||
// object has not been deleted?
|
// object has not been deleted?
|
||||||
|
@ -214,7 +218,7 @@ func CheckStrike(iTime)
|
||||||
x=1;
|
x=1;
|
||||||
p="Slice1";
|
p="Slice1";
|
||||||
}
|
}
|
||||||
// CreateParticle(p, AbsX(obj->GetX())+RandomX(-1,1), AbsY(obj->GetY())+RandomX(-1,1), 0, 0, 100, RGB(255,255,255), obj);
|
CreateParticle(p, AbsX(obj->GetX())+RandomX(-1,1), AbsY(obj->GetY())+RandomX(-1,1), 0, 0, 100, RGB(255,255,255), obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sound and done. We can only hit one target
|
// sound and done. We can only hit one target
|
||||||
|
|
|
@ -75,16 +75,6 @@ func FxIntWeaponChargeStart(pTarget, effect, iTemp, length)
|
||||||
|
|
||||||
func FxIntWeaponChargeTimer(pTarget, effect, iEffectTime)
|
func FxIntWeaponChargeTimer(pTarget, effect, iEffectTime)
|
||||||
{
|
{
|
||||||
// check whether the Clonk is still striking
|
|
||||||
/*if(this->GetChargeType() == L_WN_straight)
|
|
||||||
{
|
|
||||||
if(!pTarget->IsWalking())
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if(!pTarget->IsJumping())
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}*/
|
|
||||||
if(this->Contained() != pTarget) return -1;
|
if(this->Contained() != pTarget) return -1;
|
||||||
if(!pTarget->~IsWalking() && !pTarget->~IsJumping()) return -1;
|
if(!pTarget->~IsWalking() && !pTarget->~IsJumping()) return -1;
|
||||||
var strikeTime=effect.length;
|
var strikeTime=effect.length;
|
||||||
|
|
Loading…
Reference in New Issue