Projectile weapon library added and improved

stable-5.2
Charles Spurrill 2010-01-14 18:07:50 -08:00
parent a0a03a62c9
commit 1ff9850309
21 changed files with 137 additions and 122 deletions

View File

@ -1,20 +0,0 @@
[DefCore]
id=POCH
Version=4,9,10,10
Category=C4D_Object
MaxUserSelect=30
Width=6
Height=9
Offset=-3,-5
Vertices=3
VertexX=-2,2,0
VertexY=4,4,-4
VertexCNAT=9,10,4
VertexFriction=40,40,50
Picture=6,0,21,21
Value=25
Mass=10
Collectible=1
Components=METL=1;BPDR=1;
Rebuy=1
Rotate=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -1,30 +0,0 @@
/*-- Shot Pouch --*/
#strict 2
local iAmmo;
protected func Initialize()
{
iAmmo=8;
}
public func TakeAmmo()
{
if(iAmmo!=0) {
iAmmo=--iAmmo;
}
}
public func CheckEmpty()
{
if(AmmoCount()==0) RemoveObject();
}
public func AmmoCount() { return iAmmo; }
public func IsToolProduct() { return 1; }
func Definition(def) {
SetProperty("Name", "$Name$", def);
}

View File

@ -14,6 +14,6 @@ VertexFriction=50
Picture=0,0,4,4
Value=2
Mass=2
Collectible=0
Collectible=1
Components=METL=1;
Rebuy=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -1,16 +1,18 @@
/*-- Musket Ball --*/
#strict 2
#include L_ST
public func IsAmmo() { return 1; }
public func BaseDamage() { return 20; }
public func MaxDamage() { return 30; }
public func MaxStackCount() { return 8; }
protected func Hit()
{
//Stops bullets from driving over the terrain. Should be removed as soon as ricochets are in physics.
SetVelocity(Random(359), 5);
Explode(5);
}
private func Check()
@ -26,7 +28,6 @@ private func BulletWound(object pObj)
Sound("FleshHit*"); //Bullet-wound sound
Punch(pObj,RandomX(BaseDamage(),(MaxDamage()-BaseDamage())));
// pObj->CreateObject(MBLL); //shoddy ammo-saving script
RemoveObject();
}

View File

@ -4,9 +4,9 @@ Version=4,9,10,10
Category=C4D_Object
Width=16
Height=16
Offset=-8,-16
Vertices=1
Offset=-8,-40
Vertices=2
VertexX=0
VertexY=0
Mass=1
Rotate=1
Rotate=1

View File

@ -4,15 +4,18 @@
protected func Initialize()
{
SetAction("Flash");
//Having trouble with EndCall right now. Current work-around.
Schedule("RemoveObject()", 8);
}
public func Remove() { return RemoveObject(); }
func Definition(def) {
SetProperty("ActMap", {
Flash = {
Prototype = Action,
Name = "Flash",
Procedure = DFA_FLIGHT,
Procedure = DFA_ATTACH,
Directions = 2,
FlipDir = 1,
Length = 8,
@ -22,7 +25,7 @@ Y = 0,
Wdt = 16,
Hgt = 16,
FacetBase = 0,
EndCall="RemoveObject",
EndCall="Remove",
}, }, def);
SetProperty("Name", "Muzzle Flash", def);
}

View File

