Worst-case scenario: the UEd Goblin wipes the map and burns down your house.

Difference between revisions of "UE1:Authorizer"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
(Thanks Raven!)
(Source Code)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{classbox| [[Legacy:UT|UT]] :: [[Legacy:Actor_(UT)|Actor_(UT)]] >> [[Legacy:Triggers_(UT)|Triggers_(UT)]] >> Authorizer}}
+
__TOC__
  
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 [[Legacy:Trigger|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.
+
==About==
 +
This is very old script I've created to Skaarj Evasion TC (RIP). As a base was used KeyMover tutorial from [http://chimeric.beyondunreal.com/tutorials/tut11.html Chimeric].
  
 +
==Properties==
 +
===Visible===
 +
; class<inventory> KeyClass : key class to search in players inventory
 +
; bool bDestroyKey : should key be deleted from inventory
 +
; bool bCheckKeyOnceOnly : if true and key was found, this class starts acting like standard trigger
 +
; bool bShowSuccessMessage : if true will show message when key was found
 +
; bool bShowFailtureMessage : if true will show message when key can not be found
 +
; localized String SuccessMessage : message visible when player has a key
 +
; localized String FailtureMessage : message visible when player don't have a key
 +
 +
===Hidden===
 +
; bool bWasOpened : true if key was found and bCheckKeyOnceOnly is set to true
 +
 +
==Source Code==
 +
{{Infobox class
 +
| class  = Authorizer
 +
| custom  = yes
 +
| parent1 = Triggers
 +
| parent2 = Actor
 +
}}
 
<uscript>
 
<uscript>
 
//=================================================
 
//=================================================
Line 10: Line 31:
 
//=================================================
 
//=================================================
 
// by Raven
 
// by Raven
// http://turniej.unreal.pl
+
// http://turniej.unreal.pl/rp
// http://tcn.unreal.pl
+
 
// for The Chosen One SP mod
 
// for The Chosen One SP mod
 
//=================================================
 
//=================================================
class Authorizer extends Triggers;
+
class Authorizer extends Trigger;
  
#exec TEXTURE IMPORT NAME=Authorizer FILE="textures\Icons\auth.bmp" GROUP=Icons LODSET=2
+
var() class<inventory> KeyClass;
 
+
var() bool bDestroyKey;
var() class keyclass;
+
var() bool bCheckKeyOnceOnly;
var() bool DestroyKey;
+
var() bool bShowSuccessMessage;
var() bool NormalAfterDestroying;  
+
var() bool bShowFailtureMessage;
var() bool ShowSuccessMessage;  
+
var() bool ShowFailtureMessage;  
+
 
var() localized String SuccessMessage;  
 
var() localized String SuccessMessage;  
 
var() localized String FailtureMessage;  
 
var() localized String FailtureMessage;  
var bool norm;
+
var bool bWasOpened;
var bool opened;  
+
  
 
replication
 
replication
 
{
 
{
 
// Variables the server should send to the client.
 
// Variables the server should send to the client.
reliable if( Role==ROLE_Authority ) opened, norm;
+
reliable if( Role==ROLE_Authority )
 +
bWasOpened;
 
}
 
}
  
 
function Touch( actor Other )
 
function Touch( actor Other )
 
{
 
{
    local Inventory key;
+
local Inventory key;
    local actor A;
+
local actor A;
  
    // BroadcastMessage("Bumped by "$Other.Name);
+
if (Other.IsA('Pawn') && KeyClass != none && !bWasOpened)
 +
{
 +
key = Pawn(Other).FindInventoryType(KeyClass);
  
    // First check to make sure this is a Pawn, cause they are
+
if (key != none && Event != '' && !bCheckKeyOnceOnly)
    // only things that have inventories (i think:), and then
+
foreach AllActors( class 'Actor', A, Event )
    // make sure we have a keyclass to check for.
+
A.Trigger( Other, Other.Instigator );
    if (Other.IsA('Pawn') && keyclass != NONE)
+
    {
+
      // BroadcastMessage("Other.Class: "$Other.Class$", keyclass: "$keyclass);
+
  
      // Now we just use FindInventoryType() to see if they have
+
if(bDestroyKey)
      // a copy of our desired key in their inventory...
+
if(!bWasOpened) Pawn(Other).DeleteInventory(key);
      key = Pawn(Other).FindInventoryType(keyclass);
+
if(bCheckKeyOnceOnly)
 
+
bWasOpened=true;
      // ...if so call the old foreach function and let the trigger
+
}
      // do its thing.
+
if(bWasOpened && Event != '')
      if (key != NONE)
+
foreach AllActors( class 'Actor', A, Event )
      {
+
A.Trigger( Other, Other.Instigator );
        // Broadcastmessage("Found key");
+
if( PlayerPawn(Other) != none )
        if( Event != '' ) // trigger all matching actors.
+
{
          foreach AllActors( class 'Actor', A, Event )
+
if( bShowSuccessMessage && bWasOpened )
          {
+
PlayerPawn(Other).ClientMessage(SuccessMessage);
            A.Trigger( Other, Other.Instigator );
+
if( bShowFailtureMessage && !bWasOpened )
          }
+
PlayerPawn(Other).ClientMessage(FailtureMessage);
 
+
}
        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
 
defaultproperties
 
{
 
{
     ShowFailtureMessage=True
+
     bShowFailtureMessage=True
 
     SuccessMessage="Access granded."
 
     SuccessMessage="Access granded."
 
     FailtureMessage="You need a key to open this door."
 
     FailtureMessage="You need a key to open this door."
    Texture=Texture'Authorizer.Icons.Authorizer'
 
 
}
 
}
</uscript>
 
  
[[Category:Legacy Mapping|{{PAGENAME}}]]
+
</uscript>
[[Category:Legacy Custom Class (UT)|{{PAGENAME}}]]
+

Latest revision as of 01:30, 5 August 2010

About[edit]

This is very old script I've created to Skaarj Evasion TC (RIP). As a base was used KeyMover tutorial from Chimeric.

Properties[edit]

Visible[edit]

class<inventory> KeyClass 
key class to search in players inventory
bool bDestroyKey 
should key be deleted from inventory
bool bCheckKeyOnceOnly 
if true and key was found, this class starts acting like standard trigger
bool bShowSuccessMessage 
if true will show message when key was found
bool bShowFailtureMessage 
if true will show message when key can not be found
localized String SuccessMessage 
message visible when player has a key
localized String FailtureMessage 
message visible when player don't have a key

Hidden[edit]

bool bWasOpened 
true if key was found and bCheckKeyOnceOnly is set to true

Source Code[edit]

UE1 Actor >> Triggers >> Authorizer (custom)
//=================================================
// 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/rp
// for The Chosen One SP mod
//=================================================
class Authorizer extends Trigger;
 
var() class<inventory> KeyClass< SEMI >
var() bool bDestroyKey;
var() bool bCheckKeyOnceOnly;
var() bool bShowSuccessMessage;
var() bool bShowFailtureMessage;
var() localized String SuccessMessage; 
var() localized String FailtureMessage; 
var bool bWasOpened;
 
replication
{
	// Variables the server should send to the client.
	reliable if( Role==ROLE_Authority )
		bWasOpened;
}
 
function Touch( actor Other )
{
	local Inventory key;
	local actor A;
 
	if (Other.IsA('Pawn') && KeyClass != none && !bWasOpened)
	{
		key = Pawn(Other).FindInventoryType(KeyClass);
 
		if (key != none && Event != '' && !bCheckKeyOnceOnly)
			foreach AllActors( class 'Actor', A, Event )
				A.Trigger( Other, Other.Instigator );
 
		if(bDestroyKey)
			if(!bWasOpened) Pawn(Other).DeleteInventory(key);
		if(bCheckKeyOnceOnly)
			bWasOpened=true;
	}
	if(bWasOpened && Event != '')
		foreach AllActors( class 'Actor', A, Event )
			A.Trigger( Other, Other.Instigator );
	if( PlayerPawn(Other) != none )
	{
		if( bShowSuccessMessage && bWasOpened )
			PlayerPawn(Other).ClientMessage(SuccessMessage);
		if( bShowFailtureMessage && !bWasOpened )
			PlayerPawn(Other).ClientMessage(FailtureMessage);
	}
}
 
defaultproperties
{
     bShowFailtureMessage=True
     SuccessMessage="Access granded."
     FailtureMessage="You need a key to open this door."
}