forked from Mirrors/openclonk
Melee Weapons: Code formatted for remaining melee weapons
No actual changes, just added spaces and brackets for improved readabilitymaster
parent
69d6b2e8d2
commit
21102bb4ef
|
@ -60,7 +60,8 @@ public func ControlUseStart(object clonk, int iX, int iY)
|
|||
|
||||
// Find tree that is closest to the clonk's axe when swung
|
||||
var x_offs = 10;
|
||||
if(clonk->GetDir() == DIR_Left) {
|
||||
if (clonk->GetDir() == DIR_Left)
|
||||
{
|
||||
x_offs = -x_offs;
|
||||
}
|
||||
|
||||
|
@ -144,7 +145,10 @@ public func ControlUse(object clonk, int iX, int iY)
|
|||
if (clonk->IsJumping())
|
||||
{
|
||||
rand = 1;
|
||||
if(clonk->GetYDir() < -5) rand = 2;
|
||||
if (clonk->GetYDir() < -5)
|
||||
{
|
||||
rand = 2;
|
||||
}
|
||||
animation = Format("SwordJump%d.%s", rand, arm);
|
||||
}
|
||||
|
||||
|
@ -223,7 +227,8 @@ func FxIntAxeTimer(object clonk, effect, int time)
|
|||
|
||||
//Which direction does the clonk face?
|
||||
var x = 10;
|
||||
if(clonk->GetDirection() == COMD_Left) x = x * -1;
|
||||
if (clonk->GetDirection() == COMD_Left)
|
||||
x = x * -1;
|
||||
|
||||
//Create the woodchip particles
|
||||
var particles = Particles_WoodChip();
|
||||
|
@ -300,6 +305,7 @@ func CheckStrike(iTime)
|
|||
var offset_y = 0;
|
||||
if(Contained()->GetDir() == DIR_Left) offset_x*=-1;
|
||||
|
||||
|
||||
if (!(Contained()->GetContact(-1) & CNAT_Bottom))
|
||||
offset_y = 10;
|
||||
|
||||
|
@ -319,7 +325,7 @@ func CheckStrike(iTime)
|
|||
// don't hit objects twice
|
||||
if (!GetEffect(effect_name, obj))
|
||||
{
|
||||
AddEffect(effect_name, obj, 1, 60 /* arbitrary */);
|
||||
AddEffect(effect_name, obj, 1, 60);
|
||||
|
||||
if (GetEffect(axe_name, obj))
|
||||
{
|
||||
|
@ -336,7 +342,7 @@ func CheckStrike(iTime)
|
|||
continue;
|
||||
|
||||
// fixed damage (3)
|
||||
var damage = ((100-shield) * this.WeaponStrength * 1000 / 100);
|
||||
var damage = (100 - shield) * this.WeaponStrength * 1000 / 100;
|
||||
WeaponDamage(obj, damage, FX_Call_EngGetPunched, true);
|
||||
|
||||
if (obj)
|
||||
|
@ -371,6 +377,7 @@ func FxAxeStrikeStopStart(pTarget, effect, iTemp)
|
|||
func FxAxeStrikeStopStop(pTarget, effect, iCause, iTemp)
|
||||
{
|
||||
if(iTemp) return;
|
||||
return;
|
||||
pTarget->PopActionSpeed("Walk");
|
||||
movement_effect = nil;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
Club
|
||||
|
||||
Simple striking weapon.
|
||||
*/
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ public func HitByWeapon(by, iDamage)
|
|||
var shield_angle = iAngle;
|
||||
// angle difference: 0..180
|
||||
var angle_diff = Abs(Normalize(shield_angle - object_angle, -180));
|
||||
if (angle_diff > 45) return 0;
|
||||
if (angle_diff > 45)
|
||||
return 0;
|
||||
|
||||
Sound("Objects::Weapons::Shield::MetalHit?");
|
||||
|
||||
|
@ -147,7 +148,8 @@ func UpdateShieldAngle(object clonk, int x, int y)
|
|||
iAngle = angle;
|
||||
|
||||
var weight = 0;
|
||||
if( Abs(angle) > 90) weight = 1000*( Abs(angle)-60 )/90;
|
||||
if (Abs(angle) > 90)
|
||||
weight = 1000 * (Abs(angle) - 60) / 90;
|
||||
|
||||
var handLR;
|
||||
if (clonk->GetHandPosByItemPos(clonk->GetItemPos(this)) == 0)
|
||||
|
@ -180,8 +182,10 @@ func AdjustSolidMaskHelper()
|
|||
}
|
||||
else
|
||||
{
|
||||
if(solid_mask_helper) return solid_mask_helper->RemoveObject();
|
||||
else return;
|
||||
if (solid_mask_helper)
|
||||
return solid_mask_helper->RemoveObject();
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,7 +195,8 @@ func AdjustSolidMaskHelper()
|
|||
var distance = 8;
|
||||
var y_adjust = -5;
|
||||
var x_adjust = 1;
|
||||
if(Contained()->GetDir() == DIR_Left) x_adjust=-1;
|
||||
if (Contained()->GetDir() == DIR_Left)
|
||||
x_adjust = -1;
|
||||
var x = Sin(angle, distance) + x_adjust;
|
||||
var y = -Cos(angle, distance) + y_adjust;
|
||||
solid_mask_helper->SetVertexXY(0, -x, -y);
|
||||
|
@ -222,7 +227,8 @@ func FxShieldStopControlTimer(object target, effect)
|
|||
|
||||
func FxShieldStopControlQueryCatchBlow(object target, effect, object obj)
|
||||
{
|
||||
if (obj->GetOCF() & OCF_Alive) return false;
|
||||
if (obj->GetOCF() & OCF_Alive)
|
||||
return false;
|
||||
|
||||
// angle of shield
|
||||
var shield_angle = iAngle;
|
||||
|
@ -238,7 +244,8 @@ func FxShieldStopControlQueryCatchBlow(object target, effect, object obj)
|
|||
var angle_diff = Abs(Normalize(shield_angle - object_angle, -180));
|
||||
|
||||
// objects hits if the angle difference is greater than 45 degrees
|
||||
if (angle_diff > 45) return false;
|
||||
if (angle_diff > 45)
|
||||
return false;
|
||||
|
||||
// projectile bounces off
|
||||
var sxd = Sin(shield_angle, 15);
|
||||
|
@ -267,13 +274,17 @@ public func GetCarryMode() { return CARRY_HandBack; }
|
|||
public func GetCarrySpecial(clonk) { return carry_bone; }
|
||||
public func GetCarryTransform(clonk, sec, back)
|
||||
{
|
||||
if(aim_anim && !sec) return Trans_Mul(Trans_Rotate(180,0,1,0),Trans_Rotate(90,0,1,0));
|
||||
if(aim_anim && sec) return Trans_Mul(Trans_Rotate(180,0,0,1), Trans_Rotate(90,0,1,1));
|
||||
if (aim_anim && !sec)
|
||||
return Trans_Mul(Trans_Rotate(180, 0, 1, 0), Trans_Rotate(90, 0, 1, 0));
|
||||
if (aim_anim && sec)
|
||||
return Trans_Mul(Trans_Rotate(180, 0, 0, 1), Trans_Rotate(90, 0, 1, 1));
|
||||
|
||||
if(mTrans != nil) return mTrans;
|
||||
if (mTrans != nil)
|
||||
return mTrans;
|
||||
if (!sec)
|
||||
{
|
||||
if(back) return Trans_Mul(Trans_Rotate(-90, 0, 1, 0),Trans_Translate(0,-400,0));
|
||||
if (back)
|
||||
return Trans_Mul(Trans_Rotate(-90, 0, 1, 0), Trans_Translate(0, -400, 0));
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -292,3 +303,4 @@ local Name = "$Name$";
|
|||
local Description = "$Description$";
|
||||
local Collectible = true;
|
||||
local Components = {Wood = 1, Metal = 1};
|
||||
|
||||
|
|
|
@ -85,11 +85,13 @@ public func ControlUse(object clonk, int x, int y)
|
|||
if (!GetEffect("SwordStrikeStop", clonk))
|
||||
movement_effect = AddEffect("SwordStrikeStop", clonk, 2, length, this);
|
||||
}
|
||||
else
|
||||
if(clonk->IsJumping())
|
||||
else if (clonk->IsJumping())
|
||||
{
|
||||
rand = 1;
|
||||
if(clonk->GetYDir() < -5) rand = 2;
|
||||
if (clonk->GetYDir() < -5)
|
||||
{
|
||||
rand = 2;
|
||||
}
|
||||
animation = Format("SwordJump%d.%s", rand, arm);
|
||||
|
||||
if (!slow && !GetEffect("DelayTranslateVelocity", clonk))
|
||||
|
@ -98,8 +100,10 @@ public func ControlUse(object clonk, int x, int y)
|
|||
var a = Angle(0, 0, x, y);
|
||||
var x_dir = Sin(a, 60);
|
||||
|
||||
if(Inside(a, 35+90, 35+180)) // the player aims downwards
|
||||
if((BoundBy(x_dir, -1, 1) == BoundBy(clonk->GetXDir(), -1, 1)) || (clonk->GetXDir() == 0)) // the player aims into the direction the Clonk is already jumping
|
||||
if (Inside(a, 35 + 90, 35 + 180))
|
||||
// the player aims downwards
|
||||
if ((BoundBy(x_dir, -1, 1) == BoundBy(clonk->GetXDir(), -1, 1)) || (clonk->GetXDir() == 0))
|
||||
// the player aims into the direction the Clonk is already jumping
|
||||
{
|
||||
clonk->SetXDir(x_dir);
|
||||
clonk->SetYDir(-Cos(a, 60));
|
||||
|
@ -110,7 +114,8 @@ public func ControlUse(object clonk, int x, int y)
|
|||
animation = Format("SwordSlash1.%s", arm);
|
||||
downwards_stab = true;
|
||||
|
||||
if(GetEffect("Fall", clonk)) RemoveEffect("Fall", clonk);
|
||||
if (GetEffect("Fall", clonk))
|
||||
RemoveEffect("Fall", clonk);
|
||||
|
||||
// visual effect
|
||||
AddEffect("VisualJumpStrike", clonk, 1, 2, nil, Sword);
|
||||
|
@ -144,7 +149,10 @@ func FxVisualJumpStrikeStart(target, effect, temp)
|
|||
{
|
||||
if(temp) return;
|
||||
effect.x_add = 20;
|
||||
if(target->GetXDir() < 0) effect.x_add *= -1;
|
||||
if (target->GetXDir() < 0)
|
||||
{
|
||||
effect.x_add *= -1;
|
||||
}
|
||||
effect.visual = CreateObjectAbove(Sword_JumpEffect, 0, 0, nil);
|
||||
effect.visual->Point({x = target->GetX() + effect.x_add, y = target->GetY() + 10}, {x = target->GetX() + effect.x_add, y = target->GetY() + 10});
|
||||
}
|
||||
|
@ -169,7 +177,7 @@ func FxVisualJumpStrikeStop(target, effect, reason, temp)
|
|||
|
||||
func SwordDamage(int shield)
|
||||
{
|
||||
return ((100-shield)*9*1000 / 100);
|
||||
return (100 - shield) * 9 * 1000 / 100;
|
||||
}
|
||||
|
||||
func CheckStrike(iTime)
|
||||
|
@ -177,7 +185,8 @@ func CheckStrike(iTime)
|
|||
//if(iTime < 20) return;
|
||||
var offset_x = 7;
|
||||
var offset_y = 0;
|
||||
if(Contained()->GetDir() == DIR_Left) offset_x*=-1;
|
||||
if (Contained()->GetDir() == DIR_Left)
|
||||
offset_x *= -1;
|
||||
|
||||
if (!(Contained()->GetContact(-1) & CNAT_Bottom))
|
||||
offset_y = 10;
|
||||
|
@ -187,13 +196,17 @@ func CheckStrike(iTime)
|
|||
var angle = 0;
|
||||
|
||||
var doBash = Abs(Contained()->GetXDir()) > 5 || Abs(Contained()->GetYDir()) > 5;
|
||||
if(!doBash) doBash=Contained()->GetContact(-1) & CNAT_Bottom;
|
||||
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())));
|
||||
else
|
||||
angle = (Max(5, Abs(Contained()->GetXDir())));
|
||||
}
|
||||
|
||||
for(var obj in FindObjects(Find_AtRect(offset_x - width/2, offset_y - height/2, width, height),
|
||||
|
@ -240,11 +253,9 @@ func CheckStrike(iTime)
|
|||
{
|
||||
if (offset_y)
|
||||
ApplyWeaponBash(obj, 100, 0);
|
||||
else
|
||||
if(!first)
|
||||
else if (!first)
|
||||
ApplyWeaponBash(obj, damage / 50, Angle(0, 0, angle, -10));
|
||||
else
|
||||
if(!offset_y)
|
||||
else if (!offset_y)
|
||||
DoWeaponSlow(obj, 300);
|
||||
|
||||
// Particle effect
|
||||
|
@ -268,7 +279,6 @@ func CheckStrike(iTime)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func FxSwordStrikeStopStart(pTarget, effect, iTemp)
|
||||
|
@ -281,7 +291,8 @@ func FxSwordStrikeStopStop(pTarget, effect, iCause, iTemp)
|
|||
{
|
||||
if(iTemp) return;
|
||||
pTarget->PopActionSpeed("Walk");
|
||||
if (this) movement_effect = nil;
|
||||
if (this)
|
||||
movement_effect = nil;
|
||||
}
|
||||
|
||||
func FxSwordStrikeStopTimer(pTarget, effect)
|
||||
|
@ -299,7 +310,8 @@ func FxSwordStrikeSpeedUpTimer(pTarget, effect, iEffectTime)
|
|||
{
|
||||
if (!pTarget->GetContact(-1) & CNAT_Bottom)
|
||||
return -1;
|
||||
if(iEffectTime > 35*2) return -1;
|
||||
if (iEffectTime > 35 * 2)
|
||||
return -1;
|
||||
}
|
||||
|
||||
func FxSwordStrikeSpeedUpStop(pTarget, effect, iCause, iTemp)
|
||||
|
@ -320,7 +332,8 @@ func FxSwordStrikeSlowStart(pTarget, effect, iTemp, iTime)
|
|||
|
||||
func FxSwordStrikeSlowTimer(pTarget, effect, iEffectTime)
|
||||
{
|
||||
if(iEffectTime > effect.starttime) return -1;
|
||||
if (iEffectTime > effect.starttime)
|
||||
return -1;
|
||||
}
|
||||
|
||||
func FxSwordStrikeSlowStop(pTarget, effect, iCause, iTemp)
|
||||
|
@ -353,7 +366,8 @@ public func GetCarryTransform(clonk, sec, back)
|
|||
return Trans_Rotate(-90, 1, 0, 0);
|
||||
}
|
||||
|
||||
func Definition(def) {
|
||||
func Definition(def)
|
||||
{
|
||||
SetProperty("PictureTransformation", Trans_Rotate(20, 0, 0, 1), def);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue