private static void HandleTrapDetected(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, uint detector)
        {
            trap.Detected = true;
           
            NWEffect vfx = s.SupernaturalEffect(s.EffectNWN2SpecialEffectFile(trap.TrapTriggerVFX, OBJECT_INVALID, s.Vector(0.0f, 0.0f, 0.0f)));
            s.ApplyEffectToObject(DURATION_TYPE_PERMANENT, vfx, s.GetObjectByTag(trap.Tag, 0), 0.0f);

            uint detectWidget = s.CreateObject(OBJECT_TYPE_PLACEABLE, "acr_trap_disarm", s.GetLocation(detector), TRUE, trap.Tag + "_");
            if (!String.IsNullOrEmpty(trap.Description))
            {
                s.SetDescription(detectWidget, trap.Description);
            }
            s.SetFirstName(detectWidget, String.Format("Disarm the {0} trap", trap.SpellTrap ? "Spell" : "Mechanical"));
            
            // If they clicked to walk, let's stop them from walking into the hazard they just found.
            if (s.GetCurrentAction(detector) == ACTION_MOVETOPOINT)
            {
                s.AssignCommand(detector, delegate { s.ClearAllActions(0); });
            }
            s.PlaySound("alert", FALSE);
            s.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, s.SupernaturalEffect(s.EffectNWN2SpecialEffectFile("fx_bang", detector, s.Vector(0.0f,0.0f,0.0f))), detector, 6.0f);
            s.SendMessageToPC(detector, "You spot a trap!");
        }
