Пример #1
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); });
        }
Пример #2
0
 public static void LoadAreas(CLRScriptBase s)
 {
     if (!ACR_Candlekeep.ArchivesInstance.WaitForResourcesLoaded(false))
     {
         s.DelayCommand(6.0f, delegate { LoadAreas(s); });
         return;
     }
     ALFA.Shared.Modules.InfoStore.ActiveAreas = new Dictionary<uint, ALFA.Shared.ActiveArea>();
     List<uint> areas = new List<uint>();
     foreach (uint area in s.GetAreas())
     {
         ALFA.Shared.ActiveArea activeArea = new ALFA.Shared.ActiveArea();
         activeArea.Id = area;
         activeArea.Name = s.GetName(area).Trim();
         activeArea.Tag = s.GetTag(area);
         activeArea.GlobalQuests.Add("Infestation", s.GetLocalInt(area, "ACR_QST_MAX_INFESTATION"));
         ALFA.Shared.Modules.InfoStore.ActiveAreas.Add(area, activeArea);
         areas.Add(area);
     }
     int count = 0;
     foreach(KeyValuePair<string, string> keyValue in ALFA.Shared.Modules.InfoStore.AreaNames)
     {
         ALFA.Shared.Modules.InfoStore.ActiveAreas[areas[count]].LocalizedName = keyValue.Value;
         ALFA.Shared.Modules.InfoStore.ActiveAreas[areas[count]].ConfigureDisplayName();
         s.SetLocalString(areas[count], "ACR_AREA_RESREF", keyValue.Key);
         count++;
     }
     foreach (ALFA.Shared.ActiveArea activeArea in ALFA.Shared.Modules.InfoStore.ActiveAreas.Values)
     {
         foreach (uint thing in s.GetObjectsInArea(activeArea.Id))
         {
             uint target = s.GetTransitionTarget(thing);
             if (s.GetIsObjectValid(target) != FALSE)
             {
                 ALFA.Shared.ActiveTransition activeTransition = new ALFA.Shared.ActiveTransition();
                 activeTransition.AreaTarget = ALFA.Shared.Modules.InfoStore.ActiveAreas[s.GetArea(target)];
                 activeTransition.Id = thing;
                 activeTransition.Target = target;
                 activeArea.ExitTransitions.Add(activeTransition, activeTransition.AreaTarget);
             }
         }
     }
 }
Пример #3
0
        public static void CalculatePrice(CLRScriptBase script, uint target)
        {
            #region Reject to Price Objects Which Can't or Shouldn't be Priced
            if (script.GetObjectType(target) != OBJECT_TYPE_ITEM)
            {
                return;
            }

            int itemType = script.GetBaseItemType(target);
            if (GetIsOOCItem(itemType))
            {
                return;
            }
            #endregion

            #region Find out What the Item Should be Worth
            int targetValue = 0;
            if (GetIsWeapon(itemType) || GetIsAmmunition(itemType))
            {
                targetValue = GetWeaponPrice(script, target);
            }
            else if (GetIsArmor(itemType))
            {
                targetValue = GetArmorPrice(script, target);
            }
            else
            {
                targetValue = GetWonderousPrice(script, target);
            }
            #endregion

            #region Early Return for Illegal and Custom-Scripted Items
            if (targetValue == -1)
            {
                // We can't price this item, because it's illegal.
                script.SetFirstName(target, "(Illegal) " + script.GetName(target));
                return;
            }
            else if (targetValue == -2)
            {
                return;
            }
            #endregion

            #region Determine if the Item Requires Adjustment, and Adjust if Necessary
            bool isPlot = false;
            bool isUnidentified = false;
            if (script.GetLocalInt(target, localVarName) == pricingVersion)
            {
                // We've already used this logic to price this item. We have nothing to add.
                return;
            }
            if (script.GetPlotFlag(target) == TRUE)
            {
                script.SetPlotFlag(target, FALSE);
                isPlot = true;
            }
            if (script.GetIdentified(target) == FALSE)
            {
                script.SetIdentified(target, TRUE);
                isUnidentified = true;
            }
            int currentValue = script.GetGoldPieceValue(target);
            if (script.GetItemStackSize(target) > 1)
            {
                currentValue /= script.GetItemStackSize(target);
            }
            if (currentValue != targetValue)
            {
                script.StoreCampaignObject(ItemChangeDBName, PriceChangeVarName, target, script.OBJECT_SELF);
                if (ALFA.Shared.Modules.InfoStore.ModifiedGff.Keys.Contains(PriceChangeVarName))
                {
                    if (ALFA.Shared.Modules.InfoStore.ModifiedGff[PriceChangeVarName].TopLevelStruct["ModifyCost"].ValueInt == 0 ||
                        targetValue > currentValue ||
                        script.GetLocalInt(target, localVarName) != 0)
                    {
                        // We only want to adjust the price if either a) no effort to control the item's price has been made or
                        // b) the item is actually less valuable than the current price reads. Artificial inflations of price are
                        // legal in ALFA.

                        // Also, if this item was priced automatically, we want to be able to correct it.
                        script.SetLocalInt(target, localVarName, pricingVersion);
                        AdjustPrice(script, target, targetValue - currentValue);
                    }
                }
            }
            if (isPlot)
            {
                script.SetPlotFlag(target, TRUE);
            }
            if (isUnidentified)
            {
                script.SetIdentified(target, FALSE);
            }
            #endregion
        }
