IDGCaptainRussia
Skeletron
This mod, will be getting a proper github when SGAmod releases, and on that note
I've been having quite a few people only wanting the code for their own mods.
Please don't directly copy code from Idglib to avoid using it as a dependency
I made this library largely from edited vanilla code, and what code I did borrow I have permission to use, if you really want to avoid using the library but use code from it please just credit me somewhere as well or write your own; this isn't asking much ;/
If your taking like one function and leaving credit that's fine and I can understand that, but if you start taking several functions for the sole reason of the above, then we have a problem.
Oh and, don't take the DrawSkeletronLikeArms and credit me, that code was made by @direwolf420 and you'd have to get his permission for it! I have permission to use it in IDGLib.
If this continues I'll be forced to close-source not only this mod, but all my mods, and I DON'T want to do that!
Thank you for understanding!
Hello everyone, I am happy to announce I have just launched my Base Mod to the mobrowser that'll house functions for all future mods of mine. But, I have made this detailed thread so anyone can use Idglib:
It should go without saying this is only for coders who know what they are doing. And have covered more than just the basics.
First and for most, make sure you read Blushiemagic's tutorial on cross mod content here before we get started: blushiemagic/tModLoader
I will be updating this as I add more functions
First thing you need to do is add the mod as a dependancy to your build.txt file, to do this, add this line in said text file at the bottom.
Now, in order to use this in your mod, you will first need to add
to every .cs file that will call functions from this.
Now you should be ready to use these functions:
This is pretty much the same as Main.NewText, but it also accommodates for networking and broadcasts messages to clients.
This allows you to find the closest object from a specified location (loc)
Targettype is the 0 for npc, or 1 for player.
size is a Vector2 consisting of half the width and half the height of the npc/player ideally. But it can be anything, it's used for the Centerpoint.
Block (optional) allows you to filter out targets behind solid blocks (on by default)
friendlycheck (optional, only works on Targettype=0) checks if the npc is friendly or not. It allows you to only target friendy NPCs if set to false (if you wanted to get the closest town NPC, for example)
This is a bit of ease-of-bytes type code, that gets the angle from here to there, the game might have one of these built in, but I never found one.
This code creates a fan of projectiles of your choice, and returns a list of all projectiles created from it. Projectiles created with function will automatically have hostile set to true.
centershot is whether or not a center shot is created
globalangularoffset allows you add an angle to all projectiles, say if you want them to spin in a circle.
spread is half the angle that projectiles will fan out.
widthheight is again, the centerpoint like with FindClosestTarget
Draws a tether-like sprite similar to Plantera's hooks and Wall of Flesh's Hungry. This function will only work in Draw events.
Tex is the string of the texture you wish to use as the tether
this function does not stretch the texture, it will repeat it and seamlessly crop it to prevent it from overextending.
alpha is optional; it defaults to 255
Draws skeletron-like arms with any texture of your choice!
selfPos is the "hand" and centerPos is the 'head"
the rest is trial and error to see what looks best.
This was contributed by @direwolf420 who took apart the vanilla code and made something workable with it! So major thanks to him!
Converts colors into a hexadecimal color code for text!
Casts a ray down from the location and returns where it hits, keep in mind this is in tile space, so you need to use a 1/16 of the coord value your really checking!
---non-general functions---
Basic code that bypasses buff immunities for NPCs; is otherwise the same as AddBuff
this code allows you to return a list of different types. an example:
List<NPC> myzombies = Idglib.FindNPCsMultitype(new ushort[] {(ushort)NPCID.ZombieElf,(ushort)NPCID.BaldZombie});
allows you to add any buff with any time to an npc or projectile that inflicted on a player it hits. This function is synced online automatically.
This is a client-side function that gets basic projectile data (position, velocity, damage, timeLeft) from the server's projectile and syncs it over to the projectile on the client's end. I made this after discovering New projectiles arn't synced automatically and a way to deal with randomness factors like velocity.
Only call this on creation or in few cases as it's not very light.
---bonus stuff!---
Idglib has a custom item class called ProjectileSpearBase that you can use to easily make a customized and simple spear projectile, when I get a github I can go more into detail on this.
Idglib adds a few built in debuffs that other mods can use easily:
Easy way to give a player Radiation, this debuff comes in 3 tiers (named "RadiationOne","RadiationTwo",RadiationThree" lastly) that you can pick with a level of 0-2.
This debuff functions like its Starbound counterpart, lowering player max HP, however, the lowered hp will slowly recover over time if not radiated and persists through saving and quiting.
--Idglib also adds a bunch of debug tools and weapons that i made to basically help me make other mods and things that other mods while testing my own mods' features didn't have for debugging purposes, they start with IDG so you can find them via cheatsheet if you want.
I've been having quite a few people only wanting the code for their own mods.
Please don't directly copy code from Idglib to avoid using it as a dependency
I made this library largely from edited vanilla code, and what code I did borrow I have permission to use, if you really want to avoid using the library but use code from it please just credit me somewhere as well or write your own; this isn't asking much ;/
If your taking like one function and leaving credit that's fine and I can understand that, but if you start taking several functions for the sole reason of the above, then we have a problem.
Oh and, don't take the DrawSkeletronLikeArms and credit me, that code was made by @direwolf420 and you'd have to get his permission for it! I have permission to use it in IDGLib.
If this continues I'll be forced to close-source not only this mod, but all my mods, and I DON'T want to do that!
Thank you for understanding!
Hello everyone, I am happy to announce I have just launched my Base Mod to the mobrowser that'll house functions for all future mods of mine. But, I have made this detailed thread so anyone can use Idglib:
It should go without saying this is only for coders who know what they are doing. And have covered more than just the basics.
First and for most, make sure you read Blushiemagic's tutorial on cross mod content here before we get started: blushiemagic/tModLoader
I will be updating this as I add more functions
First thing you need to do is add the mod as a dependancy to your build.txt file, to do this, add this line in said text file at the bottom.
Code:
modReferences = Idglibrary
Now, in order to use this in your mod, you will first need to add
Code:
using Idglibrary;
Now you should be ready to use these functions:
Code:
Idglib.Chat(string message,byte color1,byte color2,byte color3); returns nothing
Code:
Idglib.FindClosestTarget(int targettype,Vector2 loc,Vector2 size,bool block,bool friendlycheck); returns a int
Targettype is the 0 for npc, or 1 for player.
size is a Vector2 consisting of half the width and half the height of the npc/player ideally. But it can be anything, it's used for the Centerpoint.
Block (optional) allows you to filter out targets behind solid blocks (on by default)
friendlycheck (optional, only works on Targettype=0) checks if the npc is friendly or not. It allows you to only target friendy NPCs if set to false (if you wanted to get the closest town NPC, for example)
Code:
Idglib.LookAt(Vector2 here, Vector2 there); returns a float
Code:
Idglib.Shattershots(Vector2 here,Vector2 there,Vector2 widthheight,int type,int damage,float Speed,float spread,int count,bool centershot,float globalangularoffset,bool tilecollidez,int timeleft) returns a list consisting of all the Terraria.Projectile class created
centershot is whether or not a center shot is created
globalangularoffset allows you add an angle to all projectiles, say if you want them to spin in a circle.
spread is half the angle that projectiles will fan out.
widthheight is again, the centerpoint like with FindClosestTarget
Code:
Idglib.DrawTether(string Tex,Vector2 Start,Vector2 End,int Alpha = 255); returns nothing
Tex is the string of the texture you wish to use as the tether
this function does not stretch the texture, it will repeat it and seamlessly crop it to prevent it from overextending.
alpha is optional; it defaults to 255
Code:
Idglib.DrawSkeletronLikeArms(SpriteBatch spriteBatch, string texString, Vector2 selfPos, Vector2 centerPos, float selfPad = 0f, float centerPad = 0f, float direction = 0f); returns nothing
selfPos is the "hand" and centerPos is the 'head"
the rest is trial and error to see what looks best.
This was contributed by @direwolf420 who took apart the vanilla code and made something workable with it! So major thanks to him!
Code:
Idglib.ColorText(Color color,string text); returns a string with a color code.
Code:
Idglib.RaycastDown(int x, int y)
---non-general functions---
Code:
IdgNPC.AddBuffBypass(int npcid, int type, int time); returns nothing
Code:
IdgNpc.FindNPCs(int npctype); returns of a list consisting of all the Terraria.NPC classes that matched the type
Code:
IdgNPC.FindNPCsMultitype(ushort[] npctypes); returns of a list consisting of all the Terraria.NPC classes that matched the ushort array
List<NPC> myzombies = Idglib.FindNPCsMultitype(new ushort[] {(ushort)NPCID.ZombieElf,(ushort)NPCID.BaldZombie});
Code:
IdgNPC.AddOnHitBuff(int npcid,int buff, int time); returns nothing
Code:
IdgProjectile.AddOnHitBuff(int projectileid,int buff, int time); returns nothing
Code:
IdgProjectile.Sync(int projectileid); returns nothing
Only call this on creation or in few cases as it's not very light.
---bonus stuff!---
Idglib has a custom item class called ProjectileSpearBase that you can use to easily make a customized and simple spear projectile, when I get a github I can go more into detail on this.
Idglib adds a few built in debuffs that other mods can use easily:
Code:
IdgPlayer.AddRadiationDebuff(Player player,int time,int level=0,bool quiet=false); returns nothing, last 2 arguments are optional
This debuff functions like its Starbound counterpart, lowering player max HP, however, the lowered hp will slowly recover over time if not radiated and persists through saving and quiting.
--Idglib also adds a bunch of debug tools and weapons that i made to basically help me make other mods and things that other mods while testing my own mods' features didn't have for debugging purposes, they start with IDG so you can find them via cheatsheet if you want.
Last edited: