Aller au contenu

Photo

An NPC or placeable to exchange one type of item for another.


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

#26
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Thank you guys for the further refinement of this. As I mentioned the previous version does seem to be working, the only bugs I found were when testing locally it was not destroying 2 shards for all the types of exchanges, but it was however doing this correctly live on the server for some reason. The only other things is it was not showing 2 shards being destroyed in the log (perhaps because are in a stack), however if you watch your inventory it does in fact destroy 2.

I am not a scripter though, so perhaps you 2 can see potential problems that are not apparent to me, so I will give this update a try. Thank again you two!
Laz

Edit: I just read the rest of Lighfoot8's post, and yep I see the problems. I will certainly give these edits a try.

Modifié par Lazarus Magni, 03 septembre 2011 - 06:26 .


#27
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
[quote]Lightfoot8 wrote...


Line: DelayCommand(0.5,ExportSingleCharacter(oPC));
Now this is an interresting one.  First I do not see anyreason to export the character without also updating the DB if you are also storing shard information in the DB.   Doing so just risks getting the DB and character out os sink in the event of a server crash.   but that is not the real problem here.   This export of the PC at a 0.5 delay risks saving the character in a state out of sink with itsself.    The DestroyNumItems function above destroys stacks of items at an incremental delay of 0.3 seconds.  So if it ever destroys more then one stack on the PC, they will be saved at a time when there inventory is out of sink.  I would suggest just removing the line.

[/quote][/quote]

Oh by the way, just in case you were interested. I believe this was a relic of the initial script attempt I had posted, which was basically just a hack job of our shard to QP conversion script. The shards are not stored in the DB, but the QP are. Guilie prolly just assumed I had a reason for having that in there originally, but really I was just trying to modify an existing script that had a similar function (quite unsucessfully I might add.)

#28
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Umm well, this update didn't exactly work. When I go to do one exchange, it starts converting every single shard I have into the type I was exchanging to.

#29
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
arrrg. well as soon as I get rid of all the orange gems tha I just created on my character, ill figure out what I did wrong.

#30
ffbj

ffbj
  • Members
  • 593 messages
I usually put the restrictions for number of items in the sc.  Like this:

int GetNumItems(object oTarget,string sItem)
{
int nNumItems = 0;
object oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(oItem) == TRUE)
{
if (GetTag(oItem) == sItem)
{
nNumItems = nNumItems + GetNumStackedItems(oItem);
}
oItem = GetNextItemInInventory(oTarget);
}
return nNumItems;
}
 

int StartingConditional()
{
object oPC = GetPCSpeaker();

if (!(GetNumItems(oPC, "TagOfItem") >= 3)) return FALSE;

return TRUE;
}
 So the sc would check for 3 or more of the specified item.

Then in the action taken simply:

#include "nw_i0_plot"

//Put this on action taken in the conversation editor

void main()
{
object oPC = GetPCSpeaker();
object oItem;
oItem = GetItemPossessedBy(oPC, "TagOfItem ");
TakeNumItems(oPC, "TagOfItem", 3);

if (GetIsObjectValid(oItem))
   DestroyObject(oItem);

CreateItemOnObject("resrefoitemcreated", oPC);
}

Don't know if that's helpful in this particular case.

Modifié par ffbj, 03 septembre 2011 - 11:34 .


#31
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
 The line line in your main script where I had: 

if(!nMaxStack) Get2DAString("baseitems","Stacking",GetBaseItemType(oItem));

Posted Image Oops.   I never placed the value whee it needed to go.   change it to.

if(!nMaxStack) nMaxStack = StringToInt(Get2DAString("baseitems","Stacking",GetBaseItemType(oItem)));

Sorry about that.  Im going to edit the other post also.

#32
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
@ffbj:  I think his starting condition is still
  
     object oPC = GetPCSpeaker();
    // Custom Function that returns the # of a particular item
    // (included stack counts) that the PC has on them
    int nCount = GetIemCount(oPC, sItemTagName);
    if (nCount >= nRequired && GetGold(oPC) >= nGoldRequired)
    { return TRUE; }
    else
    { return FALSE; }
.........

with the config stuff above it to define the vars.  

#33
ffbj

ffbj
  • Members
  • 593 messages
Yeah I should have figured you guys had it covered.

#34
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Thank you Light, I will give that a try. Guess I will test it locally first though before putting it on the server (I should know better by now lol.)

#35
Lazarus Magni

Lazarus Magni
  • Members
  • 1 134 messages
Tested locally, and live, looks like this is all good now. TYVM all!

#36
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
welcome.