예제 #2
0
        public bool recalculate(CLRScriptBase script)
        {
            // Ensure that both our hide and our creature are still valid.
            if (script.GetIsObjectValid(m_oCreature) == CLRScriptBase.FALSE || script.GetIsObjectValid(m_oCreature) == CLRScriptBase.FALSE)
            {
                return false;
            }

            // Recreate the hide.
            script.AssignCommand(m_oCreature, delegate { script.ClearAllActions(CLRScriptBase.FALSE); });
            uint oOldHide = getHide(script);
            m_oHide = script.CreateItemOnObject("acr_pchide", m_oCreature, 1, "acr_pchide", CLRScriptBase.FALSE);

            // Temp variables to store bonuses, to allow stacking from different sources.
            Dictionary<int, int> saveBonuses = new Dictionary<int, int>();
            Dictionary<int, int> skillBonuses = new Dictionary<int, int>();
            Dictionary<string, int> otherBonuses = new Dictionary<string, int>();

            // Initialize dictionaries.
            for (int i = 0; i < 68; i++)
            {
                skillBonuses.Add(i, 0);
            }
            for (int i = 0; i < 4; i++)
            {
                saveBonuses.Add(i, 0);
            }

            #region Skill Focus feats
            // Handle all new shiny skill focus feats.
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_BALANCE, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_BALANCE] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CLIMB, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CLIMB] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CRFT_ALCH, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CRAFT_ALCHEMY] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CRFT_ARM, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CRAFT_ARMORSMITHING] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CRFT_BOW, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CRAFT_BOWMAKING] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_CRFT_WPN, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_CRAFT_WEAPONSMITHING] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_DECIPHER, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_DECIPHER_SCRIPT] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_DISGUISE, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_DISGUISE] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_ESC_ART, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_ESCAPE_ARTIST] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_HAND_ANIM, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_HANDLE_ANIMAL] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_JUMP, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_JUMP] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_ARC, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_ARCANA] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_DUNG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_DUNGEONEERING] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_ENG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_ENGINEERING] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_GEO, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_GEOGRAPHY] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_HIST, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_HISTORY] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_LOC, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_LOCAL] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_NATR, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_NATURE] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_NOBL, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_NOBILITY] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_PLAN, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_THE_PLANES] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_KNOW_RELG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_RELIGION] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_ACT, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_ACT] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_COMD, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_COMEDY] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_DANC, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_DANCE] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_KEYB, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_KEYBOARD] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_ORAT, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_ORATORY] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_PERC, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_PERCUSSION] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_SING, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_SING] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_STRG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_STRING_INSTRUMENTS] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PERF_WIND, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PERFORM_WIND_INSTRUMENTS] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_PROF, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_PROFESSION] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_RIDE, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_RIDE] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_SENS_MOTV, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_SPEAK_LANGUAGE] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_SPK_LANG, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_KNOWLEDGE_LOCAL] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_SWIM, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_SWIM] += 3;
            if (script.GetHasFeat((int)FEATS.FEAT_SKILL_FOCUS_USE_ROPE, m_oCreature, 1) == CLRScriptBase.TRUE) skillBonuses[(int)SKILLS.SKILL_USE_ROPE] += 3;
            #endregion

            // Artist is one bad-ass feat.
            if (script.GetHasFeat(CLRScriptBase.FEAT_ARTIST, m_oCreature, 1) == CLRScriptBase.TRUE)
            {
                // Previously: +2 perform, +2 diplomacy
                // Currently: +2 perform (all), 3 extra bardic music uses per day
                skillBonuses[CLRScriptBase.SKILL_DIPLOMACY] -= 2;
                skillBonuses[(int)SKILLS.SKILL_PERFORM_ACT] += 2;
                skillBonuses[(int)SKILLS.SKILL_PERFORM_COMEDY] += 2;
                skillBonuses[(int)SKILLS.SKILL_PERFORM_DANCE] += 2;
                skillBonuses[(int)SKILLS.SKILL_PERFORM_KEYBOARD] += 2;
                skillBonuses[(int)SKILLS.SKILL_PERFORM_ORATORY] += 2;
                skillBonuses[(int)SKILLS.SKILL_PERFORM_PERCUSSION] += 2;
                skillBonuses[(int)SKILLS.SKILL_PERFORM_SING] += 2;
                skillBonuses[(int)SKILLS.SKILL_PERFORM_STRING_INSTRUMENTS] += 2;
                skillBonuses[(int)SKILLS.SKILL_PERFORM_WIND_INSTRUMENTS] += 2;
            }

            // Add skill bonuses to item.
            foreach (int skill in skillBonuses.Keys)
            {
                if (skillBonuses[skill] == 0)
                {
                    continue;
                }
                else if (skillBonuses[skill] > 0)
                {
                    script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skill, skillBonuses[skill]), m_oHide, 0.0f);
                }
                else if (skillBonuses[skill] < 0)
                {
                    script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertyDecreaseSkill(skill, Math.Abs(skillBonuses[skill])), m_oHide, 0.0f);
                }
            }

            // Add save bonuses to item.
            foreach (int save in saveBonuses.Keys)
            {
                if (saveBonuses[save] == 0)
                {
                    continue;
                }
                else if (saveBonuses[save] > 0)
                {
                    script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrow(save, saveBonuses[save]), m_oHide, 0.0f);
                }
                else if (saveBonuses[save] < 0)
                {
                    script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertyReducedSavingThrow(save, Math.Abs(saveBonuses[save])), m_oHide, 0.0f);
                }
            }

            // Make the person equip the new item.
            script.AssignCommand(m_oCreature, delegate { script.ClearAllActions(CLRScriptBase.FALSE); });
            script.AssignCommand(m_oCreature, delegate { script.ActionEquipItem(m_oHide, CLRScriptBase.INVENTORY_SLOT_CARMOUR); });
            script.DestroyObject(oOldHide, 0.0f, CLRScriptBase.FALSE);
            script.SendMessageToPC(m_oCreature, "PC Hide refreshed.");

            // Everything looks fine, return our success.
            return true;
        }
        public static void Fire(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, uint specialTarget)
        {
            List<uint> targets = new List<uint>();
            if (s.GetIsObjectValid(specialTarget) == TRUE)
            {
                targets.Add(specialTarget);
            }
            foreach (uint contents in s.GetObjectsInPersistentObject(s.GetObjectByTag(trap.Tag, 0), OBJECT_TYPE_CREATURE, 0))
            {
                if (FitsTrapTargetRestriction(s, trap, contents))
                {
                    targets.Add(contents);
                }
            }

            if (targets.Count == 0)
            {
                // Might be that they all left. In any case
                // we have nothing to shoot
                trap.IsFiring = false;
                return;
            }
            uint target;
            if (targets.Count == 1)
            {
                target = targets[0];
            }
            else
            {
                target = targets[s.Random(targets.Count)];
            }

            uint caster;
            if (s.GetIsObjectValid(trap.TrapOrigin) == FALSE)
            {
                caster = s.GetObjectByTag(trap.Tag, 0);
            }
            else
            {
                caster = trap.TrapOrigin;
            }

            if (trap.SpellTrap)
            {
                // It's a spell-- guess this is simple.
                s.AssignCommand(caster, delegate { s.ActionCastSpellAtObject(trap.SpellId, target, METAMAGIC_NONE, TRUE, 0, 0, 1); });
            }
            else
            {
                foreach (uint victim in s.GetObjectsInShape(trap.EffectArea, trap.EffectSize, s.GetLocation(target), false, OBJECT_TYPE_CREATURE, s.GetPosition(caster)))
                {
                    s.ApplyEffectToObject(DURATION_TYPE_INSTANT, GetTrapEffect(s, trap, victim), victim, 0.0f);
                    _doSoloVFX(s, trap, victim);
                }
                _doGroupVFX(s, trap, s.GetLocation(target));
            }

            if (trap.NumberOfShots > -1)
            {
                if (trap.NumberOfShots < 2)
                {
                    TrapDisable.RemoveTrap(s, trap);
                    return;
                }
                else
                {
                    trap.NumberOfShots--;
                }
            }

            trap.IsFiring = true;
            s.DelayCommand(6.0f, delegate { Fire(s, trap); });
        }
