private void ScanArea(NWCreature user, Location targetLocation) { NWArea area = (_.GetAreaFromLocation(targetLocation)); var spawns = _spawn.GetAreaPlaceableSpawns(area); var spawn = spawns .Where(x => !string.IsNullOrWhiteSpace(x.SpawnPlaceable.GetLocalString("RESOURCE_RESREF")) && x.SpawnPlaceable.IsValid) .OrderBy(o => _.GetDistanceBetweenLocations(targetLocation, o.Spawn.Location)) .FirstOrDefault(); const float BaseScanningRange = 20.0f; if (spawn == null || _.GetDistanceBetweenLocations(targetLocation, spawn.SpawnLocation) > BaseScanningRange) { user.FloatingText("Couldn't locate any nearby resources..."); } else { var position = _.GetPositionFromLocation(spawn.SpawnLocation); int cellX = (int)(position.m_X / 10); int cellY = (int)(position.m_Y / 10); _biowarePosition.TurnToFaceLocation(spawn.SpawnLocation, user); user.FloatingText("Nearest resource is located at coordinates (" + cellX + ", " + cellY + ")"); } }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { Location effectLocation; NWPlayer player = (user.Object); if (!string.IsNullOrWhiteSpace(target.GetLocalString("RESOURCE_RESREF"))) { ScanResource(user, target); DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(0.05f, 0.1f)); effectLocation = target.Location; } else { user.FloatingText("You cannot scan that object with this type of scanner."); return; } _.ApplyEffectAtLocation(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Fnf_Summon_Monster_3), effectLocation); if (user.IsPlayer && GetLocalBool(user, target.GlobalID.ToString()) == false) { int scanningBonus = item.ScanningBonus; SkillService.GiveSkillXP(player, SkillType.Harvesting, 150); user.SetLocalInt(target.GlobalID.ToString(), 1 + scanningBonus); } }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWArea area = user.Area; NWPlayer player = new NWPlayer(user); string structureID = area.GetLocalString("PC_BASE_STRUCTURE_ID"); Guid structureGuid = new Guid(structureID); PCBaseStructure pcbs = DataService.PCBaseStructure.GetByID(structureGuid); BaseStructure structure = DataService.BaseStructure.GetByID(pcbs.BaseStructureID); int repair = SkillService.GetPCSkillRank(player, SkillType.Piloting); int maxRepair = (int)structure.Durability - (int)pcbs.Durability; if (maxRepair < repair) { repair = maxRepair; } // TODO - add perks to make repairing faster/better/shinier/etc. // Maybe a perk to allow repairing in space, with ground repairs only otherwise? NWCreature ship = area.GetLocalObject("CREATURE"); if (ship.IsValid) { ship.SetLocalInt("HP", ship.GetLocalInt("HP") + repair); ship.FloatingText("Hull repaired: " + ship.GetLocalInt("HP") + "/" + ship.MaxHP); } pcbs.Durability += repair; DataService.SubmitDataChange(pcbs, DatabaseActionType.Update); player.SendMessage("Ship repaired for " + repair + " points. (Hull points: " + pcbs.Durability + "/" + structure.Durability + ")"); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { Location effectLocation; NWPlayer player = (user.Object); // Targeted a location or self. Locate nearest resource. if (!target.IsValid || Equals(user, target)) { ScanArea(user, targetLocation); _durability.RunItemDecay(player, item, _random.RandomFloat(0.02f, 0.08f)); effectLocation = targetLocation; } else if (!string.IsNullOrWhiteSpace(target.GetLocalString("RESOURCE_RESREF"))) { ScanResource(user, target); _durability.RunItemDecay(player, item, _random.RandomFloat(0.05f, 0.1f)); effectLocation = target.Location; } else { user.FloatingText("You cannot scan that object with this type of scanner."); return; } _.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3), effectLocation); if (user.IsPlayer && user.GetLocalInt(target.GlobalID.ToString()) == FALSE) { int scanningBonus = item.ScanningBonus; _skill.GiveSkillXP(player, SkillType.Harvesting, 150); user.SetLocalInt(target.GlobalID.ToString(), 1 + scanningBonus); } }