heyas;
i had thought i read somewhere that local variables aren't used any more in dragon age. not like in nwn, when you could store all kinds of good info on a creature or placeable. yet, i happily found 'setlocalint' and 'getlocalint' etc etc, so i used them.
i THOUGHT it was working. no, really. but apparently, it is not, because the wiki entries for the local variables all say this is NOT going to work, EVER, unless you predefine them all in some 2da. well... i don't want to do that.
here's what i want to do. i'm making a tailor shop (clothing store) and have npc models. i want to store their default outfit so they put that back on when they're done modelling. then i want them, via conversation, to page through their inventory, putting on the next outfit, etc etc.
that has it's own problem, since you cant change equipment in the middle of a conversation, but thanks to sea and proleric, i've sussed all that out. and i was using a local int named CURR_OUTFIT. if it was -1, the pc was wearing his/her default outfit, and the conversation would start on the first branch. if it was NOT -1, then it was the # of the outfit in the inventory array that they were currently wearing, and they'd jump to the next/prev/buy/done branch.
this worked yesterday, i swear.
also, the 'next' script is working. it pages through the entire inventory one item at a time. since i'm keeping count via the CURR_OUTFIT local int... i don't see how it's working unless a number is actually being stored there.
all right, here is what i want to do.
1: not edit any 2da files :X
2: keep track of the npc default outfit and have them change back to the default outfit when the conversation is over. (not mission critical)
3: keep track of the current outfit so the npc can switch to the next/prev in inventory. keep in mind that do do the actual equipping, the conversation needs to be restarted w/ BeginConversation.
here's another thing i can't wrap my head around... i have one script for the npc to store the default outfit and to restore it and return to his post. when the npc 'starts,' i want the outfit they are wearing to be recorded as the default outfit. first, i did that using a DO_ONCE flag in the script global variables itself. but then i realized wait... i was ALSO calling this same script in the conversation. wouldn't that re-start the entire script? and wouldn't that clearn the DO_ONCE variable???
does it???
because the rest of the script reads the default outfit and equips it. and if the script is not being reset/rerun each time i call it, then i CAN keep track of the default outfit in a global variable in it, can't i?
can i???
i'm really confused. can i use one of the core creature variables to store the current outfit count? if i can't store it in a script variable between runs. and i dont see any pre-defined local objects where i can store the default outfit. i see a 'resource'... :/
here are the scripts, in their current states.
13TTAIL_NPC -- runs on the creature's script slot (instead of creature_core)
#include "events_h"
#include "wrappers_h"
void main()
{
//--okay, im not going to check events and do handle/dont handle
//--after it does this it will drop to the standard core,
//--and that ought to know what our convo is, to start it.
//--except it DOESNT! grrr! oh, maybe because i didnt define ev :X
event ev = GetCurrentEvent();
int evType = GetEventType(ev);
object oDefault = GetItemInEquipSlot(INVENTORY_SLOT_CHEST);
object oWP = GetObjectByTag("wp_home_"+StringLowerCase(GetName(OBJECT_SELF)));
location locHome = GetLocation(oWP);
if(evType == EVENT_TYPE_SPAWN)
{
SetLocalObject(OBJECT_SELF, "DEFAULT_OUTFIT", oDefault);
SetLocalInt(OBJECT_SELF, "CURR_OUTFIT", -1);
AddCommand(OBJECT_SELF,
CommandJumpToLocation(locHome));
}
if(evType == 0) //--called by the convo
{
//--this will be called upon to reset the NPC, too
//--put on our usual clothes, if not on
oDefault = GetLocalObject(OBJECT_SELF, "DEFAULT_OUTFIT");
// if(oDefault != GetItemInEquipSlot(INVENTORY_SLOT_CHEST))
{
EquipItem(OBJECT_SELF, oDefault, INVENTORY_SLOT_CHEST);
}
//--set the outfit count to -1 flag
SetLocalInt(OBJECT_SELF, "CURR_OUTFIT", -1);
//ClearAllCommands(OBJECT_SELF);
AddCommand(OBJECT_SELF,
CommandMoveToLocation(locHome, FALSE));
}
//--okay, now run the normal creature code
HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);
}
13TTAIL_NEXT -- this runs on the 'next' conversation line, to change the clothing. note, this somehow seems to be working right.
void main()
{
int nCurrOutfit = GetLocalInt(OBJECT_SELF, "CURR_OUTFIT");
object[] oInv = GetItemsInInventory(OBJECT_SELF);
int nMax = GetArraySize(oInv);
object oEquip;
nCurrOutfit++;
if(nCurrOutfit >= nMax)
nCurrOutfit = 0;
SetLocalInt(OBJECT_SELF, "CURR_OUTFIT", nCurrOutfit);
oEquip = oInv[nCurrOutfit];
/* DisplayFloatyMessage(OBJECT_SELF,
GetName(oEquip),
FLOATY_MESSAGE, 16777215,
2.0);
*/ //--this wont display unless i do a cutscene. maybe.
//--according to proleric... if i restart the convo,
//--it will be with this thing equipped.
EquipItem(OBJECT_SELF, oEquip, INVENTORY_SLOT_CHEST);
BeginConversation(GetPCSpeaker(), OBJECT_SELF, R"13ttail_convo.dlg");
}
13TTAIL_PREV -- note this is essentially the same as the 'next.' however, when used over and over, it just switches between two outfits and doesn't get down the inventory list in reverse. not sure if equipping stuff is changing the order of inventory items or what.
void main()
{
int nCurrOutfit = GetLocalInt(OBJECT_SELF, "CURR_OUTFIT");
object[] oInv = GetItemsInInventory(OBJECT_SELF);
int nMax = GetArraySize(oInv);
object oEquip;
nCurrOutfit--;
if(nCurrOutfit < 0)
nCurrOutfit = nMax - 1;
SetLocalInt(OBJECT_SELF, "CURR_OUTFIT", nCurrOutfit);
oEquip = oInv[nCurrOutfit];
DisplayFloatyMessage(OBJECT_SELF,
GetName(oEquip),
FLOATY_MESSAGE, 16777215,
2.0);
//--this wont display unless i do a cutscene. maybe.
//--according to proleric... if i restart the convo,
//--it will be with this thing equipped.
EquipItem(OBJECT_SELF, oEquip, INVENTORY_SLOT_CHEST);
BeginConversation(GetPCSpeaker(), OBJECT_SELF, R"13ttail_convo.dlg");
}
Local Variables... or Not
Débuté par
BloodsongVengeance
, avril 21 2011 03:56
#1
Posté 21 avril 2011 - 03:56
#2
Posté 22 avril 2011 - 02:17
social.bioware.com/project/1787/
Sorry, I'm really sleepy, and I don't have time to read your entire post, but I use this for local variables, so I don't have to mess with 2DA's and such.
Sorry, I'm really sleepy, and I don't have time to read your entire post, but I use this for local variables, so I don't have to mess with 2DA's and such.
Modifié par Challseus, 22 avril 2011 - 02:18 .
#3
Posté 22 avril 2011 - 08:26
I wouldn't rule out using a custom variable 2DA, either - it really is very easy. Module variables persist for all area lists. Variable 2DA files have to be in core override (whereas regular 2DA files work in module override).
When changing costumes, I often use invisible containers, to avoid the overhead of creating objects.
When changing costumes, I often use invisible containers, to avoid the overhead of creating objects.
#4
Posté 24 avril 2011 - 07:28
heyas;
if i'm making an add-in for the single player game, and i want it to be as painless and compatible as possible with everything.... what's the best method? i don't think i can use the talmud variable thing, because that has to modify the module script.
pro, im curious about your statement of invisible containers and creating objects.... my costumes/outfits are just in the npc inventory. ...?
if i'm making an add-in for the single player game, and i want it to be as painless and compatible as possible with everything.... what's the best method? i don't think i can use the talmud variable thing, because that has to modify the module script.
pro, im curious about your statement of invisible containers and creating objects.... my costumes/outfits are just in the npc inventory. ...?
#5
Posté 29 avril 2011 - 07:33
annnnnd....
how do i make/use a custom variable 2da?? is it possible to make one that my custom creatures use, but no other creature in the game does? or do i have to modify some existing something?
how do i make/use a custom variable 2da?? is it possible to make one that my custom creatures use, but no other creature in the game does? or do i have to modify some existing something?
#6
Posté 30 avril 2011 - 05:42
You can make your own version of the var_creature 2da.
Give it a unique name, then place it in your add-in's core override.
Unlike M2DA files, variable tables are not merged, so you'll probably want to include all the official variables (to support core systems) plus your custom variables.
Your custom file will only be used by creatures if you set their "Variable 2DA" property accordingly. All other creatures will use the default.
Same applies to variable tables for the other resource types.
I'm no expert on modding SP, sorry.
As for invisible containers, I have situations in which the PC or NPC may need to change uniform and inventory, depending on conversation choices. I find it convenient to use an empty placeable with an invisible appearance to store their current kit, and another with a pre-defined inventory as the source of their new stuff, using this script.
Give it a unique name, then place it in your add-in's core override.
Unlike M2DA files, variable tables are not merged, so you'll probably want to include all the official variables (to support core systems) plus your custom variables.
Your custom file will only be used by creatures if you set their "Variable 2DA" property accordingly. All other creatures will use the default.
Same applies to variable tables for the other resource types.
I'm no expert on modding SP, sorry.
As for invisible containers, I have situations in which the PC or NPC may need to change uniform and inventory, depending on conversation choices. I find it convenient to use an empty placeable with an invisible appearance to store their current kit, and another with a pre-defined inventory as the source of their new stuff, using this script.
Modifié par Proleric1, 30 avril 2011 - 05:49 .
#7
Posté 01 mai 2011 - 09:02
There are three CREATURE_COUNTER variables that are free to use I think. They couldn't be used to store objects, but they could be used with the hidden container to set/store clothing.
#8
Posté 01 mai 2011 - 07:18
pro...
how would one go about making a variable.2da? is it really an xls file? or something? OH! oh, i found the var_creature 2da, there it is. or xls. or whatever it is. i'll try that as a template, then. it's in utils/source/2da/toolset
so when you change outfits, you have the armor/gloves/boots/helm for them? or multiple pieces. i'm only dealing with clothing and robes, so i don't have multiple parts.
obadiah: yeah, im starting to think i might use those. but if i can make a custom variable 2da and not have it interfere with anything, or have to be listed in something... that might work, too.
cool, thanks guys!
how would one go about making a variable.2da? is it really an xls file? or something? OH! oh, i found the var_creature 2da, there it is. or xls. or whatever it is. i'll try that as a template, then. it's in utils/source/2da/toolset
so when you change outfits, you have the armor/gloves/boots/helm for them? or multiple pieces. i'm only dealing with clothing and robes, so i don't have multiple parts.
obadiah: yeah, im starting to think i might use those. but if i can make a custom variable 2da and not have it interfere with anything, or have to be listed in something... that might work, too.
cool, thanks guys!
#9
Posté 02 mai 2011 - 07:57
Since you already found the source .xls files, all you need to do is to copy-edit the .xls then compile it to .gda format.BloodsongVengeance wrote...
pro...
how would one go about making a variable.2da? is it really an xls file? or something? OH! oh, i found the var_creature 2da, there it is. or xls. or whatever it is. i'll try that as a template, then. it's in utils/source/2da/toolset
so when you change outfits, you have the armor/gloves/boots/helm for them? or multiple pieces. i'm only dealing with clothing and robes, so i don't have multiple parts.
Most of my outfit changes involve armor/gloves/boots/helm/shield/weapons.
Sometimes the same uniform may be required for several different characters, in which case it's especially convenient to use a common placeable resource.
Of course, the method works just as well for a one-piece costume.
#10
Posté 04 mai 2011 - 06:47
heyas;
okay, ran into three kinds of headache trying to create/save/compile a 2da.
soooooo, i cheated horribly.
in the var_creature.xls file, i noticed there WERE object type variables. they just did not appear (through some form of 2da voodoo) in the variable list on the creature utc. so i hijacked one for my clothing object (AI_CUSTOM_AI_VAR_OBJECT) and used CREATURE_COUNTER_1 as my outfit array counting thingy.
i'm happy to report, all is working well, now.
pro:
as i understand the move inventory script is moving items from one place (ie: the storage chest) to another (the npc). meaning.... that they are REMOVED from one to give to the other. is that right? what i had wanted to do, originally, was COPY items from the merchant's stock into the 2 npcs.
now, i can get the merchant's inventory, and i can find the npc, but i can't seem to send the npc copies of the stuff. mainly because the create item wants a resource :/ do you have any ideas/experience with that?
this is the code i tried to use. haha, the R doesn't like building a utc name like that :X
object oStore = GetObjectByTag("13ttail_merchant");
object[] oInventory = GetItemsInInventory(oStore);
int nItems = GetArraySize(oInventory);
object oNPC = GetObjectByTag("13ttail_butler");
string sItemName;
int c;
for(c=0;c<nItems;c++)
{ //--this is totally not going to work. r's are a PITA!
sItemName = GetTag(oInventory[c]) + ".uti";
CreateItemOnObject(R(sItemName), oNPC);
}
okay, ran into three kinds of headache trying to create/save/compile a 2da.
soooooo, i cheated horribly.
in the var_creature.xls file, i noticed there WERE object type variables. they just did not appear (through some form of 2da voodoo) in the variable list on the creature utc. so i hijacked one for my clothing object (AI_CUSTOM_AI_VAR_OBJECT) and used CREATURE_COUNTER_1 as my outfit array counting thingy.
i'm happy to report, all is working well, now.
pro:
as i understand the move inventory script is moving items from one place (ie: the storage chest) to another (the npc). meaning.... that they are REMOVED from one to give to the other. is that right? what i had wanted to do, originally, was COPY items from the merchant's stock into the 2 npcs.
now, i can get the merchant's inventory, and i can find the npc, but i can't seem to send the npc copies of the stuff. mainly because the create item wants a resource :/ do you have any ideas/experience with that?
this is the code i tried to use. haha, the R doesn't like building a utc name like that :X
object oStore = GetObjectByTag("13ttail_merchant");
object[] oInventory = GetItemsInInventory(oStore);
int nItems = GetArraySize(oInventory);
object oNPC = GetObjectByTag("13ttail_butler");
string sItemName;
int c;
for(c=0;c<nItems;c++)
{ //--this is totally not going to work. r's are a PITA!
sItemName = GetTag(oInventory[c]) + ".uti";
CreateItemOnObject(R(sItemName), oNPC);
}
#11
Posté 04 mai 2011 - 07:07
crud, i guess that also means i can't give the pc a copy out of the npc's inventory?? :/
#12
Posté 05 mai 2011 - 05:51
Sadly, AFAIK you can't copy items in a script.
Also, it seems that resource variables can only be populated with literals (see wiki).
So, I suspect your choices are
Also, it seems that resource variables can only be populated with literals (see wiki).
So, I suspect your choices are
- Put the resource literals for every costume in your script so that you can CreateItemOnObject
- Make a new 2DA containing the resource literals
- Move the items (moving them back when the PC tries another costume)
#13
Posté 05 mai 2011 - 05:45
or...
make the pc go buy the clothing off the rack (merchant/store). ugly, but easiest.
because (not to complain (though i'm liking nwnscript better these days :X :X ))
1: too work intensive, plus a pain in the butt to add custom outfits.
2: ditto.
3: that would leave my npc kinda nekkie, and the pc still couldn't acquire multiple copies of one outfit in that manner.
thanks, pro!
make the pc go buy the clothing off the rack (merchant/store). ugly, but easiest.
because (not to complain (though i'm liking nwnscript better these days :X :X ))
1: too work intensive, plus a pain in the butt to add custom outfits.
2: ditto.
3: that would leave my npc kinda nekkie, and the pc still couldn't acquire multiple copies of one outfit in that manner.
thanks, pro!





Retour en haut







