I've been working on a mod to spawn companions from Origins into Vigil's Keep in Awakenings. The biggest glitch I'm having however is, despite entering a specific area and coordinates, the creature I'm creating is spawning in several locations, across different maps. The script I'm using to spawn my character is below. Any help on what I'm doing wrong would be greatly appreciated:
#include "wrappers_h"
void main()
{
// The first thing we want to do, before anything, is look around and see
// if we have already spawned this merchant
object oPlayer = GetMainControlled();
object oMerchant = UT_GetNearestObjectByTag(oPlayer, "lelianatwo");
if (!IsObjectValid(oMerchant))
{
// If we get to this code, it means the merchant has not been placed yet
// So let’s do that
// get an object pointer to the party camp area
object oArea = GetObjectByTag("vgk210ar_throne_room");
// create a location for where our merchant NPC will be placed
location lMerchantLocation = Location(oArea, Vector(-14.546064, -7.368423, -0.447728), -118.790512085);
// Spawn the NPC
CreateObject(OBJECT_TYPE_CREATURE, R"lelianatwo.utc", lMerchantLocation);
}
}
custom merchant spawning across several maps.
Débuté par
Firinneach
, avril 19 2010 02:14
#1
Posté 19 avril 2010 - 02:14
#2
Posté 19 avril 2010 - 04:02
Perhaps you're attempting to create the object when the target area isn't loaded?
What you could do is add this to your area event script. In the Area Load Preloadexit event, check the area tag to see if the target area is loading - if it is, and the object doesn't exist, create it.
What you could do is add this to your area event script. In the Area Load Preloadexit event, check the area tag to see if the target area is loading - if it is, and the object doesn't exist, create it.
#3
Posté 19 avril 2010 - 04:45
Thanks for the reply. Unfortunately, I know very little of scripting and had copy/pasted the above from a a tutorial on adding a custom merchant to the party camp. I just replaced the area and coordinates he had with the ones I wanted for Vigil's Keep. I have confirmed by looking around that it seems to be spawning my creature--leliana2--anywhere that has the first two set of coordinates in the fifth to last line, and seems to be ignoring the:
GetObjectByTag("vgk210ar_throne_room");
which if I understand correctly should limit it to the throne room. I'm wondering if in the line with the coordinates, instead of just putting "oarea" I can specify there the area code I want. Again, though, knowing next to nothing of scripting, I'd pretty much need someone to tell me just what code I should replace with what.
Cheers.
GetObjectByTag("vgk210ar_throne_room");
which if I understand correctly should limit it to the throne room. I'm wondering if in the line with the coordinates, instead of just putting "oarea" I can specify there the area code I want. Again, though, knowing next to nothing of scripting, I'd pretty much need someone to tell me just what code I should replace with what.
Cheers.
#4
Posté 19 avril 2010 - 06:21
Are you using the PRCSCR GDA? If not it's very useful, basically you tell it an area and script, and whenever that area is loaded, it runs that script, that way the script won't run in other areas, hopefully eliminating your multi-area spawn issue.
A basic overview of PRCSCR can be found on the wiki here and script templates for using it can be found on the wiki here.
A basic overview of PRCSCR can be found on the wiki here and script templates for using it can be found on the wiki here.
#5
Posté 19 avril 2010 - 07:10
#include "wrappers_h"
void main()
{
object oPlayer = GetMainControlled();
object oArea = GetArea(oPlayer);
// The first thing we want to do, before anything, is look around and see
// if we have already spawned this merchant
if (GetTag(oArea)=="vgk210ar_throne_room")
{
object oMerchant = UT_GetNearestObjectByTag(oPlayer, "lelianatwo");
if (!IsObjectValid(oMerchant))
{
// If we get to this code, it means the merchant has not been placed yet
// So let’s do that
// create a location for where our merchant NPC will be placed
location lMerchantLocation = Location(oArea, Vector(-14.546064, -7.368423, -0.447728), -118.790512085);
// Spawn the NPC
CreateObject(OBJECT_TYPE_CREATURE, R"lelianatwo.utc", lMerchantLocation);
}
}
}
I rearranged your code to check for being in the throne room first, then spawn the merchant if it couldn't be found. Where do you assign this script? There are several ways to get the results. Not sure what works well for modifying the campaign.
Edit: Meh, sometimes the formatting works, sometimes not.
void main()
{
object oPlayer = GetMainControlled();
object oArea = GetArea(oPlayer);
// The first thing we want to do, before anything, is look around and see
// if we have already spawned this merchant
if (GetTag(oArea)=="vgk210ar_throne_room")
{
object oMerchant = UT_GetNearestObjectByTag(oPlayer, "lelianatwo");
if (!IsObjectValid(oMerchant))
{
// If we get to this code, it means the merchant has not been placed yet
// So let’s do that
// create a location for where our merchant NPC will be placed
location lMerchantLocation = Location(oArea, Vector(-14.546064, -7.368423, -0.447728), -118.790512085);
// Spawn the NPC
CreateObject(OBJECT_TYPE_CREATURE, R"lelianatwo.utc", lMerchantLocation);
}
}
}
I rearranged your code to check for being in the throne room first, then spawn the merchant if it couldn't be found. Where do you assign this script? There are several ways to get the results. Not sure what works well for modifying the campaign.
Edit: Meh, sometimes the formatting works, sometimes not.
Modifié par Magic, 19 avril 2010 - 07:16 .
#6
Posté 20 avril 2010 - 02:16
Appreciate the help folks. I may just have to accept that scripts aren't something I can get my head around.
Lord thing: I initially hadn't used one and spend (too much!) of the day looking into them. I found a walkthrough on adding one and though as far as I can tell I followed it correctly I must have gone wrong somewhere as it didn't have any effect in game.
I tried your script Magic, but the result was that my created creature wasn't spawning anywhere now!
At the risk of really showing my noob-status, I'm not sure what you mean by where I assign the script.
Cheers all and thanks for taking the time.
Lord thing: I initially hadn't used one and spend (too much!) of the day looking into them. I found a walkthrough on adding one and though as far as I can tell I followed it correctly I must have gone wrong somewhere as it didn't have any effect in game.
I tried your script Magic, but the result was that my created creature wasn't spawning anywhere now!
Cheers all and thanks for taking the time.
#7
Posté 20 avril 2010 - 06:13
If Magic's script isn't working, the first thing to check is that the Tag of your area (as shown in the Object Inspector) is vgk210ar_throne_room.
PRCSCR might have failed for the same reason - the area tag must match exactly.
A script has to be started by something - hence the question about where it is assigned.
If the script is being started by PRCSCR, all well and good. There is a tried-and-tested script for creating a creature in the PRCSCR article on the wiki. It will work if you persist, double-checking every detail.
If the script is being started by a resource such as the module or the area, I'd expect to see some event handling code.
PRCSCR might have failed for the same reason - the area tag must match exactly.
A script has to be started by something - hence the question about where it is assigned.
If the script is being started by PRCSCR, all well and good. There is a tried-and-tested script for creating a creature in the PRCSCR article on the wiki. It will work if you persist, double-checking every detail.
If the script is being started by a resource such as the module or the area, I'd expect to see some event handling code.
Modifié par Proleric1, 20 avril 2010 - 06:13 .
#8
Posté 20 avril 2010 - 02:47
Actually, for the PRCSCR to work, you have to specify the AreaList name, not the Area name. That is probably where you are getting stuck.
If you do not know the AreaList name, just put 'any' (without quotes) in the AreaList column in the PRCSCR; Magic's script should work then (make sure the Area tag matches what you have in the script though).
If you do not know the AreaList name, just put 'any' (without quotes) in the AreaList column in the PRCSCR; Magic's script should work then (make sure the Area tag matches what you have in the script though).
Modifié par TimelordDC, 20 avril 2010 - 02:48 .
#9
Posté 20 avril 2010 - 05:01
Thanks all!
Got the PRCSCR problem fixed, plus was helped with my other mistake: Under the manage modules section I hadn't set the script filed to "none." So it was running my original script all the time instead of just when my PRCSCR file told it to.
Cheers.
Got the PRCSCR problem fixed, plus was helped with my other mistake: Under the manage modules section I hadn't set the script filed to "none." So it was running my original script all the time instead of just when my PRCSCR file told it to.
Cheers.





Retour en haut






