예제 #1
0
        public void Run(NWObject target, params object[] args)
        {
            int             roll        = RandomService.Random(0, 100);
            ResourceQuality quality     = ResourceQuality.Low;
            string          qualityName = "Low Quality";

            const int NormalQualityChance   = 20;
            const int HighQualityChance     = 10;
            const int VeryHighQualityChance = 2;

            var dbArea  = DataService.Single <Area>(x => x.Resref == target.Area.Resref);
            int tier    = dbArea.ResourceQuality;
            int maxTier = dbArea.MaxResourceQuality;

            if (tier <= 0)
            {
                Console.WriteLine("WARNING: Area '" + target.Area.Name + "' has resources but the RESOURCE_QUALITY variable is not set. Edit the area properties and add this value to set up resources.");
                return;
            }

            if (roll <= VeryHighQualityChance)
            {
                quality     = ResourceQuality.VeryHigh;
                qualityName = "Very High Quality";
            }
            else if (roll <= HighQualityChance)
            {
                quality     = ResourceQuality.High;
                qualityName = "High Quality";
            }
            else if (roll <= NormalQualityChance)
            {
                quality     = ResourceQuality.Normal;
                qualityName = "Normal Quality";
            }


            roll = RandomService.Random(0, 100);
            if (roll <= 2)
            {
                tier++;
            }

            if (tier > 10)
            {
                tier = 10;
            }

            if (tier > maxTier)
            {
                tier = maxTier;
            }

            target.SetLocalInt("RESOURCE_QUALITY", (int)quality);
            target.SetLocalInt("RESOURCE_TIER", tier);
            target.SetLocalInt("RESOURCE_COUNT", RandomService.Random(3, 10));
            target.SetLocalString("RESOURCE_RESREF", GetResourceResref(tier));
            target.SetLocalString("RESOURCE_QUALITY_NAME", qualityName);
        }
        public void CopyVariables(NWObject oSource, NWObject oCopy)
        {
            int variableCount = _nwnxObject.GetLocalVariableCount(oSource);

            for (int variableIndex = 0; variableIndex < variableCount - 1; variableIndex++)
            {
                LocalVariable stCurVar = _nwnxObject.GetLocalVariable(oSource, variableIndex);

                switch (stCurVar.Type)
                {
                case LocalVariableType.Int:
                    oCopy.SetLocalInt(stCurVar.Key, oSource.GetLocalInt(stCurVar.Key));
                    break;

                case LocalVariableType.Float:
                    oCopy.SetLocalFloat(stCurVar.Key, oSource.GetLocalFloat(stCurVar.Key));
                    break;

                case LocalVariableType.String:
                    oCopy.SetLocalString(stCurVar.Key, oSource.GetLocalString(stCurVar.Key));
                    break;

                case LocalVariableType.Object:
                    oCopy.SetLocalObject(stCurVar.Key, oSource.GetLocalObject(stCurVar.Key));
                    break;

                case LocalVariableType.Location:
                    oCopy.SetLocalLocation(stCurVar.Key, oSource.GetLocalLocation(stCurVar.Key));
                    break;
                }
            }
        }
예제 #3
0
        public void JumpPCToBuildingInterior(NWPlayer player, NWArea area)
        {
            NWObject exit = null;

            NWObject @object = (_.GetFirstObjectInArea(area.Object));

            while (@object.IsValid)
            {
                if (@object.Tag == "building_exit")
                {
                    exit = @object;
                }

                @object = (_.GetNextObjectInArea(area.Object));
            }

            if (exit == null)
            {
                player.FloatingText("ERROR: Couldn't find the building interior's exit. Inform an admin of this issue.");
                return;
            }

            _player.SaveLocation(player);

            exit.SetLocalLocation("PLAYER_HOME_EXIT_LOCATION", player.Location);
            exit.SetLocalInt("IS_BUILDING_DOOR", 1);

            Location location = area.GetLocalLocation("INSTANCE_ENTRANCE");

            player.AssignCommand(() =>
            {
                _.ActionJumpToLocation(location);
            });
        }
