A script to Update a Journal entry when I remove an item from a chest.
A script to spawn X amount of monsters when I walk over a certain trigger
Pretty simple stuff I am assuming... I would appreciate it if anyone can supply these scripts, I also would like them to be Generic, not Preset ( as in I can set my own monsters, and how many spawn )
REQUESTING SCRIPTS
Débuté par
Leyf
, févr. 01 2011 11:03
#1
Posté 01 février 2011 - 11:03
#2
Posté 01 février 2011 - 11:29
Try something like this:
void main()
{
object oPC = GetLastDisturbed();
object oItem = GetInventoryDisturbItem();
int nType = GetInventoryDisturbType();
string sItem = GetTag(oItem);
if ((sItem == "item") && (nType == INVENTORY_DISTURB_TYPE_REMOVED))
{
AddJournalQuestEntry("JournalEntryName", 20, oPC);
}
}
void main()
{
object oPC = GetLastDisturbed();
object oItem = GetInventoryDisturbItem();
int nType = GetInventoryDisturbType();
string sItem = GetTag(oItem);
if ((sItem == "item") && (nType == INVENTORY_DISTURB_TYPE_REMOVED))
{
AddJournalQuestEntry("JournalEntryName", 20, oPC);
}
}
#3
Posté 02 février 2011 - 12:14
#4
Posté 02 février 2011 - 12:24
Have you made out your journal quest yet?
View|Journal|Module
Click Add Category. The tag of the journal category is what you would put in for "JournalEntryName".
Click Add Entry. The ID of that entry is what you would put in place of the 20.
View|Journal|Module
Click Add Category. The tag of the journal category is what you would put in for "JournalEntryName".
Click Add Entry. The ID of that entry is what you would put in place of the 20.
#5
Posté 02 février 2011 - 12:25
You really, really, really need to learn about storing and retrieving local variables. To make this script more generic, you would have it look for a few local variables on the chest: a string for the item tag, a string for the journal entry name, an integer for the quest state, etc.
But seriously, read KnightMare's tutorial. It's extremely well-written and this is part of what it teaches.
But seriously, read KnightMare's tutorial. It's extremely well-written and this is part of what it teaches.
#6
Posté 02 février 2011 - 12:59
I would use an on acquire script on the item, rather than a script on the chest. Like this one which I use in my Silverwand Sample Campaign:
// i_moes_sticks_aq.nss
// moes_sticks OnAcquired handler
// This script is executed automatically when the item is acquired
// To trigger properly the name of the script MUST be "i_" + itemtag + "_aq"
#include "ginc_debug"
#include "ginc_item_script"
void main()
{
//PrettyDebug("i_moessticks2_aq: update stooges quest");
object oPC = GetOwnedCharacter(GetFactionLeader(GetFirstPC()));
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 acquired by a player or party member
if (!IsItemAcquiredByPartyMember())
return;
// if the quest was accepted then update the journal
// otherwise allow the script to be run again in case
// the person sets down the item and then picks it up after
// accepting the quest
if( GetJournalEntry("quest_stooges", oPC) > 10 )
{
// 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);
// update the journal
AddJournalQuestEntry("quest_stooges", 35, oPC);
}
}
Modifié par Kaldor Silverwand, 02 février 2011 - 01:01 .
#7
Posté 02 février 2011 - 04:31
if I ever make a mod I'm gonna have Moe, Curly, & Larry
as the companions
The Three Stooges meet the Witch-King!!
( credit *will* be given, KS
Leyf, you really gotta learn the basics .. then your questions become more specific, much easier to answer. The above snip of code spawns in ~10 monsterMoes (can never get that loop-thing right without testing), and you'll have to create Moe in the toolset unless there already is one. You watch 3 Stooges, right?
ahead. of. their. time.!
( you may need a 'wrapper' for CreateObject() - it's been a while - think of it as a separate little function at the very top of a script that gets 'called' from inside the void main() part )
ps. Tested this with pixies .. it works
ya never knew how tuff pixies are, till a plague of 'em hits ya!!! New spell Idea : Pixie Plague.
as the companions
The Three Stooges meet the Witch-King!!
( credit *will* be given, KS
object oPC = GetFirstPC();
int iNumberMoes = 1;
while (iNumberMoes < 10)
{
CreateObject(OBJECT_TYPE_CREATURE, "my_moe_tag", GetLocation(oPC));
iNumberMoes ++;
}Leyf, you really gotta learn the basics .. then your questions become more specific, much easier to answer. The above snip of code spawns in ~10 monsterMoes (can never get that loop-thing right without testing), and you'll have to create Moe in the toolset unless there already is one. You watch 3 Stooges, right?
ahead. of. their. time.!
( you may need a 'wrapper' for CreateObject() - it's been a while - think of it as a separate little function at the very top of a script that gets 'called' from inside the void main() part )
ps. Tested this with pixies .. it works
ya never knew how tuff pixies are, till a plague of 'em hits ya!!! New spell Idea : Pixie Plague.
#8
Posté 02 février 2011 - 09:30
The downside to 'On Acquire' scripts is that you need one for each different item.
A version of Orion7486's script that pulls local variables from the container itself would make it into a generic script that can be used for any quest item that is within a container. You'd have to store the item tag (a string), the journal quest tag (another string) and the journal entry number (an integer) as variables on the chest:
void main()
{
object oPC = GetLastDisturbed();
object oItem = GetInventoryDisturbItem();
int iDone = GetLocalInt(oItem, "OnceOnly");
if (iDone == 1)
return; // Only trigger the journal entry once for each item
// Local variables on container
string sTag = GetLocalString(OBJECT_SELF,"ItemTag");
string sQTag = GetLocalString(OBJECT_SELF, "QuestTag");
int iQuestNo = GetLocalInteger(OBJECT_SELF, "QuestNumber")
int nType = GetInventoryDisturbType();
string sItem = GetTag(oItem);
if ((sItem == sTag) && (nType == INVENTORY_DISTURB_TYPE_REMOVED))
{
AddJournalQuestEntry(sQuestTag,iQuestNo, oPC);
SetLocalInt(oItem, "OnceOnly", 1); // Make sure the journal entry isn't triggered again
}
}
You'd have no choice but to resort to 'On Acquire' scripts for objects looted from corpses though.
A version of Orion7486's script that pulls local variables from the container itself would make it into a generic script that can be used for any quest item that is within a container. You'd have to store the item tag (a string), the journal quest tag (another string) and the journal entry number (an integer) as variables on the chest:
void main()
{
object oPC = GetLastDisturbed();
object oItem = GetInventoryDisturbItem();
int iDone = GetLocalInt(oItem, "OnceOnly");
if (iDone == 1)
return; // Only trigger the journal entry once for each item
// Local variables on container
string sTag = GetLocalString(OBJECT_SELF,"ItemTag");
string sQTag = GetLocalString(OBJECT_SELF, "QuestTag");
int iQuestNo = GetLocalInteger(OBJECT_SELF, "QuestNumber")
int nType = GetInventoryDisturbType();
string sItem = GetTag(oItem);
if ((sItem == sTag) && (nType == INVENTORY_DISTURB_TYPE_REMOVED))
{
AddJournalQuestEntry(sQuestTag,iQuestNo, oPC);
SetLocalInt(oItem, "OnceOnly", 1); // Make sure the journal entry isn't triggered again
}
}
You'd have no choice but to resort to 'On Acquire' scripts for objects looted from corpses though.
Modifié par DannJ, 02 février 2011 - 09:37 .
#9
Posté 02 février 2011 - 10:51
Ugh. This scripting stuff is very confusing to me. Im going to go read Knightmares tutorial and hopefully i will understand things a bit more... but in the mean time unfortunatly I dont understand how to implement any of the scripts provided.
#10
Posté 03 février 2011 - 12:14
There are always multiple ways to do these things. I prefer to keep scripts related to the object they are for. If you use a script on the container the thing is in and then later decide for other reasons that you'd like the item to be found elsewhere you may very well forget that the container has special logic associated with it for that item. You may not test for it and then you'll wonder why the journal isn't being initiated. If you use an on acquire script this won't happen. I find when modding that I frequently move things around for a variety of reasons and when I do I don't want to have things break. Of course if you frequently find yourself changing the tags of items you create then you will break the on acquire scripts. So my suggestion is do whatever works best for you and is least likely to create bugs based on the way you work.
#11
Posté 03 février 2011 - 12:24
To implement the script I suggested:
Create and compile the script
Create the journal entries
Create the item blueprint
Place a container in the toolset
Select the container and view its properties
In the 'OnDisturbed' section, enter the name of the script you want to run when something is added or removed. You can click on the down-arrow and select the script from a dropdown list, or just type the script name manually.
Find the 'Variables' entry in the container properties, and click the [...]
Add a variable to the list, give it a name, and enter the value you want in the appropriate section. For a text variable, enter the text in the 'string' section. Otherwise use the 'integer' (whole numbers) or 'float' (decimal numbers) sections.
Put the journal-triggering object into the chest
If the variables on the container are all correct (item tag, quest tag, quest number), then when you remove the object from the chest a journal entry will be written.
Or as KS suggests, you can investigate tag-based scripting. Although I use tag-based scripts quite a bit, I don't think I'd recommend the subject for someone's first foray into scripting.
Create and compile the script
Create the journal entries
Create the item blueprint
Place a container in the toolset
Select the container and view its properties
In the 'OnDisturbed' section, enter the name of the script you want to run when something is added or removed. You can click on the down-arrow and select the script from a dropdown list, or just type the script name manually.
Find the 'Variables' entry in the container properties, and click the [...]
Add a variable to the list, give it a name, and enter the value you want in the appropriate section. For a text variable, enter the text in the 'string' section. Otherwise use the 'integer' (whole numbers) or 'float' (decimal numbers) sections.
Put the journal-triggering object into the chest
If the variables on the container are all correct (item tag, quest tag, quest number), then when you remove the object from the chest a journal entry will be written.
Or as KS suggests, you can investigate tag-based scripting. Although I use tag-based scripts quite a bit, I don't think I'd recommend the subject for someone's first foray into scripting.
#12
Posté 04 février 2011 - 12:07
Ah thank you! So its as simple as setting the chests "On Disturb" to the script provided above, then adding the variables? btw, i finished Knightmares Scripting for Noobs, so i can read your script like a book now!





Retour en haut






