Endershot355
Steampunker
pls?
example? I never used modplayer before
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace Mod
{
public class Player : ModPlayer
{
public bool accessoryOn;//this is the property Im talking about
}
}
Yes I know bool I just dont know how to use it in the sit im talking aboutCode:using System; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Mod { public class Player : ModPlayer { public bool accessoryOn;//this is the property Im talking about } }
In an if statement, you would useYes I know bool I just dont know how to use it in the sit im talking about
Yeah, just change "Player" to another name. Your code would allow your mob to spawn on the surface during day. Make sure, however, that CanSpawn() returns 0f if the accessoryOn is falseso...
if
{
((Player)player.GetModPlayer(mod, "Player")).accessoryOn
}
then
{
spawning params?
]
how do I get it to spawn thou? I dont want it to spawn instantly, like an item. I just want it to enable spawning of that mob.
Oh I just relized
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
If
{ ((Player)player.GetModPlayer(mod, "Player")).accessoryOn
}
then
{
return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 0.5f : 0f;
}
}
Does that mean it wont spawn?Yeah, just change "Player" to another name. Your code would allow your mob to spawn on the surface during day. Make sure, however, that CanSpawn() returns 0f if the accessoryOn is false
Also, its !Main.Day.Time. The ! means it wont, so it spawns at night ^_^Yeah, just change "Player" to another name. Your code would allow your mob to spawn on the surface during day. Make sure, however, that CanSpawn() returns 0f if the accessoryOn is false
Totally knew thatDoes 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?
and no, you would put the "return 0f;" outside of the if statement, like in an else statement.Does that mean it wont spawn?
Can you make a quick example thing for me so I can easily copy paste it when I get back from dinner?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
Player:Can you make a quick example thing for me so I can easily copy paste it when I get back from dinner?
Thanks so muchPlayer:
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;
}
no problemThanks 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;
}
}
}
public override void UpdateAccessory(Player player, bool hideVisual)
Plsspeaking 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.
What exactly do you mean? 'Still control the spawns'?
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 stuffWhat exactly do you mean? 'Still control the spawns'?