tAPI Some questions...

Zephyr

Terrarian
I have been looking for a way to do these things on my mod, but i couldn't find a way to do them yet...

1- Custom the chance of dodging?
2- Prevent someone to equip an accessory if there's a certain item equiped at the time?
3- Making an effect like "On Fire" wich takes 1% of players max health on each second without show those red numbers all over the time?

If anyone can help me with these questions...
Thanks
-Zephyr
 
1 Override PreHurt method in ModPlayer class
2 OnEquip and check through items table ?
3 Just do a custom buff whats the problem here ? :D
 
1 Override PreHurt method in ModPlayer class
2 OnEquip and check through items table ?
3 Just do a custom buff whats the problem here ? :D
Please tech me how to do the 1 and the 2 :p
About the 3, i want it to take damage, but without showing the Damage Numbers (Those red numbers over the players/Npcs heads)
 
Please tech me how to do the 1 and the 2 :p
About the 3, i want it to take damage, but without showing the Damage Numbers (Those red numbers over the players/Npcs heads)
oh my
1.

Code:
 public override void PreHurt(bool pvp, bool quiet, ref bool getHurt, ref bool playSound, ref bool genGore, ref int damage, ref int hitDirection, ref string deathText, ref bool crit, ref float critMultiplier)
        {
            base.PreHurt(pvp, quiet, ref getHurt, ref playSound, ref genGore, ref damage, ref hitDirection, ref deathText, ref crit, ref critMultiplier);
           //for example with random
if(Main.rand.Next(YOUR_CHANCE_NUMBER) ==0)
getHurt=false;  
        }
2.

Code:
 public override bool CanEquip(Player player, TAPI.UIKit.ItemSlot slot)
        {
            foreach (Item i in player.inventory)
            {
                if ( i.type == ItemDef.byName["YOUR_MOD:YOUR_ITEM"].type)
                    return false;
            }
            return base.CanEquip(player, slot);
        }
//never really played with inventory but thats my first guess
 
oh my
1.

Code:
 public override void PreHurt(bool pvp, bool quiet, ref bool getHurt, ref bool playSound, ref bool genGore, ref int damage, ref int hitDirection, ref string deathText, ref bool crit, ref float critMultiplier)
        {
            base.PreHurt(pvp, quiet, ref getHurt, ref playSound, ref genGore, ref damage, ref hitDirection, ref deathText, ref crit, ref critMultiplier);
           //for example with random
if(Main.rand.Next(YOUR_CHANCE_NUMBER) ==0)
getHurt=false; 
        }
2.

Code:
 public override bool CanEquip(Player player, TAPI.UIKit.ItemSlot slot)
        {
            foreach (Item i in player.inventory)
            {
                if ( i.type == ItemDef.byName["YOUR_MOD:YOUR_ITEM"].type)
                    return false;
            }
            return base.CanEquip(player, slot);
        }
//never really played with inventory but thats my first guess
Thanks this helps a lot! Also do u know a way to create npcs which drops an item only if a certain Npc is dead? (Like the Twins)
 
Do some static boolean which you will change to true if npc is killed , do in ModWorld or ModBase and save/load it to bin buffer, then in npc spawn code check if variable is true
 
Do some static boolean which you will change to true if npc is killed , do in ModWorld or ModBase and save/load it to bin buffer, then in npc spawn code check if variable is true
Teach me again? :/ I rlly don't get it
 
Back
Top Bottom