Standalone [1.3] tModLoader - A Modding API

The projectile works good, but the buff... What i need to put into public virtual void Update(Player player, ref int buffIndex)?
Here's all you need to do for minion buffs:
1: Continuously set the buff time so it's infinite (you can do that in Update which is already automatic)
2: Check if the buff ends, and if so kill all minion projectiles
 
Here's all you need to do for minion buffs:
1: Continuously set the buff time so it's infinite (you can do that in Update which is already automatic)
2: Check if the buff ends, and if so kill all minion projectiles
You can give me any example code? Im not in my house to send to you my code, sory :S
 
Note that until we get ModPlayer in, this is the only practical way. (using vanilla minion booleans) The only downside to this is if you have both your minion and the stardust dragon (as in the example), you'll have to right click on both the buff icons to de-spawn them. No big deal, bear with it.
Code:
public override void Update(Player player, ref int buffIndex)
        {
            if (player.ownedProjectileCounts[mod.ProjectileType("NyanCatMinion")] > 0)
            {
                player.stardustDragon = true;
            }
            if (!player.stardustDragon)
            {
                player.DelBuff(buffIndex);
                buffIndex--;
            }
            else
            {
                player.buffTime[buffIndex] = 18000;
            }
        }
Projectile.AI needs to have something like this somewhere in there.
Code:
if (player9.dead)
                {
                    player9.stardustDragon = false;
                }
                if (player9.stardustDragon)
                {
                    projectile.timeLeft = 2;
                }
 
Note that until we get ModPlayer in, this is the only practical way. (using vanilla minion booleans) The only downside to this is if you have both your minion and the stardust dragon (as in the example), you'll have to right click on both the buff icons to de-spawn them. No big deal, bear with it.
Code:
public override void Update(Player player, ref int buffIndex)
        {
            if (player.ownedProjectileCounts[mod.ProjectileType("NyanCatMinion")] > 0)
            {
                player.stardustDragon = true;
            }
            if (!player.stardustDragon)
            {
                player.DelBuff(buffIndex);
                buffIndex--;
            }
            else
            {
                player.buffTime[buffIndex] = 18000;
            }
        }
Projectile.AI needs to have something like this somewhere in there.
Code:
if (player9.dead)
                {
                    player9.stardustDragon = false;
                }
                if (player9.stardustDragon)
                {
                    projectile.timeLeft = 2;
                }
Oh, now i understand. TY
 
Hmmm, what is the problem with this?

Error CS1501:
Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Ersion.Buffs;
using Terraria.ModLoader;

namespace Ersion.Items.Armor
{
    public class FleshHelmet : ModItem
    {
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Head);
            return true;
        }

        public override void SetDefaults()
        {
            item.name = "Flesh Helmet";
            item.width = 18;
            item.height = 18;
            item.toolTip = "The Helmet of the Depths";
            item.value = 5000;
            item.rare = 6;
            item.defense = 4;
        }
      
        public override void UpdateEquip(Player player)
        {
            player.maxMinions ++;
        }
      

        public override bool IsArmorSet(Item head, Item body, Item legs)
        {
            return body.type == mod.ItemType("FleshBreastplate") && legs.type == mod.ItemType("FleshLeggings");
        }

        public override void UpdateArmorSet(Player player)
        {
            player.setBonus = "Summons The Hungry";
            player.AddBuff(mod.BuffType("Hungry")); // The problem is here!!
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "LivingFlesh", 8);
            recipe.AddTile(16);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
Hmmm, what is the problem with this?

Error CS1501:
Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Ersion.Buffs;
using Terraria.ModLoader;

namespace Ersion.Items.Armor
{
    public class FleshHelmet : ModItem
    {
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Head);
            return true;
        }

        public override void SetDefaults()
        {
            item.name = "Flesh Helmet";
            item.width = 18;
            item.height = 18;
            item.toolTip = "The Helmet of the Depths";
            item.value = 5000;
            item.rare = 6;
            item.defense = 4;
        }
     
        public override void UpdateEquip(Player player)
        {
            player.maxMinions ++;
        }
     

        public override bool IsArmorSet(Item head, Item body, Item legs)
        {
            return body.type == mod.ItemType("FleshBreastplate") && legs.type == mod.ItemType("FleshLeggings");
        }

        public override void UpdateArmorSet(Player player)
        {
            player.setBonus = "Summons The Hungry";
            player.AddBuff(mod.BuffType("Hungry")); // The problem is here!!
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "LivingFlesh", 8);
            recipe.AddTile(16);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
Adding a buff (like you do on the line in question) also requires a 'time' parameter in the form of an integer, so:
Code:
player.AddBuff(mod.BuffType("Hungry"), 2);
I made the second parameter a '2' instead of a '1', because this seems to be the value that is best suited when adding a buff to a player from an item (accessory/armor) in my experience.
 
Adding a buff (like you do on the line in question) also requires a 'time' parameter in the form of an integer, so:
Code:
player.AddBuff(mod.BuffType("Hungry"), 2);
I made the second parameter a '2' instead of a '1', because this seems to be the value that is best suited when adding a buff to a player from an item (accessory/armor) in my experience.
Oh, TY. And you know how i can make to spawn the projectile?
 
Oh, TY. And you know how i can make to spawn the projectile?
You mean to check if the player already has the summon that corresponds with the armor worn? I think you can just check if the player does not already have the buff in question and then spawn a projectile like you normally would...
 
You mean to check if the player already has the summon that corresponds with the armor worn? I think you can just check if the player does not already have the buff in question and then spawn a projectile like you normally would...
When i have the armor, i have the buff but the minion doesnt appears
 
