Exemplo n.º 1
0
        private static void OnModuleNWNXChat()
        {
            NWPlayer pc      = NWNXChat.GetSender();
            string   newName = NWNXChat.GetMessage();

            if (!CanHandleChat(pc))
            {
                return;
            }

            NWNXChat.SkipMessage();
            NWItem renameItem = pc.GetLocalObject("CRAFT_RENAMING_ITEM_OBJECT");

            pc.DeleteLocalInt("CRAFT_RENAMING_ITEM");
            pc.DeleteLocalObject("CRAFT_RENAMING_ITEM_OBJECT");

            if (!renameItem.IsValid)
            {
                pc.SendMessage("Cannot find the item you were renaming.");
                return;
            }

            if (newName.Length < 3 || newName.Length > 64)
            {
                pc.SendMessage("Item names must be between 3 and 64 characters long.");
                return;
            }

            renameItem.Name = newName;

            pc.FloatingText("New name set!");
        }
Exemplo n.º 2
0
        private void LoadHeader()
        {
            NWPlayer player = GetPC();

            player.SetLocalBool("ITEM_RENAMING_LISTENING", true);

            NWItem item         = player.GetLocalObject("ITEM_BEING_RENAMED");
            string originalName = item.GetLocalString("RENAMED_ITEM_ORIGINAL_NAME");

            if (string.IsNullOrWhiteSpace(originalName))
            {
                originalName = item.Name;
            }
            string currentName  = item.Name;
            string renamingName = player.GetLocalString("RENAMED_ITEM_NEW_NAME");

            if (string.IsNullOrWhiteSpace(renamingName))
            {
                renamingName = "{UNSPECIFIED}";
            }

            string header = "You are renaming an item.\n\n";

            header += ColorTokenService.Green("Original Name: ") + originalName + "\n";
            header += ColorTokenService.Green("Current Name: ") + currentName + "\n";
            header += ColorTokenService.Green("New Name: ") + renamingName + "\n";
            header += "Type in a new name, click 'Refresh', and then select 'Change Name' to make the changes. Click 'Reset Name' to switch back to the item's original name.";

            SetPageHeader("MainPage", header);
        }
Exemplo n.º 3
0
        private void ChangeName()
        {
            NWPlayer player = GetPC();

            // Player hasn't specified a new name for this item.
            string newName = player.GetLocalString("RENAMED_ITEM_NEW_NAME");

            if (string.IsNullOrWhiteSpace(newName))
            {
                player.FloatingText("Enter a new name into the chat box, select 'Refresh' then select 'Change Name'.");
                return;
            }
            NWItem item = player.GetLocalObject("ITEM_BEING_RENAMED");

            // Item isn't in player's inventory.
            if (_.GetItemPossessor(item) != player.Object)
            {
                player.FloatingText("Item must be in your inventory in order to rename it.");
                return;
            }

            // Item's original name isn't being stored. Do that now.
            if (string.IsNullOrWhiteSpace(item.GetLocalString("RENAMED_ITEM_ORIGINAL_NAME")))
            {
                item.SetLocalString("RENAMED_ITEM_ORIGINAL_NAME", item.Name);
            }

            item.Name = newName;

            player.FloatingText("Item renamed to '" + newName + "'.");
            EndConversation();
        }
Exemplo n.º 4
0
        public bool Run(params object[] args)
        {
            NWPlayer    player = NWPlayer.Wrap(Object.OBJECT_SELF);
            NWPlaceable forge  = NWPlaceable.Wrap(player.GetLocalObject("FORGE"));
            string      resref = forge.GetLocalString("FORGE_ORE");

            forge.DeleteLocalObject("FORGE_USER");
            player.DeleteLocalObject("FORGE");
            forge.DeleteLocalString("FORGE_ORE");
            player.IsBusy = false;

            PCSkill pcSkill     = _skill.GetPCSkill(player, SkillType.Engineering);
            int     level       = _craft.GetIngotLevel(resref);
            string  ingotResref = _craft.GetIngotResref(resref);

            if (pcSkill == null || level < 0 || string.IsNullOrWhiteSpace(ingotResref))
            {
                return(false);
            }

            int delta = pcSkill.Rank - level;
            int count = 2;

            if (delta > 2)
            {
                count = delta;
            }
            if (count > 6)
            {
                count = 6;
            }

            if (_random.Random(100) + 1 <= _perk.GetPCPerkLevel(player, PerkType.Lucky))
            {
                count++;
            }

            if (_random.Random(100) + 1 <= _perk.GetPCPerkLevel(player, PerkType.ProcessingEfficiency) * 10)
            {
                count++;
            }

            for (int x = 1; x <= count; x++)
            {
                _.CreateItemOnObject(ingotResref, player.Object);
            }

            int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(100, level, pcSkill.Rank);

            _skill.GiveSkillXP(player, SkillType.Engineering, xp);

            if (_random.Random(100) + 1 <= 3)
            {
                _food.DecreaseHungerLevel(player, 1);
            }
            return(true);
        }
