MoltenMonarch: Fix musket/blunderbuss

alut-include-path
Mark 2017-01-07 02:10:00 +01:00
parent dfc4483ae9
commit db9451dcce
3 changed files with 48 additions and 52 deletions

View File

@ -2,54 +2,26 @@
local king_size;
public func MakeKingSize() { king_size = true; return(SetMeshMaterial("KingMusket",0)); }
public func MakeNormalSize() { king_size = false; return(SetMeshMaterial("Musket",0)); }
public func Departure() { MakeNormalSize(); }
private func FireWeapon(object clonk, int angle)
public func MakeKingSize()
{
var shot = Contents(0)->TakeObject();
if(king_size)
{
var box = CreateObjectAbove(LeadBullet,0,0,this->GetOwner());
shot->LessDamage();
shot->Launch(clonk,angle,iBarrel,260+Random(40));
shot=box->TakeObject();
shot->LessDamage();
shot->Launch(clonk,angle-3,iBarrel,240+Random(30));
shot=box->TakeObject();
shot->LessDamage();
shot->Launch(clonk,angle-2,iBarrel,240+Random(30));
shot=box->TakeObject();
shot->LessDamage();
shot->Launch(clonk,angle+2,iBarrel,240+Random(30));
shot=box->TakeObject();
shot->LessDamage();
shot->Launch(clonk,angle+3,iBarrel,240+Random(30));
box->RemoveObject();
king_size = true;
}
else
shot->Launch(clonk,angle,iBarrel,200);
this.BulletsPerShot = 10;
this.BulletSpread = 500;
this.BulletSpeed = [240, 270];
loaded = false;
SetProperty("PictureTransformation",Trans_Mul(Trans_Translate(1500,0,-1500),Trans_Rotate(170,0,1,0),Trans_Rotate(30,0,0,1)));
Sound("Objects::Weapons::Blunderbuss::GunShoot?");
// Muzzle Flash & gun smoke
var IX=Sin(180-angle,MuskFront);
var IY=Cos(180-angle,MuskUp)+MuskOffset;
if(Abs(Normalize(angle,-180)) > 90)
IY=Cos(180-angle,MuskDown)+MuskOffset;
var x = Sin(angle, 20);
var y = -Cos(angle, 20);
CreateParticle("Smoke", IX, IY, PV_Random(x - 20, x + 20), PV_Random(y - 20, y + 20), PV_Random(40, 60), Particles_Smoke(), 20);
clonk->CreateMuzzleFlash(IX, IY, angle, 20);
CreateParticle("Flash", 0, 0, 0, 0, 8, Particles_Flash());
SetMeshMaterial("KingMusket", 0);
}
public func MakeNormalSize()
{
king_size = false;
this.BulletsPerShot = 5;
this.BulletSpread = 300;
this.BulletSpeed = [196, 204];
SetMeshMaterial("Musket", 0);
}
public func Departure() { MakeNormalSize(); }

View File

@ -1,10 +1,33 @@
#appendto LeadBullet
local lowering;
public func LessDamage() { lowering=6; SetClrModulation(RGB(255,128,0)); }
public func ProjectileDamage() { return 10-lowering; }
public func LessDamage()
{
lowering = 6;
SetClrModulation(RGB(255,128,0));
}
public func ProjectileDamage() { return 10 - lowering; }
public func TrailColor(int time)
{
if(!lowering) return RGBa(255,255,255,240*Max(0,FlightTime()-time)/FlightTime());
else return RGBa(255-Min(time*5),255-Min(time*18,255),0,240*Max(0,FlightTime()-time)/FlightTime());
var r = 255, g = 255, b = 255;
if (lowering)
{
r = 255 - Min(time * 5);
g = 255 - Min(time * 18, 255);
b = 0;
}
return RGBa(255, 255, 255, 240 * Max(0, FlightTime() - time) / FlightTime());
}
public func Launch(object shooter, int angle, int dist, int speed, int offset_x, int offset_y, int prec_angle)
{
if (speed > Blunderbuss.BulletSpeed[1])
{
LessDamage();
}
return _inherited(shooter, angle, dist, speed, offset_x, offset_y, prec_angle);
}

View File

@ -167,7 +167,7 @@ public func FireWeapon(object clonk, int angle)
if (!Contents(0))
break;
var shot = Contents(0)->TakeObject();
shot->Launch(clonk, angle * 100 + RandomX(-this.BulletSpread, this.BulletSpread), RandomX(-1, 1), 200 + RandomX(-4, 4), off_x, off_y, 100);
shot->Launch(clonk, angle * 100 + RandomX(-this.BulletSpread, this.BulletSpread), RandomX(-1, 1), RandomX(this.BulletSpeed[0], this.BulletSpeed[1]), off_x, off_y, 100);
}
// Muzzle Flash & gun smoke.
@ -238,5 +238,6 @@ local Components = {Wood = 1, Metal = 2};
local BulletsPerShot = 5;
local BulletSpread = 300;
local BulletSpeed = [196, 204];
local ExtraSlotFilter = "IsBullet"; // For editor-provided ammo list