Like this or how?
Code:
Main.recipe[1346].requiredItem[0].SetDefaults(ItemID.StoneBlock);
Main.recipe[1346].requiredItem[0].stack = 0;


D8keIUR.png
Hey, just wanted to ask, how did you fix yours? I'm trying to make my player actually hold the sword on the handle, if it's ok can you edit it? Thanks(in advance).
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace CraftKnightMod.Items.Weapons
{
    public class SwordofDestruction : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Sword of Destruction";
            item.damage = 500;
            item.melee = true;
            item.width = 100;
            item.height = 100;
            item.toolTip = "You earned this.";
            item.useTime = 37;
            item.useAnimation = 37;
            item.useStyle = 1;
            item.knockBack = 6;
            item.value = 100000000;
            item.rare = 9;
            item.useSound = 1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Wood);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
       
        public override void UseStyle(Player player)
        {
            player.itemLocation.X -= 2f * player.direction;
            player.itemLocation.Y += 1f * player.gravDir;
        }
    }
}
 

Attachments

  • SwordofDestruction.png
    SwordofDestruction.png
    1.5 KB · Views: 186
hey, so I've been having a problem with this since always, figured wait for the installer maybe that will help.

right now when I install it it just sends me this
jP3M74B.jpg

is it because I have the GOG version?
 
When i have the armor, i have the buff but the minion doesnt appears
If you didn't spawn the projectile, it won't be there: https://github.com/bluemagic123/tMo...6dab5996c96474/ExampleMod/NPCs/Octopus.cs#L57

is it because I have the GOG version?
Yes, it is. Removing all the steam specific code and maintaining two separate code bases would be a lot of work, at least at this stage. (sorry, :( )

How I change the color of liquid of golden shower?
Golden shower uses vanilla dust 170, which is gold color. You can do a globalprojectile, copy over all the AI code into PreAI, have that return false, but change the dust that is spawned. Are you making a new weapon or just changing a vanilla weapon?

I want to make upgraded lunar armors anyone know what the code would be? I mean for the bonuses from the armors.
You'll probably want to decompile Terraria...
Here is Solar, see what you can do with this:
Code:
if (this.head == 171 && this.body == 177 && this.legs == 112)
            {
                this.setSolar = true;
                this.setBonus = Lang.setBonus(43, false);
                this.solarCounter++;
                int num11 = 240;
                if (this.solarCounter >= num11)
                {
                    if (this.solarShields > 0 && this.solarShields < 3)
                    {
                        for (int num12 = 0; num12 < 22; num12++)
                        {
                            if (this.buffType[num12] >= 170 && this.buffType[num12] <= 171)
                            {
                                this.DelBuff(num12);
                            }
                        }
                    }
                    if (this.solarShields < 3)
                    {
                        this.AddBuff(170 + this.solarShields, 5, false);
                        for (int num13 = 0; num13 < 16; num13++)
                        {
                            Dust dust = Main.dust[Dust.NewDust(this.position, this.width, this.height, 6, 0f, 0f, 100, default(Color), 1f)];
                            dust.noGravity = true;
                            dust.scale = 1.7f;
                            dust.fadeIn = 0.5f;
                            dust.velocity *= 5f;
                            dust.shader = GameShaders.Armor.GetSecondaryShader(this.ArmorSetDye(), this);
                        }
                        this.solarCounter = 0;
                    }
                    else
                    {
                        this.solarCounter = num11;
                    }
                }
                for (int num14 = this.solarShields; num14 < 3; num14++)
                {
                    this.solarShieldPos[num14] = Vector2.Zero;
                }
                for (int num15 = 0; num15 < this.solarShields; num15++)
                {
                    this.solarShieldPos[num15] += this.solarShieldVel[num15];
                    Vector2 value = ((float)this.miscCounter / 100f * 6.28318548f + (float)num15 * (6.28318548f / (float)this.solarShields)).ToRotationVector2() * 6f;
                    value.X = (float)(this.direction * 20);
                    this.solarShieldVel[num15] = (value - this.solarShieldPos[num15]) * 0.2f;
                }
                if (this.dashDelay >= 0)
                {
                    this.solarDashing = false;
                    this.solarDashConsumedFlare = false;
                }
                bool flag = this.solarDashing && this.dashDelay < 0;
                if (this.solarShields > 0 || flag)
                {
                    this.dash = 3;
                }
            }
            else
            {
                this.solarCounter = 0;
            }
 
hey, so I've been having a problem with this since always, figured wait for the installer maybe that will help.

right now when I install it it just sends me this
jP3M74B.jpg

is it because I have the GOG version?
Yes. The forum rules prevent me from distributing mod executables that remove the Steam checks, so the only way I can distribute a GOG version would be through a diff patch. However, creating a diff patch requires that I have the vanilla GOG version myself, which requires me to buy it.
 
Golden shower uses vanilla dust 170, which is gold color. You can do a globalprojectile, copy over all the AI code into PreAI, have that return false, but change the dust that is spawned. Are you making a new weapon or just changing a vanilla weapon?[/CODE]
I am making a sprite to a mod that will add a platinum shower, with better buff but I don't have idea of how i do this :/
 
Is there any way to add possible drops for the extractinator? It looks to me like the code for extractinating is in Player.cs so I'm guessing it's won't be possible until ModPlayer is added.
 
Is there any way to add possible drops for the extractinator? It looks to me like the code for extractinating is in Player.cs so I'm guessing it's won't be possible until ModPlayer is added.
I'll probably have to add a hook for that in the next update.

this mod decrease spawn ratio?
my underworld's max enemies are change to 5
No, it doesn't decrease the spawn cap.
 
To me too is decreased, in the blood moon normally 40-50 monsters spawn, but in my three last blood moons only 10
 
Back
Top Bottom