// Use this for initialization
        void Start()
        {
            if (!thisAction)
                thisAction = GetComponent<DaggerfallAction>();
            if (!rigBody)
                rigBody = this.GetComponent<Rigidbody>();

            SetupCollision();
        }
        //For Doors that are also action objects, executes action when door opened / closed
        private void ExecuteActionOnToggle()
        {
            DaggerfallAction action = GetComponent <DaggerfallAction>();

            if (action != null)
            {
                action.Receive(gameObject, DaggerfallAction.TriggerTypes.Door);
            }
        }
        /// <summary>
        /// 11
        /// Pop-up text
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="thisAction"></param>
        public static void ShowText(GameObject triggerObj, DaggerfallAction thisAction)
        {
            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallWorkshop.Game.DaggerfallUI.UIManager, null);

            messageBox.SetTextTokens(thisAction.Index + TYPE_11_TEXT_INDEX);
            messageBox.ClickAnywhereToClose        = true;
            messageBox.ParentPanel.BackgroundColor = Color.clear;
            messageBox.Show();
        }
        /// <summary>
        /// 17
        /// Unlocks a door
        /// </summary>
        public static void UnlockDoor(GameObject triggerObj, DaggerfallAction thisAction)
        {
            DaggerfallActionDoor door;

            if (!GetDoor(thisAction.gameObject, out door))
            {
                DaggerfallUnity.LogMessage(string.Format("No DaggerfallActionDoor component found to unlock door"), true);
            }
            else
            {
                door.CurrentLockValue = 0;
            }
        }
Exemple #5
0
        // Use this for initialization
        void Start()
        {
            if (!thisAction)
            {
                thisAction = GetComponent <DaggerfallAction>();
            }
            if (!rigBody)
            {
                rigBody = this.GetComponent <Rigidbody>();
            }

            SetupCollision();
        }
 /// <summary>
 /// 1-8
 /// Handles translation / rotation type actions.
 /// </summary>
 public static void Move(GameObject triggerObj, DaggerfallAction thisAction)
 {
     if (thisAction.CurrentState == ActionState.Start)
     {
         thisAction.CurrentState = ActionState.PlayingForward;
         thisAction.TweenToEnd(thisAction.Duration);
     }
     else if (thisAction.CurrentState == ActionState.End)
     {
         thisAction.CurrentState = ActionState.PlayingReverse;
         thisAction.TweenToStart(thisAction.Duration);
     }
 }