예제 #4
0
        public static uint _SpawnObject(string sResRef, int nObjectType, uint oWP, NWLocation lLoc, int nFlags, int nAlternate, CLRScriptBase s)
        {
            // if the object is not being spawned at it's waypoint location, we need to make sure
            // the actual spawn-in location isn't violating the "in PC sight" guidelines.
            if ((nAlternate != CLRScriptBase.FALSE) && ((nFlags & _SPAWN_FLAGS_IN_PC_SIGHT) == 0))
            {
                uint oNeighbor = s.GetNearestCreatureToLocation(CLRScriptBase.CREATURE_TYPE_PLAYER_CHAR, CLRScriptBase.PLAYER_CHAR_IS_PC, lLoc, 1, -1, -1, -1, -1);
                if (s.GetIsObjectValid(oNeighbor) == CLRScriptBase.FALSE && (s.GetDistanceBetweenLocations(lLoc, s.GetLocation(oNeighbor)) <= PC_PERCEPTION_RANGE))
                { // ACR_GetPCVisualRange() )) {
                    return CLRScriptBase.OBJECT_INVALID;
                }
                if (GetPrespawnPrediction(s) == CLRScriptBase.FALSE)
                {
                    uint oTestWP = s.GetNearestObjectToLocation(CLRScriptBase.OBJECT_TYPE_WAYPOINT, lLoc, 1);
                    int nWP_Index = 1;
                    while ((oTestWP != CLRScriptBase.OBJECT_INVALID) && (s.GetDistanceBetweenLocations(lLoc, s.GetLocation(oTestWP)) <= PC_PERCEPTION_RANGE))
                    { // ACR_GetPC_VisualRange() )) {
                        if (s.GetTag(oTestWP) == "ACR_SA_WP")
                        {
                            return CLRScriptBase.OBJECT_INVALID;
                        }
                        else
                        {
                            nWP_Index = nWP_Index + 1;
                            oTestWP = s.GetNearestObjectToLocation(CLRScriptBase.OBJECT_TYPE_WAYPOINT, lLoc, nWP_Index);
                        }
                    }
                }
            }

            uint oSpawned = s.CreateObject(nObjectType, sResRef, lLoc, nFlags & _SPAWN_FLAGS_WITH_ANIMATION, "");

            // Check to make sure it spawned ok, print an error and exit if not.
            if (s.GetIsObjectValid(oSpawned) == CLRScriptBase.FALSE)
            {
                return CLRScriptBase.OBJECT_INVALID;
            }

            // If it should be in stealth mode, place it there.
            if ((nFlags & _SPAWN_IN_STEALTH) == _SPAWN_IN_STEALTH)
            {
                s.SetActionMode(oSpawned, CLRScriptBase.ACTION_MODE_STEALTH, 1);
            }

            // If it should be in detect mode, place it there.
            if ((nFlags & _SPAWN_IN_DETECT) == _SPAWN_IN_DETECT)
            {
                s.SetActionMode(oSpawned, CLRScriptBase.ACTION_MODE_DETECT, 1);
            }

            // If this creature should buff himself, do it.
            if ((nFlags & _SPAWN_BUFFED) == _SPAWN_BUFFED)
            {
                ActivateLongTermBuffs(oSpawned, s);
            }

            // Play the spawn animation.
            s.PlayAnimation(s.GetLocalInt(oWP, _WP_SPAWN_ANIMATION), 1.0f, 0.0f);

            // Play the spawn in VFX.
            s.ApplyEffectAtLocation(CLRScriptBase.DURATION_TYPE_INSTANT, s.EffectVisualEffect(s.GetLocalInt(oWP, _WP_SPAWN_IN_VFX), CLRScriptBase.FALSE), s.GetLocation(oSpawned), 0.0f);

            // Play the spawn in SFX.
            s.AssignCommand(oSpawned, delegate { s.PlaySound(s.GetLocalString(oWP, _WP_SPAWN_IN_SFX), CLRScriptBase.FALSE); });

            // Determine facing.
            if ((nFlags & _SPAWN_FLAGS_RANDOM_FACING) == _SPAWN_FLAGS_RANDOM_FACING)
            {
                // Spawn facing is random.
                s.AssignCommand(oSpawned, delegate { s.SetFacing(new Random().Next() * 360.0f, CLRScriptBase.FALSE); });
            }

            // Colorize name if needed.
            if (s.GetLocalString(oSpawned, ACR_COLOR_NAME) != "")
            {
                s.SetFirstName(oSpawned, "<C='" + s.GetLocalString(oSpawned, ACR_COLOR_NAME) + "'>" + s.GetName(oSpawned) + "</C>");
                s.SetLastName(oSpawned, "");
            }

            // Run the spawn-in scripts, if any.
            int i = 1;
            while (true)
            {
                string sScript = s.GetLocalString(oWP, _WP_SPAWN_IN_SCRIPT_ARRAY + s.IntToString(i));
                if (sScript == "")
                {
                    break;
                }
                s.ExecuteScript(sScript, oSpawned);
                i++;
            }

            _AddObjectToSpawnPoint(oWP, oSpawned, s);

            return oSpawned;
        }