예제 #4
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            if (currentTick % 2 == 0)
            {
                return;
            }

            Location    location = oTarget.Location;
            NWPlaceable oBlood   = (_.CreateObject(ObjectType.Placeable, "plc_bloodstain", location));

            oBlood.Destroy(48.0f);

            int amount = 1;

            if (!string.IsNullOrWhiteSpace(data))
            {
                amount = Convert.ToInt32(data);
            }

            oTarget.SetLocalInt(AbilityService.LAST_ATTACK + oCaster.GlobalID, AbilityService.ATTACK_DOT);

            oCaster.AssignCommand(() =>
            {
                Effect damage = _.EffectDamage(amount);
                _.ApplyEffectToObject(DurationType.Instant, damage, oTarget.Object);
            });
        }
예제 #5
0
        private static void OnStoreOpened()
        {
            NWObject store            = Object.OBJECT_SELF;
            int      playersAccessing = store.GetLocalInt("STORE_SERVICE_PLAYERS_ACCESSING") + 1;

            store.SetLocalInt("STORE_SERVICE_PLAYERS_ACCESSING", playersAccessing);
        }
예제 #6
0
        private static void OnHitCastSpell()
        {
            NWPlayer oPC = Object.OBJECT_SELF;

            if (!oPC.IsValid)
            {
                return;
            }

            NWObject oTarget = _.GetSpellTargetObject();
            NWItem   oItem   = _.GetSpellCastItem();

            // If this method was triggered by our own armor (from getting hit), return.
            if (oItem.BaseItemType == BASE_ITEM_ARMOR)
            {
                return;
            }

            // Flag this attack as physical so that the damage scripts treat it properly.
            LoggingService.Trace(TraceComponent.LastAttack, "Setting attack type from " + oPC.GlobalID + " against " + _.GetName(oTarget) + " to physical (" + ATTACK_PHYSICAL.ToString() + ")");
            oTarget.SetLocalInt(LAST_ATTACK + oPC.GlobalID, ATTACK_PHYSICAL);

            HandleGrenadeProficiency(oPC, oTarget);
            HandlePlasmaCellPerk(oPC, oTarget);
            int activeWeaponSkillID = oPC.GetLocalInt("ACTIVE_WEAPON_SKILL");

            if (activeWeaponSkillID <= 0)
            {
                return;
            }
            int activeWeaponSkillFeatID = oPC.GetLocalInt("ACTIVE_WEAPON_SKILL_FEAT_ID");

            if (activeWeaponSkillFeatID < 0)
            {
                activeWeaponSkillFeatID = -1;
            }

            PCPerk entity  = DataService.GetAll <PCPerk>().Single(x => x.PlayerID == oPC.GlobalID && x.PerkID == activeWeaponSkillID);
            var    perk    = DataService.Get <Data.Entity.Perk>(entity.PerkID);
            var    handler = PerkService.GetPerkHandler(activeWeaponSkillID);

            if (handler.CanCastSpell(oPC, oTarget))
            {
                handler.OnImpact(oPC, oTarget, entity.PerkLevel, activeWeaponSkillFeatID);

                if (oTarget.IsNPC)
                {
                    ApplyEnmity(oPC, oTarget.Object, perk);
                }
            }
            else
            {
                oPC.SendMessage(handler.CannotCastSpellMessage(oPC, oTarget) ?? "That ability cannot be used at this time.");
            }

            oPC.DeleteLocalString("ACTIVE_WEAPON_SKILL_UUID");
            oPC.DeleteLocalInt("ACTIVE_WEAPON_SKILL");
            oPC.DeleteLocalInt("ACTIVE_WEAPON_SKILL_FEAT_ID");
        }