Exemple #7
0
 /// <summary>
 /// Triggers the next action in chain if any
 /// </summary>
 private void ActivateNext()
 {
     if (NextObject == null)
     {
         DaggerfallUnity.LogMessage(string.Format("Next object is null"));
         return;
     }
     else
     {
         DaggerfallAction action = NextObject.GetComponent <DaggerfallAction>();
         if (action != null)
         {
             action.Receive(this.gameObject, false);
         }
     }
 }
 /// <summary>
 /// Triggers the next action in chain if any
 /// </summary>
 private void ActivateNext()
 {
     if (NextObject == null)
     {
         //DaggerfallUnity.LogMessage(string.Format("Next action object in chain is null"));
         return;
     }
     else
     {
         DaggerfallAction action = NextObject.GetComponent <DaggerfallAction>();
         if (action != null)
         {
             action.Receive(this.gameObject, TriggerTypes.ActionObject);
         }
     }
 }
        /// <summary>
        /// 16
        /// Locks door when activated. Lock value used is unknown
        /// </summary>
        /// <param name="prevObject"></param>
        /// <param name="thisAction"></param>
        public static void LockDoor(GameObject triggerObj, DaggerfallAction thisAction)
        {
            DaggerfallActionDoor door;

            if (!GetDoor(thisAction.gameObject, out door))
            {
                DaggerfallUnity.LogMessage(string.Format("No DaggerfallActionDoor component found to lock door"), true);
            }
            else
            {
                if (!door.IsLocked)
                {
                    door.CurrentLockValue = 16; //don't know what what setting Daggerfall uses here
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// 14
        /// This is assumes will always be activated by player directly and input object will always be player.
        /// </summary>
        public static void Teleport(GameObject playerObj, DaggerfallAction thisAction)
        {
            if (thisAction.NextObject == null)
            {
                DaggerfallUnity.LogMessage(string.Format("Teleport next object null - can't teleport"));
                return;
            }
            if (playerObj == null)
            {
                DaggerfallUnity.LogMessage(string.Format("Player object null - can't teleport"));
                return;
            }

            //Might need to adjust for player collider height
            playerObj.transform.position = thisAction.NextObject.transform.position;
            playerObj.transform.rotation = thisAction.NextObject.transform.rotation;
        }
        /// <summary>
        /// 12
        /// Pop-up text that returns player input
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="thisAction"></param>
        public static void ShowTextWithInput(GameObject triggerObj, DaggerfallAction thisAction)
        {
            int textID = thisAction.Index + TYPE_12_TEXT_INDEX;

            if (actionTypeTwelveLookup.ContainsKey(textID))
            {
                thisAction.type12_answers = actionTypeTwelveLookup[textID];
            }
            else
            {
                Debug.LogError(string.Format("Error: invalid key: {0} for action type 12, couldn't get answer(s)", textID));//todo - display error message
            }
            DaggerfallInputMessageBox inputBox = new DaggerfallInputMessageBox(DaggerfallWorkshop.Game.DaggerfallUI.UIManager, textID, 20, "\t> ", false, null);

            inputBox.ParentPanel.BackgroundColor = Color.clear;
            inputBox.OnGotUserInput += thisAction.UserInputHandler;
            inputBox.Show();
        }
        /// <summary>
        /// 28
        /// Drains Magicka
        /// Only on models in vanilla daggerfall (usually on bottom of pits, drains magica while you walk around)
        /// </summary>
        /// <param name="playerObj"></param>
        /// <param name="thisAction"></param>
        public static void DrainMagicka(GameObject triggerObj, DaggerfallAction thisAction)
        {
            GameObject   playerObject;
            PlayerEntity playerEntity;

            if (!GetPlayer(out playerObject, out playerEntity))
            {
                DaggerfallUnity.LogMessage("Failed to get Player or Player entity", true);
                return;
            }
            if (thisAction.IsFlat)
            {
                playerEntity.DecreaseMagicka((int)Mathf.Max(1, thisAction.Magnitude));
            }
            else
            {
                playerEntity.DecreaseMagicka((int)Mathf.Max(1, thisAction.ActionAxisRawValue));
            }
        }
        /// <summary>
        /// 14
        /// Teleports player to next object position.
        /// </summary>
        public static void Teleport(GameObject triggerObj, DaggerfallAction thisAction)
        {
            if (thisAction.NextObject == null)
            {
                DaggerfallUnity.LogMessage(string.Format("Teleport next object null - can't teleport"), true);
                return;
            }

            GameObject   playerObject;
            PlayerEntity playerEntity;

            if (!GetPlayer(out playerObject, out playerEntity))
            {
                DaggerfallUnity.LogMessage("Failed to get Player or Player entity", true);
                return;
            }
            playerObject.transform.position = thisAction.NextObject.transform.position;
            playerObject.transform.rotation = thisAction.NextObject.transform.rotation;
        }
Exemple #14
0
        /// <summary>
        /// 9
        /// Creates spell. Use Action's index to get the spell by index from Spells.STD
        /// </summary>
        /// <param name="triggerObj"></param>
        /// <param name="thisAction"></param>
        public static void CastSpell(GameObject triggerObj, DaggerfallAction thisAction)
        {
            thisAction.Cooldown -= 45.454546f; // Approximates classic based on observation
            if (thisAction.Cooldown <= 0)
            {
                SpellRecord.SpellRecordData spell;
                if (GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(thisAction.Index, out spell))
                {
                    // Create effect bundle settings from classic spell
                    EffectBundleSettings bundleSettings;
                    if (GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(spell, BundleTypes.Spell, out bundleSettings))
                    {
                        if (bundleSettings.TargetType == TargetTypes.CasterOnly)
                        {
                            // Spell is readied on player for free
                            GameManager.Instance.PlayerEffectManager.SetReadySpell(thisAction.Index, true);
                        }
                        else
                        {
                            // Spell is fired at player, at strength of player level, from triggering object
                            DaggerfallMissile missile = GameManager.Instance.PlayerEffectManager.InstantiateSpellMissile(bundleSettings.ElementType);
                            missile.Payload = new EntityEffectBundle(bundleSettings);
                            Vector3 customAimPosition = thisAction.transform.position;
                            customAimPosition.y       += 40 * MeshReader.GlobalScale;
                            missile.CustomAimPosition  = customAimPosition;
                            missile.CustomAimDirection = Vector3.Normalize(GameManager.Instance.PlayerObject.transform.position - thisAction.transform.position);

                            // If action spell payload is "touch" then set to "target at range" (targets player position as above)
                            if (missile.Payload.Settings.TargetType == TargetTypes.ByTouch)
                            {
                                EffectBundleSettings settings = missile.Payload.Settings;
                                settings.TargetType      = TargetTypes.SingleTargetAtRange;
                                missile.Payload.Settings = settings;
                            }
                        }
                    }
                }

                //Reset cooldown
                thisAction.Cooldown = 1000;
            }
        }
Exemple #15
0
        /// <summary>
        /// 18
        /// Opens (and unlocks if is locked) door
        /// </summary>
        public static void OpenDoor(GameObject prevObj, DaggerfallAction thisAction)
        {
            DaggerfallActionDoor door;

            if (!GetDoor(thisAction.gameObject, out door))
            {
                DaggerfallUnity.LogMessage(string.Format("No DaggerfallActionDoor component found"));
            }
            else
            {
                if (door.IsOpen)
                {
                    return;
                }
                else
                {
                    door.CurrentLockValue = 0;
                    door.ToggleDoor();
                }
            }
        }
        /// <summary>
        /// 20
        /// Closes door on activate.  If door has a starting lock value, will re-lock door.
        /// </summary>
        public static void CloseDoor(GameObject triggerObj, DaggerfallAction thisAction)
        {
            DaggerfallActionDoor door;

            if (!GetDoor(thisAction.gameObject, out door))
            {
                DaggerfallUnity.LogMessage(string.Format("No DaggerfallActionDoor component found"), true);
            }
            else
            {
                if (!door.IsOpen)
                {
                    return;
                }
                else
                {
                    door.ToggleDoor();
                    door.CurrentLockValue = door.StartingLockValue;
                }
            }
        }
Exemple #17
0
        /// <summary>
        /// 20
        /// Closes door on activate.  If door has a starting lock value, will re-lock door.
        /// </summary>
        public static void CloseDoor(GameObject triggerObj, DaggerfallAction thisAction)
        {
            // Try regular action door
            DaggerfallActionDoor door;

            if (!GetDoor(thisAction.gameObject, out door))
            {
                DaggerfallUnity.LogMessage(string.Format("No DaggerfallActionDoor or DaggerfallActionDoorSpecial component found"), true);
            }
            else
            {
                if (!door.IsOpen)
                {
                    return;
                }
                else
                {
                    door.ToggleDoor();
                    door.CurrentLockValue = door.StartingLockValue;
                    return;
                }
            }

            // Try special action door
            if (thisAction != null && thisAction.gameObject)
            {
                DaggerfallActionDoorSpecial specialDoor = thisAction.gameObject.GetComponent <DaggerfallActionDoorSpecial>();
                if (specialDoor)
                {
                    if (specialDoor.IsClosed)
                    {
                        return;
                    }
                    else
                    {
                        specialDoor.ToggleDoor();
                    }
                }
            }
        }
        public bool IsPlaying()
        {
            // Check if this action or any chained action is playing
            if (currentState == ActionState.PlayingForward || currentState == ActionState.PlayingReverse)
            {
                return(true);
            }
            else
            {
                if (NextObject == null)
                {
                    return(false);
                }

                DaggerfallAction nextAction = NextObject.GetComponent <DaggerfallAction>();
                if (nextAction == null)
                {
                    return(false);
                }

                return(nextAction.IsPlaying());
            }
        }
        /// <summary>
        /// 21
        /// Damages players health, uses random range & activates sporadically
        /// </summary>
        /// <param name="prevObj"></param>
        /// <param name="thisAction"></param>
        public static void DrainHealth21(GameObject triggerObj, DaggerfallAction thisAction)
        {
            //action type 21 activates every ~20 times for some reason.  Might be better to rand instead
            if (thisAction.activationCount % 20 != 0)
            {
                return;
            }

            GameObject   playerObject;
            PlayerEntity playerEntity;

            if (!GetPlayer(out playerObject, out playerEntity))
            {
                DaggerfallUnity.LogMessage("Failed to get Player or Player entity", true);
                return;
            }

            int damage = 0;

            damage = UnityEngine.Random.Range(Mathf.Max(1, (int)thisAction.Magnitude), Mathf.Max(1, thisAction.Index)) * Mathf.Max(playerEntity.Level, 1);
            playerObject.SendMessage("RemoveHealth", damage);
            //DaggerfallUnity.LogMessage("DrainHealth21, damage: " + damage, true);
        }
Exemple #20
0
        /// <summary>
        /// 14
        /// Teleports player to next object position.
        /// </summary>
        public static void Teleport(GameObject triggerObj, DaggerfallAction thisAction)
        {
            if (thisAction.NextObject == null)
            {
                DaggerfallUnity.LogMessage(string.Format("Teleport next object null - can't teleport"), true);
                return;
            }

            GameObject   playerObject;
            PlayerEntity playerEntity;

            if (!GetPlayer(out playerObject, out playerEntity))
            {
                DaggerfallUnity.LogMessage("Failed to get Player or Player entity", true);
                return;
            }
            GameManager.Instance.PlayerMotor.FreezeMotor = 0.5f;

            RaiseOnTeleportActionEvent(thisAction.gameObject, thisAction.NextObject);

            playerObject.transform.position = thisAction.NextObject.transform.position;
            playerObject.transform.rotation = thisAction.NextObject.transform.rotation;
        }
        private void Open(float duration, bool ignoreLocks = false, bool activatedByPlayer = false, float scale = 1)
        {
            // Handle DoorText actions. On first activation, show the text but don't try to open the door.
            DaggerfallAction action = GetComponent <DaggerfallAction>();

            if (action != null &&
                action.ActionFlag == DFBlock.RdbActionFlags.DoorText &&
                (action.TriggerFlag == DFBlock.RdbTriggerFlags.Door || action.TriggerFlag == DFBlock.RdbTriggerFlags.Direct) && // Door to Mynisera's room has a "Direct" trigger flag
                action.activationCount == 0 &&
                activatedByPlayer)
            {
                ExecuteActionOnToggle();
                if (!action.ActionEnabled) // ActionEnabled will still be false if there was valid text to display. In that case, don't open the door for this first activation.
                {
                    return;
                }
            }

            // Do nothing if door cannot be opened right now
            if ((IsLocked && !ignoreLocks) || IsOpen)
            {
                if (!IsOpen)
                {
                    PlayerActivate.LookAtInteriorLock(CurrentLockValue);
                }
                return;
            }

            if (activatedByPlayer)
            {
                ExecuteActionOnToggle();
            }

            // Tween rotation
            Hashtable rotateParams = __ExternalAssets.iTween.Hash(
                "amount", new Vector3(0f, OpenAngle * scale / 360f, 0f),
                "space", Space.Self,
                "time", duration * scale,
                "easetype", __ExternalAssets.iTween.EaseType.linear,
                "oncomplete", "OnCompleteOpen");

            __ExternalAssets.iTween.RotateBy(gameObject, rotateParams);

            // Set collider to trigger only
            MakeTrigger(true);

            // Play open sound if flagged and ready
            if (PlaySounds && OpenSound > 0 && duration * scale > 0 && audioSource &&
                currentState != ActionState.PlayingForward)
            {
                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource != null)
                {
                    dfAudioSource.PlayOneShot(OpenSound);
                }
            }

            currentState = ActionState.PlayingForward;

            // Set flag
            //IsMagicallyHeld = false;
            CurrentLockValue = 0;
        }
        /// <summary>
        /// 28
        /// Drains Magicka
        /// Only on models in vanilla daggerfall (usually on bottom of pits, drains magica while you walk around)
        /// </summary>
        /// <param name="playerObj"></param>
        /// <param name="thisAction"></param>
        public static void DrainMagicka(GameObject triggerObj, DaggerfallAction thisAction)
        {
            GameObject playerObject;
            PlayerEntity playerEntity;

            if (!GetPlayer(out playerObject, out playerEntity))
            {
                DaggerfallUnity.LogMessage("Failed to get Player or Player entity", true);
                return;
            }
            if(thisAction.IsFlat)
                playerEntity.DecreaseMagicka((int)Mathf.Max(1, thisAction.Magnitude));
            else
                playerEntity.DecreaseMagicka((int)Mathf.Max(1, thisAction.ActionAxisRawValue));
        }
        /// <summary>
        /// 17
        /// Unlocks a door. Doesn't relock on reverse.
        /// </summary>
        public static void UnlockDoor(GameObject prevObj, DaggerfallAction thisAction)
        {
            DaggerfallActionDoor door;
            if (!GetDoor(thisAction.gameObject, out door))
            {
                DaggerfallUnity.LogMessage(string.Format("No DaggerfallActionDoor component found to unlock door"));

            }
            else
            {
                door.CurrentLockValue = 0;

            }
        }
 /// <summary>
 /// 9
 /// Creates spell. Use Action's index to get the spell by index from Spells.STD
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="thisAction"></param>
 public static void CastSpell(GameObject triggerObj, DaggerfallAction thisAction)
 {
     //Debug.Log("Action Type 9: CastSpell");
 }
 /// <summary>
 /// 9
 /// Creates spell. Use Action's index to get the spell by index from Spells.STD
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="thisAction"></param>
 public static void CastSpell(GameObject triggerObj, DaggerfallAction thisAction)
 {
     //Debug.Log("Action Type 9: CastSpell");
 }
 /// <summary>
 /// 18
 /// Opens (and unlocks if is locked) door
 /// </summary>
 public static void OpenDoor(GameObject prevObj, DaggerfallAction thisAction)
 {
     DaggerfallActionDoor door;
     if (!GetDoor(thisAction.gameObject, out door))
     {
         DaggerfallUnity.LogMessage(string.Format("No DaggerfallActionDoor component found"));
     }
     else
     {
         if (door.IsOpen)
             return;
         else
         {
             door.CurrentLockValue = 0;
             door.ToggleDoor();
         }
     }
 }
 /// <summary>
 /// 1-8
 /// Handles translation / rotation type actions.  
 /// </summary>
 public static void Move(GameObject obj, DaggerfallAction thisAction)
 {
     if (thisAction.CurrentState == ActionState.Start)
     {
         thisAction.CurrentState = ActionState.PlayingForward;
         thisAction.TweenToEnd(thisAction.Duration);
     }
     else if (thisAction.CurrentState == ActionState.End)
     {
         thisAction.CurrentState = ActionState.PlayingReverse;
         thisAction.TweenToStart(thisAction.Duration);
     }
 }
 /// <summary>
 /// 26
 /// Seems to poison / infect player.
 /// </summary>
 /// <param name="triggerObj"></param>
 /// <param name="thisAction"></param>
 public static void Poison(GameObject triggerObj, DaggerfallAction thisAction)
 {
     //Debug.Log("Action Type 26: Poison");
 }
        /// <summary>
        /// 14
        /// Teleports player to next object position.
        /// </summary>
        public static void Teleport(GameObject triggerObj, DaggerfallAction thisAction)
        {
            if (thisAction.NextObject == null)
            {
                DaggerfallUnity.LogMessage(string.Format("Teleport next object null - can't teleport"), true);
                return;
            }

            GameObject playerObject;
            PlayerEntity playerEntity;

            if (!GetPlayer(out playerObject, out playerEntity))
            {
                DaggerfallUnity.LogMessage("Failed to get Player or Player entity", true);
                return;
            }
            playerObject.transform.position = thisAction.NextObject.transform.position;
            playerObject.transform.rotation = thisAction.NextObject.transform.rotation;
        }
 public void Start()
 {
     if (!thisAction)
         thisAction = GetComponent<DaggerfallAction>();
 }
        /// <summary>
        /// 21
        /// Damages players health, uses random range & activates sporadically
        /// </summary>
        /// <param name="prevObj"></param>
        /// <param name="thisAction"></param>
        public static void DrainHealth21(GameObject triggerObj, DaggerfallAction thisAction)
        {
            //action type 21 activates every ~20 times for some reason.  Might be better to rand instead
            if (thisAction.activationCount % 20 != 0)
                return;

            GameObject playerObject;
            PlayerEntity playerEntity;

            if(!GetPlayer(out playerObject, out playerEntity))
            {
                DaggerfallUnity.LogMessage("Failed to get Player or Player entity", true);
                return;
            }

            int damage = 0;
            damage = UnityEngine.Random.Range(Mathf.Max(1, (int)thisAction.Magnitude), Mathf.Max(1, thisAction.Index)) * Mathf.Max(playerEntity.Level, 1);
            playerObject.SendMessage("RemoveHealth", damage);
            //DaggerfallUnity.LogMessage("DrainHealth21, damage: " + damage, true);
        }
        /// <summary>
        /// 22-25
        /// Damages players health every hit
        /// </summary>
        /// <param name="prevObj"></param>
        /// <param name="thisAction"></param>
        public static void DrainHealth(GameObject triggerObj, DaggerfallAction thisAction)
        {
            GameObject playerObject;
            PlayerEntity playerEntity;

            if (!GetPlayer(out playerObject, out playerEntity))
            {
                DaggerfallUnity.LogMessage("Failed to get Player or Player entity", true);
                return;
            }

            int damage = 0;
            if(thisAction.IsFlat)
                damage = (int)thisAction.Magnitude * Mathf.Max(playerEntity.Level, 1);
            else
                damage = (int)thisAction.ActionAxisRawValue * Mathf.Max(playerEntity.Level, 1);

            playerObject.SendMessage("RemoveHealth", damage);

            //DaggerfallUnity.LogMessage("DrainHealth damage: " + damage, true);
        }
 /// <summary>
 /// 11
 /// Pop-up text
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="thisAction"></param>
 public static void ShowText(GameObject obj, DaggerfallAction thisAction)
 {
     DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallWorkshop.Game.DaggerfallUI.UIManager, null);
     messageBox.SetTextTokens(thisAction.Index + TYPE_11_TEXT_INDEX);
     messageBox.ClickAnywhereToClose = true;
     messageBox.ParentPanel.BackgroundColor = Color.clear;
     messageBox.Show();
 }
        /// <summary>
        /// 20
        /// Closes door on activate.  If door has a starting lock value, will re-lock door.
        /// </summary>
        public static void CloseDoor(GameObject triggerObj, DaggerfallAction thisAction)
        {
            DaggerfallActionDoor door;
            if (!GetDoor(thisAction.gameObject, out door))
                DaggerfallUnity.LogMessage(string.Format("No DaggerfallActionDoor component found"), true);
            else
            {
                if (!door.IsOpen)
                    return;
                else
                {
                    door.ToggleDoor();
                    door.CurrentLockValue = door.StartingLockValue;
                }

            }
        }
 /// <summary>
 /// 12
 /// Pop-up text that returns player input
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="thisAction"></param>
 public static void ShowTextWithInput(GameObject obj, DaggerfallAction thisAction)
 {
     int textID = thisAction.Index + TYPE_12_TEXT_INDEX;
     if (actionTypeTwelveLookup.ContainsKey(textID))
     {
         thisAction.type12_answers = actionTypeTwelveLookup[textID];
     }
     else
     {
         Debug.LogError(string.Format("Error: invalid key: {0} for action type 12, couldn't get answer(s)", textID));//todo - display error message
     }
     DaggerfallInputMessageBox inputBox = new DaggerfallInputMessageBox(DaggerfallWorkshop.Game.DaggerfallUI.UIManager, textID, 20, "\t> ", true, false, null);
     inputBox.ParentPanel.BackgroundColor = Color.clear;
     inputBox.OnGotUserInput += thisAction.UserInputHandler;
     inputBox.Show();
 }
Exemple #36
0
 /// <summary>
 /// 31
 /// Sets global variable in quest system.
 /// </summary>
 public static void SetGlobalVar(GameObject triggerObj, DaggerfallAction thisAction)
 {
     // Global variable index stored in action axis value
     GameManager.Instance.PlayerEntity.GlobalVars.SetGlobalVar(thisAction.ActionAxisRawValue, true);
     Debug.LogFormat("Action set global variable #{0}", thisAction.ActionAxisRawValue);
 }
        /// <summary>
        /// 14
        /// This is assumes will always be activated by player directly and input object will always be player.
        /// </summary>
        public static void Teleport(GameObject playerObj, DaggerfallAction thisAction)
        {
            if (thisAction.NextObject == null)
            {
                DaggerfallUnity.LogMessage(string.Format("Teleport next object null - can't teleport"));
                return;
            }
            if (playerObj == null)
            {
                DaggerfallUnity.LogMessage(string.Format("Player object null - can't teleport"));
                return;
            }

            //Might need to adjust for player collider height
            playerObj.transform.position = thisAction.NextObject.transform.position;
            playerObj.transform.rotation = thisAction.NextObject.transform.rotation;
        }
 // <summary>
 /// Just activates next object in chain.
 /// </summary>
 public static void Activate(GameObject prevObj, DaggerfallAction thisAction)
 {
     return;
 }
        /// <summary>
        /// This just simulates activating one of the action objects that hurt the player.
        /// 21 does lots of damage, and varies.  Can only activate once.
        /// 22-25 do Player Level * Magnitude in Damage. Multiple activation
        /// </summary>
        public static void Hurt(GameObject playerObj, DaggerfallAction thisAction)
        {
            if (playerObj == null)
                return;

            playerObj.SendMessage("RemoveHealth", SendMessageOptions.DontRequireReceiver);
        }
 /// <summary>
 /// 26
 /// Seems to poison / infect player.
 /// </summary>
 /// <param name="triggerObj"></param>
 /// <param name="thisAction"></param>
 public static void Poison(GameObject triggerObj, DaggerfallAction thisAction)
 {
     //Debug.Log("Action Type 26: Poison");
 }
        /// <summary>
        /// 16
        /// Locks door when activated. Lock value used is unknown
        /// </summary>
        /// <param name="prevObject"></param>
        /// <param name="thisAction"></param>
        public static void LockDoor(GameObject prevObject, DaggerfallAction thisAction)
        {
            DaggerfallActionDoor door;
            if (!GetDoor(thisAction.gameObject, out door))
            {
                DaggerfallUnity.LogMessage(string.Format("No DaggerfallActionDoor component found to lock door"), true);

            }
            else
            {
                if (!door.IsLocked)
                    door.CurrentLockValue = 16; //don't know what what setting Daggerfall uses here
            }
        }
 // <summary>
 /// Just activates next object in chain.
 /// </summary>
 public static void Activate(GameObject triggerObj, DaggerfallAction thisAction)
 {
     return;
 }
Exemple #43
0
        /// <summary>
        /// 32
        /// Shows text at the top of the screen when player clicks on associated door in info mode.
        /// </summary>
        public static void DoorText(GameObject triggerObj, DaggerfallAction thisAction)
        {
            // The way that classic handles this action has some problems. The text is only displayed
            // if the door is clicked in info mode, so it can easily be missed, and if clicked in info mode
            // the trespassing check isn't run but the door is still opened, making it an exploit.
            // For DF Unity, we're showing the text on the first click of the door, and opening the door
            // and running the trespassing check from the second click onward, all regardless of interaction mode.

            int DoorTextID = TYPE_99_TEXT_INDEX + thisAction.Index;

            // Patch some textID lookups.
            switch (DoorTextID)
            {
            case 7700:                           // action.Index was 0.
                thisAction.ActionEnabled = true; // This means skip over trying to display the message and proceed to the trespassing check.
                                                 // DaggerfallActionDoor will also proceed with opening the door even on first activation.
                break;

            case 7701:
            case 7702:
            case 7703:
            case 7704:
            {
                DoorTextID = 7705;         // All of these are the same except that only 7705 correctly has "allowed" instead of "allow"
                break;
            }

            case 7706:      // Doesn't exist. This is on a door in Castle Wayrest to a room with some potions, bookshelves, weighting scales and a telescope.
            {
                thisAction.ActionEnabled = true;
                break;
            }

            case 7715:      // Doesn't exist. Found on doors in back of Orsinium throne room.
            {
                thisAction.ActionEnabled = true;
                break;
            }

            case 7719:      // Doesn't exist. This is on the doors to a room near the start of the Orsinium dungeon area with a long table lined with chairs and a fireplace.
            {
                thisAction.ActionEnabled = true;
                break;
            }
            }

            if (thisAction.activationCount == 1 && DoorTextID != 7700 && !thisAction.ActionEnabled)
            {
                TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(DoorTextID);
                if (tokens != null)
                {
                    DaggerfallUI.AddHUDText(tokens, 2.0f);
                }
                else
                {
                    throw new System.Exception(string.Format("DaggerfallAction: Bad DoorTextID requested: {0}.", DoorTextID));
                }
            }
            else
            {
                // Classic seems to only check whether this value is greater than 5, as a trespassing check
                if (thisAction.ActionAxisRawValue > 5)
                {
                    GameManager.Instance.MakeEnemiesHostile();
                }
            }
        }