Aller au contenu

Photo

Problem With Add Item Script... Help Please


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

#1
Robert184e

Robert184e
  • Members
  • 7 messages
:crying:
Hi i'm new to this but I cannot get one thing working. The script I am
using works wonders... It adds items to newly created chars or ones
that I load. Except 1 problem. If I equip my items on a character
besides my Main, it will give me the items the other char is using
again (For instance the angelicshield and swordoftheangelic on
Alistair, I will get those again when I load, but not the ones my character is
wearing.) I would like to stop this from happening. I have tried Plot
flags but always get a constant_h.nss error... Or when they do not have
errors it keeps giving me the items anyhow.

So can anyone help me modify the script to check all party members, not just my main? (Maybe even those in Party Camp? If Possible?) Can I get a Bioware dude to help maybe? Anyone?

Also for those of u
whose items are not showing up, export without dependents, for both the
script and items then go to Documents/Bioware/Dragon
Age/packages/core/override/toolsetexport > Delete all in this
folder. Load the game and should work from there.

Here is a copy of the code I use, what do I need to add to get it to not add items if another party member is using them???

Another
note for plot... I have tried it but for some reason it doesn't change
to TRUE; and it just adds the items every load.

I Do not take credit for this script for it is a little bit of everything I have found useful from others work...


// ---------- Script Starts Here ----------

#include "utility_h"
#include "wrappers_h"
#include "events_h"

void main()
{

event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);

object oPC = GetHero();

int nDoOnce = GetLocalInt(OBJECT_SELF, "QUICKITEMADDED");

if ( nDoOnce != 1 )
{
switch(nEventType)
{

case EVENT_TYPE_CHARGEN_END:
case EVENT_TYPE_MODULE_LOAD:
{

int nHas1 = CountItemsByTag(oPC, "ancestralamulet");
int nHas2 = CountItemsByTag(oPC, "ancestralmirror");
int nHas3 = CountItemsByTag(oPC, "ancestralrobe");
int nHas4 = CountItemsByTag(oPC, "ancestralwrap");
int nHas5 = CountItemsByTag(oPC, "daggeroftheangelic");
int nHas6 = CountItemsByTag(oPC, "ringoftheancients");
int nHas7 = CountItemsByTag(oPC, "ringofthemagi");
int nHas8 = CountItemsByTag(oPC, "swordoftheangelic");
int nHas9 = CountItemsByTag(oPC, "swordofthedamned");
int nHas10 = CountItemsByTag(oPC, "swordofthedemented");
int nHas11 = CountItemsByTag(oPC, "shieldoftheangelic");

// If we do not, then we add it to the inventory
if ( nHas1 == 0 )
UT_AddItemToInventory(R"ancestralamulet2.uti");
if ( nHas2 == 0 )
UT_AddItemToInventory(R"ancestralmirror2.uti");
if ( nHas3 == 0 )
UT_AddItemToInventory(R"ancestralrobe2.uti");
if ( nHas4 == 0 )
UT_AddItemToInventory(R"ancestralwrap2.uti");
if ( nHas5 == 0 )
UT_AddItemToInventory(R"daggeroftheangelic2.uti");
if ( nHas6 == 0 )
UT_AddItemToInventory(R"ringoftheancients2.uti");
if ( nHas7 == 0 )
UT_AddItemToInventory(R"ringofthemagi2.uti");
if ( nHas8 == 0 )
UT_AddItemToInventory(R"swordoftheangelic2.uti");
if ( nHas9 == 0 )
UT_AddItemToInventory(R"swordofthedamned2.uti");
if ( nHas10 == 0 )
UT_AddItemToInventory(R"swordofthedemented2.uti");
if ( nHas11 == 0 )
UT_AddItemToInventory(R"shieldoftheangelic.uti");

break;
}
}

SetLocalInt(OBJECT_SELF,"QUICKITEMADDED", 1);
}

}
// ---------- Script Ends Here ----------



#2
Eshme

Eshme
  • Members
  • 756 messages
I have recently read something which is what you explained. I would like it sooner or later as well but i forgot

It could be on the wiki i am not sure

#3
Eshme

Eshme
  • Members
  • 756 messages
No here

http://dragonagemodd...efore-spawning/

#4
Robert184e

Robert184e
  • Members
  • 7 messages
Alright I will try and re-code my script to match that one and see how well it works for me. Thank you!

#5
Robert184e

Robert184e
  • Members
  • 7 messages
Well i don't understand how that one works? I tried to work it into my script, but i am new to scripting, and don't understand how to do the script for 11 items. If you could give me a good example I might be able to do it. Lol...

#6
Eshme

Eshme
  • Members
  • 756 messages
Ooo i dont know . It is probably meant as a extension to another tutorial. So perhaps you take a look at that too , but this one doesnt have the best method to add an item it seems.



http://dragonagemodd...player-an-item/

#7
Robert184e

Robert184e
  • Members
  • 7 messages
