Standalone [1.3] tModLoader - A Modding API

Does that mean it wont spawn?
[DOUBLEPOST=1457561402,1457561159][/DOUBLEPOST]
Also, its !Main.Day.Time. The ! means it wont, so it spawns at night ^_^
[DOUBLEPOST=1457561688][/DOUBLEPOST]One last thing, how do I make the bool go to true when I equip it?
Totally knew that ;)
In the Update() method of ModItem:
((Player)player.GetModPlayer(mod, "Player")).accessoryOn = true;
EDIT: also, in the PreUpdate() method of ModPlayer:
((Player)player.GetModPlayer(mod, "Player")).accessoryOn = false;
what this does is make it so that when the accessory is taken off the NPC wont spawn anymore
[DOUBLEPOST=1457564818][/DOUBLEPOST]
Does that mean it wont spawn?
and no, you would put the "return 0f;" outside of the if statement, like in an else statement.
this makes it so that the NPC wont spawn if you dont have the accessory on
 
Totally knew that ;)
In the Update() method of ModItem:
((Player)player.GetModPlayer(mod, "Player")).accessoryOn = true;
EDIT: also, in the PreUpdate() method of ModPlayer:
((Player)player.GetModPlayer(mod, "Player")).accessoryOn = false;
what this does is make it so that when the accessory is taken off the NPC wont spawn anymore
[DOUBLEPOST=1457564818][/DOUBLEPOST]
and no, you would put the "return 0f;" outside of the if statement, like in an else statement.
this makes it so that the NPC wont spawn if you dont have the accessory on
Can you make a quick example thing for me so I can easily copy paste it when I get back from dinner?
 
Can you make a quick example thing for me so I can easily copy paste it when I get back from dinner?
Player:

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Mod
{
public class myModPlayer : ModPlayer
{
public bool accessoryOn = false;


public override void PreUpdate()
{
accessoryOn = false;
}

}
////////////////////////////////////////////////
Accessory:

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Mod.Items
{
public class Accessory : ModItem
{
public override void SetDefaults()
{
item.name = "NPC Thingy";
item.width = 24;
item.height = 24;
item.toolTip = "Allows stuff to spawn";
item.value = Item.buyPrice(0, 10, 0, 0);
item.rare = 9;
item.accessory = true;
item.defense = 6;
}

public override void UpdateAccessory(Player player)
{
((myModPlayer)player.GetModPlayer(mod, "myModPlayer")).accessoryOn= true;
}


}
}
////////////////////////////////////////////////////////////////
NPC(just paste this in within your NPC class):

public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
if(((myModPlayer)player.GetModPlayer(mod, "myModPlayer")).accessoryOn== true;)
{
return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 0.5f : 0f;
}
return 0f;
}
 
Player:

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Mod
{
public class myModPlayer : ModPlayer
{
public bool accessoryOn = false;


public override void PreUpdate()
{
accessoryOn = false;
}

}
////////////////////////////////////////////////
Accessory:

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Mod.Items
{
public class Accessory : ModItem
{
public override void SetDefaults()
{
item.name = "NPC Thingy";
item.width = 24;
item.height = 24;
item.toolTip = "Allows stuff to spawn";
item.value = Item.buyPrice(0, 10, 0, 0);
item.rare = 9;
item.accessory = true;
item.defense = 6;
}

public override void UpdateAccessory(Player player)
{
((myModPlayer)player.GetModPlayer(mod, "myModPlayer")).accessoryOn= true;
}


}
}
////////////////////////////////////////////////////////////////
NPC(just paste this in within your NPC class):

public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
if(((myModPlayer)player.GetModPlayer(mod, "myModPlayer")).accessoryOn== true;)
{
return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 0.5f : 0f;
}
return 0f;
}
Thanks so much
 
aw crap
c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Items\EnderuimTotem.cs(23,22) : error CS0115: 'Enderuim.Items.EnderuimTotem.UpdateAccessory(Terraria.Player)': no suitable method found to override

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Enderuim.Items
{
public class EnderuimTotem : ModItem
{
public override void SetDefaults()
{
item.name = "Enderuim Totem";
item.width = 30;
item.height = 30;
item.toolTip = "Awakens monsters of Dark Mode when worn";
item.value = Item.buyPrice(0, 10, 0, 0);
item.rare = 9;
item.accessory = true;
item.defense = 6;
}

public override void UpdateAccessory(Player player)
{
((myModPlayer)player.GetModPlayer(mod, "myModPlayer")).accessoryOn= true;
}


}
}
 
aw crap
c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Items\EnderuimTotem.cs(23,22) : error CS0115: 'Enderuim.Items.EnderuimTotem.UpdateAccessory(Terraria.Player)': no suitable method found to override

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Enderuim.Items
{
public class EnderuimTotem : ModItem
{
public override void SetDefaults()
{
item.name = "Enderuim Totem";
item.width = 30;
item.height = 30;
item.toolTip = "Awakens monsters of Dark Mode when worn";
item.value = Item.buyPrice(0, 10, 0, 0);
item.rare = 9;
item.accessory = true;
item.defense = 6;
}

public override void UpdateAccessory(Player player)
{
((myModPlayer)player.GetModPlayer(mod, "myModPlayer")).accessoryOn= true;
}


}
}
Code:
public override void UpdateAccessory(Player player, bool hideVisual)
^ That's the correct method signature.
 
speaking of which, how can I create something that walks around like a fighter but I can still control the spawns... Its really important for my mod.
 
If I use the AI of a zombie, it will despawn during the Day, but I want it to spawn during the day. I also wouldn't mind editing the AI to summon projectiles and stuff
You know you'll want to delve into programming AI then? That's not something anyone's eager to code for someone (good reasons not counting), since it's very time consuming.

Anyway, a good start would be to look at how vanilla fighter AI is handled.
 
You know you'll want to delve into programming AI then? That's not something anyone's eager to code for someone (good reasons not counting), since it's very time consuming.

Anyway, a good start would be to look at how vanilla fighter AI is handled.
The issue is I can't. For some reason the ilspy thing doesn't work, and I litteraly no nothing of AI code
 
It crashes every time I use it. But does aiStyle = 1; make it so it is a fighter AI?
Yeah, it does.
The type of the NPC, however, determines a LOT of other things (like speed, jumping, etc).
When you assign no aiType to your NPC and use aiStyle 1, your NPC will move even slower than your average zombie.
 
Yeah, it does.
The type of the NPC, however, determines a LOT of other things (like speed, jumping, etc).
When you assign no aiType to your NPC and use aiStyle 1, your NPC will move even slower than your average zombie.
Oh...
[DOUBLEPOST=1457572949,1457572723][/DOUBLEPOST]What about flying AI? Would that be different in any way
 
Oh...
[DOUBLEPOST=1457572949,1457572723][/DOUBLEPOST]What about flying AI? Would that be different in any way
You can experiment with aiStyles and corresponding aiTypes, but ultimately it is dependent on the code that is there already. You can do clever things in preai and postai, but usually you'd want to look at the source to see how and when to do those things. (see how the vanilla ai uses the 4 ai float variables.)

For flying enemies, just experiment.
 
You can experiment with aiStyles and corresponding aiTypes, but ultimately it is dependent on the code that is there already. You can do clever things in preai and postai, but usually you'd want to look at the source to see how and when to do those things. (see how the vanilla ai uses the 4 ai float variables.)

For flying enemies, just experiment.
Alright
 
Back
Top Bottom