private void DoHarvest(GlobalPoint3D point, ITMHand hand) { var gamerID = hand.Player.GamerID; FloodSearchList = new List <GlobalPoint3D>(); FloodSearchCrop(point, gamerID); for (int i = 0; i < FloodSearchList.Count; i++) { if (amountFound <= maxHarvestToFind && !degradeScythe) {//degrade is off so run this one FloodSearchCrop(FloodSearchList[i], gamerID); amountFound++; } else if (amountFound <= maxHarvestToFind && durabilityToRemove <= GetRemainHandDurability(hand)) {//degrade is on so run this one but stop when tool will break FloodSearchCrop(FloodSearchList[i], gamerID); amountFound++; } } if (degradeScythe) { DecreaseHandItemDurability(hand, durabilityToRemove); } durabilityToRemove = 0; amountFound = 0; }
void SpawnVehicle(VehicleType type, ITMHand hand) { var owner = hand.Owner as ITMPlayer; if (owner == null) { return; } if (owner.SwingFace == BlockFace.ProxyDefault) { return; } var list = GetVehicleTypeArray(type); var data = list[Game.Random.Next(list.Length)]; var blockID = (Block)Map.GetBlockID(owner.SwingTarget); if (blockID != data.TrackNE && blockID != data.TrackSW) { Game.AddNotification("Must place Vehicle on " + Globals1.ItemData[(int)data.TrackNE].Name + " or " + Globals1.ItemData[(int)data.TrackSW].Name, NotifyRecipient.Local); return; } if (hand.HandType == InventoryHand.Left) { AutoSpawnVehicle(type, hand); } else { SpawnVehicle(type, owner.SwingTarget, owner.ViewDirection); } }
void DecreaseHandItemDurability(ITMHand hand, ushort amt) { ITMPlayer player = hand.Player; var item = player.Inventory.Items[player.LeftHand.HandIndex]; if (hand.HandType == InventoryHand.Right) { item = player.Inventory.Items[player.RightHand.HandIndex]; } if (amt >= item.Durability) { //game.AddNotification("Amount " + amt + " >= item.durability " + item.Durability ); amt = (ushort)(item.Durability - 1); //game.AddNotification("setting to " + amt ); } item.Durability -= amt; // game.AddNotification("durability " + item.Durability + " amount " + amt); if (hand.HandType == InventoryHand.Right) { player.Inventory.Items[player.RightHand.HandIndex] = item; } else { player.Inventory.Items[player.LeftHand.HandIndex] = item; } }
private void DoVeinMine(GlobalPoint3D point, ITMHand hand) { //game.AddNotification("DoVeinMin"); GamerID gamerID = hand.Player.GamerID; //setup the initial search pattern FloodSearchList = new List <GlobalPoint3D>(); FloodSearchOre(point, gamerID, targetOre); for (int i = 0; i < FloodSearchList.Count; i++) { //game.AddNotification("FloodSearchList.Count " + FloodSearchList.Count); if (amountFound <= maxOreToFind && !degradePick) {//not degrading do this one FloodSearchOre(FloodSearchList[i], gamerID, targetOre); } else if (amountFound <= maxOreToFind && durabilityToRemove <= GetRemainHandDurability(hand)) {//degrade is on so run this one but stop when tool will break FloodSearchOre(FloodSearchList[i], gamerID, targetOre); amountFound++; } } if (degradePick) { DecreaseHandItemDurability(hand, durabilityToRemove); } durabilityToRemove = 0; amountFound = 0; targetOre = Block.None; }
private void DoLumberJack(GlobalPoint3D point, ITMHand hand) { var gamerID = hand.Player.GamerID; FloodSearchList = new List <GlobalPoint3D>(); FloodSearchList.Add(point); for (int i = 0; i < FloodSearchList.Count; i++) { if (amountFound <= maxTreeToFind && !degradeAx) {//not degrading tools FloodSearchTree(FloodSearchList[i], gamerID); amountFound++; } else if (amountFound <= maxTreeToFind && durabilityToRemove <= GetRemainHandDurability(hand)) {//degrade is on so run this one but stop when tool will break FloodSearchTree(FloodSearchList[i], gamerID); amountFound++; } } //game.AddNotification("dur: " + GetRemainHandDurability(hand) + " to remove " + durabilityToRemove); if (degradeAx) { DecreaseHandItemDurability(hand, durabilityToRemove); } durabilityToRemove = 0; amountFound = 0; }
ushort GetRemainHandDurability(ITMHand hand) { ITMPlayer player = hand.Player; var item = player.Inventory.Items[player.LeftHand.HandIndex]; if (hand.HandType == InventoryHand.Right) { item = player.Inventory.Items[player.RightHand.HandIndex]; } return(item.Durability); }
void onAxeSwing(Item item, ITMHand hand) { /* Check for blocks around it XXX and above and below OXO * XWX OWO * XXX 0XO */ var player = hand.Player; var blockID = map.GetBlockID(player.SwingTarget); if (blockID == Block.Wood || blockID == Block.BirchWood) { game.AddNotification("Has Detected Block", NotifyRecipient.Local); } }
void AutoSpawnVehicle(VehicleType type, ITMHand hand) { var owner = hand.Owner as ITMPlayer; for (int i = autoSpawnPoint.Count - 1; i >= 0; --i) { if (autoSpawnPoint[i] == owner.SwingTarget) { autoSpawnPoint.RemoveAt(i); autoSpawnItems.RemoveAt(i); autoSpawnDir.RemoveAt(i); return; } } autoSpawnItems.Add(hand.ItemID); autoSpawnPoint.Add(owner.SwingTarget); autoSpawnDir.Add(owner.ViewDirection); }
void OnLockpickSwing(Item itemID, ITMHand hand) { var player = hand.Owner as ITMPlayer; if (player == null) { return; } if (player.SwingFace == BlockFace.ProxyDefault) { return; } var playerData = player.Tag as PlayerData; if (playerData.LockPickState > LockPickStatus.None) { return; } var blockID = map.GetBlockID(player.SwingTarget); if (blockID == Block.LockedDoorBottom) { if (world.IsBlockReceivingPower(player.SwingTarget)) { world.SetPower(player.SwingTarget, false, player); map.Commit(); } else { playerData.LockPickState = LockPickStatus.Picking; playerData.LockPickDoorPos = player.SwingTarget; playerData.PickAttemptsCount = 0; var b = map.GetBlockID(player.SwingTarget + GlobalPoint3D.Down); playerData.PickAttemptsRequired = b == Block.Granite ? 3 : b == Block.Rhyolite ? 4 : 2; } } }
void MyAction(Block block, byte aux, GlobalPoint3D point, ITMHand hand) { if (!keyDown) { if (IsBlockWood(block) && IsAxeValid(hand.ItemID) && LumberJack) { DoLumberJack(point, hand); } if (IsBlockMineable(block) && IsPickAxeValid(hand.ItemID) && VeinMining) { targetOre = block; DoVeinMine(point, hand); } if (IsBlockCrop(block) && IsScythValid(hand.ItemID) && Harvesting) { DoHarvest(point, hand); } ProcessErrorMessages(); } }
void OnVehicleSpawnerSwing(Item itemID, ITMHand hand) { SpawnVehicle(Game.Random.Next(2) == 0 ? VehicleType.Car : VehicleType.Truck, hand); }
void OnTrainSpawnerSwing(Item itemID, ITMHand hand) { SpawnVehicle(VehicleType.TrainEngine, hand); }
public void EventBlockMined(Block block, byte b, GlobalPoint3D point, ITMHand hand) { helper.NotifyAdmins("[" + point.X + ", " + point.Y + ", " + point.Z + "] " + hand.Player.Name + " mined a " + block.ToString() + "! Watch out!"); }
public void EventSwingItem(Item item, ITMHand hand) { helper.NotifyAll(hand.Owner.Name + " rolled a [" + game.Random.Next(1, 6) + "]"); }
void OverrideInput(Item itemID, ITMHand hand) { hand.Player.OverrideControlInput = !hand.Player.OverrideControlInput; }
private void ItemSwingEvent(Item item, ITMHand hand) { Logger.Log($"{item} swung"); this.Get(item).ConvertToItems(hand.Player, 1); }
void Paste(Item itemID, ITMHand hand) { pastePoint.X += pasteMap.MapSize.X; shouldPaste = true; }