Aller au contenu

Photo

How to CreateObject in Gnawed Noble


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

#1
MerAnne

MerAnne
  • Members
  • 1 157 messages
I can do this, but I would like an efficient solution rather than the one that I have come up with ;)

The goal is to CreateObject inside the Gnawed Noble.  I have done this in other locations, but the Gnawed Noble is 'special' because it is in an Area List and is not the first area that you enter.  My preference is to use a PRCSCR file, but that only seems to work in the Denerim Market OR if you save in the Gnawed Noble and then load that save (seems to really kill the immersion).  So far all of the EVENT_TYPEs seem to be loading an area for the first time and don't (seem) to work for the transition from the Denerim Market to inside the Gnawed Noble.

Yes, I can do it by checking the areaid every time any 'event' occurs,
but I would like to check just the 'event' of transitioning between
areas.

Anyone have an idea on what event I can look for?  Or will I be forced to do something inefficient? :o

#2
Yara C.

Yara C.
  • Members
  • 240 messages
As little as I understand from DAScript I would check first the PRCSCR script.
How do you set the location in this script, MerAnne?
Is the area where the object should be spawned still determined by GetMainControlled()?

#3
MerAnne

MerAnne
  • Members
  • 1 157 messages
Denerim Market (including the Gnawed Noble) is a part of the area list. When the GW enters the Denermin Market and then enters the Gnawed Noble, the new NPC does not appear. If I do a SaveGame in the Gnawed Noble and load from the Save, the NPC appears.

Since I removed all checks associated with area and IsObjectValid (when I was testing), it shouldn't be any conditions within the script that are causing it not to run the first time.

This same script works perfectly if I change the location from inside the Gnawed Noble to the Denerim Market

#4
dr.drummie

dr.drummie
  • Members
  • 51 messages
does prcscr script triggers when you enter into gnawed noble?

#5
Yara C.

Yara C.
  • Members
  • 240 messages
So it is a NPC you want to spawn. Sorry, then I have no idea.

Though it still sounds to me as if the referenced area would be bound to the main controlled object. If the area list is loaded into the memory it is usually the Denerim Market area to which you transition when you leave the area of another area list. And if you load a save game the Gnawed Noble Tavern will be the first area of this area list you transition to.

Did you try to set the npc inactive and move it to the its location in "den220ar_noble_tavern" and reactivate it there again?

Modifié par Yara Cousland, 13 octobre 2013 - 07:52 .


#6
MerAnne

MerAnne
  • Members
  • 1 157 messages
Dr Drummie - the prcscr does not trigger if the Gnawed Noble is entered from the Denerim Market. If the game is saved while the GW is in the Gnawed Noble and the Saved game is Loaded, then the prcscr is triggered.

NPCs are created with 'create object' so it would be like any other placeable in that respect. I didn't try the inactivate/reactivate, but reactivating would have the same 'problem' - a prcscr file wouldn't initiate the script. I don't HAVE to use the prcscr file to initiate the script, but Denerim has a tendency to lag so I hate to do any of the flag/areaid checking if I don't have to.

#7
dr.drummie

dr.drummie
  • Members
  • 51 messages
i guess it's ok while you have a workaround.. :)

in my case i added dwarf to dust town in ozrammar (also part of area list), but i was using "any" option in prcscr gda, then in prcscr script i check for dwarf added flag in my plot and for area tag when player enters it, so if area is dust town and dwarf wasn't added, i add him.. im not sure if i tried to save and see if there are some problems with save..

#8
MerAnne

MerAnne
  • Members
  • 1 157 messages
I almost always have an alternative. :)

I don't particularly care for using 'any', but that is my personal preference. If it works for you, then go for it!

#9
Sunjammer

Sunjammer
  • Members
  • 925 messages
Have you tried using the Gnawed Noble's area name rather than the area list name? In other words simply ignore the fact that it is in an area list?

Modifié par Sunjammer, 16 octobre 2013 - 06:03 .


#10
MerAnne

MerAnne
  • Members
  • 1 157 messages
i don't know of a way to get to the Gnawed Noble, without going through the Denerim Market first. So, yes, my GW is entering through the Denerim Market.

My solution (which may not be the optimal) was to use the prcscr to set a flag to TRUE that the GW has entered an area in the arealist. The area id is checked until the GW enters the Gnawed Noble. At that point, the creature (future companion) is created and the flag is set to FALSE (so that area id checking stops). Exiting the arealist also causes the flag to be set to FALSE.

If there is a better solution, I'm not emotionally attached to my solution ;)

#11
Sunjammer

Sunjammer
  • Members
  • 925 messages
I did some testing and it appears that the PRCSCR is creating the creature in the current area (i.e. Denerim Market) even if you pass in the desired location (i.e. one in the Gnawed Noble). Fortunately you can easily correct this simply by using SetLocation to move the creature immediately after creating it.

For example:

