Standalone [1.3] tModLoader - A Modding API

thx for the page

i found something funky the way i made it

i tryed to make the example sword 10 times longer but then it wont swing right

useing shortsword style works for the long sword but its hitbox is funky right below and above the player going 10 blocks up and down but somewhat good hitbox out the sword itselv just blocks like grass gets cut way off hitbox 10 blocks up and down from both tip and player of the sword

and the dust the example sword spawns up in sky and down in ground where the full texture box is
That's probably because you haven't changed the position values of the dusts.
Anyway, that's probably something you'll not want to do if it behaves that weird :)
 
That's probably because you haven't changed the position values of the dusts.
Anyway, that's probably something you'll not want to do if it behaves that weird :)

lets just say i have alot of fun with this sword now

1 damage per hit

usetime 3 (i know 2 is fastest it can) (i got a melee speed +3% on so usetime 2 wont work)

drops a copper coin per hit or silver,gold,platinum with there own changes coppercoin is default if all others fail
(platinum 1.000.000)
(gold 10.000)
(silver 100)
(copper 1)

useing else if as the codes

on the destroyer normal mode

coin rain and they drop so fast they dont land berfor dieing to max items

sword size 400x400
normal size 40x40
 
Questions never end!
Well, I'm tryna make myself a glow stone block, a block that can produce light.
So just add some codes to my TestBlockTile like:
Code:
        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            r = 5f;
            g = 5f;
            b = 5f;
        }
Then it produces light, but the light is purely white and obviously it's too magical.
I looked up in wiki, the RGB of a normal vanilla torch would be 1,95,8. I don't know how I should adapt this to the codes. I tried:
Code:
        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            r = 1f;
            g = 95f;
            b = 8f;
        }
It simply becomes another kind of super magical green.
Does this "rgb" in codes mean something different from the "RGB" in wiki?
 
Questions never end!
Well, I'm tryna make myself a glow stone block, a block that can produce light.
So just add some codes to my TestBlockTile like:
Code:
        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            r = 5f;
            g = 5f;
            b = 5f;
        }
Then it produces light, but the light is purely white and obviously it's too magical.
I looked up in wiki, the RGB of a normal vanilla torch would be 1,95,8. I don't know how I should adapt this to the codes. I tried:
Code:
        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            r = 1f;
            g = 95f;
            b = 8f;
        }
It simply becomes another kind of super magical green.
Does this "rgb" in codes mean something different from the "RGB" in wiki?
For ModifyLight, it is preferred for the RGB values to range from 0 to 1.
 
Questions never end!
Well, I'm tryna make myself a glow stone block, a block that can produce light.
So just add some codes to my TestBlockTile like:
Code:
        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            r = 5f;
            g = 5f;
            b = 5f;
        }
Then it produces light, but the light is purely white and obviously it's too magical.
I looked up in wiki, the RGB of a normal vanilla torch would be 1,95,8. I don't know how I should adapt this to the codes. I tried:
Code:
        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            r = 1f;
            g = 95f;
            b = 8f;
        }
It simply becomes another kind of super magical green.
Does this "rgb" in codes mean something different from the "RGB" in wiki?
Also, RGB stands for Red-Green-Blue, so raising the value of 'g' would result in a green light, whereas if you raise the 'r' value, the red would intensify.
 
Also, RGB stands for Red-Green-Blue, so raising the value of 'g' would result in a green light, whereas if you raise the 'r' value, the red would intensify.
Yeah, I know that.
I turned these values (1, 95, 8)into percentage, like
red 0.0096
green 0.913
bule 0.0774
But it's not the normal torch light. How should I create a torch light color?
 
Yeah, I know that.
I turned these values (1, 95, 8)into percentage, like
red 0.0096
green 0.913
bule 0.0774
But it's not the normal torch light. How should I create a torch light color?
Try these:
R = 1f;
G = 0.95f;
B = 0.8f;
 
Em... I'm now creating an advanced archery potion. Looking up in the reference, only find myself Player.arrowDamage. Where should the "20% increased arrow speed" be? Can't find it in the reference.
And in fact, I downloaded the source code of Terraria, and I managed to discover the item.cs and player.cs. I can first find ID in item.cs then use the ID to find the item and its effect in player.cs. This works just fine for weapons or armors, but not for potions. Seems potion's data isn't in player.cs, no idea which file I should check.
 