예제 #7
0
        public void Run(NWObject target, params object[] args)
        {
            var dbArea = DataService.Area.GetByResref(target.Area.Resref);
            int tier   = dbArea.ResourceQuality;

            if (tier <= 0)
            {
                Console.WriteLine("WARNING: Area '" + target.Area.Name + "' has resources but the RESOURCE_QUALITY variable is not set. Edit the area properties and add this value to set up resources.");
                return;
            }

            int difficulty = ((tier - 1) * 5) + 1;
            int lootTable  = tier;

            target.SetLocalInt("SCAVENGE_POINT_LEVEL", difficulty);
            target.SetLocalInt("SCAVENGE_POINT_LOOT_TABLE_ID", lootTable);
        }
        public void Main()
        {
            // Check for timeout.  Refresh every game hour.
            NWObject self  = NWGameObject.OBJECT_SELF;
            int      hour  = self.GetLocalInt("HOUR");
            int      day   = self.GetLocalInt("DAY");
            int      month = self.GetLocalInt("MONTH");
            int      year  = self.GetLocalInt("YEAR");

            if (_.GetTimeHour() > hour || _.GetCalendarDay() > day || _.GetCalendarMonth() > month || _.GetCalendarYear() > year)
            {
                SpaceService.CreateSpaceEncounter(NWGameObject.OBJECT_SELF, (NWPlayer)_.GetEnteringObject());
                self.SetLocalInt("HOUR", _.GetTimeHour());
                self.SetLocalInt("DAY", _.GetCalendarDay());
                self.SetLocalInt("MONTH", _.GetCalendarMonth());
                self.SetLocalInt("YEAR", _.GetCalendarYear());
            }
        }
예제 #9
0
 public static void SetActiveLanguage(NWObject obj, SkillType language)
 {
     if (language == SkillType.Basic)
     {
         obj.DeleteLocalInt("ACTIVE_LANGUAGE");
     }
     else
     {
         obj.SetLocalInt("ACTIVE_LANGUAGE", (int)language);
     }
 }
예제 #10
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            if (currentTick % 2 != 0) return;
            int damage = RandomService.D4(1);
            oTarget.SetLocalInt(AbilityService.LAST_ATTACK + oCaster.GlobalID, AbilityService.ATTACK_DOT);

            oCaster.AssignCommand(() =>
            {
                _.ApplyEffectToObject(DurationType.Instant, _.EffectDamage(damage, DamageType.Divine), oTarget);
            });
            
        }
예제 #11
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            int damage = Convert.ToInt32(data);

            oTarget.SetLocalInt(AbilityService.LAST_ATTACK + oCaster.GlobalID, AbilityService.ATTACK_DOT);

            oCaster.AssignCommand(() =>
            {
                Effect effect = _.EffectDamage(damage, DamageType.Electrical);
                _.ApplyEffectToObject(DurationType.Instant, effect, oTarget);
            });
        }
예제 #12
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            int damage = Convert.ToInt32(data);

            oTarget.SetLocalInt(AbilityService.LAST_ATTACK + oCaster.GlobalID, AbilityService.ATTACK_DOT);

            oCaster.AssignCommand(() =>
            {
                Effect effect = _.EffectDamage(damage, DAMAGE_TYPE_ELECTRICAL);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, effect, oTarget);
            });
        }
예제 #13
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            AbilityService.EndConcentrationEffect(oCaster);

            NWPlayer player   = oTarget.Object;
            int      restTick = oTarget.GetLocalInt("REST_TICK") + 1;


            // Pull original position from data
            string[] values           = data.Split(',');
            Vector   originalPosition = _.Vector
                                        (
                Convert.ToSingle(values[0]),
                Convert.ToSingle(values[1]),
                Convert.ToSingle(values[2])
                                        );

            // Check position
            Vector position = player.Position;

            if ((Math.Abs(position.m_X - originalPosition.m_X) > 0.01f ||
                 Math.Abs(position.m_Y - originalPosition.m_Y) > 0.01f ||
                 Math.Abs(position.m_Z - originalPosition.m_Z) > 0.01f) ||
                !CanRest(player) ||
                !player.IsValid)
            {
                player.IsBusy = false;
                CustomEffectService.RemovePCCustomEffect(player, CustomEffectType.Rest);
                return;
            }

            player.IsBusy = true;

            player.AssignCommand(() =>
            {
                _.ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0f, 6.1f);
            });

            if (restTick >= 6)
            {
                int amount = CalculateAmount(player);

                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(amount), player);
                Effect vfx = _.EffectVisualEffect(VFX_IMP_HEAD_HOLY);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, vfx, player);
                restTick = 0;
            }

            oTarget.SetLocalInt("REST_TICK", restTick);
        }
