00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 | //============================================================================= // Spatial Fear // Class: SFInteractTrigger // Description: Subclasses of SFUseKeyTrigger that only fires, if a // special inventory item is possesed, if NeededItem is empty the trigger is // always fired. Because it is a subclass of SFUseKey the property // IgnoreTouching can be used to use the trigger as "UseKey" trigger // // Author: Markus Nuebel //============================================================================= class SFInteractTrigger extends SFUseKeyTrigger; var (SpatialFear) class<Actor> NeededItem; // Class of an item that is needed to make the trigger fire. E.g. Botpack.Enforcer, when the class is null this rule is not enforced. var (SpatialFear) string NeededMessage; // Message that is displayed, when the check for configured "needed inventory item" fails. If empty, no message will be generated. var (SpatialFear) name FailureEvent; // If this name is set, the event with name: FailureEvent is send in case the needed item is not found in the inventory. var (SpatialFear) bool bRememberPassedItemCheck; // This flag set to true tells the trigger, to do no further needed item checks, after the first successfull check. Default: false var bool m_bCheckAreadyPassed; // Private: If this variable is set, no further checking for needed items is done. Default: false // Checks wheater the needed item type is in the current // inventory or not function bool checkNeededItem(actor Other) { local inventory S; local pawn player; local class classItem; player = Pawn(Other); if(None == player) return true; if((NeededItem==None) || m_bCheckAreadyPassed) return true; else { //class'SFUtils'.Static.sfLogEx(15,"SFInteractTrigger::checkNeededItem: NeededITem:>"$ NeededItem.name $ "<"); classItem = NeededItem; S = player.FindInventoryType(ClassItem); if ( S==None ) { // Notify player if(NeededMessage != "") player.ClientMessage(NeededMessage, 'SFTrigger'); return false; } else { // Needed item found if(bRememberPassedItemCheck) m_bCheckAreadyPassed=true; return true; } } } // Called when something touches the trigger. function Touch( actor Other ) { if(IgnoreTouching) return; // Fire, if needed item is in inventory if(checkNeededItem(Other)) Super.Touch(Other); } // Called, when within a UseKey range of the SFPlayer function FireEvent( actor Other ) { if(checkNeededItem(Other)) { //class'SFUtils'.Static.sfLogEx(15,"SFInteractTrigger::FireEvent: Trigger fired."); Super.FireEvent(Other); } else FireCustomEvent(FailureEvent, Other); } // Fires a normal event from this trigger function FireCustomEvent(name nameEvent, actor Other) { local actor A; // Broadcast the Trigger message to all matching actors. if( nameEvent != '' ) foreach AllActors( class 'Actor', A, nameEvent ) { A.Trigger( Other, Other.Instigator ); } } defaultproperties { NeededMessage="You do not own the needed item" } |