Used that one already, Like I said the script is not my own. It is a mix of scripts that actually work. Using other scripts / commands to improve it. It works great, even on character creation. But when say Alistair has one of the custom items equipped, it will give me the items he is using again. I need to figure out how to check all party members for the items. 1 guy posted something, but I do not know how to combine it into my code.



this is what he posted



object[] oChar = GetPartyPoolList();

int nSize = GetArraySize(oChar);

int i;

object oCurrent;

int nHasItem = 0:



for(i = 0; i < nSize; i++)

{

oCurrent = oChar[i];

nHasItem += CountItemsByTag(oCurrent, "new_item");

}



if ( nHasItem == 0 )

UT_AddItemToInventory(R"new_item.uti");





How Can I incorporate that into my script?

#8
BrotherJason

BrotherJason
  • Members
  • 99 messages
try this:

// ---------- Script Starts Here ----------

#include "utility_h"
#include "wrappers_h"
#include "events_h"

void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);

if ( GetLocalInt(OBJECT_SELF, "QUICKITEMADDED") != 1 )
{
switch(nEventType)
{
case EVENT_TYPE_CHARGEN_END:
case EVENT_TYPE_MODULE_LOAD:
{
// If we do not, then we add it to the inventory
if (!IsObjectValid(GetObjectByTag("ancestralamulet")))
UT_AddItemToInventory(R"ancestralamulet2.uti",1);

if (!IsObjectValid(GetObjectByTag("ancestralmirror")))
UT_AddItemToInventory(R"ancestralmirror2.uti",1);

if (!IsObjectValid(GetObjectByTag("ancestralrobe")))
UT_AddItemToInventory(R"ancestralrobe2.uti",1);

if (!IsObjectValid(GetObjectByTag("ancestralwrap")))
UT_AddItemToInventory(R"ancestralwrap2.uti",1);

if (!IsObjectValid(GetObjectByTag("daggeroftheangelic")))
UT_AddItemToInventory(R"daggeroftheangelic2.uti",1);

if (!IsObjectValid(GetObjectByTag("ringoftheancients")))
UT_AddItemToInventory(R"ringoftheancients2.uti",1);

if (!IsObjectValid(GetObjectByTag("ringofthemagi")))
UT_AddItemToInventory(R"ringofthemagi2.uti",1);

if (!IsObjectValid(GetObjectByTag("swordoftheangelic")))
UT_AddItemToInventory(R"swordoftheangelic2.uti",1);

if (!IsObjectValid(GetObjectByTag("swordofthedamned")))
UT_AddItemToInventory(R"swordofthedamned2.uti");

if (!IsObjectValid(GetObjectByTag("swordofthedemented")))
UT_AddItemToInventory(R"swordofthedemented2.uti",1);

if (!IsObjectValid(GetObjectByTag("shieldoftheangelic")))
UT_AddItemToInventory(R"shieldoftheangelic.uti",1);

break;
}
}

SetLocalInt(OBJECT_SELF,"QUICKITEMADDED", 1);
}

}
// ---------- Script Ends Here ----------

#9
Robert184e

Robert184e
  • Members
  • 7 messages
Alright BrotherJason, that is working great as of the loading event. I added another item and it works, but when I level up and add stat / skill / etc. It gives me the last item on list. Could I have done something wrong to cause this?

Here is the code with the new item.

I would also like to say Thank you to both of you for helping me, and for being patient with me.:)


// ---------- Script Starts Here ----------

#include "utility_h"
#include "wrappers_h"
#include "events_h"

void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);

if ( GetLocalInt(OBJECT_SELF, "QUICKITEMADDED") != 1 )
{
switch(nEventType)
{
case EVENT_TYPE_CHARGEN_END:
case EVENT_TYPE_MODULE_LOAD:
{
// If we do not, then we add it to the inventory
if (!IsObjectValid(GetObjectByTag("ancestralamulet")))
UT_AddItemToInventory(R"ancestralamulet2.uti",1);

if (!IsObjectValid(GetObjectByTag("ancestralmirror")))
UT_AddItemToInventory(R"ancestralmirror2.uti",1);

if (!IsObjectValid(GetObjectByTag("ancestralrobe")))
UT_AddItemToInventory(R"ancestralrobe2.uti",1);

if (!IsObjectValid(GetObjectByTag("ancestralwrap")))
UT_AddItemToInventory(R"ancestralwrap2.uti",1);

if (!IsObjectValid(GetObjectByTag("daggeroftheangelic")))
UT_AddItemToInventory(R"daggeroftheangelic2.uti",2);

if (!IsObjectValid(GetObjectByTag("ringoftheancients")))
UT_AddItemToInventory(R"ringoftheancients2.uti",1);

if (!IsObjectValid(GetObjectByTag("ringofthemagi")))
UT_AddItemToInventory(R"ringofthemagi2.uti",1);

if (!IsObjectValid(GetObjectByTag("swordoftheangelic")))
UT_AddItemToInventory(R"swordoftheangelic2.uti",1);

if (!IsObjectValid(GetObjectByTag("swordofthedamned")))
UT_AddItemToInventory(R"swordofthedamned2.uti");

if (!IsObjectValid(GetObjectByTag("swordofthedemented")))
UT_AddItemToInventory(R"swordofthedemented2.uti",1);

if (!IsObjectValid(GetObjectByTag("shieldoftheangelic")))
UT_AddItemToInventory(R"shieldoftheangelic.uti",1);

if (!IsObjectValid(GetObjectByTag("staffoftheancients")))
UT_AddItemToInventory(R"staffoftheancients.uti",1);

break;
}
}

SetLocalInt(OBJECT_SELF,"QUICKITEMADDED", 1);
}

}
// ---------- Script Ends Here ----------