예제 #14
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            AbilityService.EndConcentrationEffect(oCaster);

            NWPlayer player   = oTarget.Object;
            int      restTick = oTarget.GetLocalInt("REST_TICK") + 1;


            // Pull original position from data
            string[] values           = data.Split(',');
            Vector3  originalPosition = _.Vector3
                                        (
                Convert.ToSingle(values[0]),
                Convert.ToSingle(values[1]),
                Convert.ToSingle(values[2])
                                        );

            // Check position
            Vector3 position = player.Position;

            if ((Math.Abs(position.X - originalPosition.X) > 0.01f ||
                 Math.Abs(position.Y - originalPosition.Y) > 0.01f ||
                 Math.Abs(position.Z - originalPosition.Z) > 0.01f) ||
                !CanRest(player) ||
                !player.IsValid)
            {
                player.IsBusy = false;
                CustomEffectService.RemovePCCustomEffect(player, CustomEffectType.Rest);
                return;
            }

            player.IsBusy = true;

            player.AssignCommand(() =>
            {
                _.ActionPlayAnimation(Animation.LoopingSitCross, 1.0f, 6.1f);
            });

            if (restTick >= 6)
            {
                int amount = CalculateAmount(player);

                _.ApplyEffectToObject(DurationType.Instant, _.EffectHeal(amount), player);
                Effect vfx = _.EffectVisualEffect(VisualEffect.Vfx_Imp_Head_Holy);
                _.ApplyEffectToObject(DurationType.Instant, vfx, player);
                restTick = 0;
            }

            oTarget.SetLocalInt("REST_TICK", restTick);
        }
예제 #15
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            if (currentTick % 2 != 0)
            {
                return;
            }
            int damage = RandomService.D4(1);

            oTarget.SetLocalInt(AbilityService.LAST_ATTACK + oCaster.GlobalID, AbilityService.ATTACK_DOT);
            oCaster.AssignCommand(() =>
            {
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectDamage(damage, DAMAGE_TYPE_ACID), oTarget);
            });
        }
예제 #16
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            NWPlayer player       = oTarget.Object;
            int      meditateTick = oTarget.GetLocalInt("MEDITATE_TICK") + 1;

            // Pull original position from data
            string[] values           = data.Split(',');
            Vector   originalPosition = _.Vector
                                        (
                Convert.ToSingle(values[0]),
                Convert.ToSingle(values[1]),
                Convert.ToSingle(values[2])
                                        );

            // Check position
            Vector position = player.Position;

            if ((Math.Abs(position.m_X - originalPosition.m_X) > 0.01f ||
                 Math.Abs(position.m_Y - originalPosition.m_Y) > 0.01f ||
                 Math.Abs(position.m_Z - originalPosition.m_Z) > 0.01f) ||
                !CanMeditate(player) ||
                !player.IsValid)
            {
                player.IsBusy = false;
                _customEffect.RemovePCCustomEffect(player, CustomEffectType.Meditate);
                return;
            }

            player.IsBusy = true;

            player.AssignCommand(() =>
            {
                _.ActionPlayAnimation(ANIMATION_LOOPING_MEDITATE, 1.0f, 6.1f);
            });

            if (meditateTick >= 6)
            {
                int amount = CalculateAmount(player);

                _ability.RestoreFP(player, amount);
                Effect vfx = _.EffectVisualEffect(VFX_IMP_HEAD_MIND);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, vfx, player);
                meditateTick = 0;
            }

            oTarget.SetLocalInt("MEDITATE_TICK", meditateTick);
        }
예제 #17
0
        private static void OnStoreClosed()
        {
            NWObject store            = Object.OBJECT_SELF;
            int      playersAccessing = store.GetLocalInt("STORE_SERVICE_PLAYERS_ACCESSING") - 1;

            if (playersAccessing <= 0)
            {
                playersAccessing = 0;
                // We don't want to immediately clean it,
                // to give players a grace period to come back and buy back something they mistakenly sold.
                // So we'll track the current timestamp and later check it on the heartbeat event.
                DateTime now       = DateTime.UtcNow;
                string   nowString = now.ToString(CultureInfo.InvariantCulture);
                store.SetLocalString("STORE_SERVICE_LAST_CLOSE_DATE", nowString);
            }
            store.SetLocalInt("STORE_SERVICE_PLAYERS_ACCESSING", playersAccessing);
        }