location lSpawn = GetLocation(GetObjectByTag("ap_den220cr_waitress_1_02"));
        object oCreature = CreateObject(OBJECT_TYPE_CREATURE, R"sandbox_talker.utc", lSpawn);
        SetLocation(oCreature, lSpawn);

Modifié par Sunjammer, 18 octobre 2013 - 11:16 .


#12
MerAnne

MerAnne
  • Members
  • 1 157 messages
hmmmm - I'm always willing to do a little experimentation when it comes to scripting. I'm not doubting that it can be done, I'm doubting my ability to do it 'easily' on the first attempt. ;-)

Looks easy - so much for going to sleep early :-)

#13
dr.drummie

dr.drummie
  • Members
  • 51 messages
so when area list is loaded, i can get location of npc in second area just by asking for "already known npc" location, it does have sense cause areas are loaded in memory, but i was thinking that i need somehow to specify location IN area where i want it to spawn.
this is useful to know.. tnx..

Modifié par dr.drummie, 19 octobre 2013 - 11:02 .


#14
MerAnne

MerAnne
  • Members
  • 1 157 messages
woohoo! I got it to work. I used the bartender rather than a waitress to get the Area object and then created the new location based on the coordinates that I had originally established.

Thanks Sunjammer!

#15
Sunjammer

Sunjammer
  • Members
  • 925 messages

dr.drummie wrote...
so when area list is loaded, i can get location of npc in second area just by asking for "already known npc" location, it does have sense cause areas are loaded in memory, but i was thinking that i need somehow to specify location IN area where i want it to spawn.

I only used the
ap_den220cr_waitress_1_02
waypoint as a shortcut (because I'm lazy) but it should be possible to construct a Location manually if you want by supplying an area object, a vector and a facing. Admitedly I haven't tested that but I suspect it will require the same approach i.e. create the object and then set its location.

At some point I'll have to tested CreateObject futher to determine the key ingrediants that make up this issue, for example, does it only happen with PRCSCR script, only happen when area's are loading/pre-loading, only happen with creatures, etc. If when I do I'll update the CreateObject page.

#16
MerAnne

MerAnne
  • Members
  • 1 157 messages
I used a little script to get coordinates (the equivalent of 'you are here' using displayfloaty) and wrote them down. I used the bartender to get the area (object). I combined the coordinates and the generated area to create the location. So my statement looked something like:

object oArea = GetAreaFromLocation(GetLocation(GetObjectByTag("den220cr_bartender")));
location ILoc = Location (oArea, Vector(10.44, 20.58, 0.04), -101.04);
oHuman2 = CreateObject(OBJECT_TYPE_CREATURE,R"merh_mhuman2.utc", ILoc);
SetLocation (oHuman2, ILoc);
(with some more checks so that the object is only created once, etc etc)

I was using PRCSCR to run the script. I originally tried using the area instead of the area list - that didn't work. Using the area list, I included a check so that it would only run 'if in Gnawed Noble'. If the GW came in through the Denerim Gates and went straight to the Gnawed Noble, 'oHuman2' did not appear in the Gnawed Noble. If I saved the game and then loaded a save from within the Gnawed Noble, 'oHuman2' appeared. What SEEMS to be happening is that the PRCSCR is only running the first time the arealist is entered. I tried some of the EVENT types without any success.

My workaround was to use the prcscr to run a script that set a flag 'createNPC' to indicate that the NPC should be created as soon as the GW enters the Gnawed Noble. As soon as the GW entered the Gnawed Noble, the flag would be checked, would run a function/subroutine to create the NPC, and would set the flag to false. I had some additional checks so that the flag would be set to false if the GW left Denerim entirely or if the NPC had already been created. This was functional, but not very elegant.

The NPC that I'm creating is a thief and there was no difference between creating the Creature and creating the placeable (a vase) that she was about to rob.
  • sapphim aime ceci

#17
MerAnne

MerAnne
  • Members
  • 1 157 messages
Sorry - should have added, the 4 lines of script worked from the PRCSCR using the arealist and replaced all of the various flags and checks to see if the GW was inside the Gnawed Noble.

#18
Sunjammer

Sunjammer
  • Members
  • 925 messages

MerAnne wrote...

What SEEMS to be happening is that the PRCSCR is only running the first time the arealist is entered.

Pretty much. It will not run when you move between areas on the same arealist but it will run again if you leave the arealist (by entering an area that is on a different arealist or which has no arealist) and then return to an area on the original arealist. For example I tested leaving the Market and going to the Alienage and then returning to the Market and the PRCSCR ran when I initially entered the Market and when I returned from the Alienage.

MerAnne wrote...

The NPC that I'm creating is a thief and there was no difference between creating the Creature and creating the placeable (a vase) that she was about to rob.

At least it is being consistent even if it is being consistently obtuse!

Modifié par Sunjammer, 19 octobre 2013 - 08:12 .