For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Rail-gun like weapon.

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
fxsr789

Rail-gun like weapon.

Post by fxsr789 »

Releasing the source of this, granted that I got permission from my friend to do so.

If anyone wants to use the code as a base they may, TraceActors was quite useful. Credit goes to >MewTwo 0) )
Pawn(Owner).PlayRecoil(FiringSpeed);

TraceFire(0.0);
}

function AltFire( float Value )
{
GoToState('AltFiring');
}

function Finish()
{
//bMuzzleFlash = 0;
if ( ((Pawn(Owner).bFire!=0) || (Pawn(Owner).bAltFire!=0)) && (FRand() < 0.6) )
Timer();
Super.Finish();
}

function KillPawn( pawn Other )
{
local Inventory Inv;

if( Other == None )
return;
else if ( Other != None )
{

for( Inv=Other.Inventory; Inv!=None; Inv=Inv.Inventory )
{
if( Inv.bIsAnArmor )
Inv.Destroy();
}

Other.Health = 1;
Other.ReducedDamageType = 'None';
Other.ReducedDamagePct = 0.000000;
Other.Mass = 0.000001;

if(ScriptedPawn(Other) != None)
ScriptedPawn(Other).bIsBoss = false;

Other.TakeDamage(100000000, Pawn(Owner), Other.Location, VRand()*0.00075, 'gibbed');

if( Other != None )
{
Other.Mass = Other.Default.Mass;

if(ScriptedPawn(Other) != None)
ScriptedPawn(Other).bIsBoss = false;
}

}

}

function TraceFire( float Accuracy )
{
local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z;
local actor Other,Other2;

Owner.MakeNoise(Pawn(Owner).SoundDampening);
GetAxes(Pawn(owner).ViewRotation,X,Y,Z);
StartTrace = Owner.Location + CalcDrawOffset() + FireOffset.Y * Y + FireOffset.Z * Z;
EndTrace = StartTrace + Accuracy * (FRand() - 0.5 )* Y * 1000
+ Accuracy * (FRand() - 0.5 ) * Z * 1000 ;

AdjustedAim = pawn(owner).AdjustAim(1000000, StartTrace, 2.75*AimError, False, False);
EndTrace += (10000 * vector(AdjustedAim));

foreach TraceActors(Class'Engine.Actor',Other,HitLocation,HitNormal,EndTrace,StartTrace)
{
ProcessTraceHit(Other, HitLocation, HitNormal, vector(AdjustedAim),Y,Z);
}

Other2 = Trace(HitLocation,HitNormal,EndTrace,StartTrace,False);
ProcessTraceHit2(Other2, HitLocation, HitNormal, vector(AdjustedAim),Y,Z);
}

function ProcessTraceHit2(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
local int i;
local PlayerPawn PlayerOwner;

if (Other==None || HitLocation == vect(0,0,0))
{
HitNormal = -X;
HitLocation = Owner.Location + X*10000.0;
}

PlayerOwner = PlayerPawn(Owner);

SpawnEffect(HitLocation, Owner.Location + CalcDrawOffset() + (FireOffset.X + 20) * X + FireOffset.Y * Y + FireOffset.Z * Z);

if ( (Other == Level) || (Other.IsA('Brush')) )
{
Spawn(class'DarkNight.InstaGibbHit',,, HitLocation+HitNormal*4,rotator(HitNormal)+rot(-16384,0,0));
Spawn(class'DarkNight.InstaGibbRing',,, HitLocation+HitNormal*4,rotator(HitNormal));
}
}

function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
local int i;
local PlayerPawn PlayerOwner;

if (Other==None || HitLocation == vect(0,0,0))
{
HitNormal = -X;
HitLocation = Owner.Location + X*10000.0;
}

PlayerOwner = PlayerPawn(Owner);

if ( (Other != self) && (Other != Owner) && (Other != None) )
{
if( (Other.IsA('Pawn')) || (Pawn(Other) != None) )
KillPawn(Pawn(Other));
else
Other.TakeDamage(1000000000, Pawn(Owner), HitLocation, 250000.0*X, 'jolted');
}
}


function SpawnEffect(vector HitLocation, vector SmokeLocation)
{
local InstaGibbBeam Smoke,shock;
local Vector DVector,MoveAmount;
local int NumPoints;
local rotator SmokeRotation;

DVector = HitLocation - SmokeLocation;
NumPoints = VSize(DVector)/45.0;
if ( NumPoints < 1 )
return;
SmokeRotation = rotator(DVector);
SmokeRotation.roll = Rand(65535);

Smoke = Spawn(class'DarkNight.InstaGibbBeam',,,SmokeLocation,SmokeRotation);
// MoveAmount MUST be broken down into components!
MoveAmount = DVector/NumPoints;
Smoke.MX = MoveAmount.X;
Smoke.MY = MoveAmount.Y;
Smoke.MZ = MoveAmount.Z;
Smoke.NumPuffs = NumPoints - 1;
}

