Aller au contenu

Photo

GetItemAcquired (Solved)


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

#1
Alupinu

Alupinu
  • Members
  • 528 messages
Hey, does anybody know how that whole “GetItemAcquired” thing works?
Basically I’m trying to get a journal update when the pc acquires a certain item off a dead creature. (Quest item)
It’s turning out to be a little more complicated then I originally anticipated.

Modifié par Alupinu, 30 mai 2012 - 01:25 .


#2
Dann-J

Dann-J
  • Members
  • 3 161 messages
The easiest way is to use tag-based scripting. If the item has a tag called 'tag', then you'd create a script called 'i_tag_aq' which will fire when the item is acquired.

Modifié par DannJ, 22 mai 2012 - 12:58 .


#3
bealzebub

bealzebub
  • Members
  • 352 messages
You can use the script assist to get a item acquire template. It's pretty self-explanitory.

#4
Alupinu

Alupinu
  • Members
  • 528 messages
All right what can I possible be doing wrong? Script is not working. I have followed the template to the letter and yes I have tripled checked my tags. There’s got to be something missing, here’s a copy of the script maybe somebody can see something I don’t.


// i_yellowbox_aq
/*
Template for an Acquire item script.
This script will run each time the item is acquired.

How to use this script:
Replace the word "temp" (in line 1) with the tag of the item. Rename the script with this name.

Additional Info:
In general, all the item "tag-based" scripts will be named as follows:
- a prefix ("i_" by defualt)
- the tag of the item
- a postfix indicating the item event.

This script will be called automatically (by defualt) whether it exists or not. If if does not exist, nothing happens.
"_aq" was used for the Acquire postfix because "_ac" was already taken by Activate.

Note: this script runs on the module object, an important consideration for assigning actions.
-ChazM
*/
// Name_Date

#include "ginc_item_script"

void main()
{
object oPC = GetModuleItemAcquiredBy();
object oItem = GetModuleItemAcquired();
int iStackSize = GetModuleItemAcquiredStackSize();
object oFrom = GetModuleItemAcquiredFrom();


// Once marked complete, never run this script again.
if (IsItemMarkedAsDone(oItem, SCRIPT_MODULE_ON_ACQUIRE_ITEM))
return;

// Don't run this script unless it's aqcuired by a player or party member
// (This event runs at the start of the game
if (!IsItemAcquiredByPartyMember())
return;


AddJournalQuestEntry("the_yellow_pack", 1, oPC, TRUE, FALSE);



// Permanently mark item as complete so script will never run again (even if the character is exported to another game)
//MarkItemAsDone(oItem, SCRIPT_MODULE_ON_ACQUIRE_ITEM);

}



#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Try putting in a couple debug (send message) lines. One towards the top to make sure it's running and one just above each "return;" to see if it is stopping on one of those lines.

Modifié par GhostOfGod, 22 mai 2012 - 05:34 .


#6
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Take out the do-once, for now (or replace it with a check of the journal quest it adds). The script might be running first when the original owner of the item spawns in, and then a second time when the PC picks it up off their corpse.

#7
Alupinu

Alupinu
  • Members
  • 528 messages
Well I “//” out all the lines that LRS suggested. I even tried the debug mode, not sure if I did it right though. All I got was a message: “Vertual Machine reports unsuccessful execution of script i_yellowbox_aq for AAtest.” AAtest being the PC.
Not really a scripter so not sure what else to do. I guess I’m going to have to start thinking of a work around. Thanks anyway guy’s.

#8
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Even a broken script would run, so the problem must be something else, like the compiled script file not actually being in the module.

#9
Alupinu

Alupinu
  • Members
  • 528 messages

Lugaid of the Red Stripes wrote...

Even a broken script would run, so the problem must be something else, like the compiled script file not actually being in the module.


LoL, well LRS it’s in my mod script list, I’ve opened and closed it several times now and compiled it I don’t know how many times. I’ve even re-made it. I’m starting to think it’s something out of my realm like the x2_script or the ginc_script not working. If that’s the case well that’s way over my head.
The good news is that I did come up with a work around. Not as cool as when you had to chase and kill the drow priestess. Now she just stands by the item and guards it. Original huh? LOL. Oh well, I guess it will work.

#10
bealzebub

bealzebub
  • Members
  • 352 messages
Check your Module Properties, On Module Load Script. What ever script you are using should have a line that says;
SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);
Make sure it says TRUE

#11
bealzebub

bealzebub
  • Members
  • 352 messages
I made a test mod, added your script named i_yellowbox_aq, tagged an item yellowbox, and added a debug line to your script. It worked fine, so the problem is not with your script.

#12
Alupinu

Alupinu
  • Members
  • 528 messages
Hey bealzebub, thanks for taking the time to test out my script.

I did as you suggested and checked my mod script “OnModuleLoadScript” and yes it was True. I didn’t test it on debug mode just tested it to see if it would give me my journal update and of course nothing happen. Could it be my journal command? Though I don’t see how.

Does anybody have any other idea’s?

#13
Shaughn78

Shaughn78
  • Members
  • 637 messages
The script looks like it should work fine. Throw in some debug messages before and after the add journal.
As to the journal check everything there, tag and entry number. Just to verify, if you are using a campaign you need to be using the campaign journal, not the module journal.


The tag based script is a fine way to do this, for similar type events I have used the inventory on disturbed scripts.

#14
Alupinu

Alupinu
  • Members
  • 528 messages
Yea I guess I could turn off the destroy corpse and use an inventory disturbed script. But wait, can you make a corpse work like a container? I’ll have to play with that.

#15
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
You can always spawn a placeable container off the on-death script.

But back to the original issue, didn't using "rs i_yellowbox_aq" in the debug console give you an error? That only happens if the script doesn't exist (i.e. you misspelled the script name, or messed up the parameters). I think there must be a typo somewhere that's messing things up.

#16
Darin

Darin
  • Members
  • 282 messages
Since it's updating a journal, you could use a much simpler set of script functions to do this...

// script_name: i_yellowbox_aq
/* Description: Updates journal entry "the_yellow_pack" when the player acquires the item
Uses a much simpler set of codes that allow it to update, using the Journal
entry itself as the check.
*/
//name_date: Darin LaSota on May 25th, 2012

void main()
{
//variable instancing
object oPC = GetModuleItemAcquiredBy();

// only run if the player does not have the entry yet; this checks if the player's entry is 0,
// could change this if needed
// basically runs if the entry the player has in this journal is not id 1 or higher
if(! ( GetJournalEntry("the_yellow_pack", oPC) >= 1 ) )
{
AddJournalQuestEntry("the_yellow_pack", 1, oPC, TRUE, FALSE);
}
}

Modifié par EpicFetus, 25 mai 2012 - 04:42 .


#17
Alupinu

Alupinu
  • Members
  • 528 messages
@EpicFetus, just thought I let you know that I got a chance to try out your script today and it worked great. Did just what I had wanted it to do. Like to thank you for taking the time and effort to help me out, not forgotten.

Also I like to thank everybody else for getting their two cents in always appreciated.