예제 #18
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            Random random = new Random();
            int    amount = random.Next(1, 2);

            oTarget.SetLocalInt(AbilityService.LAST_ATTACK + oCaster.GlobalID, AbilityService.ATTACK_DOT);

            oCaster.AssignCommand(() =>
            {
                Effect damage = _.EffectDamage(amount, _.DAMAGE_TYPE_FIRE);
                _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, damage, oTarget.Object);
            });

            Effect vfx = _.EffectVisualEffect(_.VFX_COM_HIT_FIRE);

            _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, vfx, oTarget.Object);
        }
예제 #19
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            Random random = new Random();
            int    amount = random.Next(1, 2);

            oTarget.SetLocalInt(AbilityService.LAST_ATTACK + oCaster.GlobalID, AbilityService.ATTACK_DOT);

            oCaster.AssignCommand(() =>
            {
                Effect damage = _.EffectDamage(amount, DamageType.Fire);
                _.ApplyEffectToObject(DurationType.Instant, damage, oTarget.Object);
            });

            Effect vfx = _.EffectVisualEffect(VisualEffect.Vfx_Com_Hit_Fire);

            _.ApplyEffectToObject(DurationType.Instant, vfx, oTarget.Object);
        }
예제 #20
0
        public static int AddCardToCollection(NWItem card, NWObject collection)
        {
            // Adds the card represented by card to collection, destroying the card item and returning its new index in the collection.
            int CardType = card.GetLocalInt("PAZAAK_CARD_TYPE");

            // Find the first available slot in the collection.
            int index = 1;

            while (collection.GetLocalInt("CARD_" + index) != 0)
            {
                index++;
            }

            collection.SetLocalInt("CARD_" + index, CardType);
            card.Destroy();

            return(index);
        }
예제 #21
0
        private static void OnModuleHeartbeat()
        {
            NWObject oMod      = _.GetModule();
            int      nHour     = _.GetTimeHour();
            int      nLastHour = oMod.GetLocalInt("WEATHER_LAST_HOUR");

            if (nHour != nLastHour)
            {
                if (AdjustWeather())
                {
                    foreach (var player in NWModule.Get().Players)
                    {
                        DoWeatherEffects(player);
                    }
                }

                oMod.SetLocalInt("WEATHER_LAST_HOUR", nHour);
            }
        }
예제 #22
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            Random random = new Random();
            int    amount = random.Next(3, 7);

            oTarget.SetLocalInt(AbilityService.LAST_ATTACK + oCaster.GlobalID, AbilityService.ATTACK_DOT);

            oCaster.AssignCommand(() =>
            {
                Effect damage = _.EffectDamage(amount);
                _.ApplyEffectToObject(DurationType.Instant, damage, oTarget.Object);
            });

            Effect decreaseAC = _.EffectACDecrease(2);

            oCaster.AssignCommand(() =>
            {
                _.ApplyEffectToObject(DurationType.Temporary, decreaseAC, oTarget.Object, 1.0f);
            });

            _.ApplyEffectToObject(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Imp_Acid_S), oTarget.Object);
        }
예제 #23
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            Random random = new Random();
            int    amount = random.Next(3, 7);

            oTarget.SetLocalInt(AbilityService.LAST_ATTACK + oCaster.GlobalID, AbilityService.ATTACK_DOT);

            oCaster.AssignCommand(() =>
            {
                Effect damage = _.EffectDamage(amount);
                _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, damage, oTarget.Object);
            });

            Effect decreaseAC = _.EffectACDecrease(2);

            oCaster.AssignCommand(() =>
            {
                _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, decreaseAC, oTarget.Object, 1.0f);
            });

            _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectVisualEffect(_.VFX_IMP_ACID_S), oTarget.Object);
        }