Exemplo n.º 5
0
        private void ResetName()
        {
            NWPlayer player = GetPC();
            NWItem   item   = player.GetLocalObject("ITEM_BEING_RENAMED");

            if (string.IsNullOrWhiteSpace(item.GetLocalString("RENAMED_ITEM_ORIGINAL_NAME")))
            {
                item.SetLocalString("RENAMED_ITEM_ORIGINAL_NAME", item.Name);
            }

            item.Name = item.GetLocalString("RENAMED_ITEM_ORIGINAL_NAME");
        }
Exemplo n.º 6
0
        public static MapPin GetMapPin(NWPlayer oPC, int index)
        {
            index++;
            MapPin mapPin = new MapPin
            {
                Text      = oPC.GetLocalString("NW_MAP_PIN_NTRY_" + index),
                PositionX = oPC.GetLocalFloat("NW_MAP_PIN_XPOS_" + index),
                PositionY = oPC.GetLocalFloat("NW_MAP_PIN_YPOS_" + index),
                Area      = (oPC.GetLocalObject("NW_MAP_PIN_AREA_" + index)),
                Tag       = oPC.GetLocalString("CUSTOM_NW_MAP_PIN_TAG_" + index),
                Player    = oPC,
                Index     = index
            };

            return(mapPin);
        }
