Page 1 of 1

Making alternate uses for Scope/Laser/Ammo-Switch functions.

PostPosted: Sun Sep 17, 06 12:53 am
by Allan
This hopes to teach a little about how to make your own cool functions out of the Ammo Switching, Scope, and Laser Sight functions.

First off, identifying the functions that'll be needed to be changed to edit the functionality of these functions.

First off: Scope.

    ScopeOn()
    ScopeOff()
    ScopeToggle()


and their codes are:

Code: Select all
function ScopeOn()
{
   if (bHasScope && !bZoomed && (Owner != None) && Owner.IsA('DeusExPlayer'))
   {
      // Show the Scope View
      bZoomed = True;
      RefreshScopeDisplay(DeusExPlayer(Owner), False, bZoomed);
   }
}

function ScopeOff()
{
   if (bHasScope && bZoomed && (Owner != None) && Owner.IsA('DeusExPlayer'))
   {
      bZoomed = False;
      // Hide the Scope View
      RefreshScopeDisplay(DeusExPlayer(Owner), False, bZoomed);
      //DeusExRootWindow(DeusExPlayer(Owner).rootWindow).scopeView.DeactivateView();
   }
}

simulated function ScopeToggle()
{
   if (IsInState('Idle'))
   {
      if (bHasScope && (Owner != None) && Owner.IsA('DeusExPlayer'))
      {
         if (bZoomed)
            ScopeOff();
         else
            ScopeOn();
      }
   }
}


However, you don't want a boring old scope button thingy, do you? No? Well then, hang about. I'm going to show you how to get it to do something intresting... ;) First, we strip out as much crap as possible...

Code: Select all
function ScopeOn()
{
}

function ScopeOff()
{
}

simulated function ScopeToggle()
{
   if (bHasScope)
   {
      if (bZoomed)
         ScopeOff();
      else
         ScopeOn();
   }
}


Right, that's gotten rid of everything that the original scope needs. (Note, this'll mean you can no longer use a scope, so make something decent to replace it...) Now, to make it do something cool. Hmm... ideas ideas ideas...

Well, I suppose summoning a Plasma Bolt will have to do. I can't think of anything better.

Code: Select all
function ScopeOn()
{
    Spawn(class'PlasmaBolt',Pawn(Owner),,Pawn(Owner).Location,Pawn(Owner).ViewRotation);
}

function ScopeOff()
{
    Spawn(class'PlasmaBolt',Pawn(Owner),,Pawn(Owner).Location,Pawn(Owner).ViewRotation);

}

simulated function ScopeToggle()
{
   if (bHasScope)
   {
      if (bZoomed)
         ScopeOff();
      else
         ScopeOn();
   }
}


The Pawn(Owner) parts are being used to get the location and rotation to fire the projectile at. Also, this can be used to modify the owner of a weapon in several other 'interesting' ways... Now, if you have a weapon with a scope on it, and this code in it's source, the scope will, instead of zooming in, spit out plasma bolts.

I'm going to have to add to this later/tomorrow, school work beckons to be dealt with...

PostPosted: Sun Sep 17, 06 5:39 am
by Dae
Good work :gj:

PostPosted: Sun Sep 17, 06 1:21 pm
by Cozmo
Ooh thanks! :D
I always wanted to know how this was done, because lee protected his code i couldnt see it...
:)

PostPosted: Sun Jan 28, 07 9:42 am
by MainMan
It is much cooler if you alter these directly at the source in the player class, which is what I do for the skateboard in my mod. Whilst skating, it remaps the keys (reload is heelflip, scope is kickflip, etc)

PostPosted: Sun Jan 28, 07 3:18 pm
by ~ô¿ô~Nobody~
Mainman, not everyone wants to make a whole new gametype for extending a weapon. :)

PostPosted: Sun Jan 28, 07 4:10 pm
by Wasted
O rly?

PostPosted: Sun Jan 28, 07 5:36 pm
by Allan
ya rly.