예제 #24
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer        player     = user.Object;
            ResourceQuality quality    = (ResourceQuality)target.GetLocalInt("RESOURCE_QUALITY");
            int             tier       = target.GetLocalInt("RESOURCE_TIER");
            int             remaining  = target.GetLocalInt("RESOURCE_COUNT") - 1;
            string          itemResref = target.GetLocalString("RESOURCE_RESREF");
            int             gemChance  = ResourceService.CalculateChanceForComponentBonus(player, tier, quality);
            int             roll       = RandomService.Random(1, 100);
            int             rank       = SkillService.GetPCSkillRank(player, SkillType.Harvesting);

            if (item.RecommendedLevel < rank)
            {
                rank = item.RecommendedLevel;
            }

            int difficulty = (tier - 1) * 10 + ResourceService.GetDifficultyAdjustment(quality);
            int delta      = difficulty - rank;

            int baseXP = 0;

            if (delta >= 6)
            {
                baseXP = 400;
            }
            else if (delta == 5)
            {
                baseXP = 350;
            }
            else if (delta == 4)
            {
                baseXP = 325;
            }
            else if (delta == 3)
            {
                baseXP = 300;
            }
            else if (delta == 2)
            {
                baseXP = 250;
            }
            else if (delta == 1)
            {
                baseXP = 225;
            }
            else if (delta == 0)
            {
                baseXP = 200;
            }
            else if (delta == -1)
            {
                baseXP = 150;
            }
            else if (delta == -2)
            {
                baseXP = 100;
            }
            else if (delta == -3)
            {
                baseXP = 50;
            }
            else if (delta == -4)
            {
                baseXP = 25;
            }

            int itemHarvestBonus = item.HarvestingBonus;
            int scanningBonus    = user.GetLocalInt(target.GlobalID.ToString());

            gemChance += itemHarvestBonus * 2 + scanningBonus * 2;

            baseXP = baseXP + scanningBonus * 5;

            // Spawn the normal resource.
            NWItem resource = CreateItemOnObject(itemResref, player);

            user.SendMessage("You harvest " + resource.Name + ".");

            // If player meets the chance to acquire a gem, create one and modify its properties.
            if (quality > ResourceQuality.Low && roll <= gemChance)
            {
                // Gemstone quality is determined by the quality of the vein.
                switch (quality)
                {
                case ResourceQuality.Normal:
                    resource = CreateItemOnObject("flawed_gemstone", player);
                    break;

                case ResourceQuality.High:
                    resource = CreateItemOnObject("gemstone", player);
                    break;

                case ResourceQuality.VeryHigh:
                    resource = CreateItemOnObject("perfect_gemstone", player);
                    break;
                }

                var ip = ResourceService.GetRandomComponentBonusIP(quality);
                BiowareXP2.IPSafeAddItemProperty(resource, ip.Item1, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true);

                switch (ip.Item2)
                {
                case 0:
                    resource.Name = ColorTokenService.Green(resource.Name);
                    break;

                case 1:
                    resource.Name = ColorTokenService.Blue(resource.Name);
                    break;

                case 2:
                    resource.Name = ColorTokenService.Purple(resource.Name);
                    break;

                case 3:
                    resource.Name = ColorTokenService.Orange(resource.Name);
                    break;

                case 4:
                    resource.Name = ColorTokenService.LightPurple(resource.Name);
                    break;

                case 5:
                    resource.Name = ColorTokenService.Yellow(resource.Name);
                    break;

                case 6:
                    resource.Name = ColorTokenService.Red(resource.Name);
                    break;

                case 7:
                    resource.Name = ColorTokenService.Cyan(resource.Name);
                    break;
                }

                user.SendMessage("You harvest " + resource.Name + ".");
            }

            float decayMinimum = 0.03f;
            float decayMaximum = 0.07f;

            if (delta > 0)
            {
                decayMinimum += delta * 0.1f;
                decayMaximum += delta * 0.1f;
            }

            DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(decayMinimum, decayMaximum));
            int xp = baseXP;

            SkillService.GiveSkillXP(player, SkillType.Harvesting, xp);

            if (remaining <= 0)
            {
                NWPlaceable prop = target.GetLocalObject("RESOURCE_PROP_OBJ");

                if (prop.IsValid)
                {
                    prop.Destroy();
                }

                target.Destroy();
                user.DeleteLocalInt(target.GlobalID.ToString());
            }
            else
            {
                target.SetLocalInt("RESOURCE_COUNT", remaining);
            }

            ApplyEffectAtLocation(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Fnf_Summon_Monster_3), target.Location);
        }