Exemplo n.º 7
0
        public bool Run(params object[] args)
        {
            NWPlaceable resource = NWPlaceable.Wrap(Object.OBJECT_SELF);
            NWPlayer    oPC      = NWPlayer.Wrap(_.GetLastDamager(resource.Object));

            if (oPC.GetLocalInt("NOT_USING_CORRECT_WEAPON") == 1)
            {
                oPC.DeleteLocalInt("NOT_USING_CORRECT_WEAPON");
                return(true);
            }

            PlayerCharacter pcEntity = _db.PlayerCharacters.Single(x => x.PlayerID == oPC.GlobalID);

            NWItem    oWeapon            = NWItem.Wrap(_.GetLastWeaponUsed(oPC.Object));
            Location  location           = oPC.Location;
            string    resourceItemResref = resource.GetLocalString("RESOURCE_RESREF");
            int       activityID         = resource.GetLocalInt("RESOURCE_ACTIVITY");
            string    resourceName       = resource.GetLocalString("RESOURCE_NAME");
            int       resourceCount      = resource.GetLocalInt("RESOURCE_COUNT");
            int       difficultyRating   = resource.GetLocalInt("RESOURCE_DIFFICULTY_RATING");
            int       weaponChanceBonus;
            SkillType skillType;
            int       perkChanceBonus;
            int       secondResourceChance;
            int       durabilityChanceReduction = 0;
            int       hasteChance;
            int       lucky = _perk.GetPCPerkLevel(oPC, PerkType.Lucky) + oPC.EffectiveLuckBonus;
            bool      hasBaggerPerk;

            if (activityID == 1) // 1 = Logging
            {
                weaponChanceBonus = oWeapon.LoggingBonus;
                if (weaponChanceBonus > 0)
                {
                    weaponChanceBonus        += _perk.GetPCPerkLevel(oPC, PerkType.LoggingAxeExpert) * 5;
                    durabilityChanceReduction = _perk.GetPCPerkLevel(oPC, PerkType.LoggingAxeExpert) * 10 + lucky;
                }

                skillType            = SkillType.Logging;
                perkChanceBonus      = _perk.GetPCPerkLevel(oPC, PerkType.Lumberjack) * 5 + lucky;
                secondResourceChance = _perk.GetPCPerkLevel(oPC, PerkType.PrecisionLogging) * 10;
                hasteChance          = _perk.GetPCPerkLevel(oPC, PerkType.SpeedyLogger) * 10 + lucky;

                if (pcEntity.BackgroundID == (int)BackgroundType.Lumberjack)
                {
                    hasteChance += 10;
                }

                hasBaggerPerk = _perk.GetPCPerkLevel(oPC, PerkType.WoodBagger) > 0;
            }
            else if (activityID == 2) // Mining
            {
                weaponChanceBonus = oWeapon.MiningBonus;
                if (weaponChanceBonus > 0)
                {
                    weaponChanceBonus        += _perk.GetPCPerkLevel(oPC, PerkType.PickaxeExpert) * 5;
                    durabilityChanceReduction = _perk.GetPCPerkLevel(oPC, PerkType.PickaxeExpert) * 10 + lucky;
                }
                skillType            = SkillType.Mining;
                perkChanceBonus      = _perk.GetPCPerkLevel(oPC, PerkType.Miner) * 5 + lucky;
                secondResourceChance = _perk.GetPCPerkLevel(oPC, PerkType.PrecisionMining) * 10;
                hasteChance          = _perk.GetPCPerkLevel(oPC, PerkType.SpeedyMiner) * 10 + lucky;

                if (pcEntity.BackgroundID == (int)BackgroundType.Miner)
                {
                    hasteChance += 10;
                }

                hasBaggerPerk = _perk.GetPCPerkLevel(oPC, PerkType.OreBagger) > 0;
            }
            else
            {
                return(false);
            }
            PCSkill skill = _skill.GetPCSkillByID(oPC.GlobalID, (int)skillType);
            int     durabilityLossChance = 100 - durabilityChanceReduction;

            if (_random.Random(100) <= durabilityLossChance)
            {
                _durability.RunItemDecay(oPC, oWeapon);
            }

            int baseChance = 10;
            int chance     = baseChance + weaponChanceBonus;

            chance += CalculateSuccessChanceDeltaModifier(difficultyRating, skill.Rank);
            chance += perkChanceBonus;

            bool givePityItem = false;

            if (chance > 0)
            {
                if (_random.Random(100) + 1 <= hasteChance)
                {
                    _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectHaste(), oPC.Object, 8.0f);
                }

                // Give an item if the player hasn't gotten anything after 6-8 attempts.
                int      attemptFailureCount = oPC.GetLocalInt("RESOURCE_ATTEMPT_FAILURE_COUNT") + 1;
                NWObject failureResource     = NWObject.Wrap(oPC.GetLocalObject("RESOURCE_ATTEMPT_FAILURE_OBJECT"));

                if (!failureResource.IsValid || !Equals(failureResource, resource))
                {
                    failureResource     = resource;
                    attemptFailureCount = 1;
                }

                int pityItemChance = 0;
                if (attemptFailureCount == 6)
                {
                    pityItemChance = 60;
                }
                else if (attemptFailureCount == 7)
                {
                    pityItemChance = 80;
                }
                else if (attemptFailureCount >= 8)
                {
                    pityItemChance = 100;
                }

                if (_random.Random(100) + 1 <= pityItemChance)
                {
                    givePityItem        = true;
                    attemptFailureCount = 0;
                }

                oPC.SetLocalInt("RESOURCE_ATTEMPT_FAILURE_COUNT", attemptFailureCount);
                oPC.SetLocalObject("RESOURCE_ATTEMPT_FAILURE_OBJECT", failureResource.Object);
            }

            if (chance <= 0)
            {
                oPC.FloatingText("You do not have enough skill to harvest this resource...");
            }
            else if (_random.Random(100) <= chance || givePityItem)
            {
                if (hasBaggerPerk)
                {
                    _.CreateItemOnObject(resourceItemResref, oPC.Object);
                }
                else
                {
                    _.CreateObject(OBJECT_TYPE_ITEM, resourceItemResref, location);
                }


                oPC.FloatingText("You break off some " + resourceName + ".");
                resource.SetLocalInt("RESOURCE_COUNT", --resourceCount);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(10000), resource.Object);

                if (_random.Random(100) + 1 <= secondResourceChance)
                {
                    oPC.FloatingText("You break off a second piece.");

                    if (hasBaggerPerk)
                    {
                        _.CreateItemOnObject(resourceItemResref, oPC.Object);
                    }
                    else
                    {
                        _.CreateObject(OBJECT_TYPE_ITEM, resourceItemResref, location);
                    }
                }

                float deltaModifier = CalculateXPDeltaModifier(difficultyRating, skill.Rank);
                float baseXP        = (100 + _random.Random(20)) * deltaModifier;
                int   xp            = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(baseXP, oWeapon.RecommendedLevel, skill.Rank);
                _skill.GiveSkillXP(oPC, skillType, xp);

                oPC.DeleteLocalInt("RESOURCE_ATTEMPT_FAILURE_COUNT");
                oPC.DeleteLocalObject("RESOURCE_ATTEMPT_FAILURE_OBJECT");
            }

            if (resourceCount <= 0)
            {
                SpawnSeed(resource, oPC);

                NWObject prop = NWObject.Wrap(resource.GetLocalObject("RESOURCE_PROP_OBJ"));
                if (prop.IsValid)
                {
                    prop.Destroy();
                }
                resource.Destroy();
            }
            return(true);
        }
