Marcin JOT.PE
Terrarian
Maybe someone can send me some custom AI code over and describe what makes each line of code?
This is a very tricky question (I guess it's a question), since AI has so many different elements to it.Maybe someone can send me some custom AI code over and describe what makes each line of code?
Maybe someone can send me some custom AI code over and describe what makes each line of code?
Allright, it may take a little time and your quesion might be already answered by the time I'm done, but I'm going to post it anyway.
It is kinda out of date, since it's for tAPI.Why? I have use that for create my mod(who contains qew boss) and he is not out of date... if you have with Visual studio and use button search of forum, you found all for create correctly a npc.
Yeah, I see programming experience (may it be with C# or some other language) and/or knowledge as a MUST if you want to mod. Especially with tModLoader as-is, since it's pure C#. I do also, however, want to give the 'dummies' (excuse me for using that term ) among us a chance to get their ideas in game with an API functioning as medium. In this case a more 'back to the basics' example would be best suited. Although the tut blue made is very nice and could help a lot of us, just some general AI knowledge would serve this situation better (IMO). This is in no way me denying or denigrating anything you said, no worries!You have reason, sure. I have already a mod programmed with java in other game and already programmed with many others languages :x (but never C# before.)
(I do hope this doesn't turn into a double post. Shame on me).
public override bool PreAI()
{
return false;
}
public override bool PreAI()
{
npc.ai[0]++;
if(npc.ai[0] >= 60)
{
npc.ai[0] = 0;
}
return false;
}
public override bool PreAI()
{
if(npc.ai[0] == 0)
{
if(npc.life <= npc.lifeMax / 2)
{
npc.ai[0] = 1;
}
}
else if(npc.ai[0] == 1)
{
npc.ai[1]++;
if(npc.ai[1] >= 60)
{
npc.ai[1] = 0;
}
}
return false;
}
public override bool PreAI()
{
if(npc.life <= npc.lifeMax / 2)
{
npc.ai[0] = 1;
}
int maxSpeed = 3;
npc.TargetClosest(true);
Vector2 dir = Main.player[npc.target].Center - npc.Center;
dir.Normalize();
if(npc.ai[0] == 1)
{
npc.ai[1]++;
if(npc.ai[1] >= 60)
{
int shootSpeed = 4;
int damage = 10;
int knockBack = 0;
int type = 84;
Projectile.NewProjectile(npc.Center.X, npc.Center.Y, dir.X * shootSpeed, dir.Y * shootSpeed, type, damage, knockBack, Main.myPlayer);
npc.ai[1] = 0;
}
maxSpeed = 5;
}
npc.velocity = dir * maxSpeed;
return false;
}
Projectile.NewProjectile(xPosition, yPosition, xSpeed, ySpeed, projectileType, projectileDamage, projectileKnockback, owner);
fyi, that tutorial isn't out of date, it's only focused on tAPI. For vanilla code, nothing much has changed, you can still learn a lot from the tutorial.Snrasha this tut is pretty out of date
Are you getting an error? Not the correct pricing?item.value = Item.sellPrice(0, 10, 0, 0);
Theres something wrong with that line, but I don't know what.
Pls tell me whats wrong with it.
The item is a gun.
I have the same problem with my modded Bow and my modded Rocket Launcher.
Lemme write you a little story, hang onNice now time to start coding my own boss. You will surely ask why I started from such a difficult thing and not knowing #C language. So I started from custom ai and not about things like item, tile of some basic npc because if you can do the hardest thing then all will be easy. And some questions
1. You write everything in Pre Ai. What is the difference between Pre Ai , post Ai en Ai?
2. Can i write for example in Pre ai movement and in Ai Projectiles ?
3. can you explain more over movement , charge , stay above player , jumping ?
4. How about change frames from frame movement to frame charge of stay above player?
Sorry for English all wrote in google tlanslator
item.value = Item.sellPrice(0, 10, 0, 0);
Theres something wrong with that line, but I don't know what.
Pls tell me whats wrong with it.
The item is a gun.
I have the same problem with my modded Bow and my modded Rocket Launcher.
Just to be clear, you are getting that error when building in game, correct? CSteamworks.dll should be in the terraria steam directory, you shouldn't even touch it, and it shouldn't have even come up. Try this: http://javid.ddns.net/tModLoader/generator/ModSkeletonGenerator.html and also if it's not working, show a screenshot of the error screen and your folder and folder path.
[doublepost=1463984297,1463983995][/doublepost]
None of this matters to tmodloader. tmodloader will build the mod itself and doesn't care what you have in your .sln or .csproj file.
UIElements not showing up: The main cause for this is doing something like: recipe.addTile(ItemID.Anvil); instead of the TileID
Other reasons include throwing exceptions in your code somewhere.
Anyway, if you can't see it immediately, move items out of the mod until you see your problem is fixed, or post the troubling code.
Not sure about the first one, unless somehow you have an extra copy of that dll, but the second one is a mp3sharp.dll in the steam terraria directory that you need to delete.error CS1704: An assembly with the same simple name 'Steamworks.NET, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side.
error CS1704: An assembly with the same simple name 'MP3Sharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side.
this is my error but im not sure if this is the same case as the first one. I used the mod skeleton, and added it to the "C:\Users\Lolz\Documents\My Games\Terraria\ModLoader\Mod Sources" (yes i extracted the skeleton already) but when i build the mod this error shows up. Please help me and thank you in advance
Thank you ! the second error is now remove thx!Not sure about the first one, unless somehow you have an extra copy of that dll, but the second one is a mp3sharp.dll in the steam terraria directory that you need to delete.