Jump to content

Removing Buzzard spawn points


Recommended Posts

Long time reader, first time posting code so I'm hoping someone with more experience could let me know if there's a better way to do it?

So I would like to remove a problem Buzzard spawner from my existing world, similar to archived thread: https://forums.kleientertainment.com/forums/topic/113898-can-you-remove-buzzard-spawn-points/)

While trying to figure out how I found a method to remove Meteor spawns (posted by @ADM in https://forums.kleientertainment.com/forums/topic/125995-deleting-specific-meteor-spawners/). I altered the code for buzzard spawns and it seems to work fine with only one slight issue in that if a buzzard is flying overhead the shadow just stops moving and doesn't go away until disconnecting & restarting the server.

It's a 2 step process:

First you need to stand directly under the buzzard spawner map icon or use the Go Next command to teleport to the buzzard spawner you want to remove:

c_gonext("buzzardspawner")

Don't move after teleporting to the buzzard spawner you want to remove and run the following code:

GetClosestInstWithTag({"buzzardspawner", "CLASSIFIED"}, ThePlayer, 5):Remove()
Spoiler


Original code that works, but do to improper syntax it removes more than just buzzard spawners:


VarSpawner = GetClosestInstWithTag({"buzzardspawner"} and {"CLASSIFIED"}, ThePlayer, 5) VarSpawner:Remove()

That's it, the buzzard spawner icon should be removed from the map and once you deal with any buzzards on the ground no more will spawn.

I look forward to any feedback, thank  you :)

Link to comment
Share on other sites

There’s a easy function called c_find() that I really like for these kinds of things. You can do c_find(“buzzardspawner”):Remove()

EDIT: My apologies, now that I'm testing, it seems c_find() doesn't actually work with buzzard spawners in particular because of the way it finds nearby entities. I would instead suggest something like c_findnext or c_selectnext for this purpose

c_selectnext("buzzardspawner"):Remove()

and to remove the nearest flying buzzard shadow:

c_find(“circlingbuzzard”):Remove()

(and you can instead do c_selectnext for the buzzard shadow too if you want)

Spoiler

or if ya wanna have a little fun instead:

for k,v in pairs(Ents) do if v.prefab == "buzzardspawner" then v.components.childspawner.childname = "carnival_crowkid" end end

 

Link to comment
Share on other sites

16 hours ago, MalusNox said:

VarSpawner = GetClosestInstWithTag({"buzzardspawner"} and {"CLASSIFIED"}, ThePlayer, 5) VarSpawner:Remove()

 

This will target anything with a classified tag, not just buzzardspawners.

You only need to check for the buzzardspawner tag.

Link to comment
Share on other sites

@Friendly Grass during my initial testing I was using c_selectnear and it didn't work, c_selectnext does work but it removes the next spawn instead of the one you're standing at, not a big issue with proper planning but currently the best way I'm aware of because of the unintended issue described below. The c_find to remove the stuck shadow animation works nicely :)

c_selectnext("buzzardspawner"):Remove()
c_find(“circlingbuzzard”):Remove()

 

@penguin0616 I'm new to LUA code and you're correct it doesn't work entirely as intended, I tested it with a MeteorSpawner which only has the classified tag and it removed it, so I guess the SelectNext method mentioned above is the better way to do it. What I was trying to do was search for an entity with both tags using "and" so it would only select an entity with both the "buzzardspawner" and "CLASSIFIED" tags because my code doesn't work without the Classified tag, it returns a nil value error with only "buzzardspawner" but it works with both tags. When I looked in the "buzzardspawner.lua" file in prefabs it adds both tags in the CreateEntity function so that's why I tried using both. I wanted to make it only remove the 1 buzzard spawner you're standing at and nothing else.

Thank you :)

Link to comment
Share on other sites

15 hours ago, MalusNox said:

@Friendly Grass during my initial testing I was using c_selectnear and it didn't work, c_selectnext does work but it removes the next spawn instead of the one you're standing at, not a big issue with proper planning but currently the best way I'm aware of because of the unintended issue described below. The c_find to remove the stuck shadow animation works nicely :)

you're right this is an issue. Now I remember why I prefer c_find :wilson_laugh:

14 hours ago, MalusNox said:

Any reason not to use the RemoveEntity(#) function? it works using the numbers provided by c_gonext("buzzardspawner").

Yeah, that works. It's not numbers that it returns but essentially the entity itself. So you can totally just do:

c_gonext("buzzardspawner"):Remove()

However, I am sorry to inform you that c_gonext does use the same exact code as c_selectnext to find which entity to reference. It iterates through the same way.

With everything's downsides, it looks like you were right on from the beginning!

GetClosestInstWithTag({"buzzardspawner", "CLASSIFIED"}, ThePlayer, 50):Remove()

-- the command c_findtag simplifies this but does the same thing

c_findtag({"buzzardspawner", "CLASSIFIED"}):Remove()

c_findtag({"buzzardspawner", "CLASSIFIED"}):Remove()

The classified tag is necessary because the engine function to find nearby entities that these functions stem from seems to ignore prefabs with the tag by default. That is also why only the commands that iterated through all the prefabs in the world worked for this scenario :/

 

15 hours ago, MalusNox said:

What I was trying to do was search for an entity with both tags using "and" so it would only select an entity with both the "buzzardspawner" and "CLASSIFIED"

Just a minor syntax issue. You only needed to separate the tags with a comma and inside the same curly brackets.

 

By the way, to just remove all buzzards and buzzard spawners in your world you can run this while on the surface. I swear this one actually works as I say it does! :???:

for k,v in pairs(Ents) do if v.prefab and v.prefab:find("buzzard") then v:Remove() end end

 

Link to comment
Share on other sites

@Friendly Grass I'm very new to LUA and syntax will get you every time, no matter what language :wilson_laugh:

I wish there was a DST code syntax manual or something lol...

After more testing I think the fixed original version (simplified with correct syntax) is the way to go as it will only remove the buzzard spawn you're standing at and hopefully nothing else. The goal is to remove only specific buzzard spawners and not all of them. I tested both versions using Buzzard and Meteor Spawners again and using the GetClosestInst version gives a nil value error if you're out of range of a buzzardspawner (range I believe is basically wall sections so 5 is a very small radius, I'm guessing 4 would be 1 pitchfork tile), while the c_findtag version removes the next buzzardspawner it finds no matter the distance.

to remove all buzzard spawners why not just use

c_removeall("buzzardspawner")

thanks again, it looks like we'll crack this one yet lol

I wonder if I should edit the OP with the final version of the code once we figure it out lol...

Link to comment
Share on other sites

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.

×
  • Create New...