///////////////////////////////////////////////////////
state NormalFire
{
function Fire(float F)
{
}
function AltFire(float F)
{
}

Begin:
FinishAnim();
PlayIdleAnim();
FinishAnim();
Sleep(0.25);
Finish();
}

state Idle
{

function AltFire( float Value )
{
GoToState('AltFiring');
}

function Fire( float Value )
{
Global.Fire(0);
}


function BeginState()
{
if (Pawn(Owner).bFire!=0) Fire(0.0);
bPointing = false;
Super.BeginState();
}

function EndState()
{
Super.EndState();
}

Begin:
bPointing=False;
if ( Pawn(Owner).bFire!=0 ) Fire(0.0);
Disable('AnimEnd');
PlayIdleAnim();
}

///////////////////////////////////////////////////////
state AltFiring
{

function Timer()
{
if (Pawn(Owner).bAltFire == 0)
{
if (PlayerPawn(Owner) != None)
PlayerPawn(Owner).StopZoom();
bPointing=True;
GoToState('Idle');
}
}

Begin:
bPointing=True;
if ( Owner.IsA('PlayerPawn') )
{
PlayerPawn(Owner).ToggleZoom();
SetTimer(0.075,True);
}
else
{
Pawn(Owner).bFire = 1;
Pawn(Owner).bAltFire = 0;
Global.Fire(0);
}
}

///////////////////////////////////////////////////////
function PlayFiring()
{
Owner.PlaySound(Sound'DarkNight.Sounds.UT3InsGibFire', SLOT_None, Pawn(Owner).SoundDampening*4.0,false,,SimRandRange(0.950000,1.050000));
Owner.PlaySound(Sound'DarkNight.Sounds.UT3InsGibLayer', SLOT_None, Pawn(Owner).SoundDampening*0.7,false,,SimRandRange(0.950000,1.050000));
PlayAnim('Fire1', 1.0,0.05);
}

function PlayAltFiring();

function PlayPostSelect()
{
PlayAnim('still');
}

function PlayIdleAnim()
{
PlayAnim('still');
}

function TweenDown()
{
Owner.PlaySound(Sound'DarkNight.Sounds.UT3SRifleLower', SLOT_None, Pawn(Owner).SoundDampening*1.0,false,,SimRandRange(0.950000,1.050000));

if ( (AnimSequence != '') && (GetAnimGroup(AnimSequence) == 'Select') )
TweenAnim( AnimSequence, AnimFrame * 0.4 );
else
PlayAnim('Down', 1.0, 0.05);
}

function PlaySelect()
{
PlayAnim('Select',1.0,0.0);
Owner.PlaySound(Sound'DarkNight.Sounds.UT3SRifleRaise', SLOT_None, Pawn(Owner).SoundDampening*1.0,false,,SimRandRange(0.950000,1.050000));
}

defaultproperties
{
bInstantHit=True
bAltInstantHit=True
FiringSpeed=2.000000
FireOffset=(X=18.000000,Y=-5.000000,Z=-8.000000)
MyDamageType=Gibbed
AltRefireRate=0.000000
DeathMessage="%o was absolutely destroyed by %k's %w."
ItemName="Shock Rifle MK3"
PlayerViewOffset=(X=4.400000,Y=-1.700000,Z=-1.600000)
PlayerViewMesh=Mesh'DarkNight.shckr2'
PlayerViewScale=2.000000
PickupViewMesh=Mesh'DarkNight.shockpick'
ThirdPersonMesh=Mesh'DarkNight.shockthird'
Mesh=Mesh'DarkNight.shockpick'
Mass=34.000000
}
[/code]

Code: Select all

//=============================================================================
// InstaGibbBeam.
//=============================================================================
class InstaGibbBeam expands Effects;

#exec OBJ LOAD FILE=..\Textures\DarkNightFire.utx PACKAGE=DarkNight

var int NumPuffs;
var int numwaits;

var float MX,MY,MZ;

replication
{
      // Things the server should send to the client.
      unreliable if( Role==ROLE_Authority )
            MX,MY,MZ, NumPuffs;
}

// Return a random number within the given range.
simulated function float SimRandRange( float Min, float Max )
{
    return Min + (Max - Min) * FRand();
}

simulated function Tick( float DeltaTime )
{
      local rotator SmokeRotation;
      
      if ( Level.NetMode != NM_DedicatedServer )
      {
            SmokeRotation = Rotation;
            SmokeRotation.roll = Rand(65535);
            SetRotation(SmokeRotation);      
            ScaleGlow = (Lifespan/Default.Lifespan);
            AmbientGlow = ScaleGlow * 255;
            LightBrightness = ScaleGlow * 255;
            Fatness = SimRandRange( 50, 200 );
      }
}


simulated function PostBeginPlay()
{
      if ( Level.NetMode != NM_DedicatedServer )
      {
            SetTimer(0.000001,false);
            Enable('Tick');
      }
}

