You can just copy the file, and make all of your mobs child classes of the worm class, so they just inherit the AI. Then just tweak with the variable at the top of the file.
Veeky Forums - Terraria General (not to be confused with Traditional Gaming)
You make that sound incredibly easy. Care to show an example? Because I'm genuinely feeling stupid. I don't know how to do child classes.
console and mobile content isn't very good, why bother?
Screenshot attached. Obviously the head, body and tail npcs need to be created, but those are just for stats and sprites.
Also, reference for inheritance:
docs.microsoft.com
Actually, after looking at the code, it is not necessary to have a class for the entire enemy. The head, body, and tail classes, however, should still inherit from the worm class.
It would be good convention to have an inherited class of worm that the head, body, and tail classes inherit from, so that the default values aren't ever out of sync.
I've been trying to wrap my head around this since you replied, but I just don't understand.
Do I make the parts (Head.cs, body.cs, etc), put the pictured code in everything but the head, and put the stuff from Worm.cs in the Head.cs?
Oh boy. First read the linked article on inheritance, classes, structs, etc.
You don't need to "put" the code from Worm.cs anywhere. In the class declaration (line 8 of the pictured code), there are two keywords: ExampleWormChildClass and Worm. The first one, ExampleWormChildClass, is the class that is being defined. The second, is the parent class that is being inherited. Thus, any data and methods in the Worm class are automatically present in the ExampleWormChildClass, provided that those are not overridden, like how SetDefaults is overridden (with the "override" keyword in the method declaration).
When making the mob, every part needs to inherit from the Worm class. This is how the parts are able to move. Once again, good coding convention would be to create a class that inherits from Worm, which all of these other classes would inherit from, in order to define stuff like minLenght, maxLength, etc, so that the values would always be in sync between the different parts.
For some reason, I thought the Worm.cs was the head. It didn't even occur to me that it was simply something being referenced.
So for example, in my modded monster's part, I'd have "public class ModName : ModNPC", it'd instead be "public class ModName : xWorm", with xWorm being whatever I name the Worm.cs? And for each part, it'd also be "public class ModHead/ModBody/ModTail : xWorm"?
Close.
You would want to have
public class xWorm : Worm
This would be where code like would be
And the individual parts would be
public class xWormHead : xWorm
I see. I think I'm 1% less stupid now.
So the Worm.cs is xWorm : Worm, and all child parts are xWormPart : xWorm. That simplified the fuck out of whatever was coursing in my head. What about how the Wyvern's parts are selected? If I recall right, it goes Head > Body (arms) > Body 1 > Body 2 > Body (arms) > Body 3 > Tail. That's 7 parts with one repeating once; what do I do to make the arms part visible twice, and all parts in this order?