예제 #5
0
 public static void _QuickBuff(uint oCaster, int nSpell, CLRScriptBase s, uint oTarget = CLRScriptBase.OBJECT_INVALID)
 {
     if (oTarget == CLRScriptBase.OBJECT_INVALID) oTarget = oCaster;
     s.AssignCommand(oCaster, delegate { s.ActionCastSpellAtObject(nSpell, oCaster, CLRScriptBase.METAMAGIC_ANY, CLRScriptBase.FALSE, 0, CLRScriptBase.PROJECTILE_PATH_TYPE_DEFAULT, CLRScriptBase.TRUE); });
 }
예제 #6
0
        public static void MountHorse(CLRScriptBase script, uint Character, uint Horse)
        {
            if (!isWarhorse.ContainsKey(Character)) isWarhorse.Add(Character, true);

            string cloakResRef;
            switch(script.GetTag(Horse))
            {
                case "abr_cr_an_horse01":
                    cloakResRef = "acr_ooc_horse01";
                    isWarhorse[Character] = true;
                    break;
                case "abr_cr_an_horse02":
                    cloakResRef = "acr_ooc_horse02";
                    isWarhorse[Character] = true;
                    break;
                case "abr_cr_an_horse03":
                    cloakResRef = "acr_ooc_horse03";
                    isWarhorse[Character] = true;
                    break;
                default:
                    cloakResRef = "acr_ooc_horse03";
                    isWarhorse[Character] = true;
                    break;
            }
            
            uint horseCloak = script.CreateItemOnObject(cloakResRef, Character, 1, "", CLRScriptBase.FALSE);
            if (script.GetLocalInt(Horse, ACR_IS_WARHORSE) == 1)
            {
                script.RemoveHenchman(Character, Horse);
                script.SetLocalInt(horseCloak, ACR_IS_WARHORSE, 1);
            }
            script.SetLocalInt(horseCloak, ACR_HORSE_ID, script.GetLocalInt(Horse, ACR_HORSE_ID));
            script.SetLocalInt(horseCloak, ACR_HORSE_HP, script.GetCurrentHitPoints(Horse));

            uint equippedCloak = script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CLOAK, Character);
            
            if (script.GetIsObjectValid(equippedCloak) == CLRScriptBase.TRUE)
            {
                foreach (NWItemProperty prop in script.GetItemPropertiesOnItem(equippedCloak))
                {
                    // copying property duration type prevents us from turning temporary properties into
                    // permanent ones. But because we don't know how long the non-permanent ones have left,
                    // we pretty much have to assign them with the expectation that they immediately expire.
                    script.AddItemProperty(script.GetItemPropertyDurationType(prop), prop, horseCloak, 0.0f);
                }
                script.SetFirstName(horseCloak, script.GetName(equippedCloak) + "(( Horse Appearance ))");
                script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertyWeightReduction(CLRScriptBase.IP_CONST_REDUCEDWEIGHT_80_PERCENT), horseCloak, 0.0f);
            }
            script.SetPlotFlag(horseCloak, CLRScriptBase.TRUE);
            script.SetPlotFlag(Horse, CLRScriptBase.FALSE);
            
            script.AssignCommand(Horse, delegate { script.SetIsDestroyable(CLRScriptBase.TRUE, CLRScriptBase.FALSE, CLRScriptBase.FALSE); });
            script.AssignCommand(Horse, delegate { script.DestroyObject(Horse, 0.0f, CLRScriptBase.FALSE); });
            script.AssignCommand(Character, delegate { script.ActionEquipItem(horseCloak, CLRScriptBase.INVENTORY_SLOT_CLOAK); });

            if (!isWarhorse[Character]) script.DelayCommand(6.0f, delegate { RidingHeartbeat(script, Character); });
        }