simulated function Timer()
{
      local InstaGibbBeam r;
      local rotator SmokeRotation;
      local vector MoveAmount;
      
      If( MX == 0 || MY == 0 || MZ == 0 )
      {
            SetTimer(0.0000001,False);
            return;
      }
      
      if (NumPuffs>0)
      {
            MoveAmount.X = MX;
            MoveAmount.Y = MY;
            MoveAmount.Z = MZ;
            SmokeRotation = Rotation;
            SmokeRotation.roll = Rand(65535);
            r = Spawn(class'DarkNight.InstaGibbBeam',,,Location+MoveAmount,SmokeRotation);
            r.RemoteRole = ROLE_None;
            r.NumPuffs = NumPuffs -1;
            r.MX=MX;
            r.MY=MY;
            r.MZ=MZ;
      }
}

defaultproperties
{
     Physics=PHYS_Rotating
     RemoteRole=ROLE_SimulatedProxy
     LifeSpan=0.250000
     DrawType=DT_Mesh
     Style=STY_Translucent
     Texture=FireTexture'DarkNight.Effects.BeamSkin'
     Mesh=LodMesh'UnrealShare.bolt1'
     DrawScale=1.500000
     bUnlit=True
     bMeshEnviroMap=True
     bMeshCurvy=True
     LightType=LT_Steady
     LightEffect=LE_NonIncidence
     LightHue=2
     LightSaturation=32
     LightRadius=2
     bFixedRotationDir=True
     Mass=0.000000
     RotationRate=(Roll=2147483647)
}

Code: Select all

//=============================================================================
// InstaGibbHit.
//=============================================================================
class InstaGibbHit expands Effects;

#exec OBJ LOAD FILE=..\Textures\DarkNightFire.utx PACKAGE=DarkNight

// Return a random number within the given range.
simulated function float SimRandRange( float Min, float Max )
{
    return Min + (Max - Min) * FRand();
}

simulated function AnimEnd()
{
      Destroy();
}

simulated function Tick( float DeltaTime )
{
      if ( Level.NetMode != NM_DedicatedServer )
      {
            ScaleGlow = (Lifespan/Default.Lifespan);
            AmbientGlow = ScaleGlow * 255;            
      }
}

simulated function PostBeginPlay()
{
      local InstaGibbRing r;

      if ( Level.NetMode != NM_DedicatedServer )
      {
            PlaySound(Sound'DarkNight.Sounds.UT3InsGibImpact', SLOT_Interact, 6.0,false,,SimRandRange(0.950000,1.050000));
            PlayAnim( 'Explo', 0.85 );
      }            
      if ( Instigator != None )
            MakeNoise(0.5);
}

defaultproperties
{
     RemoteRole=ROLE_SimulatedProxy
     LifeSpan=0.300000
     DrawType=DT_Mesh
     Style=STY_Translucent
     Texture=None
     Skin=Texture'UnrealShare.Effects.PalRed'
     Mesh=LodMesh'UnrealShare.SpikeExp'
     DrawScale=2.000000
     ScaleGlow=1.100000
     bUnlit=True
     MultiSkins(1)=FireTexture'DarkNight.Effects.BeamHit'
     LightType=LT_TexturePaletteOnce
     LightEffect=LE_NonIncidence
     LightBrightness=255
     LightRadius=8
}

Code: Select all

//=============================================================================
// InstaGibbRing.
//=============================================================================
class InstaGibbRing expands InstaGibbHit;

simulated function AnimEnd()
{
      Destroy();
}

simulated function Tick( float DeltaTime )
{
      if ( Level.NetMode != NM_DedicatedServer )
      {
            ScaleGlow = (Lifespan/Default.Lifespan);
            AmbientGlow = ScaleGlow * 255;            
      }
}

simulated function PostBeginPlay()
{
      if ( Level.NetMode != NM_DedicatedServer )
            PlayAnim( 'Explosion', 1.5 );
                  
      if ( Instigator != None )
            MakeNoise(0.5);
}

defaultproperties
{
     LifeSpan=0.800000
     Texture=Texture'UnrealShare.Belt_fx.ShieldBelt.newred'
     Skin=None
     Mesh=LodMesh'UnrealShare.FatRingM'
     DrawScale=0.500000
     bMeshEnviroMap=True
     MultiSkins(1)=None
     LightType=LT_None
     LightEffect=LE_None
     LightBrightness=0
     LightRadius=0
}


The super class "DarkNightsWeapons" is not necessary, as that was just a dummy class to make sure only HIS PLAYER CLASS can use the weapons, it would Destroy(); itself otherwise. Even if summoned.

- Fenix


fxsr789

Re: Rail-gun like weapon.

Post by fxsr789 »

Uh, someone will have to define SimRandRange in their script inorder to use the "random pitch sounds" , but that's even more unnecessary, It was defined in the superclass "DarkNightsWeapons".

Ignore any instances of SimRandRange because that was defined for the random pitch sounds that UT3 used. The weapon was based on UT3's "SoundCue" for the fire sounds ,etc.

- Fenix

Return to “UScript Board”