Em... I'm now creating an advanced archery potion. Looking up in the reference, only find myself Player.arrowDamage. Where should the "20% increased arrow speed" be? Can't find it in the reference.
And in fact, I downloaded the source code of Terraria, and I managed to discover the item.cs and player.cs. I can first find ID in item.cs then use the ID to find the item and its effect in player.cs. This works just fine for weapons or armors, but not for potions. Seems potion's data isn't in player.cs, no idea which file I should check.
If you want your buff to state "20% increased arrow speed", you can set 'Main.buffTip[this.Type]' in the SetDefaults function of the buff.
The effects of the archery potion can actually be found in Player.cs. The only thing it does is setting player.archery to true.
 
If you want your buff to state "20% increased arrow speed", you can set 'Main.buffTip[this.Type]' in the SetDefaults function of the buff.
The effects of the archery potion can actually be found in Player.cs. The only thing it does is setting player.archery to true.
Then buff of the potion may not be in the player.cs, I guess? Where should the buff data be?
And I mean, I'm making an advanced archery potion which gives 35% increased arrow speed and damage.
In order to realize this effect, I write the Archery2Buff, like
Code:
        public override void SetDefaults()
        {
            Main.buffName[this.Type] = "Archery 2";
            Main.buffTip[this.Type] = "35% increased arrow speed and damage";
            Main.debuff[Type] = false;
            Main.buffNoTimeDisplay[Type] = false;
        }

        public override void Update(Player player, ref int buffIndex)
        {
            player.arrowDamage += 35f;
        }
But I only know how to give a bonus to damage - use this player.arrowDamage I found in the reference.
Then how to give a bonus to the arrow speed?
 
Then buff of the potion may not be in the player.cs, I guess? Where should the buff data be?
And I mean, I'm making an advanced archery potion which gives 35% increased arrow speed and damage.
In order to realize this effect, I write the Archery2Buff, like
Code:
        public override void SetDefaults()
        {
            Main.buffName[this.Type] = "Archery 2";
            Main.buffTip[this.Type] = "35% increased arrow speed and damage";
            Main.debuff[Type] = false;
            Main.buffNoTimeDisplay[Type] = false;
        }

        public override void Update(Player player, ref int buffIndex)
        {
            player.arrowDamage += 35f;
        }
But I only know how to give a bonus to damage - use this player.arrowDamage I found in the reference.
Then how to give a bonus to the arrow speed?
The speed is actually handled internally, so there's no way to modify that. They're doing it using the following code in the PickAmmo function inside Player.cs:
Code:
if (sItem.useAmmo == 1 && this.archery)
{
    if (speed < 20f)
    {
        speed *= 1.2f;
        if (speed > 20f)
        {
            speed = 20f;
        }
    }
    Damage = (int)((double)((float)Damage) * 1.2);
}
Like stated though, there's no way to modify that now.
 
Then buff of the potion may not be in the player.cs, I guess? Where should the buff data be?
And I mean, I'm making an advanced archery potion which gives 35% increased arrow speed and damage.
In order to realize this effect, I write the Archery2Buff, like
Code:
        public override void SetDefaults()
        {
            Main.buffName[this.Type] = "Archery 2";
            Main.buffTip[this.Type] = "35% increased arrow speed and damage";
            Main.debuff[Type] = false;
            Main.buffNoTimeDisplay[Type] = false;
        }

        public override void Update(Player player, ref int buffIndex)
        {
            player.arrowDamage += 35f;
        }
But I only know how to give a bonus to damage - use this player.arrowDamage I found in the reference.
Then how to give a bonus to the arrow speed?
The speed is actually handled internally, so there's no way to modify that. They're doing it using the following code in the PickAmmo function inside Player.cs:
Code:
if (sItem.useAmmo == 1 && this.archery)
{
    if (speed < 20f)
    {
        speed *= 1.2f;
        if (speed > 20f)
        {
            speed = 20f;
        }
    }
    Damage = (int)((double)((float)Damage) * 1.2);
}
Like stated though, there's no way to modify that now.
It should be possible to modify the arrow speed using GlobalItem's Shoot hook. You can check the item parameter to see whether the weapon uses arrows as ammo.
 
