Repository navigation
Mounts Pets and Minions
Some things go everywhere with the player. Mounts carry them, pets keep them
company, and minions and sentries fight for them. Mounts are written with
ModMount; pets, minions and sentries are projectiles kept alive by a buff, as
in the game itself.
A mount is set up as in tModLoader: SetStaticDefaults fills MountData
(speeds, frames, offsets, buff, spawnDust), and the textures come from
Texture + "_Back", "_Front", "_BackGlow" and the other
MountTextureTypes, when the files exist. A buff mounts it:
public class ExampleMountBuff : ModBuff
{
public override void Update(Player player, ref int buffIndex)
{
player.mount.SetMount(ModContent.MountType<ExampleMount>(), player);
player.buffTime[buffIndex] = 10;
}
}and an item with Item.mountType = ModContent.MountType<ExampleMount>() gives
the buff. The hooks: SetMount(player, ref skipDust),
Dismount(player, ref skipDust), UpdateEffects, UpdateFrame (false skips
the game's animation), JumpHeight, JumpSpeed, UseAbility, AimAbility and
Draw (false draws nothing; what the hook adds to playerDrawData is drawn
behind the mount). player.mount._mountSpecificData holds any C# object for
that mount until it dismounts. The types come after the game's (MountID.Count,
MountLoader.GetMount), and MountID.Sets grow with them.
MountData.backTexture and the other texture fields are Asset<Texture2D>, and
MountData.playerYOffsets is an int[] copied in and out of the game's array:
set it whole (MountData.playerYOffsets = new[] { ... }), as tModLoader's
examples do.
A minecart (ExampleMinecartMount) sets MountID.Sets.Cart[Type], calls
Mount.SetAsMinecart(MountData, buff, MountData.frontTexture) and points
MountData.delegations.MinecartDust, MinecartJumpingSound,
MinecartLandingSound and MinecartBumperSound at a method (the game's own,
such as DelegateMethods.Minecart.SparksMeow, or one of yours). Its buff sets
BuffID.Sets.MountType[Type], and the game mounts the player while it lasts.
The phone has no MinecartUpgradeRunSpeed, MinecartUpgradeDashSpeed or
MinecartUpgradeAcceleration: the upgrade kit uses the game's values.
ExampleSimpleMinion, ExampleSentry and the two pets (Content/Pets) are
tModLoader's. A minion's or sentry's damage comes from Projectile.originalDamage,
recalculated every update: for a mod projectile it starts as the damage of the
item that spawned it (or the damage passed to NewProjectile), as in
tModLoader. Things they use: BuffID.Sets.BuffTextHandlers.Add(Type, new CachedProjectileCounterBuffTextHandler(type)) (the minion count in the buff's
tooltip), ContentSamples.ProjectilesByType[type] (a sample of each
projectile, made the first time it is asked for; the phone has no such table),
Main.ActiveNPCs, npc.CanBeChasedBy(this) from a ModProjectile,
Projectile.OwnerMinionAttackTargetNPC (IsNull when there is none, as every
game object here) and ProjectileID.Sets.CharacterPreviewAnimations. On the
phone ItemID.Sets.StaffMinionSlotsRequired is an int[], and
SoundID.Item102 with { Volume = 0.4f } does not compile (see sounds), so the
sentry plays the plain sound.
Bunny Loader wiki ·
Discord ·
Repository ·
BL Editor
Written for Bunny Loader 0.5.5-beta and Terraria Mobile 1.4.5.8.6.
Bunny Loader is not affiliated with Re-Logic or 505 Games.
