uberquake Posted February 20, 2014 Share Posted February 20, 2014 Hello, this is my first post here. You all seem to be a helpful bunch. I'm trying to make a mod that, in an aura surrounding the character, targets killer bees automatically. My problem is that bees are not differenciated by tags, but by their brains. I'm not sure how to target something based on what brain it has. As well, I'd like to automatically target houndmounds, but not any other structures. If I remove the elseif/return true command here, this code will work. I haven't tested out the bunnymen, chester, baby beefalo, eyeplant, or lureplant (because I havne't run into them in this playthrough yet, but I believe they'll work just fine based on my interactions with tallbirds and beefalo. Also, the "bunnyman" prefab may not be the correct way to avoid targeting them...local function validateTarget(target) if (target:HasTag("tallbird") or target:HasTag("wall") or target:HasTag("structure") or target.prefab == ("chester") or target:HasTag("beefalo") or target:HasTag("bee") or target:HasTag("pig") or target.prefab == ("babybeefalo") or target.prefab ==("eyeplant") or target.prefab ==("bunnyman") or target.prefab == ("lureplant") or target.prefab == ("smallbird")) then return false elseif (target:HasBrain("killerbrain") or target.prefab == ("houndmound")) then return true end return trueendAnyway, the target:HasBrain is a broken code. Either it doesn't exist or I'm not calling on it correctly. I'd just like to know what can be fixed with this code. Everything else is working so far... And thank you, in advance, for your input. Link to comment Share on other sites More sharing options...
uberquake Posted February 20, 2014 Author Share Posted February 20, 2014 I don't know how to edit my post... so I'll just say this. I want to target everything, just not certain things - regular bees included. So, everything not listed I want to have my aura attack, including killer bees and hound mounds. Link to comment Share on other sites More sharing options...
TheDanaAddams Posted February 20, 2014 Share Posted February 20, 2014 You mentioned using tags, and I think that's the best way to do it. Just use a post-init to add a tag to the creatures you want to affect. ^^(Then you'd only have to check for one tag in the code.) Link to comment Share on other sites More sharing options...
uberquake Posted February 20, 2014 Author Share Posted February 20, 2014 Right... Post init. Great idea. Now uhm... to a guy who's brand new at this whole modding thing, please tell me, what is this "post-init" thing you're referring to. Also, I'd like to add in a way to target something if I'm attacked by it. For instance, Tallbirds are hostile, but they might not be targeting me. If they're not targeting me, I want to ignore them. If they turn to target me, then I want this aura to defend me automatically. This would also be another way to target a killer bee, should one or six target me - which I think would be even better than the direction I was attempting to go. I'm still interested in your suggestion though, so you would certainly have my appreciation were you to elaborate on how I would do that. Again, I'm new to modding. I've tried doing some research on all the tags and what a local function is and all of this, but this coding language is nothing I'm familiar with. Link to comment Share on other sites More sharing options...
uberquake Posted February 20, 2014 Author Share Posted February 20, 2014 Looking through the prefabs a little more, I found that killer bees actually have a tag. I rewrote the code, and now killer bees are targetted, while regular bees are not. Now I just have to figure out how to add in a target that has decided to agro on me for something like, carrying meat around a bunnyman, or being too close to a tallbird's nest. This is my updated code:local function validateTarget(target) if (target:HasTag("killer")) then return true elseif (target:HasTag("tallbird") or target:HasTag("wall") or target:HasTag("structure") or target.prefab == ("chester") or target:HasTag("beefalo") or target:HasTag("bee") or target:HasTag("pig") or target.prefab == ("babybeefalo") or target.prefab ==("eyeplant") or target.prefab ==("bunnyman") or target.prefab == ("lureplant") or target.prefab == ("smallbird")) then return false end return trueendObviously, after I tested it out, I found out that the things I wanted to return as true had to go above those I wanted to return false. In this case it was the killer bees, but in the future I'd like to add an attacker to that list. Does that mean I have to do something like this?local function OnAttacked(inst, data) local attacker = data and data.attacker if attacker == GetPlayer() then return endendThen, somewhere after that function, call on it within the validateTarget function? Am I close? Link to comment Share on other sites More sharing options...
TheDanaAddams Posted February 20, 2014 Share Posted February 20, 2014 Post-Inits are used to add something to a prefab. (Well, not just prefabs, but usually, prefabs.) Here's an example from my Link mod:function LinkLootPostInit( inst ) if GLOBAL.GetPlayer().prefab == "link" then inst.components.lootdropper:AddChanceLoot("rupee", .6) inst.components.lootdropper:AddChanceLoot("bombs", .1) inst.components.lootdropper:AddChanceLoot("arrows", .2)-- inst.components.lootdropper:AddChanceLoot("heart", .3)-- inst.components.lootdropper:AddChanceLoot("magjar", .3) end AddPrefabPostInit("bat", LinkLootPostInit) AddPrefabPostInit("beefalo", LinkLootPostInit) AddPrefabPostInit("bishop", LinkLootPostInit) AddPrefabPostInit("bishop_nightmare", LinkLootPostInit) AddPrefabPostInit("bunnyman", LinkLootPostInit) --Cave Spiders: AddPrefabPostInit("spider_dropper", LinkLootPostInit) AddPrefabPostInit("spider_hider", LinkLootPostInit) AddPrefabPostInit("spider_spitter", LinkLootPostInit) Now, if you used the Post-Init to addinst.HasTag:"MYTAG"anything you ran the Post-Init on would have the MYTAG tag. For checking for a creature having aggro on the player... I'm not sure, but I think you can check if something has a target, so maybe that will work? Link to comment Share on other sites More sharing options...
uberquake Posted February 20, 2014 Author Share Posted February 20, 2014 I did not realize I was talking with the person who created the Link mod! Well done on that! I played him for a bit, but I haven't got much of an attention span when there are so many characters and mods to play. Regardless, he's one of the best with so much added into the game that it has to be met with much respect. As well, now I know I'm getting quite experienced help! The thing I have noticed about mobs is that they have an OnAttacked function. I'm just wondering if I can apply that function, somehow, to the player and, if OnAttacked is flagged, set the attacker to a target exempted from the return false list. If I can pull that off somehow, that would be awesome. I'm also having problems with targeting certain "structures". For instance, I haven't ran across a houndmound yet but I'd like to test this aura out on it. The aura won't attack walls or built items, but it started, for instance, to attack the houndius shootius (sp?). I added that to the list of things not to attack, and we were good to go. It also attacked slurtle mounds though... I'd hate to add every prefab one by one, but if that's what I've got to do, then I guess I will. Hound mounds might be good to have to farm hounds teeth from, but slurtle mounds are much moreso simply for the fuel they give to the player with their slurtle slime. So, maybe one smack on the mound to get the first slurtle out, but after that it should just be earthquakes that cause those little guys to slime their way along. So... postinit then. Well, I have another little mod that I'd love to have happen. I want to make it so that chest will burn and all the contents - regardless of what they are - will turn to ash. Well, maybe those with the irreplacable tag, like Lucy, should be simply dropped, but I'm having trouble just making it possible to light one on fire with a torch, or anything else next to it. I'm sure I've done something completely wrong with my postinit attempt at this, but it's better than what I had going on before.function MakeBurnPostInit( inst ) if bank == "chest" then MakeLargeBurnable(inst) inst.components.burnable:SetOnIgniteFn(OnIgnite) endendAddPrefabPostInit("treasurechest", MakeBurnPostInit)Is that close? I only want regular chests to be able to burn. It makes sense that they could burn since they're made of wood... Anyway, I'd like to use this as an alternative to lureplants. Instead of dumping everything on the ground somewhere and planting a lureplant bulb to hoover it all up, I'd rather bulid a chest, throw everything inside, then burn it and repeat. Link to comment Share on other sites More sharing options...
TheDanaAddams Posted February 21, 2014 Share Posted February 21, 2014 Using the OnAttacked code sounds plausible, for sure! I'm not the greatest when it comes to code - I'm more about the art. I think you may have to add every one, yeah... It's what I did for the monsters in the "linkloot" part of my mod. You can at least hijack a large portion of the prefabs you'd need from there! ^^To test with things, you should just use the console to spawn them. DebugSpawn("prefab") I think the command was. Haven't actually done it for a while, since I've been out of commission. And also, I use MiniTools when testing, which changes the command slightly. I'm not sure why that PostInit isn't working... maybe remove that "if bank" part, just to see if it will work without it.I made my Wooden Sword, Shield, and Arrows burnable, so maybe it'll help to look at those? Instead of a burnable chest, though, why not create a trash can?Making chests burnable could be disastrous if you accidentally set fire to an important one!If all you want to do is be able to get rid of things, a custom item that just removes the item (I think it's something like "inst:remove" - pretty sure my bottles have code pertaining to that in them) would be best!Check that it doesn't have the irreplaceable tag, and if it doesn't, remove it. Perfect trash can, and no risk of accidentally burning down a chest full of important stuff! ^^ Link to comment Share on other sites More sharing options...
uberquake Posted February 21, 2014 Author Share Posted February 21, 2014 I've actually created a topic for burnable chests here for the sidetrack I took this topic onto: http://forums.kleientertainment.com/topic/31743-burnable-chests/#entry417717 Sorry Also, burning important stuff is part of the fun I want fire hounds attacking your base to be an absolutely terrifying event. LoLz. I like your idea of a trash can mod, and one has already been created. The problem is he's like Chester, he follows you around, and he's a little buggy sometimes. I've had him crash on me just while walking around. Ideally, were I to make a trash can, I'd like it to be something with a ton of slots (so that I could potentially dump my entire RPG Hud 55 of inventory items into it), and have it be stationary as a base structure. Burnable... that'd be fun too. I like burning things... Thank you very much for your input and help Link to comment Share on other sites More sharing options...
uberquake Posted February 21, 2014 Author Share Posted February 21, 2014 Oh! Also, I forgot to mention, in regards to the actual topic here, the OnAttacked code - so far as I can tell - only works when something actually strikes. So, pigmen have it, but they're not violent until struck, unless they see something (a merm, for instance) that they will always target regardless of what's going on. What I'd like to do, with my aura, is have it attack something that is targeting me before I'm hit. So, a tallbird would not initially be attempting to target me in order to attack me, but if I stood around too long it would. I'm hoping to find something that, once it sets its sights on me with fire in its eyes, this aura would attack it regardless of that particular creature being on the ignore list. I think it would be possible, but the more I talk about it, the more I'm starting to realize that this would not be one simple prefab or postinit - even though I'd love it to be. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.