private void DoRotateConstructionSite(float rotation, bool isSet) { NWPlayer oPC = GetPC(); Model model = GetDialogCustomData <Model>(); if (!_structure.PlayerHasPermission(oPC, StructurePermission.CanRotateStructures, model.FlagID)) { oPC.FloatingText("You do not have permission to rotate structures."); BuildMainPage(); ChangePage("MainPage"); return; } int constructionSiteID = _structure.GetConstructionSiteID((NWPlaceable)GetDialogTarget()); Data.Entities.ConstructionSite entity = _structure.GetConstructionSiteByID(constructionSiteID); if (isSet) { entity.LocationOrientation = rotation; } else { entity.LocationOrientation = entity.LocationOrientation + rotation; } _structure.SaveChanges(); GetDialogTarget().Facing = (float)entity.LocationOrientation; }
private void DoBuildingInteriorPreview() { Model model = GetDialogCustomData <Model>(); Data.Entities.ConstructionSite site = _structure.GetConstructionSiteByID(model.ConstructionSiteID); if (!site.StructureBlueprint.IsBuilding || site.BuildingInterior == null) { return; } _structure.PreviewBuildingInterior(GetPC(), site.BuildingInterior.BuildingInteriorID); }
private void ToggleRotateOptions() { Model model = GetDialogCustomData <Model>(); Data.Entities.ConstructionSite site = _structure.GetConstructionSiteByID(model.ConstructionSiteID); bool isVisible = !(site != null && site.StructureBlueprint.IsBuilding); SetResponseVisible("RotatePage", 5, isVisible); SetResponseVisible("RotatePage", 6, isVisible); SetResponseVisible("RotatePage", 7, isVisible); SetResponseVisible("RotatePage", 8, isVisible); SetResponseVisible("RotatePage", 9, isVisible); SetResponseVisible("RotatePage", 10, isVisible); SetResponseVisible("RotatePage", 11, isVisible); }
private void HandleChangeLayoutPageResponse(int responseID) { DialogResponse response = GetResponseByID("ChangeLayoutPage", responseID); if (!response.HasCustomData) { ChangePage("MainPage"); return; } BuildingInterior interior = (BuildingInterior)response.CustomData[string.Empty]; Model model = GetDialogCustomData <Model>(); Data.Entities.ConstructionSite site = _structure.GetConstructionSiteByID(model.ConstructionSiteID); site.BuildingInteriorID = interior.BuildingInteriorID; _structure.SaveChanges(); BuildMainPage(); ChangePage("MainPage"); }
private void DoConstructionSitePreview() { Model model = GetDialogCustomData <Model>(); if (model.IsPreviewing) { return; } Data.Entities.ConstructionSite entity = _structure.GetConstructionSiteByID(model.ConstructionSiteID); StructureBlueprint blueprint = entity.StructureBlueprint; NWPlaceable preview = NWPlaceable.Wrap(_.CreateObject(OBJECT_TYPE_PLACEABLE, blueprint.Resref, GetDialogTarget().Location)); preview.IsUseable = false; preview.IsPlot = true; preview.Destroy(6.0f); preview.DelayCommand(() => { model.IsPreviewing = false; }, 6.0f); }
public bool Run(params object[] args) { NWPlaceable oSite = NWPlaceable.Wrap(Object.OBJECT_SELF); NWPlayer oPC = NWPlayer.Wrap(_.GetLastAttacker(oSite.Object)); int constructionSiteID = _structure.GetConstructionSiteID(oSite); if (constructionSiteID <= 0) { oPC.FloatingText("You must select a blueprint before you can build."); oPC.ClearAllActions(); return(true); } NWItem weapon = NWItem.Wrap(_.GetLastWeaponUsed(oPC.Object)); int weaponType = weapon.BaseItemType; if (weaponType != BASE_ITEM_LIGHTHAMMER) { oPC.FloatingText("A hammer must be equipped to build this structure."); oPC.ClearAllActions(); return(true); } // Offhand weapons don't contribute to building. if (weapon.Equals(oPC.LeftHand)) { return(true); } if (!_structure.IsConstructionSiteValid(oSite)) { oPC.FloatingText("Construction site is invalid. Please click the construction site to find out more."); oPC.ClearAllActions(); return(true); } Data.Entities.ConstructionSite entity = _structure.GetConstructionSiteByID(constructionSiteID); if (weapon.CraftTierLevel < entity.StructureBlueprint.CraftTierLevel) { oPC.FloatingText("Your hammer cannot be used with this blueprint. (Required Tool Level: " + entity.StructureBlueprint.CraftTierLevel + ")"); oPC.ClearAllActions(); return(true); } int rank = _skill.GetPCSkill(oPC, SkillType.Construction).Rank; int mangleChance = CalculateMangleChance(oPC, entity.StructureBlueprint.Level, rank); bool isMangle = _random.Random(100) + 1 <= mangleChance; bool foundResource = false; string updateMessage = "You lack the necessary resources..."; int totalAmount = 0; foreach (ConstructionSiteComponent comp in entity.ConstructionSiteComponents) { if (comp.Quantity > 0 && !foundResource) { NWItem item = NWItem.Wrap(_.GetItemPossessedBy(oPC.Object, comp.StructureComponent.Resref)); if (item.IsValid) { int reuseChance = isMangle ? 0 : _perk.GetPCPerkLevel(oPC, PerkType.ConservativeConstruction) * 2 + _perk.GetPCPerkLevel(oPC, PerkType.Lucky); if (_random.Random(100) + 1 <= reuseChance) { oPC.SendMessage("You conserve a resource..."); } else { item.ReduceItemStack(); } if (isMangle) { oPC.SendMessage(_color.Red("You mangle a resource due to your lack of skill...")); return(true); } string name = _item.GetNameByResref(comp.StructureComponent.Resref); comp.Quantity--; updateMessage = "You need " + comp.Quantity + " " + name + " to complete this project."; foundResource = true; } } totalAmount += comp.Quantity; } oPC.DelayCommand(() => oPC.SendMessage(updateMessage), 0.75f); if (totalAmount <= 0) { _structure.CompleteStructure(oSite); } else if (foundResource) { _structure.SaveChanges(); _durability.RunItemDecay(oPC, weapon); if (entity.StructureBlueprint.GivesSkillXP) { int xp = (int)_skill.CalculateSkillAdjustedXP(100, 0, rank); _skill.GiveSkillXP(oPC, SkillType.Construction, xp); } // Speedy Builder - Grants haste for 8 seconds int hasteChance = _perk.GetPCPerkLevel(oPC, PerkType.SpeedyBuilder) * 10; if (hasteChance > 0) { hasteChance += _perk.GetPCPerkLevel(oPC, PerkType.Lucky) * 2; } PlayerCharacter pcEntity = _player.GetPlayerEntity(oPC); if (pcEntity.BackgroundID == (int)BackgroundType.ConstructionBuilder) { hasteChance += 10; } if (_random.Random(100) + 1 <= hasteChance) { _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectHaste(), oPC.Object, 8.0f); } } else { oPC.ClearAllActions(); } return(true); }
private void BuildMainPage() { NWPlayer oPC = GetPC(); string header; Model model = GetDialogCustomData <Model>(); ClearPageResponses("MainPage"); if (model.ConstructionSiteID <= 0) { header = "Please select an option."; if (model.IsTerritoryFlag) { AddResponseToPage("MainPage", "Select Blueprint"); AddResponseToPage("MainPage", "Move"); AddResponseToPage("MainPage", _color.Red("Raze")); } else { AddResponseToPage("MainPage", "Select Blueprint", _structure.PlayerHasPermission(oPC, StructurePermission.CanBuildStructures, model.FlagID)); AddResponseToPage("MainPage", "Move", _structure.PlayerHasPermission(oPC, StructurePermission.CanMoveStructures, model.FlagID)); AddResponseToPage("MainPage", _color.Red("Raze"), _structure.PlayerHasPermission(oPC, StructurePermission.CanRazeStructures, model.FlagID)); } } else { Data.Entities.ConstructionSite entity = _structure.GetConstructionSiteByID(model.ConstructionSiteID); header = _color.Green("Blueprint: ") + entity.StructureBlueprint.Name + "\n"; if (entity.StructureBlueprint.IsVanity) { header += _color.Green("Type: ") + "Vanity\n"; } if (entity.StructureBlueprint.IsSpecial) { header += _color.Green("Type: ") + "Special\n"; } if (entity.StructureBlueprint.IsResource) { header += _color.Green("Type: ") + "Resource\n"; } if (entity.StructureBlueprint.IsBuilding) { header += _color.Green("Type: ") + "Building\n"; } header += _color.Green("Level: ") + entity.StructureBlueprint.Level + "\n"; header += _color.Green("Required Tool Level: ") + entity.StructureBlueprint.CraftTierLevel + "\n\n"; if (entity.StructureBlueprint.MaxBuildDistance > 0.0f) { header += _color.Green("Build Distance: ") + entity.StructureBlueprint.MaxBuildDistance + " meters" + "\n"; } if (entity.StructureBlueprint.VanityCount > 0) { header += _color.Green("Max # of Vanity Structures: ") + entity.StructureBlueprint.VanityCount + "\n"; } if (entity.StructureBlueprint.SpecialCount > 0) { header += _color.Green("Max # of Special Structures: ") + entity.StructureBlueprint.SpecialCount + "\n"; } if (entity.StructureBlueprint.ItemStorageCount > 0) { header += _color.Green("Item Storage: ") + entity.StructureBlueprint.ItemStorageCount + " items" + "\n"; } if (entity.BuildingInterior != null) { header += _color.Green("Interior Layout: ") + entity.BuildingInterior.Name + "\n"; } header += _color.Green("Resources Required: ") + "\n\n"; foreach (ConstructionSiteComponent comp in entity.ConstructionSiteComponents) { header += comp.Quantity > 0 ? comp.Quantity + "x " + _item.GetNameByResref(comp.StructureComponent.Resref) + "\n" : ""; } AddResponseToPage("MainPage", "Quick Build", _authorization.IsPCRegisteredAsDM(GetPC())); AddResponseToPage("MainPage", "Build"); AddResponseToPage("MainPage", "Preview"); AddResponseToPage("MainPage", "Preview Interior", entity.BuildingInterior != null); AddResponseToPage("MainPage", "Change Interior Layout", entity.BuildingInterior != null); AddResponseToPage("MainPage", "Rotate", _structure.PlayerHasPermission(oPC, StructurePermission.CanRotateStructures, model.FlagID)); AddResponseToPage("MainPage", "Move", _structure.PlayerHasPermission(oPC, StructurePermission.CanMoveStructures, model.FlagID)); AddResponseToPage("MainPage", _color.Red("Raze"), _structure.PlayerHasPermission(oPC, StructurePermission.CanRazeStructures, model.FlagID)); } SetPageHeader("MainPage", header); }