создание модов для террарии
Как создать мод с помощью Microsoft Visual Studio (MVS) [tModLoader 0.8]
Переведено и дополнено Warten’ом. Ссылка на оригинал. (На английском)
Внимание! спрашивать тупые вопросы типа: А пачему руски язик не работает? Будет вгонять автора в дикий рэйдж.
Начало
Запомните: если ваша религия запрещает читать FAQ, гуглить и пользоваться переводчиком, помощи здесь можете не ждать. Вообще.
Есть некоторые вещи которые вы должны знать, прежде чем начать моддинг:
Введение
MVS поможет вам авто-завершением кода, показывая ошибки, и вообще… Это сделает процесс написания кода куда быстрее и легче.
Microsoft Visual Studio представляет собой приложение для создания многих видов программ. Вы, наверное, слышали о нем раньше, и, возможно, кто-то даже использовал его.
Если вы используете MVS в первый раз, я рекомендую просмотреть/читать гайды/учебники по C# в первую очередь. В интернете их достаточно много.
Как создать ваш мод (Далее – проект) в MVS
Пользоваться MVS лучше с установленным англ. языком! После установки и запуска у вас откроется начальная страница, закройте ее. Потом сделайте все как в списке.
Terraria → Файлы
Terraria — приключенческая песочница с элементами платформера и видом сбоку. Вам предстоит отправиться в красочный мир, где вы сможете. Подробнее
Это инструмент для создания простых модов в считанные минуты.
Использование:
1. сначала вам нужно будет создать скелет для вашего мода на этом сайте: http://javid.ddns.net/tModLoader/generator/ModSkeletonGenerator.html
При открытии исполняемого файла вы увидите кнопку выбора рабочего каталога — это каталог, в котором расположены файлы build.txt и т. д. Теперь вы можете легко редактировать и заполнять все необходимые поля. Когда вы закончите вносить информацию, вам нужно обновить и проверить, все ли правильно — если это так, вы можете нажать кнопку, чтобы создать свой файл. Вам не нужно беспокоиться о том, куда закинуть файлы, все расположено правильно, и должно работать нормально.
2. Теперь вам нужно переместить всю папку Mod в эту папку:
C: / Users / Ваше имя пользователя / Documents / Мои игры / Terraria / ModLoader / Mod Sources
Папка может еще не существовать, если это так, просто создайте ее. Теперь вы можете открыть TerrariaModLoader и заметить новый пункт меню: нажмите «Mod Sources», и в этой папке должен быть ваш мод! Нажмите на кнопку: Build and Refresh, и ваш мод заработает!
Создание модов для террарии
Для начала модифицирования террарии нам понадобится несколько программ :
1.Terraria(без неё ничего работать не будет)
3.Любой кодовый редактор(notpad++, visual studio, или блокнот)
1. Название директории (как название мода)
3. Название первого предмета(меча)
4. Ник автора (на английском)
Нажимаем кнопку generate mod skeleton
После начинаются скачивание дректории мода.
Затем распаковываем скаченый архив по адресу
Документы / My Games / Terraria / ModLoader / Mod Sources
Открываем папку мода и видим его внутренности
Файл с главными данными о моде
Ник автора (на английском)
Версия мода (любые цифры)
Экранное название мода
Это описание или же комментарий к моду от разработчика (на английском)
Последние 3 файла является системными и не требуют редактирования без должного навыка.
Внимание в место «ModNaOruzie» будет ваше название.
Переходим к основной части:
Переходим в папку items
Да это первый предмет(код меча и его спрайт)
С начала можно отредактировать данный предмет.
Открываем «название меча».cs
Item.melee при значении true наносит урон при взмахе (обязательно для мечей)
Item.Width и item.height значения высоты и ширины спрайта (в пикселях)
Item.Style значение показывающие вид анимации атаки (значения от 1 до 5)
Item. Usesound настройка звука атаки
Остальные значения я думаю понятны такие как урон цена и отбрасывание.
После изменения параметров можно протестировать работоспособность.
Заходим в Tmodloder
После в раздел Mod Source (исходники модов)
Нажимаем создать и перезагрузить
После чего мод создаётся и отправляется в список ваших модов где его можно включить и протестировать.
Добавление ещё одного предмета
Берём и копируем один из наших предметов со спрайтом в эту же папку после чего переименовываем (копии) файла и спрайта в новый предмет (на английском)
И редактируемом новый предмет как надо
Если есть замечания или вопросы пишите в комментариях или в ЛС (но с 18 по 20 мая не смогу ответить)
tModLoader Tutorial: [1] Getting started with tModLoader
Jofairden
Duke Fishron
ExampleMod is a mod that contains various code to ‘showcase’ what tModLoader is capable of. Please note that most of these are very blunt examples, they should be considered a base reference but nothing more.
There’s also the old tAPI docs, but they’re practically useless at this point.
Now, let’s get to it already. Please note I like to write out things, a lot. If you’re not about text, it might be better to watch a video guide instead.
I’m coming with tAPI/tConfig experience, what do I need to know?
Honestly, probably not much. tModLoader can be quite different in a lot of ways. Certain things are definitely similar though, such as things like ModItem, ModBuff etc. One thing you should know is that tML does not use JSON files (as handled previously) Furthermore, most communication is handled through our Discord server and Yorai/Skiphs are available there as well for more intermediate questions.
To get started, you’re going to need a so called: ‘mod skeleton’ These are simply the base files you will need to get started. It is recommended to use jopo’s ‘mod skeleton generator’ which does most work for you, so let’s go ahaid and do that.
The generator is located here: http://javid.ddns.net/tModLoader/generator/ModSkeletonGenerator.html
You will be greeted by a few textboxes, fill these in and hit the generate button. It is common to end your mod name with ‘Mod’ so for example if I’m considering «Jofairden’s Mod» I should name it «JofairdensMod», you should delete all special characters.
Noteworthy: you should never use whitespaces for most of this stuff (as these are internal names), either don’t use spaces at all or use hyphens. E.g. My Super Sword becomes MySuperSword or My_Super_Sword. The latter is considered ugly by most developers, so going with the former is your safest bet and the most common convention in mods. Also note that if you have installed Terraria in a different location (not in C:\ for example), the reference to Terraria.exe will be broken and you’ll need to add it manually.
Your file should look something like this:
This is your ‘Mod’ class, notice how it derives from the ‘Mod’ class which lies within tML. Your mod project should have only one ‘Mod’ class.
More information about class inheritance and derived classes can be found here. In general, deriving from ‘Mod’ allows tML to pick up on your mod, and allows you (`the modder`) to access various methods to work with. (these are often called ‘hooks’) You will later notice that almost all of your classes for your mod will derive from some class that lies within tML.
Your mod skeleton has only one method, in this case it’s actually not really a method (but it certainly looks like one)
The method you see is actually your class constructor, it is called when a new instance of your class is created. In this case, we can change various properties of our mod in it, which will then be set when tML creates a new instance of your mod. More information about class constructors can be found here. In the generated skeleton, various ‘Autoload’ properties are set to true. It is recommended to keep Autoloading on, as it saves you from writing a lot of unnecessary code.
Next, we’re going to look at another file in your mod’s root directory: build.txt
The description.txt file
This file is also pretty self explanatory. The information in this file will be used when you publish your mod to the mod browser.
Let’s continue: our first item
You can open the sword file the same way you did for your mod file. You will notice, there’s quite a bit more code to this than our skeleton mod class. Your code should look similar to the following:
Notice that there are 3 methods going on. Let’s go over them and see what they do.
Just recently, SetDefaults got separated with SetStaticDefaults, and this new method was introduced together with language support for mods. Most ‘static’ stuff (that is not directly tied to the item object) will go in this method, such as setting the displayed name and tooltip(s). In my example, I want my sword to show as «Jofairden’s Sword» and not as «JofairdensSword», so let’s go ahaid and change that:
Next, we will look at the ‘regular’ SetDefaults() method. Here we can set various properties related to the item object, such as the damage and knockback. You can change these properties to your liking, and there are more properties available than you will see in the generated skeleton. This is the part where you’ll want to have Visual Studio, as it contains ‘Intellisense’ which will show you all the properties available on the item object.
For my sword, I’m going to define custom behaviour, so let’s set the damage to 1 and the knockback to nothing for the sake of exampleness:
To remove the knockback, I can set it to 0, but I can also simply omit the line of setting it, as the default knockback is always 0.
Notice that the knockback is a float and not an integer, meaning floating numbers are possible, such as 6.5f knockback. Also notice how the type is denoted by appending the ‘f’ after the number, e.g: item.knockback = 6.5f (also note that simply noting 6.5 will result in an error, as this is a double and not a float (which can also be denoted by appending a ‘d’ after the number))
It is very important that you understand the various different built-in data types in c-sharp, more information on this is available here.
The last method is AddRecipes(), in which we can create new recipes for our sword. Of course, we could create any kind of recipe we want here. But restraining the recipes created to the actual item itself is good in terms of code organization. The generated code should look something like this:
This code creates a new ModRecipe object, with our mod as the source of the recipe. Note that ‘mod’ (in new ModRecipe(mod)) is simply a mod object (of our mod) available in the current scope. Not all times is this object available, more on this in the tips section.
Next, we add ‘DirtBlock’ (a block of dirt) as a required ingredient, with the requirement of having at least 10 (`ten`). Note that the value passed here for the item is an integer, an item type or `ID` if you will. Almost all vanilla item types can be found in the Terraria.ID.ItemID namespace. Since the Terraria.ID namespace is included at the top of our file, we can simply call the ItemID class as shown. There are various ways to require modded items as an ingredient, more on this at a later stage.
Next, we add ‘WorkBenches’ as a required tile. This means the player will need to stand at any workbench for the recipe to be available. This TileID class comes from the same namespace as `ItemID`, so from the Terraria.ID namespace.
Next, we set the result to ‘this’, which is a reference to our current class, our ‘ModItem’ in this case. At the end, we call the method AddRecipe() on the ModRecipe object to add the recipe to the game. Note that if you want to create another recipe for the sword (say, with some other ingredients), you can reuse the same object and simply construct a new ModRecipe instance:
More on recipes in a later tutorial.
Right now you have the barebones set up for your mod. If you go in-game and try to build the mod, it should work.
Right under the mod’s name, it’ll either say ‘Disabled’ or ‘Enabled. Disabled mods will not be part of your Terraria.
If you want to enable a mod, either click ‘Click to enable’ or click ‘Enable All’.
Make sure to click ‘Reload mods’ when you’ve changed enabled/disabled statuses.
The ‘More info’ button shows an information tab about the mod.
‘Mod Sources’ refers to your ‘Mod Sources ‘ folder in your documents. This is where all your source files for your mods are located, which for me would be ‘JofairdensMod’. In this menu you see several buttons, showcased in the following image.
Создание модов для террарии
Прежде чем начать устанавливать моды вам надо скачать последнюю версию TModLoader [forums.terraria.org]
Переходим по гипер ссылке в верху и ищем на сайте раздел Download
Есть несколько версий, но нам надо для Windows
После того как вы скачали, надо скинуть файлы из архива по пути «C(D):/*ваш путь*/Steam/steamapps/common/terraria/» с полной заменой файлов если попросит.
После сделанного просто запускаем игру через стим и ждем. В первый раз загрузка может быть долгой так что не волнуйтесь.
Если все было сделано верно то у вас должно было появиться несколько новых возможностей и выглядить это будет премерно так:
Следующие этапы я буду проводить на примере мода Overhaul [forums.terraria.org]
Заходим в магазин стим и вбиваем в поиск «TModLoader»
Что бы скачать эту небольшую программку, вам нужно что бы у вас была куплена сама игра
После этого заходим в свою библиотеку и видим это:
Скачиваем саму террарию, скачиваем только что полученную программу и переходим ко второму этапу
Это пожалуй самый долгий и сложный сбособ из тех которые присутствуют в этом руководстве
Первым делом надо найти и скачать нужный вам мод в формате «tmod«
Как только вы нашли и скачали то перекидываем его по пути «C:/Users/*Имя пользователя*/Documents/My Games/Terraria/ModLoader/Mods«
Включаем игру. Как только игра полностью включилась переходим в раздел «Моды», надо изменить статус мода с «Отключено» на «Включено» и нажимаем «Перезагрузить моды»
После перезагрузки все моды которые вы выбрали должны быть в статусе «Включено». Так же если у вас много модов можно нажать «Включить все» что бы не нажимать на каждый по отдельности
Первым делом включаем игру и после ее включения переходим в раздел «Браузер модов».
Далее в поиске вбиваем название нужного мода (П.С. поиск включаеться автоматически, вам не надо куда либо нажимать, а надо просто ввести название мода) и нажимаем кнопочку «Скачать». Ждем.
Как только мод скачался переходим в раздел «Моды» и изменяем статус мода с «Отключено» на «Включено», а далее перезагружаем моды
С модами можно играть и вместе с другом на сервере но надо что бы у вас обоих были установлено все ИДЕНТИЧНО, любой мод который есть у вас должен быть и у вашего друга.
Вообще не партесь по сингловым модам, просто устанавливайте что хотите, а если что-то будет не так с сервером то потом разбирайтесь
После этого руководства у вас должны были пропасть вопросы «Как установить моды на террарию». Если у вас что-то не вышло то попробуйте сделать заново или другим способом, а если и это вам не помогло то увы тут я бессилен
Если вам понравилось руководство или оно вам помогло не забудьте