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

Why won't this melee code work?

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
User avatar
KillerSkaarj
OldUnreal Member
Posts: 935
Joined: Fri Jan 25, 2008 2:04 am

Why won't this melee code work?

Post by KillerSkaarj »

I'm trying to make a melee weapon similar to the impact hammer from UT, but I'm having some trouble. The melee part's not even working! The animation will paly but then nothing happens. Here's the code. I used the melee code from the Chimeric site. The melee code starts in the Altfire state.

Code: Select all

//=============================================================================
// TaryGun.
//=============================================================================
class TaryGun expands Stinger;

var bool bAlreadyFiring;
var() int hitdamage;

function float RateSelf( out int bUseAltMode )
{
      local float EnemyDist;

      if ( AmmoType.AmmoAmount  EnemyDist - 140 );
      return AIRating;
}

function PlayFiring()
{
      if ( bAlreadyFiring )
      {
            AmbientSound = sound'StingerTwoFire';
            SoundVolume = Pawn(Owner).SoundDampening*255;
            LoopAnim( 'FireOne', 0.7);            
      }
      else
      {
            Owner.PlaySound(FireSound, SLOT_Misc,2.0*Pawn(Owner).SoundDampening);
            PlayAnim( 'FireOne', 0.7 );            
      }
      bAlreadyFiring = true;
      bWarnTarget = (FRand() < 0.2);
}

function PlayAltFiring()
{
      Owner.PlaySound(AltFireSound, SLOT_Misc,2.0*Pawn(Owner).SoundDampening);            
      PlayAnim( 'FireOne', 0.6 );
}

///////////////////////////////////////////////////////
state NormalFire
{

      function Tick( float DeltaTime )
      {
            if (Owner==None) AmbientSound=None;            
            else                  
                  SetLocation(Owner.Location);
      }

      function EndState()
      {
            if (AmbientSound!=None && Owner!=None) Owner.PlaySound(Misc1Sound, SLOT_Misc,2.0*Pawn(Owner).SoundDampening);            
            AmbientSound = None;            
            bAlreadyFiring = false;
            Super.EndState();
      }

Begin:
      Sleep(0.2);
      SetLocation(Owner.Location);      
      Finish();            
}
///////////////////////////////////////////////////////////////
state AltFiring
{

function MeleeTargetting()
{
  local vector HitLoc, HitNorm, End, X, Y, Z, Start;
  local actor Other;

  GetAxes(Pawn(Owner).ViewRotation, X, Y, Z);
  Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X
          + FireOffset.Y * Y + FireOffset.Z * Z;
  AdjustedAim = Pawn(Owner).AdjustAim(1000000, Start, AimError, False, False);
   End = Owner.Location + (100 * vector(AdjustedAim));
  Other = Pawn(Owner).TraceShot(HitLoc, HitNorm, End, Start);
if (Other == Level) 
            Spawn(class'WallHitEffect',,, HitLoc+HitNorm*9, Rotator(HitNorm));
      else if ((Other != self) && (Other != Owner) && (Other != None) ) 
      {
            if ( FRand() < 0.2 )
                  X *= 5;
            Other.TakeDamage(HitDamage, Pawn(Owner), HitLoc, 3000.0*X, 'shot');
            if ( !Other.IsA('Pawn') && !Other.IsA('Carcass') )
                  spawn(class'SpriteSmokePuff',,,HitLoc+HitNorm*9);
            if ( Other.IsA('Brush') )
                  Spawn(class'WallHitEffect',,, HitLoc+HitNorm*9, Rotator(HitNorm));
      }
}            
Begin:
      FinishAnim();      
      PlayAnim('Still');
      Sleep(1.0);
         Finish();                  
}

///////////////////////////////////////////////////////////
function PlayIdleAnim()
{
      PlayAnim('Still');
}
This is modified Stinger code. Yes, I set bAltInstantHit to true, but it still won't work. Help, please! Thanks in advance.
Last edited by KillerSkaarj on Tue Oct 07, 2008 2:55 am, edited 1 time in total.
User avatar
.:..:
OldUnreal Member
Posts: 1637
Joined: Tue Aug 16, 2005 4:35 am

