Terraria Mods, technical explorations 01

Last modified by Victor Zhang on 00:27, 22/07/2020

  • The tModLoader ships with Terraria, so it means now it updates automatically with steam
  • Examplemod somehow has an Error in ExampleCritter.cs, so had to download the source and recompile, rightnow muted the autoupdate override of the item, however still can't findout where the out of index comes from, error message stack trace:
    System.IndexOutOfRangeException: Index was outside the bounds of the array.
       at ExampleMod.NPCs.ExampleCritterNPC.HookStatue(ILContext il) in ExampleMod\NPCs\ExampleCritter.cs:line 0
       at MonoMod.Cil.ILContext.Invoke(Manipulator manip)
       at MonoMod.RuntimeDetour.ILHook.Context.InvokeManipulator(MethodDefinition def, Manipulator cb)
       at MonoMod.RuntimeDetour.ILHook.Context.Refresh()
       at MonoMod.RuntimeDetour.ILHook.Apply()
       at MonoMod.RuntimeDetour.ILHook..ctor(MethodBase from, Manipulator manipulator, ILHookConfig& config)
       at MonoMod.RuntimeDetour.HookGen.HookEndpoint._NewILHook(MethodBase from, Manipulator to)
       at MonoMod.RuntimeDetour.HookGen.HookEndpoint._Add[TDelegate](Func`3 gen, TDelegate hookDelegate)
       at MonoMod.RuntimeDetour.HookGen.HookEndpoint.Modify(Delegate hookDelegate)
       at MonoMod.RuntimeDetour.HookGen.HookEndpointManager.Modify(MethodBase method, Delegate callback)
       at IL.Terraria.Wiring.add_HitWireSingle(Manipulator )
       at ExampleMod.NPCs.ExampleCritterNPC.Autoload(String& name) in ExampleMod\NPCs\ExampleCritter.cs:line 19
       at Terraria.ModLoader.Mod.AutoloadNPC(Type type)
       at Terraria.ModLoader.Mod.Autoload()
       at Terraria.ModLoader.ModContent.<>c.<Load>b__38_0(Mod mod)
       at Terraria.ModLoader.ModContent.LoadModContent(CancellationToken token, Action`1 loadAction)
       at Terraria.ModLoader.ModContent.Load(CancellationToken token)
       at Terraria.ModLoader.ModLoader.Load(CancellationToken token)
  • Seems no one else raises the issue on the issue page?
    • Need to pay follow the updates
  • Study on the example item:
    • The item sound seems inconsistant between when classify as weapon and when classify as connsumable(like potion), same sound id gives different sound, but managable, just need trial and error
    • Item will not be able to be consumed unless overriding UseItem and return true:public override bool UseItem(Player player){
         return true;
      }
      • Also , can have UseItem(Item item, Player player)
    • Player according to the vanilla field can not set currentHP, so there's probably no way to directly self-inflict damage
      • However, it might be possible to spawn an enemy projectile that does the damage and change world state
      • Did not find any world state extention method, but seems possible as vanilla has world fields, need to find how to extend them
  • Study on ExampleMod:
    • Chasing projectile possible, look at the wisp example.
    • Custom properties with mount might be possible
      • The example mount car has 3 balloons that can be damaged when player take damage, also in comment, syncing modplayer can even have functional use
      • Same reason, the mounted mg like metal-slug style might be achievable
      • Tilting with terrain seems not possible, it loads static spritesheet from <mount>_Back.png and <mount>_Front.png
Created by Victor Zhang on 15:24, 11/06/2020