Пример #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 uint SpawnCreature(string sResRef, CLRScriptBase s)
 {
     return _SpawnObject(sResRef, CLRScriptBase.OBJECT_TYPE_CREATURE, s.OBJECT_SELF, s.GetLocation(s.OBJECT_SELF), s.GetLocalInt(s.OBJECT_SELF, _SPAWN_FLAGS), CLRScriptBase.FALSE, s);
 }
Пример #6
0
        public static void _AddObjectToSpawnPoint(uint oWP, uint oObject, CLRScriptBase s)
        {
            int i;

            // Add this creature to the list of creatures spawned from this waypoint and
            // area.

            i = s.GetLocalInt(oWP, _SPAWNED_OBJECT_ARRAY_LENGTH);
            SetLocalArrayObject(oWP, _SPAWNED_OBJECT_ARRAY, i, oObject, s);
            s.SetLocalInt(oWP, _SPAWNED_OBJECT_ARRAY_LENGTH, i + 1);

            // Add a pointer back to the waypoint, for death reporting.
            s.SetLocalObject(oObject, _SPAWN_PARENT_WP, oWP);
        }
Пример #7
0
 private static void SwimHeartbeat(CLRScriptBase script, uint Creature)
 {
     uint Trigger = AppearanceTypes.currentSwimTrigger[Creature];
     foreach(uint contents in script.GetObjectsInPersistentObject(Trigger, CLRScriptBase.OBJECT_TYPE_CREATURE, CLRScriptBase.PERSISTENT_ZONE_ACTIVE))
     {
         if(contents == Creature)
         {
             if (script.GetSubRace(Creature) != CLRScriptBase.RACIAL_SUBTYPE_WATER_GENASI &&
                 script.GetLocalInt(Creature, ACR_CREATURE_AQUATIC) == 0)
             {
                 int SwimDC = script.GetLocalInt(Trigger, ACR_SWIM_DC);
                 int SinkDC = SwimDC - 5;
                 int NoAir = script.GetLocalInt(Trigger, ACR_NO_AIR);
                 int Roll = script.d20(1);
                 int Bonus = script.GetSkillRank(CLRScriptBase.SKILL_SWIM, Creature, CLRScriptBase.FALSE);
                 ProcessWaterEffects(script, Creature, Trigger);
                 if (10 + Bonus >= SwimDC)
                 {
                     // Can take 10 here.
                     Roll = 10;
                 }
                 if (Roll + Bonus >= SwimDC)
                 {
                     script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectMovementSpeedDecrease(50)), Creature, 6.0f);
                     script.SendMessageToPC(Creature, String.Format("*Swim: {0} + {1} = {2} v. DC {3} :: Success!*", Roll, Bonus, Roll+Bonus, SwimDC));
                     if(NoAir == CLRScriptBase.FALSE)
                     {
                         CurrentDrownStatus.Remove(Creature);
                         CurrentDrownDC.Remove(Creature);
                     }
                     else
                     {
                         ProcessNoAir(script, Creature);
                     }
                 }
                 else if (Roll + Bonus >= SinkDC)
                 {
                     script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectMovementSpeedDecrease(75)), Creature, 6.0f);
                     script.SendMessageToPC(Creature, String.Format("*Swim: {0} + {1} = {2} v. DC {3} :: Failure!*", Roll, Bonus, Roll + Bonus, SwimDC));
                     script.SendMessageToPC(Creature, String.Format("You struggle to move through the water."));
                     if (NoAir == CLRScriptBase.FALSE)
                     {
                         CurrentDrownStatus.Remove(Creature);
                         CurrentDrownDC.Remove(Creature);
                     }
                     else
                     {
                         ProcessNoAir(script, Creature);
                     }
                 }
                 else
                 {
                     script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectMovementSpeedDecrease(75)), Creature, 6.0f);
                     // TODO: Find a way to apply this penalty without completely screwing the PC's AC.
                     //script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectACDecrease(2, CLRScriptBase.AC_DODGE_BONUS, CLRScriptBase.DAMAGE_TYPE_ALL)), Creature, 6.0f);
                     script.SendMessageToPC(Creature, String.Format("*Swim: {0} + {1} = {2} v. DC {3} :: Failure!*", Roll, Bonus, Roll + Bonus, SwimDC));
                     script.SendMessageToPC(Creature, String.Format("You're completely overwhelmed by the pull of the water!"));
                     ProcessNoAir(script, Creature);
                 }
             }
             else
             {
                 script.SendMessageToPC(Creature, "Your swim speed and capacity to breathe water allows you to move easily through the water.");
                 return;
             }
             script.DelayCommand(6.0f, delegate { SwimHeartbeat(script, Creature); });
             return;
         }
     }
     AppearanceTypes.currentSwimTrigger[Creature] = CLRScriptBase.OBJECT_INVALID;
     AppearanceTypes.characterMovement[Creature] = AppearanceTypes.MovementType.Walking;
     if (Swimming.CurrentDrownStatus.ContainsKey(Creature)) Swimming.CurrentDrownStatus.Remove(Creature);
     AppearanceTypes.RecalculateMovement(script, Creature);
 }