Re: Why won't this melee code work?

Post by .:..: »

Code: Select all

state AltFiring
{

function MeleeTargetting()
{
  local vector HitLoc, HitNorm, End, X, Y, Z, Start;
  local actor Other;

  GetAxes(Pawn(Owner).ViewRotation, X, Y, Z);
  Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X
          + FireOffset.Y * Y + FireOffset.Z * Z;
  AdjustedAim = Pawn(Owner).AdjustAim(1000000, Start, AimError, False, False);
   End = Owner.Location + (100 * vector(AdjustedAim));
  Other = Pawn(Owner).TraceShot(HitLoc, HitNorm, End, Start);
if (Other == Level)
            Spawn(class'WallHitEffect',,, HitLoc+HitNorm*9, Rotator(HitNorm));
      else if ((Other != self) && (Other != Owner) && (Other != None) )
      {
            if ( FRand() < 0.2 )
                  X *= 5;
            Other.TakeDamage(HitDamage, Pawn(Owner), HitLoc, 3000.0*X, 'shot');
            if ( !Other.IsA('Pawn') && !Other.IsA('Carcass') )
                  spawn(class'SpriteSmokePuff',,,HitLoc+HitNorm*9);
            if ( Other.IsA('Brush') )
                  Spawn(class'WallHitEffect',,, HitLoc+HitNorm*9, Rotator(HitNorm));
      }
}
Begin:
      MeleeTargetting();
      FinishAnim();
      PlayAnim('Still');
      Sleep(1.0);
         Finish();
}
1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD :P
(ಠ_ಠ)
User avatar
KillerSkaarj
OldUnreal Member
Posts: 935
Joined: Fri Jan 25, 2008 2:04 am

Re: Why won't this melee code work?

Post by KillerSkaarj »

Somehow, I knew Dots would come to the rescue.

Thanks man, you're a genius!
Last edited by KillerSkaarj on Tue Oct 07, 2008 9:23 pm, edited 1 time in total.
User avatar
[§Ŕ] ŤhěxĐâŕkśîđěŕ
OldUnreal Member
Posts: 4425
Joined: Wed Sep 03, 2008 8:19 am

Re: Why won't this melee code work?

Post by [§Ŕ] ŤhěxĐâŕkśîđěŕ »

Well yeah tyvm Dots I also had this problem a while ago but I let it go. :)
User avatar
KillerSkaarj
OldUnreal Member
Posts: 935
Joined: Fri Jan 25, 2008 2:04 am

Re: Why won't this melee code work?

Post by KillerSkaarj »

Oh yeah... uhh... sorry for not being clear on this earlier, but can you tell me how to keep it from using up ammo on AltFire?

Thanks again.
User avatar
[§Ŕ] ŤhěxĐâŕkśîđěŕ
OldUnreal Member
Posts: 4425
Joined: Wed Sep 03, 2008 8:19 am

Re: Why won't this melee code work?

Post by [§Ŕ] ŤhěxĐâŕkśîđěŕ »

Uhhmmm... It doesn't have If(AmmoType.UseAmmo(1)). It shouldn't waste any ammo afaik.
User avatar
KillerSkaarj
OldUnreal Member
Posts: 935
Joined: Fri Jan 25, 2008 2:04 am

Re: Why won't this melee code work?

Post by KillerSkaarj »

For some reason, it still does. I don't know what's the problem. Hmmm...
User avatar
[§Ŕ] ŤhěxĐâŕkśîđěŕ
OldUnreal Member
Posts: 4425
Joined: Wed Sep 03, 2008 8:19 am

Re: Why won't this melee code work?

Post by [§Ŕ] ŤhěxĐâŕkśîđěŕ »

Well I suck at scripting but I rarely get some bizarre script errors. All of my errors are in importing. :D
User avatar
Bane
OldUnreal Member
Posts: 493
Joined: Sun Mar 03, 2002 6:32 pm

Re: Why won't this melee code work?

Post by Bane »

function AltFire( float Value ) isn't being overwritten. That's probably your problem.
Author of Hide and Seek mod, and the NALIBALL mod

Hide and Seek can be downloaded from:
http://HideNSeek.5u.com

Return to “UScript Board”