here is the start of the Unrealscript file, there are some blank spots because i still need to get some more info on the animation but here is some of it
if there are any errors please tell me
Code:
//=============================================================================
// Crossbow Weapon
//=============================================================================
class BWCross extends BallisticWeapon;
#exec OBL LOAD File=***
var bool bShootingArrow;
var() name ArrowBackAnim;
var() name ArrowShotAnim;
var float NextShotTime;
simulated event AnimEnd (int Channel)
{
local name anim;
local float frame, rate;
GetAnimParams(0, anim, frame, rate);
if (anim == 'PrepShoot' && bShootingArrow)
return;
super.AnimEnd(Channel);
}
//simulated function DoWeaponSpecial(optional byte i)
exec simulated function WeaponSpecial(optional byte i)
{
if (AmmoAmount(0) < 1 || Level.TimeSeconds < NextShootTime || bShootingArrow)
return;
PlayAnim('PrepThrow');
bShootingArrow=true;
ServerWeaponSpecial(i);
}
function ServerWeaponSpecial(optional byte i)
{
bShootingArrow=true;
}
//simulated function DoWeaponSpecialRelease(optional byte i)
exec simulated function WeaponSpecialRelease(optional byte i)
{
if (!bShootingArrow || AmmoAmount(0) < 1 || Level.TimeSeconds < NextShotTime)
return;
PlaySound(Sound'{*********}',,1.0,,32,,);
if (level.NetMode == NM_Client)
PlayAnim('Shoot', 1.5);
ServerWeaponSpecialRelease(i);
}
function ServerWeaponSpecialRelease(optional byte i)
{
PlayAnim('Shoot');
}
simulated function Notify_BWCrossShoot()
{
ShootArrow();
SetBoneScale(0, 0.0, 'Knife');
}
simulated function ShootArrow()
{
bShootingArrow=false;
NextShotTime = Level.TimeSeconds + 0.15;
if (Role == ROLE_Authority)
{
super.ConsumeAmmo(0, 1);
DoFireEffect();
}
}
// Get aim then spawn projectile
function DoFireEffect()
{
local Vector StartTrace, X, Y, Z, Start, End, HitLocation, HitNormal;
local Rotator RAim;
local actor Other;
local Projectile Proj;
GetViewAxes(X,Y,Z);
// the to-hit trace always starts right in front of the eye
Start = Instigator.Location + Instigator.EyePosition();
StartTrace = Start + X*10;
if (!WeaponCentered())
StartTrace = StartTrace + Hand * Y*10 + Z*0;
RAim = BFireMode[0].GetFireAim(StartTrace);
RAim = Rotator(BFireMode[0].GetFireSpread() >> RAim);
End = Start + (Vector(RAim)*2000);
Other = Trace (HitLocation, HitNormal, End, Start, true);
if (Other != None)
RAim = Rotator(HitLocation-StartTrace);
Proj = Spawn (class'BWArrowProjectile',,, StartTrace, RAim);
Proj.Instigator = Instigator;
}
simulated function Notify_ArrowOutOfSight()
{
SetBoneScale(0, 1.0, 'Arrow');
}
simulated function bool HasAmmo() { return true; }
//simulated function bool ConsumeAmmo(int Mode, float Load, optional bool bAmountNeededIsMax) { return true; }
//function ConsumeAmmo(int Mode, float Load) { }
// AI Interface =====
function bool CanAttack(Actor Other)
{
return true;
}
// choose between regular or alt-fire
function byte BestMode()
{
local Bot B;
local float Result;
B = Bot(Instigator.Controller);
if ( (B == None) || (B.Enemy == None) )
return 0;
if (VSize(B.Enemy.Location - Instigator.Location) > FireMode[0].MaxRange()*1.5)
return 1;
Result = FRand();
if (vector(B.Enemy.Rotation) dot Normal(Instigator.Location - B.Enemy.Location) < 0.0)
Result += 0.3;
else
Result -= 0.3;
if (Result > 0.5)
return 1;
return 0;
}
function float GetAIRating()
{
local Bot B;
local float Result, Dist;
local vector Dir;
B = Bot(Instigator.Controller);
if ( (B == None) || (B.Enemy == None) )
return AIRating;
Dir = B.Enemy.Location - Instigator.Location;
Dist = VSize(Dir);
Result = AIRating;
// Enemy too far away
if (Dist > 1500)
return 0.1; // Enemy too far away
// Better if we can get him in the back
if (vector(B.Enemy.Rotation) dot Normal(Dir) < 0.0)
Result += 0.08 * B.Skill;
// If the enemy has a knife too, a gun looks better
if (B.Enemy.Weapon != None && B.Enemy.Weapon.bMeleeWeapon)
Result = FMax(0.0, Result *= 0.7 - (Dist/1000));
// The further we are, the worse it is
else
Result = FMax(0.0, Result *= 1 - (Dist/1000));
return Result;
}
// tells bot whether to charge or back off while using this weapon
function float SuggestAttackStyle()
{
if (AIController(Instigator.Controller) == None)
return 0.5;
return AIController(Instigator.Controller).Skill / 4;
}
// tells bot whether to charge or back off while defending against this weapon
function float SuggestDefenseStyle()
{
local Bot B;
local float Result, Dist;
B = Bot(Instigator.Controller);
if ( (B == None) || (B.Enemy == None) )
return -0.5;
Dist = VSize(B.Enemy.Location - Instigator.Location);
Result = -1 * (B.Skill / 6);
Result *= (1 - (Dist/1500));
return FClamp(Result, -1.0, -0.3);
}
// End AI Stuff =====
defaultproperties
{
PlayerSpeedFactor=1.150000
TeamSkins(0)=(RedTex=Shader'',BlueTex=Shader'')
BigIconMaterial=Texture'BallisticUI2.Icons.BigIcon_X3'
BCRepClass=Class''
InventorySize=10
SpecialInfo(0)=(Info="0.0;-999.0;-999.0;-1.0;-999.0;-999.0;-999.0")
BringUpSound=(Sound=Sound'')
PutDownSound=(Sound=Sound'')
MagAmmo=1
bNoMag=True
WeaponModes(0)=(bUnavailable=True,ModeID="WM_None")
WeaponModes(1)=(bUnavailable=True)
WeaponModes(2)=(bUnavailable=True)
CurrentWeaponMode=0
bUseSights=True
CrosshairCfg=(Pic1=Texture'BallisticUI2.Crosshairs.X3OutA',Pic2=Texture'BallisticUI2.Crosshairs.X3InA',USize1=256,VSize1=256,USize2=256,VSize2=256,Color1=(R=0,A=192),Color2=(B=255,A=192),StartSize1=103,StartSize2=87)
CrosshairInfo=(SpreadRatios=(X1=0.250000,Y1=0.375000,X2=1.000000,Y2=1.000000),MaxScale=8.000000)
GunLength=0.000000
bAimDisabled=True
FireModeClass(0)=Class''
FireModeClass(1)=Class''
PutDownTime=0.500000
BringUpTime=0.500000
SelectForce="SwitchToAssaultRifle"
AIRating=0.200000
CurrentRating=0.200000
bMeleeWeapon=False
Description=""
Priority=36
CenteredOffsetY=7.000000
CenteredRoll=0
CustomCrossHairTextureName="Crosshairs.HUD.Crosshair_Cross1"
PickupClass=Class''
PlayerViewOffset=(X=5.000000,Y=7.000000,Z=-8.000000)
PlayerViewPivot=(Yaw=32768)
BobDamping=1.700000
AttachmentClass=Class''
IconMaterial=Texture''
IconCoords=(X2=127,Y2=31)
ItemName="Crossbow"
Mesh=SkeletalMesh''
DrawScale=0.300000
}
//=============================================================================
// Crossbow Attatchment
//=============================================================================
class BWCrossAttachment extends BallisticAttachment;
defaultproperties
{
ImpactManager=Class''
BrassMode=MU_None
InstantMode=MU_Both
FlashMode=MU_None
LightMode=MU_None
TrackAnimMode=MU_Both
WaterTracerClass=Class''
bHeavy=True
Mesh=SkeletalMesh''
DrawScale=0.110000
}
//=============================================================================
// BWCrossPickup.
//=============================================================================
class BWCrossPickup extends BallisticWeaponPickup
placeable;
#exec OBJ LOAD FILE=
#exec OBJ LOAD FILE=
#exec OBJ LOAD FILE=
simulated function UpdatePrecacheMaterials()
{
Level.AddPrecacheMaterial(Texture'');
Level.AddPrecacheMaterial(Texture'');
Level.AddPrecacheMaterial(Texture'');
}
simulated function UpdatePrecacheStaticMeshes()
{
Level.AddPrecacheStaticMesh(StaticMesh'');
Level.AddPrecacheStaticMesh(StaticMesh'');
}
defaultproperties
{
LowPolyStaticMesh=StaticMesh''
PickupDrawScale=0.250000
InventoryType=Class''
RespawnTime=10.000000
PickupMessage="You picked up a Crossbow"
PickupSound=Sound''
StaticMesh=StaticMesh''
Physics=PHYS_None
DrawScale=0.450000
CollisionHeight=4.000000
}
//=============================================================================
// BWCrossProjectile.
//=============================================================================
class BWCrossProjectile extends BallisticProjectile;
var bool bStuckInWall;
var bool bHitPlayer;
simulated function InitProjectile ()
{
SetTimer(0.1, false);
super.InitProjectile();
}
simulated event Timer()
{
super.Timer();
bFixedRotationDir = True;
RotationRate.Pitch = -100000;
}
simulated function ProcessTouch (Actor Other, vector HitLocation)
{
if (Other == None)
return;
if (bStuckInWall)
{
if (Pawn(Other) != None)
TakeBack(Pawn(Other));
return;
}
else if (Other == Instigator || Other == Owner)
return;
if (bHitPlayer)
return;
if (Role == ROLE_Authority)
DoDamage(Other, HitLocation);
bHitPlayer = true;
// SetLocation(HitLocation + (HitLocation-Other.Location) * 2)
SetLocation(HitLocation);
Velocity = Normal(HitLocation-Other.Location)*100;
}
function TakeBack(Pawn Other)
{
local Ammunition Ammo;
local Weapon newWeapon;
local int AmmoAmount;
if (!bStuckInWall || !Other.bCanPickupInventory)
return;
Ammo = Ammunition(Other.FindInventoryType(class'Ammo_Knife'));
if(Ammo == None)
{
Ammo = Spawn(class'Ammo_Knife');
Other.AddInventory(Ammo);
}
AmmoAmount = Ammo.AmmoAmount;
Ammo.UseAmmo(9999, true);
if(Other.FindInventoryType(class'BWCross')==None)
{
newWeapon = Spawn(class'BWCross',,,Other.Location);
if( newWeapon != None )
{
newWeapon.GiveTo(Other);
newWeapon.ConsumeAmmo(0, 9999, true);
}
}
/* Ammo = Ammunition(Other.FindInventoryType(class'Ammo_Knife'));
if(Ammo == None)
{
Ammo = Spawn(class'Ammo_Knife');
Other.AddInventory(Ammo);
}
*/ Ammo.AddAmmo(AmmoAmount + 1);
Ammo.GotoState('');
if (PlayerController(Other.Controller) != None)
PlayerController(Other.Controller).ClientPlaySound(class'BWCrossPickup'.default.PickupSound);
Destroy();
}
simulated event Landed( vector HitNormal )
{
HitWall( HitNormal, None );
}
simulated singular function HitWall(vector HitNormal, actor Wall)
{
local int Surf;
if (bStuckInWall)
return;
if (Wall != None && !Wall.bWorldGeometry && !Wall.bStatic)
{
if (Role == ROLE_Authority && !bHitPlayer)
DoDamage(Wall, Location);
if (Mover(Wall) == None)
{
bHitPlayer = true;
Velocity = HitNormal*100;
return;
}
}
SetRotation(Rotator(Velocity)/*+rot(32768,0,0)*/);
OnlyAffectPawns(true);
SetCollisionSize(40, 40);
SetPhysics(PHYS_None);
bFixedRotationDir=false;
bStuckInWall=true;
bHardAttach=true;
CheckSurface(Location, HitNormal, Surf, Wall);
LifeSpan=20.0;
if (Wall != None)
SetBase(Wall);
if (Level.NetMode != NM_DedicatedServer && ImpactManager != None && /*(!Level.bDropDetail) && (Level.DetailMode != DM_Low) && */EffectIsRelevant(Location,false))
ImpactManager.static.StartSpawn(Location, HitNormal, Surf, self);
}
function UsedBy(Pawn User)
{
TakeBack(User);
}
defaultproperties
{
ImpactManager=Class'BallisticV21.IM_KnifeThrown'
bRandomStartRotaion=False
bUsePositionalDamage=True
DamageRange=(Min=50.000000,Max=1000.000000)
DamageRangeHead=(Min=100.000000,Max=100000.000000)
DamageRangeLimb=(Min=30.000000,Max=45.000000)
DamageTypeHead=Class''
bWarnEnemy=False
Speed=30000.000000
Damage=50.000000
MyDamageType=Class''
StaticMesh=StaticMesh''
bNetTemporary=False
Physics=PHYS_Falling
LifeSpan=0.000000
DrawScale=0.150000
bUnlit=False
}
//=============================================================================
// BWCross Second Fire
// i might not use this at all...
//=============================================================================
class BWCrossSecondaryFire extends BallisticMeleeFire;
simulated function bool AllowFire()
{
if (level.TimeSeconds > X3Knife(Weapon).NextThrowTime)
return super.AllowFire();
return false;
}
event ModeDoFire()
{
if (FRand() > 0.5)
{
PreFireAnim = 'BigBack1';
FireAnim = 'BigStab1';
}
else
{
PreFireAnim = 'BigBack2';
FireAnim = 'BigSlash1';
}
Super.ModeDoFire();
}
simulated function bool HasAmmo()
{
return true;
}
defaultproperties
{
SwipePoints(0)=(offset=(Pitch=4000,Yaw=2000))
SwipePoints(1)=(offset=(Yaw=1000))
SwipePoints(2)=(offset=(Pitch=0,Yaw=0))
SwipePoints(3)=(Weight=4,offset=(Pitch=-2000,Yaw=-1000))
SwipePoints(4)=(Weight=2,offset=(Pitch=-4000))
SwipePoints(5)=(Weight=-1,offset=(Pitch=0,Yaw=0))
SwipePoints(6)=(Weight=-1,offset=(Pitch=0,Yaw=0))
WallHitPoint=2
TraceRange=(Min=96.000000,Max=96.000000)
Damage=(Min=50.000000,Max=100.000000)
DamageHead=(Min=100.000000,Max=120.000000)
DamageLimb=(Min=20.000000,Max=50.000000)
DamageType=Class''
DamageTypeHead=Class''
DamageTypeArm=Class''
KickForce=100
HookStopFactor=1.700000
HookPullForce=100.000000
bReleaseFireOnDie=False
BallisticFireSound=(Sound=SoundGroup'',Radius=32.000000,bAtten=True)
bAISilent=True
bFireOnRelease=True
PreFireAnim="BigBack1"
FireAnim="BigStab1"
FireRate=0.300000
AmmoClass=Class''
AmmoPerFire=0
ShakeRotMag=(X=64.000000,Y=128.000000)
ShakeRotRate=(X=2500.000000,Y=2500.000000,Z=2500.000000)
ShakeRotTime=2.500000
BotRefireRate=0.800000
WarnTargetPct=0.050000
}
it is similar to the X3 code because of how it works