Exemplo n.º 8
0
 public static NWPlayer GetCallReceiver(NWPlayer player)
 {
     return(player.GetLocalObject("HOLOCOM_CALL_RECEIVER_OBJECT"));
 }
Exemplo n.º 9
0
 public static NWPlayer GetCallSender(NWPlayer player)
 {
     return(player.GetLocalObject("HOLOCOM_CALL_SENDER_OBJECT"));
 }
Exemplo n.º 10
0
 public static NWPlayer GetTargetForActiveCall(NWPlayer player)
 {
     return(player.GetLocalObject("HOLOCOM_CALL_CONNECTED_WITH"));
 }
Exemplo n.º 11
0
 public static NWPlayer GetHoloGram(NWPlayer player)
 {
     return(player.GetLocalObject("HOLOCOM_HOLOGRAM"));
 }
Exemplo n.º 12
0
        private void LoadMainPage()
        {
            NWObject table = _.OBJECT_SELF;
            NWPlayer pc    = GetPC();

            game = PazaakService.GetCurrentGame(table);

            if (game == null && table.GetLocalInt("IN_GAME") == 2)
            {
                // Belt and bracers clean up code.
                table.DeleteLocalInt("IN_GAME");
            }

            // Check whether we have a game, or whether we should create one.
            if (table.GetLocalInt("IN_GAME") == 2)
            {
                CheckEndRound(table);

                if (game.nextTurn == pc)
                {
                    // Our turn.
                    BuildTurnOptions(pc);
                }
                else if (game.player2.IsNPC)
                {
                    // NPC turn.  Handle some
                    DoNPCTurn(game);
                    CheckEndRound(table);
                    if (game.nextTurn == game.player2)
                    {
                        DoNPCTurn(game);
                    }
                    BuildTurnOptions(pc);
                }
                else
                {
                    // Other player turn.
                    SetPageHeader("MainPage", "It is not currently your turn.");
                    ClearPageResponses("MainPage");
                }
            }
            // Table is open for a second player.
            else if (table.GetLocalInt("IN_GAME") == 1)
            {
                NWObject collection = pc.GetLocalObject("ACTIVE_COLLECTION");

                if (GetName(table.GetLocalObject("PLAYER_1")) == pc.Name)
                {
                    SetPageHeader("MainPage", "You are waiting for an opponent here.  Or play against the host.");
                    ClearPageResponses("MainPage");
                    AddResponseToPage("MainPage", "Table host (NPC)");
                }
                // Check that the player has an active Pazaak deck.
                else if (collection.IsValid)
                {
                    SetPageHeader("MainPage", GetName(table.GetLocalObject("PLAYER_1")) + " is waiting for an opponent.  Join game?");
                    ClearPageResponses("MainPage");
                    AddResponseToPage("MainPage", "Join game");
                }
                else
                {
                    SetPageHeader("MainPage", "Use your Pazaak Collection on this table to join the game.");
                    ClearPageResponses("MainPage");
                }
            }
            // Create a game.  Offer the PC a choice of vs NPC or vs Player.
            else
            {
                NWObject collection = pc.GetLocalObject("ACTIVE_COLLECTION");
                // Check that the player has an active Pazaak deck.
                if (collection.IsValid)
                {
                    table.SetLocalInt("IN_GAME", 1);
                    table.SetLocalObject("PLAYER_1", pc);
                    table.DeleteLocalObject("PLAYER_2");

                    SetPageHeader("MainPage", "Game created.  Will this be against another player, or the table owner?");
                    ClearPageResponses("MainPage");
                    AddResponseToPage("MainPage", "A player");
                    AddResponseToPage("MainPage", "Table host (NPC)");
                }
                else
                {
                    SetPageHeader("MainPage", "Use your Pazaak Collection on this table to join the game.");
                    ClearPageResponses("MainPage");
                }
            }
        }