Aller au contenu

Photo

An utter silly question perhaps, but still...


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

#1
fkirenicus

fkirenicus
  • Members
  • 396 messages
Right. It seems that my scripts that add to existing areas don't always work.
E.g., the scripts I've added to the Mage Origin seem to work perfectly OK, whereas none I have added in the prelude appears to work (so far; I've one chance left as I'm writing this).

I need to ask one - nay, two - questions; some might consider them silly. But I'm quite stuck now.

1) GetObjectByTag REALLY means get the TAG of the object, right? I've noticed that some objects have different tags and resource names (and in some cases the resource names are specific, like pre200ar_wolf_chest; whereas the tags are "generic", like genip_wooden_chest.Yes, this can be on one and the same object).  
2) Can we be absolutely certain that the resources provided with the toolset match with the in-game resources? I.e., if I add an item by using a script, can I be certain that my script actually tries to add to something that exists in-game?

Here is a script that I use to try to add something to the korcari wilds. Neither the necklace nor the helmet do spawn as they should:
[nwscript]
#include "utility_h"
#include "plt_0fk_plot"

void main()
{

PrintToLog("fk_prcscr: BEGIN");
string areaTag = GetTag(GetArea(GetMainControlled()));
PrintToLog(" area: " + areaTag);
object oCreature = OBJECT_INVALID;
object oPlaceable = OBJECT_INVALID;

if ( WR_GetPlotFlag( PLT_0FK_PLOT, FK_CHECK_PRE200AR ) == TRUE ) return;

if (areaTag == "pre200ar_korcari_wilds")
{
oCreature = GetObjectByTag("pre200cr_hurlock_emissary_t16");
oPlaceable = GetObjectByTag("pre200ip_iron_chest2");
}

if (!IsObjectValid(oPlaceable)) return;
if (UT_CountItemInInventory(R"gen_im_arm_hel_lgt_rlr.uti", oPlaceable) < 1)
{
PrintToLog("stocking items");
CreateItemOnObject(R"gen_im_arm_hel_lgt_rlr.uti", oPlaceable, 1, "", TRUE);
WR_SetPlotFlag( PLT_0FK_PLOT, FK_CHECK_PRE200AR, TRUE );
}

if (!IsObjectValid(oCreature)) return;
if (UT_CountItemInInventory(R"fk_silver_necklace.uti", oCreature) < 1)
{
PrintToLog("stocking items");
CreateItemOnObject(R"fk_silver_necklace.uti", oCreature, 1, "", TRUE, TRUE);
WR_SetPlotFlag( PLT_0FK_PLOT, FK_CHECK_PRE200AR, TRUE );
}

else
{
PrintToLog("no items!");
}
}
[/nwscript]  
So, returning to my questions:
1) Is it the tag of the Hurlock Emissary I should call, or the Resource Name? I'd go for the tag, as I've done, of course... But that doesn't work. 
2) Can I be certain that I call the correct chest object - or does it in fact have another tag in the game file (another tag than the one I find in the toolset database)?

I realize of course that question 2) may be impossible to answer. But if anyone knows, I'd be glad if they told me. 

I really have no clue how to solve this. 

Modifié par fkirenicus, 12 mars 2011 - 04:27 .


#2
fkirenicus

fkirenicus
  • Members
  • 396 messages
Well, I opened a savegame in the toolset and it seems that the resources in the toolset are indeed the same as those in the game.. So the problem can't lie there.
But that simply adds to my confusion. I call the correct objects, but nothing happens??

EDIT: An observation... If I run the scripts manually through the console, they DO work... There must be something wrong with my PRCSCR setup, maybe...?

EDIT II: Seems others have run into this as well... 
Now, if only I knew when to call area lists, and when to call areas...? I got some clues from Craig Graff in that thread, but I'm not sure I understand it 100%.... :innocent:

Modifié par fkirenicus, 12 mars 2011 - 08:23 .


#3
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
Man, there are not silly questions when you are learning ;)

Now, if only I knew when to call area lists, and when to call areas...? I got some clues from Craig Graff in that thread, but I'm not sure I understand it 100%....


I think that what they suggest in that older thread is to use the AreaList name instead of the Resource name when you create your PRCSCR_xxx.xls file. You should be able to get the AreaList name from the Object Inspector tab of the area in the toolset.

Another way to solve the problem is just to create a single PRCSCR_xxx.xls file that will be used for every area in the game. To do it you have to write "any" (without quotes) for the AreaList name. Then, since the script will be executed for every area, your PRCSCR script will have to check if the area that has been loaded is the one that you want to use.

void main()
{
   string sAreaTag = GetTag(GetArea(GetMainControlled()));

   if (sAreaTag=="my_area_tag") 
   {
      // Do something here.
   }
}

GetObjectByTag REALLY means get the TAG of the object, right?


Yeah. Let's suppose that we have a placeable whose resource name is "my_placeable". If I add that placeable to my area, then all the instances of that placeable will share the same resource name, but I can use different tags for each of them. For example, their tags could be "my_placeable_00", "my_placeable_01", ... GetObjectByTag() will return a reference to the instance with the given tag. A resource is more like a template that you use to create in-game objects.

Can we be absolutely certain that the resources provided with the toolset match with the in-game resources? I.e., if I add an item by using a script, can I be certain that my script actually tries to add to something that exists in-game?


When you add an item ( for example, invoking UT_AddItemToInventory() ), its corresponding resource is used to create an instance of that item. And yes, it will match its toolset resource.

Modifié par _L_o_B_o_, 13 mars 2011 - 03:48 .


#4
fkirenicus

fkirenicus
  • Members
  • 396 messages
Yeah, switching from the area to the area list for the Korcari Wilds worked. :-)

Thanks for the tip about the AL in the OI... Never thought of that (prowled the single player\\data folder for info, as per suggested by CGraff in the other post) :-)