Deus Ex Clan [A]lpha
homeabout usprojectsmembersmatches
join uschallenge usdownloadsforum
Knowledge Base

Making alternate uses for scope/laser/ammo switch functions

home / Knowledge Base / Coding / Making alternate uses for scope/laser/ammo switch functions

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:

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...
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.

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.

Written by [A]llan.


← previousindexnext →

Powered by [A]