// Generic script for "light wall". Only allows people of rank X or higher // passage through, and even then, only if the token is either bound // to them specifically or corrupted. // Mark the trigger with a local int "req_id" equal to the lowest rank you // wish to be able to cross. // Give the teleport point to teleport a denied object to, a tag // corresponding to the trigger tag + "_WP" #include "mn_h_constants" void debugMessage(string besked) { object oPC = GetFirstPC(); SendMessageToPC( oPC, besked ); } void SetAlert( int alert ) { SetLocalInt( GetArea( OBJECT_SELF ), "alert_status", alert ); // gennemloeb og opdater alle alarmlamper SetCampaignInt( MN_HOUSE_DB, "alert_status", alert ); } int Detract( int amount ) { int result = FALSE; int available_amount = GetCampaignInt( MN_HOUSE_DB, "mana" ); if (available_amount >= amount ) { available_amount -= amount; SetCampaignInt( MN_HOUSE_DB, "mana", available_amount ); result = TRUE; } return result; } void confinePC( object oPC, int crime ) { location telepoint = GetLocation (GetObjectByTag ("MN_TELEPRISON") ); AssignCommand( oPC, ClearAllActions() ); AssignCommand( oPC, ActionJumpToLocation( telepoint ) ); } void accessDenied( object oPC, object companion, string jumplocation ) { string besked = "Your companion is pushed back by an invisible forcewall"; if (GetIsPC( companion ) ) { besked = "You are pushed back by an invisible forcewall"; } FloatingTextStringOnCreature ( besked, oPC, FALSE ); location telepoint = GetLocation( GetObjectByTag( jumplocation ) ); // debugMessage( "Debug: Jumplocation: "+ jumplocation ); AssignCommand( companion, ClearAllActions() ); AssignCommand( companion, ActionJumpToLocation( telepoint ) ); } void main() { object field = OBJECT_SELF; int fieldOpen = GetLocalInt( field, "open" ); if ( fieldOpen ) { return; } object oPC = GetEnteringObject(); object companion = oPC; int requiredRank = GetLocalInt( OBJECT_SELF, "req_id" ); string jumplocation = GetTag( OBJECT_SELF ) + "_WP"; int alertStatus = GetLocalInt( GetArea( OBJECT_SELF ), "alert_status" ); int authenticRank = 0; int forgedRank = 0; object forgedPass; if ( MN_DEBUG || GetIsDM( oPC ) ) { return; } // find top in master-associate hierachy while ( GetIsObjectValid( GetMaster( oPC ) ) ) { oPC = GetMaster( oPC ); } if ( GetLocalInt( OBJECT_SELF, "lockdown" ) ) { accessDenied( oPC, companion, jumplocation ); return; } if ( GetIsPC( oPC ) ) { // Behaviour for PCs and PC's associates entering the wall object pass; pass = GetItemPossessedBy( oPC, "MN_I_PCACCESS" ); string cid = GetLocalString( oPC, "cid" ); string lid; int rank; int corrupted; if (pass == OBJECT_INVALID) { // No pass at all accessDenied( oPC, companion, jumplocation ); return; } // Loop to find the ranks to be used for the following comparison pass = GetFirstItemInInventory( oPC ); while ( pass != OBJECT_INVALID ) { if (GetTag( pass ) == "MN_I_PCACCESS" ) { lid = GetLocalString( pass, "tied_to" ); rank = GetLocalInt( pass, "rank" ); corrupted = GetLocalInt( pass, "corrupted" ); if ( !corrupted && lid == cid ) { if ( authenticRank < rank ) { authenticRank = rank; } } if ( corrupted && lid == cid ) { if (forgedRank < rank ) { forgedRank = rank; forgedPass = pass; } } } pass = GetNextItemInInventory( oPC ); } if ( authenticRank == 0 && forgedRank == 0 ) { // Shouldn't happen, but just to make sure accessDenied( oPC, companion, jumplocation ); return; } // Now, there are four different ways the wall will function, // depending on the alert status. The following CASE takes care // of this function branching. switch ( alertStatus ) { case MN_ALERT_NORMAL: // Low threat - no mana drained, but forged passes are not discovered if ( (authenticRank < requiredRank) && (forgedRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } break; case MN_ALERT_HEIGHTENED: // Intrusion suspected or expected - if a forged pass would allow // entry (and an authentic wouldn't), pass is removed, person is // confined, and alert status is scaled upwards to active. if ( (authenticRank < requiredRank) && (forgedRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } if ( authenticRank < requiredRank ) { // Tried false ID if ( Detract(1) ) { SetPlotFlag( forgedPass, FALSE ); DestroyObject( forgedPass ); SetAlert( MN_ALERT_ACTIVE ); confinePC( oPC, MN_CRIME_FALSEPASS ); return; } } break; case MN_ALERT_ACTIVE: // Intrusion confirmed - all passage is heavily screened. Any // forged pass is detected, the user is confined, and the pass // is removed. Movement is restricted to those of the rank of // allies and above( including guards ). Teleportation portals // and exit door is closed, and the teleportation restrictor // is activated, rendering all but local teleportation impossible. // Local teleportation is not usable for anyone under the rank // of ally. if ( forgedRank > 0 ) { // Tried false ID if ( Detract(1) ) { SetPlotFlag( forgedPass, FALSE ); DestroyObject( forgedPass ); confinePC( oPC, MN_CRIME_FALSEPASS ); return; } else { if ( (forgedRank < MN_RANK_ALLY ) || ( forgedRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } } } if ( (authenticRank < MN_RANK_ALLY ) || ( authenticRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } break; case MN_ALERT_INVASION: // Stronghold under attack, or treason suspected or confirmed. // Lockdown - only owner and personal friends can pass walls // or use local teleportation. Global teleportation is made // impossible by the activation of the teleportation restrictor. // Civilians are confined to the safety area for the duration of // this event. Exit door field blocks all passage. Any forged pass // is detected, the user is confined, and the pass is removed. if ( forgedRank > 0 ) { // Tried false ID if ( Detract(1) ) { SetPlotFlag( forgedPass, FALSE ); DestroyObject( forgedPass ); confinePC( oPC, MN_CRIME_FALSEPASS ); return; } else { if ( (forgedRank < MN_RANK_FRIEND ) || ( forgedRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } } return; } if ( (authenticRank < MN_RANK_FRIEND || authenticRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } break; } } else { // Behaviour for NPCs entering the portal /* int npcRank = GetLocalInt( oPC, "mn_h_rank" ); switch ( alertStatus ) { case MN_ALERT_NORMAL: // Low threat - no mana drained, but forged passes are not discovered if ( (npcRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } break; case MN_ALERT_HEIGHTENED: // Intrusion suspected or expected - if a forged pass would allow // entry (and an authentic wouldn't), pass is removed, person is // confined, and alert status is scaled upwards to active. if ( (npcRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } case MN_ALERT_ACTIVE: // Intrusion confirmed - all passage is heavily screened. Any // forged pass is detected, the user is confined, and the pass // is removed. Movement is restricted to those of the rank of // allies and above( including guards ). Teleportation portals // and exit door is closed, and the teleportation restrictor // is activated, rendering all but local teleportation impossible. // Local teleportation is not usable for anyone under the rank // of ally. if ( (npcRank < MN_RANK_ALLY ) || ( npcRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } break; case MN_ALERT_INVASION: // Stronghold under attack, or treason suspected or confirmed. // Lockdown - only owner and personal friends can pass walls // or use local teleportation. Global teleportation is made // impossible by the activation of the teleportation restrictor. // Civilians are confined to the safety area for the duration of // this event. Exit door field blocks all passage. Any forged pass // is detected, the user is confined, and the pass is removed. if ( (npcRank < MN_RANK_FRIEND || npcRank < requiredRank) ) { accessDenied( oPC, companion, jumplocation ); return; } break; } */ } }