Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //::///////////////////////////////////////////////
- //:: aa_door_open
- //:://////////////////////////////////////////////
- /*
- intended for use in a doors onopen event
- */
- //:://////////////////////////////////////////////
- //:: Created By: The Magus (2012 feb 7)
- //:: Modified:
- //:://////////////////////////////////////////////
- #include "x2_inc_switches"
- #include "NW_I0_GENERIC"
- #include "aa_inc_constants"
- #include "aa_inc_creatures"
- #include "aa_inc_time"
- void main()
- {
- int bClose, bLock = FALSE;
- object oCreature = GetLastOpenedBy();
- int bHandsRequired = GetLocalInt(OBJECT_SELF, HANDS_TO_OPEN);
- int bIncorporeal = GetCreatureFlag(oCreature, CREATURE_VAR_IS_INCORPOREAL);
- // work around for the use of unidentified keys on a locked door
- if(GetLocalInt(oCreature, "KEY_UNIDENTIFIED")<GetCurrentGameTime(FALSE, FALSE, FALSE, TRUE)+1300)
- {
- bClose = TRUE; bLock = TRUE;
- }
- // some creatures do not need to open certain doors
- else if( !GetLockKeyRequired(OBJECT_SELF) && !GetLocalInt(OBJECT_SELF,"MAGIC") && !GetLocalInt(OBJECT_SELF,"NO_PASS")
- &&
- ( bIncorporeal
- ||
- GetHasFeat(FEAT_PASS_DOOR, oCreature)
- ||
- GetIsSoftBodied(oCreature)
- )
- )
- {
- bClose = TRUE;
- AssignCommand(oCreature,
- ActionCastSpellAtObject(SPELL_ACT_PASSDOOR, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)
- );
- }
- // some doors require the use of hands
- else if( bHandsRequired
- &&
- (bIncorporeal || !GetHasHands(oCreature))
- )
- {
- bClose = TRUE;
- if(GetIsPC(oCreature))
- SendMessageToPC(oCreature, RED+"You need hands to open this door.");
- }
- if(bClose)
- {
- object oDest = GetTransitionTarget(OBJECT_SELF);
- int bDestDoor= GetObjectType(oDest)==OBJECT_TYPE_DOOR;
- PlayAnimation(ANIMATION_DOOR_CLOSE);
- if(bDestDoor)
- AssignCommand(oDest, PlayAnimation(ANIMATION_DOOR_CLOSE));
- if(bLock)
- {
- SetLocked(OBJECT_SELF,TRUE);
- if(bDestDoor)
- DelayCommand(0.2, SetLocked(oDest,TRUE));
- AssignCommand(oCreature, PlaySound("as_door_locked1"));
- FloatingTextStringOnCreature(WHITE+"*Fumbles with the door*", oCreature);
- SendMessageToPC(oCreature, "This object is locked.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment