The information in this article is for Terraria v1.0.6.1. |
The player class is the single most important class in the game, and the one that is most visible to the player. There are a wide variety of functions to control behavior and change stats, and aside from items, this is probably the most used class. | |||
|
Properties[]
Name | Type | Description |
---|---|---|
accCompass | int (bool) | Whether horizontal location displayed. |
accDepthMeter | int (bool) | Whether the depth is displayed or not.
|
accDivingHelm | bool | Whether the Diving Helm is equipped? |
accFlipper | bool | Whether the Flipper item is equipped.
|
accMerman | bool | Infinite breath in water |
accWatch | int | Whether the time is displayed.
|
active | bool | Whether player is flagged for deletion? |
activeNPCs | float | |
adjTile | bool[] |
An array that's used to tell the crafting system if you're standing near specific crafting stations. (Used for upgraded crafting station inheritance)
|
adjWater | bool | Whether the player is close to water. Might be what "needWater" crafting recipes check. |
ammo | Item[] | Likely an array containing what are in the ammo slots on the player |
ammoCost75 | bool | The player will not use ammo 25% of the time. |
ammoCost80 | bool | The player will not use ammo 20% of the time. |
archery | bool | Whether player has the effect of an Archery Potion ? |
armor | Item[] | Likely an array containing what are in their armor slots |
attackCD | int | Cooldown between attacks? |
bank | Item[] | Likely an array of items stored in a piggy bank |
bank2 | Item[] | Likely an array of items stored in a safe |
bleed | bool | If true then player cannot regenerate life (or life regeneration is limited/reduced?) (as caused by the Bleeding debuff). |
blind | bool | Whether the player is affected by a blind effect, reducing vision. This is set by the Darkness debuff. |
blockRange | int | Toolbelt Effect. Affects both Vertical and Horizontal ranges. Default 0 or 1. Every point above 0 increases block placement range by that many blocks. |
body | int | |
bodyFrame | Rectangle | The current frame on the Player Image for the body. (Including chest armor) |
bodyFrameCounter | double | |
bodyPosition | Vector2 | |
bodyRotation | float | |
bodyVelocity | Vector2 | |
boneArmor | bool | Skeleton hit sound, as granted with the Necro Armor? |
breath | int | The amount of breath the player currently has? |
breathCD | int | Something to do with breath cooldown. More testing needed. |
breathMax | int | The maximum breath the user can have. A value of 20 is 1 bubble in the bubble bar. Default value is 200. |
brokenArmor | bool | Whether the player has the Broken Armor debuff, which halves the players defense. |
buffTime | int[] | Array of times left on buffs? |
buffType | int[] | Array of buff types in use? |
bunny | bool | Is the Bunny buff active? |
canRocket | bool | Does the user have the ability to rocket like the Rocket Boots? |
changeItem | int | |
channel | bool | Whether the user is currently "channeling" a spell, so is using the mouse to keep it active? |
chatShowTime | int | |
chatText | string | |
chest | int | When the player has a chest open, this represents its ID. Otherwise it is -1. |
chestX | int | The X coordinate of the open chest. |
chestY | int | The Y coordinate of the open chest. |
confused | bool | Confusion debuff. |
controlDown | bool | The Down movement key (Default: S) |
controlHook | bool | The Grapple key (Default: E) |
controlInv | bool | The Inventory key (Default: Esc) |
controlJump | bool | The Jump key (Default: Space) |
controlLeft | bool | The Left movement key (Default: A) |
controlRight | bool | The Right movement key (Default: D) |
controlThrow | bool | The Throw key (Default: Q) |
controlUp | bool | The Up movement key (Default: W) |
controlUseItem | bool | Flag for whether a particular button was pressed? |
controlUseTile | bool | Flag for whether a particular button was pressed? |
dead | bool | Whether the player is dead. If set to true, will immediately respawn at the default(?) spawn point with 100 HP. |
delayUseItem | bool | |
detectCreature | bool | Whether the player can see creatures in the dark, same as hunter potion |
difficulty | byte | The difficulty the player is on.
|
direction | int | Direction the player is facing.
|
doubleJump | bool | Whether the player can double jump. When double jumping, the animation for Cloud In a Bottle is still shown. |
enemySpawns | bool | Doubles base spawn rate and spawn limit. Battle Potion effect(Water Candle hardcoded elsewhere). |
eyeColor | Color | Color of the player's eye |
fairy | bool | Player has a fairy? |
fallStart | int | The block calculated for the start of falling. For example if your standing 500 blocks below the top of the world and set this 1 or 0, you'll automatically take damage equivalent to a 500 block drop (even without falling or moving) |
findTreasure | bool | Whether treasure emits light (as granted by the Spelunker Potion ) |
fireWalk | bool | Whether the player avoids damage from hot bricks such as meteorite or hellstone. If it does not work with lava, then it works like an obsidian skull. If it DOES work for lava, then it works like an obsidian skin potion. |
flapSound | bool | Whether to make flapping noise for wings? |
ghost | bool | If the player has died on hardcore mode, they come back as a ghost and cannot interact with anything. |
ghostFade | float | |
ghostFrame | int | Current frame of a ghost. |
ghostFrameCounter | int | |
gills | bool | Whether the player must breathe water (as granted by the Gills Potion ) |
grapCount | int | A counter for the number of grapples the player has currently out (total attachment points). |
grappling | int[] | Is the player currently grappling? |
gravControl | bool | Whether player can direct their gravity (as per Gravitation Potion ) |
gravDir | float | Possibly the direction of gravity being applied |
gross | bool | |
hair | int | Which hair style the player is using. |
hairColor | Color | Color of the player's hair style |
hairFrame | Rectangle | |
hbLocked | bool | |
head | int | |
headFrame | Rectangle | |
headFrameCounter | double | |
headPosition | Vector2 | |
headRotation | float | |
headVelocity | Vector2 | |
height | int | The height of the player. |
heldProj | int | |
hitTile | int | |
hitTileX | int | |
hitTileY | int | |
hostile | bool | Whether player is flagged for PvP? |
immune | bool | Whether the player is immune to damage. |
immuneAlpha | int | |
immuneAlphaDirection | int | |
immuneTime | int | The time that the player is immune to attacks after being damaged. |
inventory | Item[] | The inventory. You can refrence various item properties here. For instance, Item[0].name will give you the name of the item in the 0th inventory slot. |
invis | bool | Whether player is invisible as per Invisibility Potion . Only hides skin, won't disguise armor. |
itemAnimation | int | |
itemAnimationMax | int | |
itemHeight | int | The height of the held item sprite. |
itemLocation | Vector2 | |
itemRotation | float | The angle of the held item (in radians). |
itemTime | int | |
itemWidth | int | The width of the held item sprite. |
jump | int | |
jumpAgain | bool |
infinity jumps with "doubleJump"[] |
jumpBoost | bool | Whether the player's jump height is boosted (as granted by the Shiny Red Balloon accessory). |
kbGlove | bool | Titan glove? |
killGuide | bool | Whether the player can harm the guide (as granted by the Guide Voodoo Doll accessory). |
lavaImmune | bool | Whether player is immune to the effects of lava |
lavaWet | bool | Whether the player is submerged in lava (to take damage) |
legFrame | Rectangle | |
legFrameCounter | double | |
legPosition | Vector2 | |
legRotation | float | |
legs | int | |
legVelocity | Vector2 | |
lifeRegen | int | How much life is restored when the counter completes a cycle? |
lifeRegenCount | int | Counter that counts up to lifeRegenTime. Once it completes the player gains 1 HP and it likely decrements lifeRegenTime (thus leading to rapidly accelerating regeneration). |
lifeRegenTime | int | Not exactly sure how it works, but increases as time goes on from your last damage. Possibly this is the actual counter speed. |
lightOrb | bool | This does not seem to create a light orb like the Orb of Light that follows a player. More testing needed. |
longInvince | bool | Increases length of invincibility after taking damage (as granted by the Cross Necklace accessory). |
magicCrit | int | Chance to deal double damage with a spell? I believe the default is 4 (so 4%) |
magicDamage | float | Magic damage modifier for the player. This is multiplied with the item damage, and is 1.0 by default. |
male | bool | Whether player is male or female. Sprites are asexual, only chooses the voice pack used at this point. |
manaCost | float | The player's mana cost modifier. More testing needed. |
manaFlower | bool | Mana flower buff. |
manaRegen | int | See lifeRegen |
manaRegenBuff | bool | Whether player has increased mana regeneration. As granted by the Mana Regeneration Potion . |
manaRegenCount | int | Counts up to manaRegenDelay, and then adds 1 Mana. |
manaRegenDelay | int | Time, in frames, to gain 1 Mana. |
maxMinions | int | Maximum amount of minions the player can have. |
meleeCrit | int | Chance to cause double damage in melee. I believe the default is 4 (percent) |
meleeDamage | float | Melee damage modifier for the player. This is multiplied with the item damage, and is 1.0 by default. |
meleeSpeed | float | Melee speed for the player, which dictates how fast a melee item is used. This is multiplied with the item speed, and is 1.0 by default. |
minionDamage | float | Minion damage modifier for the player. This is multiplied with the item damage, and is 1.0 by default. |
mouseInterface | bool | |
moveSpeed | float | The players move speed. |
name | string | Name of player. |
nightVision | bool | Increases the brightness of light sources, allowing better vision in dim environments, though has no effect on complete darkness. This is granted in game by the Night Owl Potion . |
noFallDmg | bool | Whether the player takes damage from falling or not (as granted by the Lucky Horseshoe accessory) |
noItems | bool | Whether or not the Player has the Cursed Debuff applied to them. |
noKnockback | bool | Whether the player is nudged from damage (as granted by the Cobalt Shield accessory) |
nonTorch | int | |
oldAdjTile | bool[] | |
oldAdjWater | bool | |
oldVelocity | Vector2 | The player's last velocity. Useful in custom animations to determine which direction they should be facing. |
onFire | bool | Check for the "On Fire!" debuff? |
pantsColor | Color | Color of player's pants |
poisoned | bool | Check for the poisioned debuff? |
position | Vector2 | The player's position. |
potionDelay | int | |
pStone | bool | Philosopher's Stone effect. |
pvpDeath | bool | Whether the player died in PvP? |
rangedCrit | int | Chance of critical strikes with ranged weapons. Default chance is 4%. |
rangedDamage | float | Damage dealt with ranged weapons? |
releaseHook | bool | Whether the Grapple key has been released. |
releaseInventory | bool | Whether the Inventory key has been released. |
releaseJump | bool | Whether the Jump key has been released. |
releaseQuickHeal | bool | Whether the Quick Heal key has been released. |
releaseQuickMana | bool | Whether the Quick Mana key has been released. |
releaseThrow | bool | Whether the Throw key has been released. |
releaseUseItem | bool | Whether the Use Item key has been released. |
releaseUseTile | bool | Whether the Use Tile key has been released. |
respawnTimer | int | How long until player respawns |
rocketBoots | int ( bool ) | Whether an item granting the Rocket Boots effect is equipped. ( 1 = true ) |
rocketDelay | int | |
rocketDelay2 | int | |
rocketFrame | bool | |
rocketRelease | bool | |
rocketTime | int | |
rocketTimeMax | int | The maximum amount of time rocket boots can be used for. This is not in seconds (a second roughly corresponds to a value of 5, so a value of 100 will last approximately 20 seconds. More testing needed.) |
rulerAcc | bool | Player can see tile placement grid (as per the Ruler accessory). |
runSoundDelay | int | |
selectedItem | int |
The ID of the selected item slot for this player. Can be 0-9 for the hotbar slots (0 is slot 1, 1 is slot 2, etc., 9 is slot 0), or 48 if the player is holding an item with the mouse. To get the actual selected item itself, index the player's inventory at this location, like "player.inventory[player.selectedItem];". |
setBonus | string | The set bonus is active foer the specified armor. |
shadow | float | |
ShadowAura | bool | Set to true in order for player shadow aura to be drawn every frame. |
shadowCount | int | |
shadowPos | Vector2[] | |
ShadowTail | bool | Set to true in order for player shadow trails to be drawn every frame. |
shirtColor | Color | The players shirt colour. |
shoeColor | Color | The players shoe colour. |
showItemIcon | bool | Whether to show the icon of an item on the mouse cursor. |
showItemIcon2 | int | The type of item to show on the mouse cursor. If this is 0, the player's currently selected item will be shown. Useful for showing that you can interact with a tile. |
sign | int | |
silence | bool | Silence debuff. |
skinColor | Color | Color of player's skin |
slow | bool | Slow debuff. |
slowCount | int | |
slowFall | bool | Whether player is affected by the slowfall effect, as granted by the Featherfall Potion . |
socialShadow | bool | It's not the blur of necro armor, its the "Purple rocket boots" given by shadow armor. |
spaceGun | bool | Whether the space gun uses mana? (as granted by the Meteor Armor set bonus). |
spawnMax | bool | |
SpawnX | int | The Spawn X co-ordinate. |
SpawnY | int | The Spawn Y co-ordinate. |
spI | int[] | |
spN | string[] | |
spX | int[] | |
spY | int[] | |
starCloak | bool | Star Cloak buff. |
statAttack | int | Current attack damage? |
statDefense | int | Current defense (2 def reduces damage by 1) |
statLife | int | Current HP |
statLifeMax | int | Max HP |
statLifeMax2 | int | Max HP granted by items/buffs |
statMana | int | Current Mana |
statManaMax | int | Max Mana granted by Mana Crystals |
statManaMax2 | int | Max Mana granted by items/buffs |
step | int | |
stickyBreak | int | |
swimTime | int | |
talkNPC | int | If/which NPC a player is chatting? |
team | int | The current team the player is on. |
thorns | bool | Whether player reflects damage as per thorns ; 1/2 of damage taken is reflected. |
tongued | bool | Whether the player has the Tongue Debuff and is being held by the tongue of the Wall of Flesh. |
toolTime | int | |
townNPCs | float | |
underShirtColor | Color | Color of player's undershirt |
velocity | Vector2 | The players currently velocity. In feet per second? |
waterWalk | bool | Whether the player can walk on water or not |
wereWolf | bool | Display player as werewolf? |
wet | bool | Whether player is in water |
wetCount | byte | Possibly a timer for how long they've been in water?? |
whoAmi | int | The ID in the Player[] array? |
width | int | The width of the player sprite. |
wings | int | 0 = none, 1 = Demon, 2 = Angel |
wingTime | int | How long the player has been using wings for. Set to 0 and they can't fly even with wings. Set to 1 or higher for infinite flight. |
wolfAcc | bool | Whether the player is holding a Moon Charm , and so will become a werewolf on full moons. |
zoneDungeon | bool | Whether player is in the Dungeon biome. |
zoneEvil | bool | Whether player is in the Corruption biome. |
zoneHoly | bool | Whether player is in the Hallow biome. |
zoneJungle | bool | Whether player is in the Jungle biome. |
zoneMeteor | bool | Whether player is in the Meteor biome. |
Static Properties[]
Name | Type | Description |
---|---|---|
deadForGood | bool | Died on Hardcore? |
tileRangeX | int | Horizontal block place range. Cannot be changed. See blockRange above. |
tileRangeY | int | Vertical block place range. Cannot be changed. See blockRange above. |
Methods[]
Method Name | Description |
---|---|
AddBuff() |
public void AddBuff(int type, int time) { } Applies a buff of the given type to the player for the specified duration. Time is in frames, 60 frames per second.
|
AdjTiles() |
public void AdjTiles() { } ???
|
BuyItem() |
public bool BuyItem(int price) { } ???
|
ChangeSpawn() |
public void ChangeSpawn(int x, int y) { } Sets the players spawn point to the location at X, Y
|
checkArmor() |
public void checkArmor() { } ???
|
clientClone() |
public object clientClone() { } Creates a clone of the object for the client, when using multiplayer.
|
Clone() |
public object Clone() { } Creates a copy of the object.
|
countBuffs() |
int countBuffs() { } Returns the number of buffs currently on the player
|
DelBuff() |
public void DelBuff(int b) { } Removes the buff at buff[] index b.
|
DoCoins() |
public void DoCoins(int i) { } Stacks all the coins in your coin slots (Platinum, Gold, Silver & Copper)
|
DropCoins() |
public void DropCoins() { } ???
|
dropItemCheck() |
public void dropItemCheck() { } ???
|
DropItems() |
public void DropItems() { } ???
|
FindSpawn() |
public void FindSpawn() { } Updates SpawnX and SpawnY.
|
GetDeathAlpha() |
public Color GetDeathAlpha(Color newColor) { } Get the alpha blending value for the player's death.
|
GetImmuneColor() |
public Color GetImmuneAlpha(Color newColor) { } Gets the color used when the player is immune to damage.
|
GetItem() |
public Item GetItem(int plr, Item newItem) { } ???
|
HasItem() |
public bool HasItem(int type) { } Whether the player as a certain item in their inventory or equipped.
|
HealEffect() |
public void HealEffect(int healAmount) { } Creates green text on player's head which shows how much they were healed.
|
Hurt() |
public double Hurt( int Damage, int hitDirection, [bool pvp = false], [bool quiet = false], [string deathText = " was slain..."] ) { } Damages the player by the given amount. The hit direction indicates the direction the damage is coming from
|
ItemCheck() |
public void ItemCheck(int i) { } ???
|
ItemSpace() |
public bool ItemSpace(Item newItem) { } ???
|
KillMe() |
public void KillMe( double dmg, int hitDirection, [bool pvp = false], [string deathText = " was slain..."] ) { } Damages the player by the given amount. The hit direction indicates the direction the damage is coming from. Always kills the player?
|
KillMeForGood() |
public void KillMeForGood() { } Possibly used when a hardcore character dies.
|
ManaEffect() |
public void ManaEffect(int manaAmount) { } Displays the blue sparkly letters above the player's head when they heal mana.
|
PlayerFrame() |
public void PlayerFrame() { } ???
|
QuickBuff() |
public void QuickBuff() { } Whether the quick buff button was pressed.
|
QuickHeal() |
public void QuickHeal() { } Whether the quick heal button was pressed.
|
QuickMana() |
public void QuickMana() { } Whether the quick mana button was pressed.
|
SellItem() |
public bool SellItem(int price) { } ???
|
Spawn() |
public void Spawn() { } Contains the state the player is in when they spawn (sets frames, makes sure the player doesnt spawn in a block, etc)
|
toggleInv() |
public void toggleInv() { } When called, shows or hides the inventory.
|
UpdatePlayer() |
public void UpdatePlayer(int i) { } Updates the player with the given index.
|
Static Methods[]
Method Name | Description |
---|---|
FindClosest() |
public static byte FindClosest( Vector2 Position, int Width, int Height ) { } Returns the closest player in the rectangle starting at Position
|
getDeathMessage() |
public static string getDeathMessage( [int plr = -1], [int npc = -1], [int proj = -1], [int other = -1] ) { } Gets the death text for the given player with the given set of conditions.
|
LoadPlayer() |
public static Player LoadPlayer(string playerPath) { } Loads a player from a file
|
SavePlayer() |
public static void SavePlayer(Player newPlayer, string playerPath) { } Saves a player to the given file
|
Notes[]
None yet
Classes in Terraria |
---|
Chest | Cloud | Collision | Dust | Gore | Item | Lighting | Liquid | Main | NPC | Player | Projectile | Recipe | Sign | Star | WorldGen |