Aller au contenu

Photo

Spawn on enter.


  • Veuillez vous connecter pour répondre
18 réponses à ce sujet

#1
PJ156

PJ156
  • Members
  • 2 983 messages

For my new mod I am going to look at spawning assets rather than using placed ones. I am looking at workflow in general and this is one aspect of this.

 

I know that others spawn rather than place, but how is this done functionally? I am thinking to spawn everything of the on_enter script but do you destroy everything on exit, I guess you have to?

 

What are the advantages of this. Are there more beyond the fact that I can modify blueprints rather than instances?

 

PJ



#2
AGhost_7

AGhost_7
  • Members
  • 62 messages

 

I know that others spawn rather than place, but how is this done functionally? 

 

You could look at gizmo's spawner code and work off of that. The basic idea would be to have ipoints which you place settings on, and start them up when the PC enters the area. You define the radius of the spawner and place the spawner where you want the creatures to pop up.
 

 

 I am thinking to spawn everything of the on_enter script but do you destroy everything on exit, I guess you have to?

 

If you're spawning stuff every time that the player enters the area (i.e., not one-time spawn) you'd definitively want to destroy everything on exit. If the player goes back and forth in the area you'll probably have creatures accumulating in a certain section of the map.
 

 

What are the advantages of this. Are there more beyond the fact that I can modify blueprints rather than instances?

 