Modifié par Robert184e, 09 février 2010 - 04:37 .


#10
BrotherJason

BrotherJason
  • Members
  • 99 messages
the script is evaluated if either the module is loaded, or if the Chargen was closed as your condionals state:



case EVENT_TYPE_CHARGEN_END:

case EVENT_TYPE_MODULE_LOAD:



Thus every time you've completed the leveling up any of your chars and close the UI, the requirement is met and the script is reevaluated.



That your script even comes so far indicates that there's something wrong with your QUICKITEMADDED variable. Did you properly define it in the objects 2da file?

#11
Robert184e

Robert184e
  • Members
  • 7 messages
I'm new to all this scripting stuff. How would I check to see if it is "properly defined".

#12
BrotherJason

BrotherJason
  • Members
  • 99 messages
k let's do this a bit differently.



First create a new plot ressource named "mod_custom_flags" and add "QUICKITEMADDED" as a new plot flag (default value must be "not set"). Check it out and export. Then change your script to this:



// ---------- Script Starts Here ----------



#include "utility_h"

#include "wrappers_h"

#include "events_h"

#include "plt_mod_custom_flags"



void main()

{

if (WR_GetPlotFlag(plt_mod_custom_flags,QUICKITEMADDED)) return;



event ev = GetCurrentEvent();

int nEventType = GetEventType(ev);



if ( GetLocalInt(OBJECT_SELF, "QUICKITEMADDED") != 1 )

{

switch(nEventType)

{

case EVENT_TYPE_CHARGEN_END:

case EVENT_TYPE_MODULE_LOAD:

{

// If we do not, then we add it to the inventory

if (!IsObjectValid(GetObjectByTag("ancestralamulet")))

UT_AddItemToInventory(R"ancestralamulet2.uti",1);



if (!IsObjectValid(GetObjectByTag("ancestralmirror")))

UT_AddItemToInventory(R"ancestralmirror2.uti",1);



if (!IsObjectValid(GetObjectByTag("ancestralrobe")))

UT_AddItemToInventory(R"ancestralrobe2.uti",1);



if (!IsObjectValid(GetObjectByTag("ancestralwrap")))

UT_AddItemToInventory(R"ancestralwrap2.uti",1);



if (!IsObjectValid(GetObjectByTag("daggeroftheangelic")))

UT_AddItemToInventory(R"daggeroftheangelic2.uti",2);



if (!IsObjectValid(GetObjectByTag("ringoftheancients")))

UT_AddItemToInventory(R"ringoftheancients2.uti",1);



if (!IsObjectValid(GetObjectByTag("ringofthemagi")))

UT_AddItemToInventory(R"ringofthemagi2.uti",1);



if (!IsObjectValid(GetObjectByTag("swordoftheangelic")))

UT_AddItemToInventory(R"swordoftheangelic2.uti",1);



if (!IsObjectValid(GetObjectByTag("swordofthedamned")))

UT_AddItemToInventory(R"swordofthedamned2.uti");



if (!IsObjectValid(GetObjectByTag("swordofthedemented")))

UT_AddItemToInventory(R"swordofthedemented2.uti",1);



if (!IsObjectValid(GetObjectByTag("shieldoftheangelic")))

UT_AddItemToInventory(R"shieldoftheangelic.uti",1);



if (!IsObjectValid(GetObjectByTag("staffoftheancients")))

UT_AddItemToInventory(R"staffoftheancients.uti",1);



break;

}

}



WR_SetPlotFlag(plt_mod_custom_flags,QUICKITEMADDED,TRUE)

}



}

// ---------- Script Ends Here ----------



save, check out and export.

#13
Robert184e

Robert184e
  • Members
  • 7 messages
Alright I am going to spend some time testing this, I believe it may finally be working right. I will make a new character and see if I get items upon zoning / leveling / loading. So far on current game (after removing items by unloading and reloading mod) it is working. Will not know till after I level. Thank you so much for all your help. I understand whats going on just never knew how to script it.



Thanks to you a ton BrotherJason!

#14
BrotherJason

BrotherJason
  • Members
  • 99 messages
if you don't want the script to be evaluated after levelup you just have to remove the

case EVENT_TYPE_CHARGEN_END:

line.