예제 #25
0
 public static void SetAreaWindModifier(NWObject oArea, int nModifier)
 {
     oArea.SetLocalInt(VAR_WEATHER_WIND, nModifier);
 }
예제 #26
0
 public static void SetAreaHeatModifier(NWObject oArea, int nModifier)
 {
     oArea.SetLocalInt(VAR_WEATHER_HEAT, nModifier);
 }
예제 #27
0
        private static void OnAreaEnter()
        {
            SetWeather();

            LoggingService.Trace(TraceComponent.Weather, "Applying weather to creature: " + _.GetName(_.GetEnteringObject()));

            DoWeatherEffects(_.GetEnteringObject());

            NWArea oArea     = (Object.OBJECT_SELF);
            int    nHour     = _.GetTimeHour();
            int    nLastHour = oArea.GetLocalInt("WEATHER_LAST_HOUR");

            if (nHour != nLastHour)
            {
                LoggingService.Trace(TraceComponent.Weather, "Cleaning up old weather");

                // Clean up any old weather placeables.
                foreach (NWObject oPlaceable in oArea.Objects)
                {
                    if (oPlaceable.ObjectType == _.OBJECT_TYPE_PLACEABLE &&
                        oPlaceable.GetLocalInt("WEATHER") == 1)
                    {
                        _.DestroyObject(oPlaceable);
                    }
                }

                // Create new ones depending on the current weather.
                int nWeather = GetWeather();
                LoggingService.Trace(TraceComponent.Weather, "Current weather: " + nWeather.ToString());

                if (nWeather == WEATHER_FOGGY)
                {
                    // Get the size in tiles.
                    int nSizeX = _.GetAreaSize(_.AREA_WIDTH, oArea);
                    int nSizeY = _.GetAreaSize(_.AREA_HEIGHT, oArea);

                    // We want one placeable per 8 tiles.
                    int nMax = (nSizeX * nSizeY) / 8;
                    LoggingService.Trace(TraceComponent.Weather, "Creating up to " + nMax.ToString() + " mist objects.");

                    for (int nCount = _.d6(); nCount < nMax; nCount++)
                    {
                        Vector vPosition = _.GetPosition(_.GetEnteringObject());

                        // Vectors are in meters - 10 meters to a tile.
                        vPosition.m_X = _.IntToFloat(_.Random(nSizeX * 10));
                        vPosition.m_Y = _.IntToFloat(_.Random(nSizeY * 10));

                        float fFacing = _.IntToFloat(_.Random(360));

                        string sResRef = "x3_plc_mist";

                        NWObject oPlaceable = _.CreateObject(_.OBJECT_TYPE_PLACEABLE, sResRef, _.Location(oArea, vPosition, fFacing));
                        _.SetObjectVisualTransform(oPlaceable, _.OBJECT_VISUAL_TRANSFORM_SCALE, _.IntToFloat(200 + _.Random(200)) / 100.0f);
                        oPlaceable.SetLocalInt("WEATHER", 1);
                    }
                }

                oArea.SetLocalInt("WEATHER_LAST_HOUR", nHour);
            }
        }
예제 #28
0
        private static void _SetWindStrength(int nWind)
        {
            NWObject oMod = _.GetModule();

            oMod.SetLocalInt(VAR_WEATHER_WIND, nWind);
        }
예제 #29
0
        private static void _SetHumidity(int nHumidity)
        {
            NWObject oMod = _.GetModule();

            oMod.SetLocalInt(VAR_WEATHER_HUMIDITY, nHumidity);
        }
예제 #30
0
        private static void _SetHeatIndex(int nHeat)
        {
            NWObject oMod = _.GetModule();

            oMod.SetLocalInt(VAR_WEATHER_HEAT, nHeat);
        }