It should be possible to modify the arrow speed using GlobalItem's Shoot hook. You can check the item parameter to see whether the weapon uses arrows as ammo.
Well, don't quite get ya. Maybe you can say more specifically?
Archery potion aims to increase arrow speed, but this isn't an attribute of player, but an attribute of the arrow, the projectile itself right?
 
It should be possible to modify the arrow speed using GlobalItem's Shoot hook. You can check the item parameter to see whether the weapon uses arrows as ammo.
Then buff of the potion may not be in the player.cs, I guess? Where should the buff data be?
And I mean, I'm making an advanced archery potion which gives 35% increased arrow speed and damage.
In order to realize this effect, I write the Archery2Buff, like
Code:
        public override void SetDefaults()
        {
            Main.buffName[this.Type] = "Archery 2";
            Main.buffTip[this.Type] = "35% increased arrow speed and damage";
            Main.debuff[Type] = false;
            Main.buffNoTimeDisplay[Type] = false;
        }

        public override void Update(Player player, ref int buffIndex)
        {
            player.arrowDamage += 35f;
        }
But I only know how to give a bonus to damage - use this player.arrowDamage I found in the reference.
Then how to give a bonus to the arrow speed?
Ah yes, would you like some wine with your code, sir?
Code:
public override bool Shoot(Item item, Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
    if (player.HasBuff(mod.BuffType("YourBuff")) > 0)
    {
         speedX *= 1.3F; speedY *= 1.3F;
    }
    return base.Shoot(item, player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockback);
}
Something like that (WARNING: untested).

EDIT:
You'll also have to check if it's an arrow being shot, ofc.
 
Ah yes, would you like some wine with your code, sir?
Code:
public override bool Shoot(Item item, Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
    if (player.HasBuff(mod.BuffType("YourBuff")) > 0)
    {
         speedX *= 1.3F; speedY *= 1.3F;
    }
    return base.Shoot(item, player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockback);
}
Something like that (WARNING: untested).

EDIT:
You'll also have to check if it's an arrow being shot, ofc.
Yeah, the wine is cool. I'll test them out.
 
Ah yes, would you like some wine with your code, sir?
Code:
public override bool Shoot(Item item, Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
    if (player.HasBuff(mod.BuffType("YourBuff")) > 0)
    {
         speedX *= 1.3F; speedY *= 1.3F;
    }
    return base.Shoot(item, player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockback);
}
Something like that (WARNING: untested).

EDIT:
You'll also have to check if it's an arrow being shot, ofc.
Code:
    public class Archery2BuffSpeed : GlobalItem
    {
        public override bool Shoot(Item item, Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            if (player.HasBuff(mod.BuffType("Archery2Buff")) > 0)
            {
                speedX *= 1.3F; speedY *= 1.3F;
            }
            return base.Shoot(item, player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockback);
        }
    }
So I created another .cs file belongs to GlobalItem to do this.
But the compiler seems not happy about this, it doesn't let me go through.
Here is the log:
Archery2BuffSpeed.cs(16,109) : error CS0103: **************************“knockback”
 
Code:
    public class Archery2BuffSpeed : GlobalItem
    {
        public override bool Shoot(Item item, Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            if (player.HasBuff(mod.BuffType("Archery2Buff")) > 0)
            {
                speedX *= 1.3F; speedY *= 1.3F;
            }
            return base.Shoot(item, player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockback);
        }
    }
So I created another .cs file belongs to GlobalItem to do this.
But the compiler seems not happy about this, it doesn't let me go through.
Here is the log:
Archery2BuffSpeed.cs(16,109) : error CS0103: **************************“knockback”
Ah yeah, you'll need to make that last line to the following:
Code:
return base.Shoot(item, player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack);
Just copy paste, that was my bad (knockBack needed a capital B :p).
 
  • Like
Reactions: wch
Back
Top Bottom