Jump to content

Spawning mob on trigger?


GermainZ

Recommended Posts

I've made a simple map. This map is composed of a circular room, and to the north of it, three small rooms separated from the circular one with gates.

Here's a quick depiction of the room:

...||..||..||....<--- The three small rooms

...-...-..- ....<--- Gates

..[[[[[]]]]]....<--- The circular room

[[[[[[]]]]]]]]

..[[[[[]]]]]

 

Basically, here's what I want:

  1. The player walks in a zone (the circular room)
  2. This triggers the mob spawn
  3. Three groups of mobs spawn
  4. Each group is composed of X mobs
  5. The first group spawns to the room in the left, the second in the middle, the third in the right
  6. The gates of these three rooms open
  7. The mobs attack the player
  8. The three gates close again

I'm a newbie, tho, so please explain as much as possible.

This probably requires scripting, and I'd be grateful for a commented script.

Thanks a lot!

Link to comment
Share on other sites

Do the gates open one at a time? or at the same time? do all the groups attack at the same time? Do the mobs have to appear spawned? or can you just put them there with leveled monsters who attack when the gate is down?

 

If, when the player enters the room, all three gates open, and release monsters that were already hostile, and already there, this is extremely easy. Much more would require some rather complicated stuff for someone just starting.

 

 

It may not be what you want, but you may want to get the following working to get familiar with the elements involved, then move on to something more complicated.

 

 

1. Place however many leveled monsters in the rooms behind the gates. Make sure they are the type of gates in nordic ruins, the type monsters can't just open on their own. (Like NorPortcullis or NorPortcullisLarge01)

2. Select the piece of room in front of the door the player will be entering.

3. Select the "Create trigger" button on the main menu bar. The one that looks like a box with a "T" in it. There's also a shortcut for this, I forget.

4. From the list, select "DefaultActivateSelfTRIG"

5. Select one of your gates. Make sure you can see the semi transparent trigger box you just added from here.

6. Double click to bring up it's properties.

7. The tabs in the middle of the window extend to the right, use the arrows by the tabs to move over till you get to the tab that says "Activate Parents"

8. Right click in the table there, and select "New"

9. In this window Click "Select Reference In Render Window"

10. With the weird round cursor thing, select the semi transparent(probably orangeish) trigger box.

11. Make sure the text boxes now say something about DefaultActivateSelfTRIG, click OK

12. If there is a new entry in the "Activate Parents" list, click OK again.

13. Repeat steps 5 through 12 for the other two gates.

Now when you walk in the room, the three gates will automatically open. The monsters, if they see the player, will go nuts and do their thing.

If you want a more complicated encounter, it will probably still involve AT LEAST the stuff we just worked with. So I recommend setting this extremely simple encounter up before trying to do anything more complicated.

a lot of this is covered here: http://www.creationkit.com/Bethesda_Tutorial_Encounters

and very well here:

 

 

Expanding your encounter (putting some of your own effort into making your encounter how you want it :D ):

 

 