Пример #8
0
 public static uint GetOwnershipItemById(CLRScriptBase script, uint Character, int HorseId)
 {
     uint item = script.GetFirstItemInInventory(Character);
     while(script.GetIsObjectValid(item) == CLRScriptBase.TRUE)
     {
         if(script.GetLocalInt(item, ACR_HORSE_ID) == HorseId)
         {
             return item;
         }
         item = script.GetNextItemInInventory(Character);
     }
     return CLRScriptBase.OBJECT_INVALID;
 }
Пример #9
0
        public static void Dismount(CLRScriptBase script, uint Character, uint Cloak, NWLocation Location)
        {
            string resRef = "";
            if (script.GetLocalInt(Cloak, ACR_IS_WARHORSE) == 1)
            {
                resRef = "abr_cr_an_horse_pal_";
                int nPalLevel = script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_PALADIN, Character);
                if (nPalLevel >= 15) resRef += "15";
                else if (nPalLevel >= 11) resRef += "11";
                else if (nPalLevel >= 8) resRef += "8";
                else if (nPalLevel >= 5) resRef += "5";
                else resRef = "abr_cr_an_horse03";
            }
            else
            {
                switch (script.GetTag(Cloak))
                {
                    case "acr_ooc_horse01":
                        resRef = "abr_cr_an_horse01";
                        break;
                    case "acr_ooc_horse02":
                        resRef = "abr_cr_an_horse02";
                        break;
                    case "acr_ooc_horse03":
                        resRef = "abr_cr_an_horse03";
                        break;
                    default:
                        // Looks like we're not actually dismounting a horse.
                        return;
                }
            }
            
            uint Horse = script.CreateObject(CLRScriptBase.OBJECT_TYPE_CREATURE, resRef, Location, CLRScriptBase.FALSE, "");
            script.SetLocalInt(Horse, ACR_HORSE_OWNER, script.GetLocalInt(Character, ACR_CID));
            script.SetLocalInt(Horse, ACR_HORSE_ID, script.GetLocalInt(Cloak, ACR_HORSE_ID));
            int damage = script.GetCurrentHitPoints(Horse) - script.GetLocalInt(Cloak, ACR_HORSE_HP);
            if(damage > 0)
            {
                script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_INSTANT, script.EffectDamage(damage, CLRScriptBase.DAMAGE_TYPE_MAGICAL, CLRScriptBase.DAMAGE_POWER_PLUS_TWENTY, CLRScriptBase.TRUE), Horse, 0.0f);
            }
            if (script.GetLocalInt(Cloak, ACR_IS_WARHORSE) == 1)
            {
                script.AddHenchman(Character, Horse);
                script.SetLocalInt(Horse, ACR_IS_WARHORSE, 1);
                script.SetLocalObject(Character, ACR_PAL_WARHORSE, Horse);
            }

            uint Item = GetOwnershipItemById(script, Character, script.GetLocalInt(Cloak, ACR_HORSE_ID));
            script.SetLocalObject(Item , ACR_HORSE_OBJECT, Horse);
            script.SetLocalObject(Horse, ACR_HORSE_OBJECT, Character);

            script.SetLocalString(Item, ACR_HORSE_PERS_LOC_AREA, script.GetTag(script.GetArea(Horse)));
            script.SetLocalFloat(Item, ACR_HORSE_PERS_LOC_X, script.GetPosition(Horse).x);
            script.SetLocalFloat(Item, ACR_HORSE_PERS_LOC_Y, script.GetPosition(Horse).y);
            script.SetLocalFloat(Item, ACR_HORSE_PERS_LOC_Z, script.GetPosition(Horse).z);

            script.SetPlotFlag(Cloak, CLRScriptBase.FALSE);
            script.DestroyObject(Cloak, 0.0f, CLRScriptBase.FALSE);
            isWarhorse.Remove(Character);
        }