114 lines
3.5 KiB
Plaintext
114 lines
3.5 KiB
Plaintext
///////////////////////////////////////////////////////////////////////////////
|
|
// Use mineable object
|
|
// By Deva Bryson Winblood. 12/28/2003
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void fnMining(int nC,object oMineable)
|
|
{ //
|
|
if (nC==0)
|
|
{
|
|
SendMessageToPC(OBJECT_SELF,"You start mining the deposit. Keep using it to mine it.");
|
|
SetLocalInt(OBJECT_SELF,"nMining",TRUE);
|
|
}
|
|
if (oMineable!=OBJECT_INVALID&&GetArea(oMineable)==GetArea(OBJECT_SELF)&&GetDistanceBetween(oMineable,OBJECT_SELF)<4.0)
|
|
{ DelayCommand(3.0,fnMining(1,oMineable)); }
|
|
else
|
|
{
|
|
SendMessageToPC(OBJECT_SELF,"You are no longer mining.");
|
|
DeleteLocalInt(OBJECT_SELF,"nMining");
|
|
}
|
|
} // fnMining()
|
|
|
|
|
|
void main()
|
|
{
|
|
object oUser=GetLastUsedBy();
|
|
int nP;
|
|
object oItem;
|
|
object oNear;
|
|
int nAmt=GetLocalInt(OBJECT_SELF,"nResAmt");
|
|
string sRes=GetResRef(OBJECT_SELF);
|
|
SetIsTemporaryEnemy(oUser,OBJECT_SELF);
|
|
AssignCommand(oUser,ClearAllActions());
|
|
AssignCommand(oUser,ActionAttack(OBJECT_SELF,TRUE));
|
|
AssignCommand(OBJECT_SELF,PlaySound("as_cv_minepick1"));
|
|
if (GetIsPC(oUser)==TRUE&&GetLocalString(oUser,"sTeamID")!="DWF") nP=Random(1000)+1;
|
|
else if (GetIsPC(oUser)==TRUE) nP=Random(333)+1; // easier for dwarves to mine
|
|
else { nP=d100(); }
|
|
if (GetIsPC(oUser)==TRUE&&GetLocalInt(oUser,"nMining")!=TRUE) AssignCommand(oUser,fnMining(0,OBJECT_SELF));
|
|
if (sRes=="resgold")
|
|
{ // gold
|
|
if (nP<25)
|
|
{ // create gold
|
|
if (GetIsPC(oUser)==TRUE)
|
|
{ // give gold directly to PC
|
|
oItem=CreateItemOnObject("nw_it_gold001",oUser,1);
|
|
} // give gold directly to PC
|
|
else
|
|
{
|
|
oNear=GetNearestObjectByTag("NW_IT_GOLD001",oUser,1);
|
|
if (oNear!=OBJECT_INVALID&&GetDistanceBetween(oNear,oUser)<3.0)
|
|
{ // add to pile
|
|
oItem=CreateObject(OBJECT_TYPE_ITEM,"nw_it_gold001",GetLocation(oUser),GetItemStackSize(oNear)+1);
|
|
DelayCommand(1.0,DestroyObject(oNear));
|
|
} // add to pile
|
|
else
|
|
{ oItem=CreateObject(OBJECT_TYPE_ITEM,"nw_it_gold001",GetLocation(oUser)); }
|
|
}
|
|
nAmt=nAmt-1;
|
|
SetLocalInt(OBJECT_SELF,"nResAmt",nAmt);
|
|
if (nAmt<1) DestroyObject(OBJECT_SELF);
|
|
} // create gold
|
|
} // gold
|
|
else if (sRes=="resadm")
|
|
{ // admantium
|
|
if (nP<6)
|
|
{ // create admantium
|
|
if(GetIsPC(oUser)==TRUE)
|
|
{ // PC
|
|
oItem=CreateItemOnObject("bar_admant",oUser,1);
|
|
} // PC
|
|
else
|
|
{
|
|
oItem=CreateObject(OBJECT_TYPE_ITEM,"bar_admant",GetLocation(oUser));
|
|
nAmt=nAmt-1;
|
|
SetLocalInt(OBJECT_SELF,"nResAmt",nAmt);
|
|
if (nAmt<1) DestroyObject(OBJECT_SELF);
|
|
}
|
|
} // create admantium
|
|
} // admantium
|
|
else if (sRes=="resiron")
|
|
{ // iron
|
|
if (nP<10)
|
|
{ // create iron
|
|
if (GetIsPC(oUser)==TRUE)
|
|
{ // PC
|
|
oItem=CreateItemOnObject("bar_iron",oUser,1);
|
|
} // PC
|
|
else
|
|
{
|
|
oItem=CreateObject(OBJECT_TYPE_ITEM,"bar_iron",GetLocation(oUser));
|
|
nAmt=nAmt-1;
|
|
SetLocalInt(OBJECT_SELF,"nResAmt",nAmt);
|
|
if (nAmt<1) DestroyObject(OBJECT_SELF);
|
|
}
|
|
} // create iron
|
|
} // iron
|
|
else if (sRes=="resmith")
|
|
{ // mithral
|
|
if (nP<3)
|
|
{ // create mithral
|
|
if (GetIsPC(oUser)==TRUE)
|
|
{ // PC
|
|
oItem=CreateItemOnObject("bar_mith",oUser);
|
|
} // PC
|
|
else
|
|
{
|
|
oItem=CreateObject(OBJECT_TYPE_ITEM,"bar_mith",GetLocation(oUser));
|
|
nAmt=nAmt-1;
|
|
SetLocalInt(OBJECT_SELF,"nResAmt",nAmt);
|
|
if (nAmt<1) DestroyObject(OBJECT_SELF);
|
|
}
|
|
} // create mithral
|
|
} // mithral
|
|
}
|