Jump to content

Removing Creatures from an Area


Rastor

Recommended Posts

I'm looking to remove all creatures with a specified death variable from an area, including any that are spawned in by scripts. I'll admit, I'm not entirely sure how to accomplish it. What I am attempting to do is to do a READ_ASCII on the creature's death variable. I figure that I can compare it against the creatures that I want to remove via a STRING_COMPARE. If it evaluates as true, then I want the creature to be removed.

 

I want to remove it completely from the area. This includes the ARE file, the BCS spawning, everything. I'm figuring that I can compare against the creature filename, but I'm not 100% sure how to do that.

 

Any ideas?

Link to comment

I'll put this in Modding Q&A since more people are likely to find it there.

 

It would help if you could provide additional details about what your goal is in removing these creatures from the area. Is there a reason mods may introduce additional creatures that share these death variables? If so, you'll want to identify creatures dynamically each time the mod is installed, but if not, you can hardcode the list of creatures. Also, do you want to remove these creatures at install-time or do you want this to trigger at some point in the middle of someone's game?

Link to comment

Well, there's no reasonable reason that I can think of that a mod will introduce the same creatures using the same death variable. In essence, I want to remove all the creatures from the area and add my versions (which are tougher). I would rather use mine with no death variable because I don't want to edit creatures outside of the original area. What I'd be concerned about would be something like if I choose to upgrade these via TP2, then I could cause the player to be fighting incredibly tough hobgoblins in Windspear Hills or the Sewers of Athkatla when I don't want that.

Link to comment

If you have a direct replacement for each creature, it should be quite easy to create a generic solution that you can use on any area you like. If that's the case, I'd recommend using an associative array:

// creatures on the left are to be replaced with those on the right
ACTION_DEFINE_ASSOCIATIVE_ARRAY replacement BEGIN
 ~cowenf2~ => ~aerie~
 ~aemerch~ => ~keldorn~
END

 

Then you can copy the .are and loop through the structures that might have these creatures (actors, spawn points, rest interruptions?), comparing creatures against the array and replacing them one-by-one.

 

You can patch the area script with the associative array above + this code:

COPY_EXISTING ~ar0020.bcs~ ~override~
 DECOMPILE_BCS_TO_BAF
 REPLACE_EVALUATE ~\(CreateCreature[^(]*\)("\([^"]+\)"~ BEGIN // replace all CreateCreature...("blah"
SPRINT creature ~%MATCH2%~ // creature now contains blah
TO_LOWER creature
PATCH_IF (VARIABLE_IS_SET $replacement(~%creature%~)) BEGIN // if we have a replacement for creature blah
  SPRINT creature $replacement(~%creature%~) // creature now contains name of the replacement instead of blah
END
 END ~%MATCH1%("%creature%"~ // reinsert CreateCreature...("creature"
 COMPILE_BAF_TO_BCS
 BUT_ONLY

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...