@ -1,68 +1,17 @@
/*-- Musket --*/
#strict 2
#include PROJ
local Ammo;
local IsLoaded;
public func BarrelLength() { return 15; } //Exit-point of projectiles... ie:End of a gun barrel
public func MuzzleVelocity() { return 300; } //Speed of projectile on launch
public func MagazineType() { return Contained()->FindContents(POCH); } //Collects bullets from this object... ie:Quiver
public func MagazineSize() { return 1; } //Amount of ammo this gun can hold
public func ProjectileType() { return MBLL; } //Object which fires from gun
public func Accuracy() { return 3; } //Spread of fired shots 0=Perfect Accuracy; 10=Horrible Accuracy;
protected func Initialize() { Ammo=0; }
protected func ControlUse(object clonk, ix, iy)
{
return 1;
}
protected func ControlUseStop(object pClonk, ix, iy)
{
if(CheckCanUse(pClonk)==1) {
// Reload from Empty
if(MagazineType() && Ammo==0) {
while(MagazineType()->AmmoCount()!=0 && Ammo<MagazineSize())
{
CreateContents(ProjectileType());
MagazineType()->TakeAmmo();
Ammo=++Ammo;
}
MagazineType()->CheckEmpty();
Message("Click!", pClonk); //Remove all these messages when sound is working
return 1;
}
// Fire
if(Ammo>=1) {
FireWeapon(pClonk, ix, iy);
Ammo=Ammo-1;
if(Ammo==0) IsLoaded=0;
return 1; }
}
return 1;
}
public func CheckCanUse(object pClonk)
{
if(pClonk->GetOCF() & OCF_NotContained) return 1;
}
private func FireWeapon(object pClonk, int iX, int iY)
{
FindContents(ProjectileType())->LaunchProjectile(Angle(0,0,iX,iY)+RandomX(-(Accuracy()), Accuracy()), BarrelLength(), MuzzleVelocity());
Sound("Blast3");
Message("Bang!", pClonk);
//Muzzle Flash
pClonk->CreateContents(FLSH)->LaunchProjectile(Angle(0,0,iX,iY), BarrelLength(),0,0,13);
}
public func IsToolProduct() { return 1; }
public func BarrelLength() { return 25; }
public func MuzzleVelocity() { return 300; }
public func MagazineSize() { return 1; }
public func ProjectileType() { return MBLL; }
public func Accuracy() { return 3; }
public func MuzzleFlashID() { return FLSH; }
public func FiringSound() { return "Blast3"; }
public func WeaponReloadAction() { return "Walk"; }
public func WeaponReloadSound() { return "MusketReload"; }
func Definition(def) {
SetProperty("Name", "$Name$", def);

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

View File

@ -0,0 +1,16 @@
[Particle]
Name=DebugReticle
MaxCount=1500
InitFn=StdInit
ExecFn=StdExec
CollisionFn=Die
DrawFn=Std
Face=0,0,8,8,-4,-4
Delay=0
Repeats=1
GravityAcc=0
VertexCount=1
VertexY=50
AlphaFade=40
Additive=1
RByV=1

View File

@ -0,0 +1,15 @@
[DefCore]
id=PROJ
Version=4,9,10,10
Category=C4D_Object
MaxUserSelect=30
Width=1
Height=1
Offset=-1,-1
Vertices=1
VertexY=1
VertexFriction=50
Value=1
Mass=1
Collectible=0
Components=PROJ=1;

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

View File

@ -0,0 +1,81 @@
/*-- Projectile Weapon Base --*/
#strict 2
public func ProjectileType() { return MBLL; } //Object which is used as ammo
public func MuzzleVelocity() { return 300; } //Speed of projectile on launch.
public func BarrelLength() { return 15; } //Exit-point of projectiles... ie:End of a gun barrel
public func MagazineSize() { return 1; } //Amount of ammo this gun can hold
public func Accuracy() { return 3; } //Spread of fired shots 0=Perfect Accuracy; 10=Horrible Accuracy;
public func MuzzleFlashID() { return FLSH; } //ID tag of the muzzle effect. Return 0 for no muzzle effect. It should be noted different barrel lengths should have different muzzle flash objects (for proper offset).
public func FiringSound() { return "Blast3"; } //Sound file to be played when weapon is fired.
public func WeaponReloadAction() { return "Walk"; } //Animation for reloading weapon.
public func WeaponReloadSound() { return 0; } //Sound file to be played when weapon is reloaded.
public func HoldingEnabled() { return true; }
public func HasExtraSlot() { return true; }
protected func ControlUse(object pClonk, ix, iy)
{
return 1;
}
public func ControlUseHolding(object pClonk, ix, iy)
{
//Angle Finder
var IX=Sin(180-Angle(0,0,ix,iy),BarrelLength());
var IY=Cos(180-Angle(0,0,ix,iy),BarrelLength());
//Create debug dot to show muzzle-point
CastParticles("DebugReticle",1,0,IX,IY,30,30,RGB(255,0,0),RGB(255,255,0));
}
protected func ControlUseStop(object pClonk, ix, iy)
{
// Reload if empty
if(!FindContents(ProjectileType()) && CheckCanUse(pClonk)==1)
{
while(FindObject(Find_Container(pClonk), Find_ID(ProjectileType())))
{
if(pClonk->GetAction()!= WeaponReloadAction()) pClonk->SetAction(WeaponReloadAction()); //Clonk's reloading animation
//pClonk->FindContents(ProjectileType())->Enter(this());
var ammo=pClonk->FindContents(ProjectileType());
ammo->TakeObject()->Enter(this());
Sound(WeaponReloadSound());
Message("Click!", pClonk); //Remove all these messages when sound is working
return 1;
}
}
// Fire
if(FindContents(ProjectileType())) {
FireWeapon(pClonk, ix, iy, BarrelLength(),13);
return 1;
}
return 1;
}
public func CheckCanUse(object pClonk)
{
if(pClonk->GetOCF() & OCF_NotContained) return 1;
}
private func FireWeapon(object pClonk, int iX, int iY)
{
FindContents(ProjectileType())->LaunchProjectile(Angle(0,0,iX,iY)+RandomX(-(Accuracy()), Accuracy()), BarrelLength(), MuzzleVelocity());
Sound(FiringSound());
Message("Bang!", pClonk); //For debug.
//Muzzle Flash
if(MuzzleFlashID()!=0) {
var flash = pClonk->CreateObject(MuzzleFlashID());
flash->SetAction("Flash",pClonk);
flash->SetR(Angle(0,0,iX,iY));
}
}
public func IsToolProduct() { return 1; }
func Definition(def) {
SetProperty("Name", "$Name$", def);
}

View File

@ -0,0 +1 @@
Name=Muskete

View File

@ -0,0 +1 @@
Name=Musket