There aren't that many advantages is you're not doing this for a PW, as the way I see it the biggest advantage is that you're keeping resources use as low as possible. I can think of a few advantages for a module though:
  • If a player goes back to an area that he's already explored, you could make it so that the creatures are spawned again.
  • You can (and probably will have to) add some level of randomness. The location of the creatures won't necessarily be the same every time, and so will the ratio of creature blueprints, etc. Could elaborate on that to make replays as interesting as possible.
  • You could add logic to your spawner so that there are more creatures which are created depending on several factors. e.g., Level, number of players in the module(if we're talking about multiplayer), difficulty setting, AC, so on...


#3
kamal_

kamal_
  • Members
  • 5 250 messages
Combined with using encounters, you get level scaling to whatever limits you include blueprints for + randomness in enemy placement which can encourage replayability.

#4
4760

4760
  • Members
  • 1 207 messages

The prologue of my campaign being 90% done, I'll keep the ScriptHidden creatures and the triggers I already wrote

void main()
{
	int iNb = d4(1); // entre 1 et 4 adversaires
	int iType = d4(1); // type de l'ennemi
	string sRef;
	switch (iType)
	{
		case 1:
			sRef="c_beetlestag_tgk";
			break;
		case 2:
			sRef="c_beetlefire_tgk";
			break;
		case 3:
			sRef="c_beetlebomb_tgk";
			break;
		case 4:
			sRef="c_spider_tgk";
			break;
	}
	while (iNb>0)
	{
		CreateObject(OBJECT_TYPE_CREATURE,sRef,GetLocation(GetObjectByTag("WP_Beetles")));
		iNb--;
	}
	// une seule fois !
	DestroyObject(OBJECT_SELF);
}

But I'll definitely check how this spawning thing works for the second module (only 25% complete, so not difficult to update).



#5
Tchos

Tchos
  • Members
  • 5 054 messages

Yes, I spawn rather than place.  I have the code for doing so in the On Client Enter script for each area, and I have it set up so that I only have to place waypoints (not ipoints) tagged or otherwise marked with a creature's resref, and a special local integer (I created a blueprint with that integer already set).

 

If I wanted the creatures to repeatedly respawn, that's when I might use an ipoint.  I could spawn an ipoint for each of them that dies, a single ipoint for all of them, or use the area's heartbeat.  I'd use an ipoint if I wanted to stop the respawning cleanly by simply destroying the ipoint, and the area heartbeat if I didn't plan to stop the respawning. 

 

For simple event-based respawning, all I have to do is set a local variable, for instance in a conversation, and the On Client Enter script does its job again next time the player enters, or of course I can spawn them directly from the conversation at that same waypoint if I need them immediately.

 

The main advantage for me is what you said -- that you can alter the blueprint at any time, and not have to open up the area(s) where the NPC is placed and alter it there.  This is especially handy when you're talking about large numbers of monsters.  Consider appearance, gear, loot, and scripts on that NPC.

 

Another advantage is a minor ease on the computer, in that placed NPCs are evaluating their scripts from the beginning of the game, even when the player has never been there, while spawned NPCs only start once the player has actually been there, because they didn't exist until then.

 

You can spawn them whenever you actually need them, not necessarily on Client Enter.

 

As AGhost said, you do not need to destroy them on exit unless the area itself is a temporary area.  My shopkeepers, for instance, are spawned once, and never destroyed.  Most spawning scripts mark their waypoints as "done" with a local integer so that they don't spawn every time the player enters, but as mentioned earlier, that integer can be removed if you want to spawn them again.



#6
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I think spawning is more flexible but an abundance of waypoints on a map can make it difficult to tell quickly what is going on in the toolset.

Regards

#7
Tchos

Tchos
  • Members
  • 5 054 messages

I use colour coding on my waypoints to determine which ones are for spawning, which are for doors or other teleports, which are for AI movement, etc.


  • Kaldor Silverwand et PJ156 aiment ceci

#8
PJ156

PJ156
  • Members
  • 2 983 messages

Thanks guys. I can see pro's and cons. I am not sure the save on computer assets matter that much but I am certain the modding of blueprints vs instances does. i have completed a module or two now and making changes to instances when balancing is a pain in the butt.

 

I think, in the end, I will likely use a mixture depending on what is happening in the area.

 

PJ

 

PS; Good to see you posting again Kaldor Silverwand.


  • Kaldor Silverwand aime ceci

#9
rjshae

rjshae
  • Members
  • 4 491 messages

For creatures I've been spawning once on first entry, then use SetScriptHidden with disable UI true on area exit.



#10
andysks

andysks
  • Members
  • 1 650 messages

I use the same as Tchos. It's really easy to get the grip. Even for me. I spawn important NPCs but I have placed commoners etc.


  • PJ156 aime ceci

#11
PJ156

PJ156
  • Members
  • 2 983 messages

I am now sure that i will mix and match but spawn on a do once script as RJS and others have said.

 

Workflow wise I am going to use a method discussed in a thread started by Kamal with his suggestions for speed modding.

 

I will complete the plot and areas then stage the whole thing in one large 32 x 32 area.

 

Once it is tested and completed/balanced I will save all the blueprints and spawn them as needed. Effectively I will spawn encounters and plot holder npcs to an area once and leave all the filler stuff in there from the start.

 

PJ



#12
Eguintir Eligard

Eguintir Eligard
  • Members
  • 1 832 messages

I really only read the initial post so I am responding to that and hope it is not a repeat.

 

I simply place all my spawn triggers at the entrance or very near it to reduce the lag (lets say 1 every 2m in game). Same effect, no scripting and you can spawn the whole dungeon that way.



#13
Dann-J

Dann-J
  • Members
  • 3 161 messages

I really only read the initial post so I am responding to that and hope it is not a repeat.

 

I simply place all my spawn triggers at the entrance or very near it to reduce the lag (lets say 1 every 2m in game). Same effect, no scripting and you can spawn the whole dungeon that way.

 

The problem with using triggers is that there's a slight (but noticable) delay when the player runs through them and the creatures spawn. Whenever I see that sort of delay in a module, I know something has just been spawned in the area, which ruins the immersion somewhat. Caching the creature blueprints in the area can reduce the pause, but never eliminates it entirely. Also, triggers on the ground can be notoriously unreliable in this game.

 

Spawning from an OnClientEnter script usually happens before the area becomes visible to the player, so they don't notice anything amiss.

 

Occasionally I'll spawn things via a door opening though. The pause still happens, but because it's not while the player is in motion you don't notice it quite as much.



#14
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi,

Just a quick couple of functions from my own system that may help:

// ACTIVATE TRIGGER ACCORDING TO VARIABLES SET
SetEncounterActive(TRUE, oEncounter);
TriggerEncounter(oEncounter, GetFirstPC(), ENCOUNTER_CALC_FROM_FACTION, -1.0);

I have interacted objects (like doors) activate the encounters (call the above lines). That way there is no lag!

Personally, I do NOT alter the parameters of the above function TriggerEncounter, but use my own homebrew function to scale encounters if I need that. The function in this basic state does trigger the encounter though, without the need for a PC to enter the trigger itself. My own triggers are just placed somewhere near where I need them for convenience, not for actual entering.

Cheers,
Lance.

#15
Dann-J

Dann-J
  • Members
  • 3 161 messages

I also spawn encounters from doors via script, using a local variable on the door to define the tag of the encounter trigger (hidden in an unwalkable location). I always notice a slight lag - but then again, I *am* anticipating it. It may depend on factors like how many encounter creatures the trigger spawns (the more, the laggier), how much grunt your computer has, or whether the creatures spawned have special OnSpawn scripts (mine often do).



#16
Eguintir Eligard

Eguintir Eligard
  • Members
  • 1 832 messages
I agree triggers are effed that's why I make a double trigger shape. Still I'd like to be able to avoid them entirely for conversations somehow. They only became unreliable with the last fixes btw. Ghost Inc over triggers and warping back where you started, turning left when stopping are all the Bs I hate of this game and were not problems when it began

#17
Darin

Darin
  • Members
  • 282 messages

I use both triggers and on-enter scripts to set up areas.  Advanced traps are not something I can effectively add later, but I can keep adding things to areas using these methods.  Triggers are sized and numbered for the rooms, and have a switch in the generic onenter/onexit to handle each trigger.  I usually have the initial setup in an onenter in a conditional, then I can set up others as "esle if"

 

i

if(!(GetLocalInt(OBJECT_SELF,"nRun")==1))
{
   SetLocalInt(OBJECT_SELF,"nRun",1);
   //insert the code to spawn stuff here
}
else if (...) 
//updates based on conditions, like adding more creatures if 
// a certain thing has happened, etc.

As for triggers, I give them a generic onenter and onexit script, name the trigger (something)_0001, then run this:

int nNumber = StringToInt(GetStringRight(GetTag(OBJECT_SELF),4));
switch(nNumber)
   {
      //room 1 trigger...
      case 1:
            //whatever you want to do in this area
            break;
       //end room 1

      //room 2
      case 2:
            break; //saving this in case I want to add something later
   }

this way, since all these are campaign scripts, I can update.  Doing that with Haunted Halls....check it out, let me know how the town works, first real update already happenin.


  • 4760 aime ceci

#18
Tchos

Tchos
  • Members
  • 5 054 messages

Nice prep work, EF!  I add pseudo-triggers after the fact by spawning invisible custom AoEs.  The same scripts that I use for triggers work on those.  But I like the idea of preemptively laying down triggers for future use, and I think I'll add that to my methods.



#19
Darin

Darin
  • Members
  • 282 messages

yeah, if you pop open Haunted Halls, play it, and debubmode 1, everything is yellow.