I don't need to test my programs. I have an error-correcting modem.

UE1:Authorizer

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 15:57, 18 November 2007 by Sweavo (Talk) (Thanks Raven!)

Jump to: navigation, search
The classbox template is only supposed to be used by the converted content imported into the Legacy: namespace. Consider adding descriptions to existing class pages instead.

When I used a key Mover for the first time I thought that some things are impossible with this class. First of all it would be better instead of a mover to place a Trigger. That's why I've made this class. Authorizer can be opened when the player has specified item in his inventory. We are able to destroy this item or turn to normal trigger after destroying key. Here is the icon: @inline@auth.

//=================================================
// Authorizer: This Trigger can replace
// KeyMover (as base I use KeyMover avidible
// form http://chimeric.beyondunreal.com/tutorials/tut11.html).
//=================================================
// by Raven
// http://turniej.unreal.pl
// http://tcn.unreal.pl
// for The Chosen One SP mod
//=================================================
class Authorizer extends Triggers;
 
#exec TEXTURE IMPORT NAME=Authorizer FILE="textures\Icons\auth.bmp" GROUP=Icons LODSET=2
 
var() class keyclass< SEMI >
var() bool DestroyKey;  
var() bool NormalAfterDestroying; 
var() bool ShowSuccessMessage; 
var() bool ShowFailtureMessage; 
var() localized String SuccessMessage; 
var() localized String FailtureMessage; 
var bool norm;
var bool opened; 
 
replication
{
	// Variables the server should send to the client.
	reliable if( Role==ROLE_Authority ) opened, norm;
}
 
function Touch( actor Other )
{
    local Inventory key;
    local actor A;
 
    // BroadcastMessage("Bumped by "$Other.Name);
 
    // First check to make sure this is a Pawn, cause they are
    // only things that have inventories (i think:), and then
    // make sure we have a keyclass to check for.
    if (Other.IsA('Pawn') && keyclass != NONE)
    {
       // BroadcastMessage("Other.Class: "$Other.Class$", keyclass: "$keyclass);
 
       // Now we just use FindInventoryType() to see if they have
       // a copy of our desired key in their inventory...
       key = Pawn(Other).FindInventoryType(keyclass);
 
       // ...if so call the old foreach function and let the trigger
       // do its thing.
       if (key != NONE)
       {
         // Broadcastmessage("Found key");
         if( Event != '' ) // trigger all matching actors.
          foreach AllActors( class 'Actor', A, Event )
          {
            A.Trigger( Other, Other.Instigator );
          }
 
         if(DestroyKey)    // if true will delete key from inventory!
           if(!norm)
             Pawn(Other).DeleteInventory(key);
         if(NormalAfterDestroying) //trigger will act like normal trigger if true
           norm=true;
         opened=true; //door was opened
       }
       if(norm) //is normal trigger
         if( Event != '' ) // trigger all matching actors.
          foreach AllActors( class 'Actor', A, Event )
           A.Trigger( Other, Other.Instigator );
       if(ShowSuccessMessage)
         BroadcastMessage(SuccessMessage);
       if(ShowFailtureMessage)
         if(!opened)
         {
           BroadcastMessage(FailtureMessage); // show Failure message when we don't have a key
         }
 
       // ...otherwise just do nothing.
       // else BroadcastMessage("Couldn't find key");
    }
}
 
defaultproperties
{
     ShowFailtureMessage=True
     SuccessMessage="Access granded."
     FailtureMessage="You need a key to open this door."
     Texture=Texture'Authorizer.Icons.Authorizer'
}