Кролик в мешке: ловля голыми руками, мешок сразу в рюкзак (перенос из Книги #71)
Механизм ванильного PickupItem (как у курицы), но предмет wildRabbit кладётся в рюкзак, а не в руку. ЛКМ с мешком - выпустить, «Разобрать» в рюкзаке - мясо 10 / кожа 2 / кости 5. Выключатель: rabbithutch off - ванильный захват в руку. Перенесено из Книги некроманта (ветка 1.7, выпущено не было). Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
# Build intermediates - the shipped DLLs in the mod root are committed instead.
|
||||||
|
HarmonySrc/obj/
|
||||||
|
HarmonySrc/bin/
|
||||||
|
*.user
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
Key,File,Type,UsedInMainMenu,NoTranslate,KeepLoaded,english,Context / Alternate Text,german,spanish,french,italian,japanese,koreana,polish,brazilian,russian,turkish,schinese,tchinese
|
||||||
|
wildRabbit,items,Item,,,,Rabbit,,Hase,Conejo,Lapin,Coniglio,ウサギ,토끼,Królik,Coelho,Кролик,Tavşan,兔子,兔子
|
||||||
|
wildRabbitDesc,items,Item,,,,"A rabbit you caught with your bare hands. It kicks inside the sack.
|
||||||
|
|
||||||
|
Left click - let it go. Scrap it in the backpack for meat, leather and bones.",,"Ein Hase, mit bloßen Händen gefangen. Er strampelt im Sack.
|
||||||
|
|
||||||
|
Linksklick - freilassen. Im Rucksack zerlegen: Fleisch, Leder und Knochen.","Un conejo atrapado con las manos desnudas. Patalea dentro del saco.
|
||||||
|
|
||||||
|
Clic izquierdo: soltarlo. Despiézalo en la mochila: carne, cuero y huesos.","Un lapin attrapé à mains nues. Il se débat dans le sac.
|
||||||
|
|
||||||
|
Clic gauche : le relâcher. Démontez-le dans le sac à dos : viande, cuir et os.","Un coniglio preso a mani nude. Scalcia nel sacco.
|
||||||
|
|
||||||
|
Clic sinistro: liberarlo. Smontalo nello zaino: carne, cuoio e ossa.","素手で捕まえたウサギ。袋の中で暴れている。
|
||||||
|
|
||||||
|
左クリック - 放す。バックパックで分解すると肉、革、骨になる。","맨손으로 잡은 토끼. 자루 안에서 발버둥친다.
|
||||||
|
|
||||||
|
좌클릭 - 풀어준다. 배낭에서 분해하면 고기, 가죽, 뼈가 나온다.","Królik złapany gołymi rękami. Wierzga w worku.
|
||||||
|
|
||||||
|
Lewy przycisk - wypuść. Rozbierz w plecaku na mięso, skórę i kości.","Um coelho pego com as próprias mãos. Ele esperneia no saco.
|
||||||
|
|
||||||
|
Clique esquerdo - soltar. Desmonte na mochila: carne, couro e ossos.","Кролик, пойманный голыми руками. Брыкается в мешке.
|
||||||
|
|
||||||
|
ЛКМ - выпустить. Разберите в рюкзаке на мясо, кожу и кости.","Çıplak elle yakalanmış bir tavşan. Çuvalın içinde tepiniyor.
|
||||||
|
|
||||||
|
Sol tık - serbest bırak. Sırt çantasında parçala: et, deri ve kemik.","徒手抓到的兔子,在袋子里乱蹬。
|
||||||
|
|
||||||
|
左键 - 放走。在背包里拆解可得肉、皮革和骨头。","徒手抓到的兔子,在袋子裡亂蹬。
|
||||||
|
|
||||||
|
左鍵 - 放走。在背包裡拆解可得肉、皮革和骨頭。"
|
||||||
|
wildRabbitGrab,PlayerMoveController.cs,Label,,,,Press [action:local:Activate][action:permanent:Activate] to Grab the Rabbit,,"[action:local:Activate][action:permanent:Activate] drücken, um den Hasen zu packen",Pulsa [action:local:Activate][action:permanent:Activate] para atrapar el conejo,Appuyez sur [action:local:Activate][action:permanent:Activate] pour attraper le lapin,Premi [action:local:Activate][action:permanent:Activate] per afferrare il coniglio,[action:local:Activate][action:permanent:Activate]でウサギを捕まえる,[action:local:Activate][action:permanent:Activate]을(를) 눌러 토끼 잡기,"Naciśnij [action:local:Activate][action:permanent:Activate], aby złapać królika",Pressione [action:local:Activate][action:permanent:Activate] para pegar o coelho,"Нажмите [action:local:Activate][action:permanent:Activate], чтобы схватить кролика",Tavşanı yakalamak için [action:local:Activate][action:permanent:Activate] tuşuna bas,按[action:local:Activate][action:permanent:Activate]抓住兔子,按[action:local:Activate][action:permanent:Activate]抓住兔子
|
||||||
|
@@ -0,0 +1,8 @@
|
|||||||
|
<config>
|
||||||
|
<!-- Живой кролик в мешке (RabbitGrab.cs; перенесено из «Книги некроманта» 10.11.2026): «Я бы хватал кролика, но
|
||||||
|
в отличие от курицы пусть он сразу оказывается в сумке». PickupItem - ванильный механизм захвата курицы
|
||||||
|
(голой рукой, E); мешок кладёт в рюкзак код. -->
|
||||||
|
<append xpath="/entity_classes/entity_class[@name='animalRabbit']">
|
||||||
|
<property name="PickupItem" value="wildRabbit"/>
|
||||||
|
</append>
|
||||||
|
</config>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<config>
|
||||||
|
<!-- Живой кролик в мешке (RabbitGrab.cs; перенесено из «Книги некроманта» 10.11.2026, там задача #71 от 22.10,
|
||||||
|
не выпускалось). Пойманный игроком кролик сразу в рюкзаке. ЛКМ с мешком в руке - выпустить (ванильный
|
||||||
|
SpawnEntity, мешок тратит код). «Разобрать» в рюкзаке - мясо 10, кожа 2, кости 5 на кролика, как ножом
|
||||||
|
(указание 22.10: «Кролика можно будет разобрать на кожу, кости и мясо», «по команде сломать»). Пункт
|
||||||
|
«Разобрать» игра даёт по материалу Mleather (кожа) и весу не меньше кожи (5). Мешок и поза в руке - как у
|
||||||
|
кожи. Иконка - ванильная блока «спящий кролик» (sleeperRabbitAnimal), по ссылке; имя предмета в игре -
|
||||||
|
просто «Кролик» (22.10). Имя файла - wildRabbit, в пару ванильному wildChicken. -->
|
||||||
|
<append xpath="/items">
|
||||||
|
<item name="wildRabbit">
|
||||||
|
<property name="Tags" value="noMods"/>
|
||||||
|
<property name="HoldType" value="45"/>
|
||||||
|
<property name="Meshfile" value="@:Other/Items/Misc/sackPrefab.prefab"/>
|
||||||
|
<property name="DropMeshfile" value="@:Other/Items/Misc/sack_droppedPrefab.prefab"/>
|
||||||
|
<property name="Material" value="Mleather"/>
|
||||||
|
<property name="CustomIcon" value="sleeperRabbitAnimal"/>
|
||||||
|
<property name="DescriptionKey" value="wildRabbitDesc"/>
|
||||||
|
<property name="Stacknumber" value="10"/>
|
||||||
|
<property name="Weight" value="5"/>
|
||||||
|
<property name="EconomicValue" value="0"/>
|
||||||
|
<property name="SellableToTrader" value="false"/>
|
||||||
|
<property name="Group" value="Resources"/>
|
||||||
|
<property name="SoundPickup" value="rabbitpain"/>
|
||||||
|
<property class="Action0">
|
||||||
|
<property name="Class" value="SpawnEntity"/>
|
||||||
|
<property name="AnimType" value="4"/>
|
||||||
|
<property name="AnimWait" value="0.3"/>
|
||||||
|
<property name="SoundWarn" value="rabbitpain"/>
|
||||||
|
<property name="Entity" value="animalRabbit"/>
|
||||||
|
<property name="EntityOffset" value="0, -1, 1.2"/>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</append>
|
||||||
|
</config>
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using HarmonyLib;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace RabbitHutch
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Живой кролик в мешке (перенесено из «Книги некроманта» 10.11.2026; там задача #71 от 22.10.2026, выпущено
|
||||||
|
/// не было). Указание 22.10: «Я бы хватал кролика, но в отличие от курицы пусть он сразу оказывается в сумке»;
|
||||||
|
/// предмет - «Живой кролик в мешке», имя в игре - просто «Кролик». Ваниль даёт схватить любое существо, у которого
|
||||||
|
/// в описании есть PickupItem (EntityAlive: команда grab голой рукой, предмет кладётся в слот руки, существо
|
||||||
|
/// уходит из мира через Collect) - так ловят курицу. Кролику PickupItem дан в entityclasses.xml, а здесь его
|
||||||
|
/// мешок кладётся сразу в рюкзак (нет места - на пояс, иначе под ноги).
|
||||||
|
///
|
||||||
|
/// Выпустить - ЛКМ с мешком в руке (ItemActionSpawnEntity, Entity=animalRabbit): ваниль предмет не тратит, тратим
|
||||||
|
/// здесь. Разделать - «Разобрать» в рюкзаке. Выключатель - rabbithutch off: тогда захват идёт ванильно,
|
||||||
|
/// мешок - в руку, как курица.
|
||||||
|
/// </summary>
|
||||||
|
public static class RabbitGrab
|
||||||
|
{
|
||||||
|
public const string SackItem = "wildRabbit";
|
||||||
|
public static bool Enabled = true;
|
||||||
|
|
||||||
|
public static bool IsSackAnimal(EntityAlive _e) => _e != null && _e.EntityClass != null && _e.EntityClass.PickupItem == SackItem;
|
||||||
|
|
||||||
|
public static bool IsSack(ItemValue _iv) => _iv != null && _iv.ItemClass != null && _iv.ItemClass.GetItemName() == SackItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Захват кролика - мешок сразу в рюкзак.</summary>
|
||||||
|
[HarmonyPatch(typeof(EntityAlive), nameof(EntityAlive.OnEntityActivated))]
|
||||||
|
public static class Patch_EntityAlive_OnEntityActivated_RabbitGrab
|
||||||
|
{
|
||||||
|
public static bool Prefix(EntityAlive __instance, EntityActivationCommand _command, EntityPlayerLocal _playerFocusing)
|
||||||
|
{
|
||||||
|
if (!RabbitGrab.Enabled || _command.commandId != "grab" || _playerFocusing == null || !RabbitGrab.IsSackAnimal(__instance))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ItemClass ic = ItemClass.GetItemClass(RabbitGrab.SackItem);
|
||||||
|
if (ic == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[RabbitHutch] RabbitGrab: нет предмета " + RabbitGrab.SackItem + " - захват ванильский");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ItemStack sack = new ItemStack(new ItemValue(ic.Id), 1);
|
||||||
|
string where = "рюкзак";
|
||||||
|
if (_playerFocusing.bag == null || !_playerFocusing.bag.AddItem(sack))
|
||||||
|
{
|
||||||
|
where = "пояс";
|
||||||
|
if (_playerFocusing.inventory == null || !_playerFocusing.inventory.AddItem(sack))
|
||||||
|
{
|
||||||
|
where = "под ноги";
|
||||||
|
_playerFocusing.world.gameManager.ItemDropServer(sack, _playerFocusing.GetPosition() + Vector3.up * 0.5f, Vector3.zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_playerFocusing.MinEventContext.Other = __instance;
|
||||||
|
_playerFocusing.FireEvent(MinEventTypes.onSelfPickupOther);
|
||||||
|
__instance.MinEventContext.Other = _playerFocusing;
|
||||||
|
__instance.FireEvent(MinEventTypes.onSelfPickedUpByOther);
|
||||||
|
Audio.Manager.PlayInsidePlayerHead(ic.Properties.GetString("SoundPickup"));
|
||||||
|
__instance.Collect(_playerFocusing.entityId);
|
||||||
|
Debug.Log("[RabbitHutch] RabbitGrab: кролик " + __instance.entityId + " пойман, мешок - " + where);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Подсказка над кроликом - своя (ваниль пишет «схватить курицу» для любого существа с PickupItem).</summary>
|
||||||
|
[HarmonyPatch(typeof(EntityAlive), nameof(EntityAlive.GetActivationText))]
|
||||||
|
public static class Patch_EntityAlive_GetActivationText_RabbitGrab
|
||||||
|
{
|
||||||
|
public static void Postfix(EntityAlive __instance, ref string __result)
|
||||||
|
{
|
||||||
|
if (RabbitGrab.Enabled && RabbitGrab.IsSackAnimal(__instance))
|
||||||
|
{
|
||||||
|
__result = Localization.Get("wildRabbitGrab");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Выпуск из мешка тратит мешок (ванильный SpawnEntity предмет не трогает).</summary>
|
||||||
|
[HarmonyPatch(typeof(ItemActionSpawnEntity), "Spawn", new System.Type[] { typeof(ItemActionData) })]
|
||||||
|
public static class Patch_ItemActionSpawnEntity_Spawn_RabbitSack
|
||||||
|
{
|
||||||
|
public static void Postfix(ItemActionData _actionData)
|
||||||
|
{
|
||||||
|
ItemInventoryData inv = _actionData?.invData;
|
||||||
|
if (inv?.holdingEntity == null || !RabbitGrab.IsSack(inv.itemValue))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Inventory pack = inv.holdingEntity.inventory;
|
||||||
|
ItemStack held = pack.GetItem(inv.slotIdx);
|
||||||
|
if (held == null || held.IsEmpty() || !RabbitGrab.IsSack(held.itemValue))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
held = held.Clone();
|
||||||
|
held.count--;
|
||||||
|
pack.SetItem(inv.slotIdx, held.count > 0 ? held : ItemStack.Empty.Clone());
|
||||||
|
Debug.Log("[RabbitHutch] RabbitGrab: кролик выпущен из мешка, осталось " + Mathf.Max(0, held.count));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Разделать кролика - «Разобрать» в рюкзаке (указание 22.10: «Кролика можно будет разобрать на кожу, кости и
|
||||||
|
/// мясо»; «Разделывать будем по команде сломать»). Пункт ваниль показывает сама: мешок из кожи (Mleather, forge_category
|
||||||
|
/// leather), вес не меньше кожи. Но ванильная разборка даёт один материал через очередь крафта - у мешка она наша:
|
||||||
|
/// вся стопка сразу, на каждого кролика добыча разделки ножом (entityclasses.xml animalRabbit, butcherHarvest).</summary>
|
||||||
|
[HarmonyPatch(typeof(ItemActionEntryScrap), nameof(ItemActionEntryScrap.OnActivated))]
|
||||||
|
public static class Patch_ItemActionEntryScrap_OnActivated_RabbitSack
|
||||||
|
{
|
||||||
|
static readonly string[] Yield = { "foodRawMeat", "resourceLeather", "resourceBone" };
|
||||||
|
static readonly int[] YieldCount = { 10, 2, 5 };
|
||||||
|
|
||||||
|
public static bool Prefix(ItemActionEntryScrap __instance)
|
||||||
|
{
|
||||||
|
if (!(__instance.ItemController is IItemStackController isc))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ItemStack st = isc.ItemStack;
|
||||||
|
if (st == null || st.IsEmpty() || !RabbitGrab.IsSack(st.itemValue))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
EntityPlayerLocal player = __instance.ItemController.xui.playerUI.entityPlayer;
|
||||||
|
XUiM_PlayerInventory pack = __instance.ItemController.xui.PlayerInventory;
|
||||||
|
int n = st.count;
|
||||||
|
isc.ItemStack = ItemStack.Empty.Clone();
|
||||||
|
for (int i = 0; i < Yield.Length; i++)
|
||||||
|
{
|
||||||
|
ItemClass ic = ItemClass.GetItemClass(Yield[i]);
|
||||||
|
if (ic == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ItemStack s = new ItemStack(new ItemValue(ic.Id), YieldCount[i] * n);
|
||||||
|
if (!pack.AddItem(s))
|
||||||
|
{
|
||||||
|
GameManager.Instance.ItemDropServer(s, player.GetPosition(), new Vector3(0.5f, 0f, 0.5f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isc.WindowGroup?.Controller?.SetAllChildrenDirty();
|
||||||
|
Audio.Manager.PlayInsidePlayerHead("rabbitdeath");
|
||||||
|
Debug.Log("[RabbitHutch] RabbitGrab: разобрано мешков с кроликами - " + n);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ConsoleCmdRabbitHutch : ConsoleCmdAbstract
|
||||||
|
{
|
||||||
|
public override bool IsExecuteOnClient => true;
|
||||||
|
|
||||||
|
public override bool AllowedInMainMenu => false;
|
||||||
|
|
||||||
|
public override string[] getCommands()
|
||||||
|
{
|
||||||
|
return new string[] { "rabbithutch" };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string getDescription()
|
||||||
|
{
|
||||||
|
return "RabbitHutch: grabbed rabbit goes straight to the backpack - switch.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string getHelp()
|
||||||
|
{
|
||||||
|
return "rabbithutch - status\n" +
|
||||||
|
"rabbithutch on|off - off: vanilla grab, the sack goes to the hand like a chicken";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
||||||
|
{
|
||||||
|
SdtdConsole con = SingletonMonoBehaviour<SdtdConsole>.Instance;
|
||||||
|
if (_params.Count >= 1 && (_params[0] == "on" || _params[0] == "off"))
|
||||||
|
{
|
||||||
|
RabbitGrab.Enabled = _params[0] == "on";
|
||||||
|
}
|
||||||
|
con.Output("rabbithutch: " + (RabbitGrab.Enabled ? "on - rabbit sack goes to the backpack" : "off - vanilla grab"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
|
<AssemblyName>RabbitHutchHarmony</AssemblyName>
|
||||||
|
<RootNamespace>RabbitHutch</RootNamespace>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<Nullable>disable</Nullable>
|
||||||
|
<!-- The DLL is loaded straight out of the mod folder by the game, not via NuGet/deps.json. -->
|
||||||
|
<GenerateDependencyFile>false</GenerateDependencyFile>
|
||||||
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
|
<OutputPath>bin\</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- Game/Harmony assemblies: compile-time only, never copied into our output (they already
|
||||||
|
exist where the game loads them from). Same layout as NecromancerHarmony.csproj. -->
|
||||||
|
<Reference Include="0Harmony">
|
||||||
|
<HintPath>..\..\0_TFP_Harmony\0Harmony.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Assembly-CSharp">
|
||||||
|
<HintPath>..\..\..\7DaysToDie_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
<!-- Vector3/Mathf/Debug (RabbitGrab.cs). -->
|
||||||
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
|
<HintPath>..\..\..\7DaysToDie_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<xml>
|
||||||
|
<Name value="RabbitHutch" />
|
||||||
|
<DisplayName value="Rabbit Hutch" />
|
||||||
|
<Description value="Catch rabbits with your bare hands, like chickens - but the sack goes straight to your backpack. Let the rabbit go or scrap the sack for meat, leather and bones. Fully localized into 13 languages. Single-player; requires EAC off." />
|
||||||
|
<Author value="Alex Cube" />
|
||||||
|
<Version value="0.1.0" />
|
||||||
|
</xml>
|
||||||
Binary file not shown.
Binary file not shown.
+17
@@ -0,0 +1,17 @@
|
|||||||
|
# Rabbit Hutch
|
||||||
|
|
||||||
|
A 7 Days to Die mod by Alex Cube. Grab the rabbit, keep it in a sack.
|
||||||
|
|
||||||
|
- Catch a rabbit with your bare hands, just like a chicken - but the sack lands straight in your backpack, no hand-carrying.
|
||||||
|
- Left click with the sack in hand to let the rabbit go.
|
||||||
|
- Scrap the sack in the backpack for meat, leather and bones, same as butchering with a knife.
|
||||||
|
- Console switch: `rabbithutch off` returns the vanilla hand-carry grab, `rabbithutch on` - back to the backpack.
|
||||||
|
|
||||||
|
Text in 13 languages. DLL mod (Harmony). Made on 7 Days to Die 3.4.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Unzip into the game's `Mods` folder so that you get `Mods/RabbitHutch/ModInfo.xml`.
|
||||||
|
Multiplayer: install on the server and on every client. Requires EAC off.
|
||||||
|
|
||||||
|
The rabbit catch moved here from the Necromancer's Tome dev branch (1.7, unreleased); the released Tome (1.6.x) never had it, so the two mods do not overlap.
|
||||||
Reference in New Issue
Block a user