Your encounter can definitely go as you're describing, it just will take some familiarity with other CK elements. To spawn and manipulate baddies of appropriate level, and have maximum control over the behavior of all elements involved, I'd recommend a familiarity with the quest manager (we're not putting the player on a quest, the quest manager just lets us do somethings useful for encounters). The basics of how to deal with scripts, even if they're written by other people, would also help.

 

Scripting basics(very very basic, don't have to get too deep):

(Put up a day or two ago by our own fg109)

 

This is the start of a multi part series on becomming familiar with the basics of using a quest(Quests can be invisible and just control things, they don't have to be quests for the player):

 

 

Link to comment
Share on other sites

Thanks a lot for your reply. As a matter of fact, I've already done most of this, leaving the quest objectives empty so it's only used to control -without being shown to the player as a quest. What I can't figure out, tho, is how to actually make mobs spawn without them being there. I thought about putting all the groups outside of the walls then move them each to a marker, but that might cause performance loss. Is there a way to "summon" the mobs, then summon other mobs once all existing mobs have died?
Link to comment
Share on other sites

Absolutely. Cool to hear your going further with learning the stuff.

 

There are quite a few options.

One reasonably obvious one is the PlaceAtMe function. This version since you're probably making leveled monsters:http://www.creationkit.com/PlaceActorAtMe_-_ObjectReference

Another is Quest aliases. Unfortunately, so far as I know, the only time a quest creates aliases is at the start, once time. That would suggest three quests, based on story manager script events. Which could easily get messy.

 

The good news, is that PlaceAtMe returns a reference to the new monster, so you can control it, to a point, from whatever script you call it from. It will only return a reference to the last actor created, so call it for each monster individually.

 

The question then becomes, how to control it all in the sequence you want.

 

Here's a bit of a solution I'm thinking:

 

Stage 10, quest creates aliases of the first set of monsters as normal, on pre positioned markers in the first room(that's how you usually do it). These aliases have, attached to them, a script, that increments a quest variable when killed(GetOwningQuest().TrackingVar += 1). The also have kill events that check if they are the last one killed. If they are ...

 

set Stage 20,

Stage 20 will then,

Try to clear all three aliases, since it's just dead things: http://www.creationkit.com/TryToClear_-_ReferenceAlias

maybe a utility.wait(2) for good measure. So things can get caught up.

Using the markers in the second room:

MonsterRef = marker1.placeatme(Lmonster) for each one (storing the reference, so you can use it)

 

Then Force your MonsterRef into one of the empty aliases: http://www.creationkit.com/ForceRefIfEmpty_-_ReferenceAlias

 

do this for each monster

 

the created monsters now have the alias script to catch when each is killed and record it.

 

Do that for however many monsters you have markers and aliases for.

When these next monsters are killed, the tracking number will be at however many monsters you've killed so far, so you can go to stage 30

 

Stage 30:

Do the same thing for the third room. I have no idea if this will work, I don't know how happy a quest is about having it's aliases cleared and forced mid quest, I haven't messed with that.

 

When the third room monsters are killed, the killed variable will be at it's max,

 

This is extremely sloppy way of presenting this I know, but I expect someone else will be along shortly with their own ideas :D See which option you like best and if this is a reasonable option and you haven't worked it out yet maybe I'll put it into ... I guess it's one script, and some fragment code.

 

My recent work with world encounter triggers and scripts leads me to think this could actually be the basis of a pre packaged multi wave encounter setup lol. That, however, is a topic for another time.

Link to comment
Share on other sites

I was thinking about a script, triggered by the activateselftrig, that would use the PlaceActorAtMe function. I can't figure out how to make it place an actor at a specific marker. I've already placed and XMarker, thinking that "MarkerProperty" should be substituted by its ID, but that didn't work in the script line below, taken from the wiki:

MarkerProperty.PlaceActorAtMe(WolfBaseProperty).StartCombat(Game.GetPlayer())

Link to comment
Share on other sites

One big thing is you have to a reference to it first, you can't just call it by name. Your script has to be pointing at that exact marker out of all the other markers in the world. A quest alias is the top way to do this. Then you can do the scripting from in the quest and they can refer to each other. You could also try, just to let them talk to, and about each other outside a quest, linking them. Then you could let them reference each other with the GetLinkedRef (http://www.creationkit.com/GetLinkedRef_-_ObjectReference) and related functions. a lot of world encounters are setup sort of like this. Sort of..

 

Oh, just thought of another idea.

 

make all the monsters initially disabled, but in place.

 

Make XMarkers, one for each of the three groups, initially enabled. Set the respective xmarker as the 'Enable Parent' of each of the monsters in each group, with the 'Set Enable State to oposite of parent' checkbox checked.. I guess this will work for leveled monsters I don't know.

 

Now the problem is reduced to enabling the three XMarkers in sequence.

 

Switch your trigger to DefaultEnableDisableLinkedRef. Link it to your first XMarker. Edit it's properties in the scripts tab so it does the following:

The trigger, on trigger, can disable your first groups xmarker (which is linked to the trigger)

This will enable the first group of monsters.

 

How to get the second two groups enabled after leveled monsters die without a quest? that will need some more thought..

Link to comment
Share on other sites

Starting them disabled then enabling them through the script is probably best way to go. Are you trying to have one group spawn when the previous one dies, or just have them all spawn at once? Obviously all at once would be easier, but maybe having a delay would be an acceptable middle option?

 

Here is my suggestion:

Keep the trigger as an activateself type so it opens the doors.

Set up 3 xmarkers in the room for each group, (or only 1 if they all spawn at once), and set the trigger box as it's activate parent just as you did for the doors.

On the xmarkers, start them as initially disabled, then add the following script on the script tab of the xmarker: (I couldn't find a good default one so I wrote my own, but I didn't look that hard)

Scriptname EnableonActivate extends ObjectReference  

Event OnActivate(objectreference akActivator)
self.Enable()
EndEvent

-note: If you are going to use the opposite enable state option that SinderionsBones suggested then change "Enable" to "Disable" and leave the xmarker initially enabled.

 

With all the enemies set with the xmarkers as their enable parents they will appear when the xmarker is activated. This way makes it easy to add in a delay as you can enter a delay number (which i believe is in seconds) under the activate parent tab for each xmarker and door.

 

Anyway, to add a reference (which I didn't use in my example) highlight the script and click on Properties then on Add Property. Choose the type you want (usually ObjectReference) and name it. Then with that new reference highlighted click Edit Value then you can usually select it from the render window.

Link to comment
Share on other sites

ya, forgot about the doors lol. good catch.

 

The opposite enable thing was because I wasn't sure if you could activate the xMarker while they are disabled. But then I didn't end up using an activate on theXMarker anyways. So it ends up fitting right into Danger's method :D

 

Thinking along the lines of finding out when your next group of baddies should enable, I thought of:

 

Linking the xMarker with regular links, in sequence, then using.

http://www.creationkit.com/GetNthLinkedRef_-_ObjectReference

http://www.creationkit.com/IsDead_-_Actor

 

By this I mean your xMarker, Link Ref'd to first monster. First monster linked to 2nd, etc etc... then last monster linked to next Xmarker

 

Then you use, in Danger's xMarker script,

 

(basing this on three monsters, customize for how many you have)

 

if self.GetNthLinkedRef(1).IsDead && self.GetNthLinkedRef(2).IsDead && self.GetNthLinkedRef(3).IsDead

self.GetNthLinkedRef(4).Enable ;or disable whichever one was the one that made the monsters appear... it was my idea and i forget which was which lol...

endif

 

These could be checked by whatever method you use to start it.

 

Ways to trigger that that come to mind (remember, we can't add scripts to the leveled mobs to get an ondeath event if they're not in quest alias's, still consider thinking in that direction)

 

A door when you try to activate the first few times, will just open another gate.

 

A lever, to open a door to leave, activates next group each time you use it till you kill them all.

 

A trigger for when you start to leave the room, blocks you, and opens next gate.

Edited by SinderionsBones
Link to comment
Share on other sites

Thanks, it did the job wonderfully.

 

I'm probably asking too much, but I'd really love to do this, if possible:

  1. Make a fourth gate (it's already there) open once all mobs are dead
  2. Once the player exits through the fourth gate, then enters the circular room again, a new wave takes place

 

Simply put, the player originally came in from the fourth gate, which closed once he got in... is there a way to place a trigger that would only activate once all mobs are dead, reopening the gate, waiting a set amount of time, then triggering another wave if the player walks on it?

 

EDIT: This was posted before seeing Sinderion's reply (didn't refresh), but since it doesn't answer the totality of my question, more tips would be appreciated :)

Thanks again, everyone.

Edited by GermainZ
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...