Guest User

Untitled

a guest
Feb 18th, 2020
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.Xna.Framework;
  4. using Microsoft.Xna.Framework.Graphics;
  5. using Terraria.ID;
  6. using Terraria;
  7. using Terraria.ModLoader;
  8.  
  9. namespace VoidMod.NPCs //We need this to basically indicate the folder where it is to be read from, so you the texture will load correctly
  10. {
  11. public class Crys : ModNPC
  12. {
  13. /*public override bool Autoload(ref string name, ref string texture, ref string[] altTextures)
  14. {
  15. name = "Void Master";
  16. return mod.Properties.Autoload;
  17. }*/
  18. public override void SetDefaults()
  19. {
  20. //npc.name = "Crys"; //the name displayed when hovering over the npc ingame.
  21. npc.townNPC = true; //This defines if the npc is a town Npc or not
  22. npc.friendly = true; //this defines if the npc can hurt you or not()
  23. npc.width = 18; //the npc sprite width
  24. npc.height = 46; //the npc sprite height
  25. npc.aiStyle = 7; //this is the npc ai style, 7 is Passive Ai
  26. npc.defense = 420; //the npc defense
  27. npc.lifeMax = 621;// the npc life
  28. npc.HitSound = SoundID.NPCHit1; //the npc sound when is hit
  29. npc.DeathSound = SoundID.NPCDeath1; //the npc sound when he dies
  30. npc.knockBackResist = 0f; //the npc knockback resistance
  31. Main.npcFrameCount[npc.type] = 26; //this defines how many frames the npc sprite sheet has
  32. NPCID.Sets.ExtraFramesCount[npc.type] = 9;
  33. NPCID.Sets.AttackFrameCount[npc.type] = 4;
  34. NPCID.Sets.DangerDetectRange[npc.type] = 1600; //this defines the npc danger detect range
  35. NPCID.Sets.AttackType[npc.type] = 1; //this is the attack type, 0 (throwing), 1 (shooting), or 2 (magic). 3 (melee)
  36. NPCID.Sets.AttackTime[npc.type] = 9; //this defines the npc attack speed
  37. NPCID.Sets.AttackAverageChance[npc.type] = 1;//this defines the npc atack chance
  38. NPCID.Sets.HatOffsetY[npc.type] = 4; //this defines the party hat position
  39. animationType = NPCID.Guide; //this copy the guide animation
  40. }
  41. public override bool CanTownNPCSpawn(int numTownNPCs, int money) //Whether or not the conditions have been met for this town NPC to be able to move into town.
  42. {
  43. if (NPC.downedSlimeKing) //so after the EoC is killed
  44. {
  45. return true;
  46. }
  47. return false;
  48. }
  49. public override bool CheckConditions(int left, int right, int top, int bottom) //Allows you to define special conditions required for this town NPC's house
  50. {
  51. return true; //so when a house is available the npc will spawn
  52. }
  53. public override string TownNPCName() //Allows you to give this town NPC any name when it spawns
  54. {
  55. return "Crys";
  56. }
  57.  
  58. public override void SetChatButtons(ref string button, ref string button2) //Allows you to set the text for the buttons that appear on this town NPC's chat window.
  59. {
  60. button = "Shop"; //this defines the buy button name
  61. }
  62. public override void OnChatButtonClicked(bool firstButton, ref bool openShop) //Allows you to make something happen whenever a button is clicked on this town NPC's chat window. The firstButton parameter tells whether the first button or second button (button and button2 from SetChatButtons) was clicked. Set the shop parameter to true to open this NPC's shop.
  63. {
  64.  
  65. if (firstButton)
  66. {
  67. openShop = true; //so when you click on buy button opens the shop
  68. }
  69. }
  70.  
  71. public override void SetupShop(Chest shop, ref int nextSlot) //Allows you to add items to this town NPC's shop. Add an item by setting the defaults of shop.item[nextSlot] then incrementing nextSlot.
  72. {
  73. /*if (NPC.downedSlimeKing) //this make so when the king slime is killed the town npc will sell this
  74. {
  75. shop.item[nextSlot].SetDefaults(ItemID.RecallPotion); //an example of how to add a vanilla terraria item
  76. nextSlot++;
  77. shop.item[nextSlot].SetDefaults(ItemID.WormholePotion);
  78. nextSlot++;
  79. }
  80. if (NPC.downedBoss3) //this make so when Skeletron is killed the town npc will sell this
  81. {
  82. shop.item[nextSlot].SetDefaults(ItemID.BookofSkulls);
  83. nextSlot++;
  84. shop.item[nextSlot].SetDefaults(ItemID.ClothierVoodooDoll);
  85. nextSlot++;
  86. }*/
  87. shop.item[nextSlot].SetDefaults(ItemID.CopperCoin);
  88. nextSlot++;
  89. shop.item[nextSlot].SetDefaults(ItemID.GenderChangePotion);
  90. /*shop.item[nextSlot].SetDefaults(mod.ItemType("CustomSword")); //this is an example of how to add a modded item
  91. nextSlot++;*/
  92.  
  93. }
  94.  
  95. public override string GetChat() //Allows you to give this town NPC a chat message when a player talks to it.
  96. {
  97. /*int wizardNPC = NPC.FindFirstNPC(NPCID.Wizard); //this make so when this npc is close to Wizard
  98. if (wizardNPC >= 0 && Main.rand.Next(4) == 0) //has 1 in 3 chance to show this message
  99. {
  100. return "Yes " + Main.npc[wizardNPC].displayName + " is a wizard.";
  101. }
  102. int guideNPC = NPC.FindFirstNPC(NPCID.Guide); //this make so when this npc is close to the Guide
  103. if (guideNPC >= 0 && Main.rand.Next(4) == 0) //has 1 in 3 chance to show this message
  104. {
  105. return "Sure you can ask " + Main.npc[guideNPC].displayName + " how to make Ironskin potion or you can buy it from me..hehehe.";
  106. }*/
  107. switch (Main.rand.Next(20)) //this are the messages when you talk to the npc
  108. {
  109. case 0:
  110. return "Oh, you've killed a god? Same.";
  111. case 1:
  112. return "27 is a pretty dope number. It's three to the third power, and three is my favorite number. Nine is also sick.";
  113. case 2:
  114. return "Haha bet you can't drink an entire bottomless water bucket. Why? Uhhhhhh.. reasons.";
  115. case 3:
  116. return "My fave food is like.. everything. No really, I'm not picky. I've literally eaten landfills.";
  117. case 4:
  118. return "Seriously?? You've fought massive disembodied eyeballs, but the thing you find weird is the talking cat raccoon from another universe??";
  119. case 5:
  120. return ".....Did you say something? Sorry, I wasn't paying attention.";
  121. case 6:
  122. return "I was never much of a gardener or a brewer, but my friends love these gender change potions!";
  123. case 7:
  124. return "*dubstep noises* oh f- hi, hello.";
  125. case 8:
  126. return "The name's Crys. Like, C-R-Y-S. Like 'Christ' without the 't', or 'crisis' without the 'is'.";
  127. case 9:
  128. return "Yeah, I could easily kill any creature in this reality. That includes you, but you don't have to worry about that. Probably.";
  129. case 10:
  130. return "So uh, just curious. How elastic is your body anyway? Don't tell me you can't even expand as large as a room.";
  131. case 11:
  132. return "uhhhhhh meow??";
  133. case 12:
  134. return "Are you SURE I can't eat ANY of the slimes?? I want to so badly.";
  135. case 13:
  136. return "You wanna harness void magic? Buddy, you need total omnipotent power over the void realm to do that.";
  137. case 14:
  138. return "The only beings that possess power over the void realm are me and the void god that gave the power to me.";
  139. case 15:
  140. return "You could never control void magic yourself. Buuut, mayyybe there's some cosmic metaphsyical void crafting station that allows you to bind raw void matter to the cosmic elements of your reality to syntheize a sort of stablized void matter that can then be forged into immensely powerful gear. Mayyyybe.";
  141. case 16:
  142. return "No, you could never actually KILL the void god. That's universally impossible. But sure, it could create a semi-mortal void body just to test your might, as they say. Who knows? Maybe it'd reward you with some metaphysical void crafting station or something.";
  143. case 17:
  144. return "Hope you don't mind me moving in! This housing is rather cozy, albeit a bit two-dimensional.";
  145. case 18:
  146. return "Yeah I have skinsuits of myself. I have a friend who's into that sort of stuff.";
  147. case 19:
  148. return "No, this food isn't from the trash! I save that food for myself!";
  149. default:
  150. return "jeff.";
  151.  
  152. }
  153. }
  154. public override void TownNPCAttackStrength(ref int damage, ref float knockback)// Allows you to determine the damage and knockback of this town NPC attack
  155. {
  156. damage = 99; //npc damage
  157. knockback = 2f; //npc knockback
  158. }
  159.  
  160. public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown) //Allows you to determine the cooldown between each of this town NPC's attack. The cooldown will be a number greater than or equal to the first parameter, and less then the sum of the two parameters.
  161. {
  162. cooldown = 0;
  163. randExtraCooldown = 0;
  164. }
  165. //------------------------------------This is an example of how to make the npc use a sward attack-------------------------------
  166. /*public override void DrawTownAttackSwing(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)//Allows you to customize how this town NPC's weapon is drawn when this NPC is swinging it (this NPC must have an attack type of 3). Item is the Texture2D instance of the item to be drawn (use Main.itemTexture[id of item]), itemSize is the width and height of the item's hitbox
  167. {
  168. scale = 1f;
  169. item = Main.itemTexture[mod.ItemType("CustomSword")]; //this defines the item that this npc will use
  170. itemSize = 56;
  171. }
  172.  
  173. public override void TownNPCAttackSwing(ref int itemWidth, ref int itemHeight) // Allows you to determine the width and height of the item this town NPC swings when it attacks, which controls the range of this NPC's swung weapon.
  174. {
  175. itemWidth = 56;
  176. itemHeight = 56;
  177. }*/
  178.  
  179. public override void TownNPCAttackProj(ref int projType, ref int attackDelay)//Allows you to determine the projectile type of this town NPC's attack, and how long it takes for the projectile to actually appear
  180. {
  181. projType = 635;
  182. attackDelay = 1;
  183. }
  184.  
  185. public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)//Allows you to determine the speed at which this town NPC throws a projectile when it attacks. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity
  186. {
  187. multiplier = 900f;
  188. // randomOffset = 4f;
  189.  
  190. }
  191.  
  192. //----------------------------------This is an example of how to make the npc use a gun and a projectile ----------------------------------
  193. /*public override void DrawTownAttackGun(ref float scale, ref int item, ref int closeness) //Allows you to customize how this town NPC's weapon is drawn when this NPC is shooting (this NPC must have an attack type of 1). Scale is a multiplier for the item's drawing size, item is the ID of the item to be drawn, and closeness is how close the item should be drawn to the NPC.
  194. {
  195. scale = 1f;
  196. item = mod.ItemType("GunName");
  197. closeness = 20;
  198. }
  199. public override void TownNPCAttackProj(ref int projType, ref int attackDelay)//Allows you to determine the projectile type of this town NPC's attack, and how long it takes for the projectile to actually appear
  200. {
  201. projType = ProjectileID.CrystalBullet;
  202. attackDelay = 1;
  203. }
  204.  
  205. public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)//Allows you to determine the speed at which this town NPC throws a projectile when it attacks. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity
  206. {
  207. multiplier = 7f;
  208. // randomOffset = 4f;
  209.  
  210. } */
  211.  
  212. }
  213. }
RAW Paste Data