A developer in our team worked on some of the skills, one being Smithing. He's no longer in the team, and we're having an issue with the skill.
What's happening is, when you try and smith, you use an anvil to create a sword or armour once or more, then you completely stop.
The script lets you smith 1, 5 or All (All being every bar in your invent, and stopping once you run out).
But when you smith 1-10 items, you completely stop, even if you have metal bars remaining to be smelted, so when you try and click the anvil again, your character just won't do anything and just stand there, even after re-selecting what you want to smelt.
After you keep trying to use the anvil, you will randomly be able to smith again, the then the bug loops, and will only let you smith 1-10 more items before locking you out completely.
Could someone please look over the script and see if you can find anything?
We have other scripts like this and they work completely the same and perfectly fine. For example, cooking.
// tb_smithing
/*-
This script checks to see if the PC has an item in their inventory
_bar = tag of the smithing material
_item = tag of item we're making
_barsused = quantity of material used per item
_quantity = quantity of items we're smithing
_nXP = xp per smith
*/
#include "tb_loops"
#include "tb_skillsandxp"
#include "nw_i0_plot"
const string ANIM_SMITH = "FORGE01";
const string SMITH_SOUND = "as_cv_smithhamr1";
object oPC;
string item;
string bar;
int xp;
int barspersmith;
int quantity;
location loc;
float nSmithTime = 6.0;
void StartSmithing();
void EndSmithing(); //you either moved on or finished all the items
void WaitForSmith(float time, float curtime = 1000.0);
void Smith();
void GiveSmithed();
void DestroyItems(object oTarget, string sItem, int nNumItems);
void main(string _bartag, string _itemtag, int _barsused, int _quantity, int _nXp)
{
oPC = GetPCSpeaker();
if (GetLocalInt(oPC, "issmithing") == 1) //a smithing loop is already firing
{ //closing all smithing scripts and starting this one
return;
}
SetLocalString(oPC, "activity", "smithing"); //activity switch aborts loops in all other activities
item = _itemtag;
bar = _bartag;
xp = _nXp;
barspersmith = _barsused;
quantity = _quantity;
loc = GetLocation(oPC);
StartSmithing();
}
void ReallyPlayCustomAnimation(object oObject, string sAnimationName, int nsmithing, float fSpeed = 1.0f)
{
PlayAnimation(0, 1.0f, 0.01f);
PlayCustomAnimation(oObject, sAnimationName, nsmithing, fSpeed);
}
void StartSmithing()
{
string hammertag = GetTag(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC));
if (hammertag != "hammer")
{
object oHammer = GetItemPossessedBy(oPC, "hammer");
AssignCommand(oPC, ActionEquipItem(oHammer, INVENTORY_SLOT_RIGHTHAND));
if (oHammer == OBJECT_INVALID)
{
EndSmithing();
SendMessageToPC(oPC, "<color=white>" + "You don't seem to have a hammer ready.");
return;
}
//test carrying pickaxe in left hand and another item in right
else if (GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC) != oHammer)
{
AssignCommand(oPC, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC)));
AssignCommand(oPC, ActionEquipItem(oHammer, INVENTORY_SLOT_RIGHTHAND));
}
}
DelayCommand(0.01, WaitForSmith(nSmithTime, nSmithTime));
AssignCommand(oPC, PlaySound(SMITH_SOUND));
}
void WaitForSmith(float time, float curtime)
{
float step = 0.5f;
float curdist = GetDistanceBetweenLocations(GetLocation(oPC), loc);
//abort if we're done or don't have enough bars
if (curdist <= 0.01)
{
SetLocalInt(oPC, "issmithing", 1);
if (quantity <= 0)
{
EndSmithing();
return;
}
if (GetNumItems(oPC, bar) < barspersmith)
{
EndSmithing();
SendMessageToPC(oPC, "<color=white>" + "You've run short on materials to smith with.");
return;
}
else if (curtime <= 0.0f)
{
quantity--;
Smith();
}
else if (GetLocalString(oPC, "activity") == "smithing")
{
DelayCommand(0.2f, AssignCommand(oPC, ReallyPlayCustomAnimation(oPC, ANIM_SMITH, 0)));
DelayCommand(step, AssignCommand(oPC, WaitForSmith(time, curtime-step)));
EndSmithing();
}
}
else
{
//SendMessageToPC(oPC, "<color=white>" + "Current Activity: " + GetLocalString(oPC, "activity"));
EndSmithing();
}
}
void Smith()
{
SendMessageToPC(oPC, "<color=white>" + "You smith successfully.");
DestroyItems(oPC, bar, barspersmith);
DelayCommand(0.1f, AssignCommand(oPC, GiveSmithed()));
GiveXP(oPC, "smithing", xp);
EndSmithing();
StartSmithing();
}
void GiveSmithed()
{
CreateItemOnObject(item, oPC, 1);
}
void EndSmithing()
{
CloseLoops(oPC);
}
void DestroyItems(object oTarget,string sItem,int nNumItems)
{
int nCount = 0;
object oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(oItem) == TRUE && nCount < nNumItems)
{
if (GetTag(oItem) == sItem)
{
int nRemainingToDestroy = nNumItems - nCount;
int nStackSize = GetItemStackSize(oItem);
if(nStackSize <= nRemainingToDestroy)
{
DestroyObject(oItem,0.1f);
nCount += nStackSize;
}
else
{
int nNewStackSize = nStackSize - nRemainingToDestroy;
SetItemStackSize(oItem, nNewStackSize);
break;
}
}
oItem = GetNextItemInInventory(oTarget);
}
return;
}





Retour en haut






