* added 2 new DefScript funcs: "GetEntry <guid>" & "GetitemProtoValue,<entry> <property>"
* misc updates to the scp storage * got angry at the "loaded item prototype...[...]" messages, disabled them for release mode.
This commit is contained in:
parent
d9a56b2a00
commit
48d8a12a71
@ -37,6 +37,8 @@ void DefScriptPackage::_InitDefScriptInterface(void)
|
|||||||
AddFunc("getscpvalue",&DefScriptPackage::SCGetScpValue);
|
AddFunc("getscpvalue",&DefScriptPackage::SCGetScpValue);
|
||||||
AddFunc("getplayerguid",&DefScriptPackage::SCGetPlayerGuid);
|
AddFunc("getplayerguid",&DefScriptPackage::SCGetPlayerGuid);
|
||||||
AddFunc("getname",&DefScriptPackage::SCGetName);
|
AddFunc("getname",&DefScriptPackage::SCGetName);
|
||||||
|
AddFunc("getentry",&DefScriptPackage::SCGetName);
|
||||||
|
AddFunc("getitemprotovalue",&DefScriptPackage::SCGetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefReturnResult DefScriptPackage::SCshdn(CmdSet& Set)
|
DefReturnResult DefScriptPackage::SCshdn(CmdSet& Set)
|
||||||
@ -371,13 +373,9 @@ DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set)
|
|||||||
DefReturnResult r;
|
DefReturnResult r;
|
||||||
uint64 guid=DefScriptTools::toNumber(Set.defaultarg);
|
uint64 guid=DefScriptTools::toNumber(Set.defaultarg);
|
||||||
r.ret="Unknown Entity";
|
r.ret="Unknown Entity";
|
||||||
if(!guid)
|
|
||||||
{
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid);
|
Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid);
|
||||||
|
if(o)
|
||||||
|
{
|
||||||
if(o->GetTypeId()==TYPEID_ITEM || o->GetTypeId()==TYPEID_CONTAINER)
|
if(o->GetTypeId()==TYPEID_ITEM || o->GetTypeId()==TYPEID_CONTAINER)
|
||||||
{
|
{
|
||||||
ItemProto *proto=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetItemProto(o->GetEntry());
|
ItemProto *proto=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetItemProto(o->GetEntry());
|
||||||
@ -389,6 +387,251 @@ DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set)
|
|||||||
}
|
}
|
||||||
// TODO: add support for gameobjects etc.
|
// TODO: add support for gameobjects etc.
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logerror("SCGetName: Object "I64FMT" not known",guid);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
DefReturnResult DefScriptPackage::SCGetEntry(CmdSet& Set)
|
||||||
|
{
|
||||||
|
if(!(((PseuInstance*)parentMethod)->GetWSession() && ((PseuInstance*)parentMethod)->GetWSession()->IsValid()))
|
||||||
|
{
|
||||||
|
logerror("Invalid Script call: SCGetEntry: WorldSession not valid");
|
||||||
|
DEF_RETURN_ERROR;
|
||||||
|
}
|
||||||
|
DefReturnResult r;
|
||||||
|
uint64 guid=DefScriptTools::toNumber(Set.defaultarg);
|
||||||
|
r.ret="0";
|
||||||
|
Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid);
|
||||||
|
if(o)
|
||||||
|
{
|
||||||
|
r.ret=DefScriptTools::toString((uint64)o->GetEntry());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logerror("SCGetEntry: Object "I64FMT" not known",guid);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
DefReturnResult DefScriptPackage::SCGetItemProtoValue(CmdSet& Set)
|
||||||
|
{
|
||||||
|
if(!(((PseuInstance*)parentMethod)->GetWSession() && ((PseuInstance*)parentMethod)->GetWSession()->IsValid()))
|
||||||
|
{
|
||||||
|
logerror("Invalid Script call: SCGetItemProtoValue: WorldSession not valid");
|
||||||
|
DEF_RETURN_ERROR;
|
||||||
|
}
|
||||||
|
DefReturnResult r;
|
||||||
|
uint32 entry=DefScriptTools::toNumber(Set.arg[0]);
|
||||||
|
ItemProto *proto=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetItemProto(entry);
|
||||||
|
if(proto)
|
||||||
|
{
|
||||||
|
std::string t=stringToLower(Set.defaultarg);
|
||||||
|
uint32 tmp=0;
|
||||||
|
if(t=="class") r.ret=toString(proto->Class);
|
||||||
|
else if(t=="subclass") r.ret=toString(proto->SubClass);
|
||||||
|
else if(t=="name1" || t=="name") proto->Name[0];
|
||||||
|
else if(t=="name2") proto->Name[1];
|
||||||
|
else if(t=="name3") proto->Name[2];
|
||||||
|
else if(t=="name4") proto->Name[3];
|
||||||
|
else if(t=="model" || t=="displayid") r.ret=toString(proto->DisplayInfoID);
|
||||||
|
else if(t=="quality") r.ret=toString(proto->Quality);
|
||||||
|
else if(t=="flags") r.ret=toString(proto->Flags);
|
||||||
|
else if(t=="buycount") r.ret=toString(proto->BuyCount);
|
||||||
|
else if(t=="buyprice") r.ret=toString(proto->BuyPrice);
|
||||||
|
else if(t=="sellprice") r.ret=toString(proto->SellPrice);
|
||||||
|
else if(t=="inventorytype") r.ret=toString(proto->InventoryType);
|
||||||
|
else if(t=="allowableclass") r.ret=toString(proto->AllowableClass);
|
||||||
|
else if(t=="allowablerace") r.ret=toString(proto->AllowableRace);
|
||||||
|
else if(t=="itemlevel") r.ret=toString(proto->ItemLevel);
|
||||||
|
else if(t=="reqlevel") r.ret=toString(proto->RequiredLevel);
|
||||||
|
else if(t=="reqskill") r.ret=toString(proto->RequiredSkill);
|
||||||
|
else if(t=="reqskillrank") r.ret=toString(proto->RequiredSkillRank);
|
||||||
|
else if(t=="reqspell") r.ret=toString(proto->RequiredSpell);
|
||||||
|
else if(t=="reqhonorrank") r.ret=toString(proto->RequiredHonorRank);
|
||||||
|
else if(t=="reqcityrank") r.ret=toString(proto->RequiredCityRank);
|
||||||
|
else if(t=="reqrepfaction") r.ret=toString(proto->RequiredReputationFaction);
|
||||||
|
else if(t=="reqreprank") r.ret=toString(proto->RequiredReputationRank);
|
||||||
|
else if(t=="maxcount") r.ret=toString(proto->MaxCount);
|
||||||
|
else if(t=="stackable") r.ret=toString(proto->Stackable);
|
||||||
|
else if(t=="slots") r.ret=toString(proto->ContainerSlots);
|
||||||
|
else if(t=="str")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<10;i++)
|
||||||
|
if(proto->ItemStat[i].ItemStatType==ITEM_STAT_STRENGTH)
|
||||||
|
tmp+=proto->ItemStat[i].ItemStatValue;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="agi")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<10;i++)
|
||||||
|
if(proto->ItemStat[i].ItemStatType==ITEM_STAT_AGILITY)
|
||||||
|
tmp+=proto->ItemStat[i].ItemStatValue;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="sta")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<10;i++)
|
||||||
|
if(proto->ItemStat[i].ItemStatType==ITEM_STAT_STAMINA)
|
||||||
|
tmp+=proto->ItemStat[i].ItemStatValue;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="int")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<10;i++)
|
||||||
|
if(proto->ItemStat[i].ItemStatType==ITEM_STAT_INTELLECT)
|
||||||
|
tmp+=proto->ItemStat[i].ItemStatValue;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="spi")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<10;i++)
|
||||||
|
if(proto->ItemStat[i].ItemStatType==ITEM_STAT_SPIRIT)
|
||||||
|
tmp+=proto->ItemStat[i].ItemStatValue;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="hp" || t=="health")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<10;i++)
|
||||||
|
if(proto->ItemStat[i].ItemStatType==ITEM_STAT_HEALTH)
|
||||||
|
tmp+=proto->ItemStat[i].ItemStatValue;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="mindmg")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==NORMAL_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMin;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="maxdmg")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==NORMAL_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMax;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="mindmg_holy")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==HOLY_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMin;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="maxdmg_holy")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==HOLY_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMax;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="mindmg_fire")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==FIRE_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMin;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="maxdmg_fire")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==FIRE_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMax;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="mindmg_nature")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==NATURE_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMin;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="maxdmg_nature")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==NATURE_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMax;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="mindmg_frost")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==FROST_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMin;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="maxdmg_frost")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==FROST_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMax;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="mindmg_shadow")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==SHADOW_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMin;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="maxdmg_shadow")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==SHADOW_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMax;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="mindmg_arcane")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==ARCANE_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMin;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="maxdmg_arcane")
|
||||||
|
{
|
||||||
|
for(uint32 i=0;i<5;i++)
|
||||||
|
if(proto->Damage[i].DamageType==ARCANE_DAMAGE)
|
||||||
|
tmp+=proto->Damage[i].DamageMax;
|
||||||
|
r.ret = toString((uint64)tmp);
|
||||||
|
}
|
||||||
|
else if(t=="armor") r.ret=toString(proto->Armor);
|
||||||
|
else if(t=="holyres") r.ret=toString(proto->HolyRes);
|
||||||
|
else if(t=="fireres") r.ret=toString(proto->FireRes);
|
||||||
|
else if(t=="natureres") r.ret=toString(proto->NatureRes);
|
||||||
|
else if(t=="frostres") r.ret=toString(proto->FrostRes);
|
||||||
|
else if(t=="shadowres") r.ret=toString(proto->ShadowRes);
|
||||||
|
else if(t=="arcaneres") r.ret=toString(proto->ArcaneRes);
|
||||||
|
else if(t=="delay") r.ret=toString(proto->Delay);
|
||||||
|
else if(t=="ammotype") r.ret=toString(proto->Ammo_type);
|
||||||
|
else if(t=="range") r.ret=toString(proto->RangedModRange);
|
||||||
|
else if(t=="bonding") r.ret=toString(proto->Bonding);
|
||||||
|
else if(t=="desc") r.ret=proto->Description;
|
||||||
|
else if(t=="pagetext") r.ret=toString(proto->PageText);
|
||||||
|
else if(t=="languageid") r.ret=toString(proto->LanguageID);
|
||||||
|
else if(t=="pagematerial") r.ret=toString(proto->PageMaterial);
|
||||||
|
else if(t=="startquest") r.ret=toString(proto->StartQuest);
|
||||||
|
else if(t=="lockid") r.ret=toString(proto->LockID);
|
||||||
|
else if(t=="material") r.ret=toString(proto->Material);
|
||||||
|
else if(t=="sheath") r.ret=toString(proto->Sheath);
|
||||||
|
else if(t=="extra") r.ret=toString(proto->Extra);
|
||||||
|
else if(t=="block") r.ret=toString(proto->Block);
|
||||||
|
else if(t=="itemset") r.ret=toString(proto->ItemSet);
|
||||||
|
else if(t=="maxdur") r.ret=toString(proto->MaxDurability);
|
||||||
|
else if(t=="area") r.ret=toString(proto->Area);
|
||||||
|
else if(t=="bagfamily") r.ret=toString(proto->BagFamily);
|
||||||
|
// TODO: add item spells
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logerror("SCGetItemProtoValue: Unknown property \"%s\" for Item Prototype %u",t.c_str(),entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logerror("SCGetItemProtoValue: Item Prototype %u not known",entry);
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,5 +29,7 @@ DefReturnResult SCScpEntryExists(CmdSet&);
|
|||||||
DefReturnResult SCGetScpValue(CmdSet&);
|
DefReturnResult SCGetScpValue(CmdSet&);
|
||||||
DefReturnResult SCGetName(CmdSet&);
|
DefReturnResult SCGetName(CmdSet&);
|
||||||
DefReturnResult SCGetPlayerGuid(CmdSet&);
|
DefReturnResult SCGetPlayerGuid(CmdSet&);
|
||||||
|
DefReturnResult SCGetEntry(CmdSet&);
|
||||||
|
DefReturnResult SCGetItemProtoValue(CmdSet&);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -72,3 +72,12 @@ std::string SCPField::GetString(std::string entry)
|
|||||||
{
|
{
|
||||||
return HasEntry(entry) ? _map[entry] : "";
|
return HasEntry(entry) ? _map[entry] : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// note that this can take a while depending on the size of the database!
|
||||||
|
uint32 SCPDatabase::GetFieldByValue(std::string entry, std::string value)
|
||||||
|
{
|
||||||
|
for(SCPFieldMap::iterator fm = _map.begin(); fm != _map.end(); fm++)
|
||||||
|
if(fm->second.HasEntry(entry) && fm->second.GetString(entry)==value)
|
||||||
|
return fm->first;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -33,6 +33,7 @@ public:
|
|||||||
SCPField& GetField(uint32 id) { return _map[id]; }
|
SCPField& GetField(uint32 id) { return _map[id]; }
|
||||||
bool HasField(uint32 id);
|
bool HasField(uint32 id);
|
||||||
uint32 LoadFromFile(char*);
|
uint32 LoadFromFile(char*);
|
||||||
|
uint32 GetFieldByValue(std::string entry, std::string value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SCPFieldMap _map;
|
SCPFieldMap _map;
|
||||||
|
|||||||
@ -211,7 +211,7 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session)
|
|||||||
buf >> proto->Unknown2; // Added in 1.12.x client branch
|
buf >> proto->Unknown2; // Added in 1.12.x client branch
|
||||||
if(proto->Id)
|
if(proto->Id)
|
||||||
{
|
{
|
||||||
logdebug("ItemProtoCache: Loaded %u [%s]",proto->Id, proto->Name[0].c_str());
|
DEBUG(logdebug("ItemProtoCache: Loaded %u [%s]",proto->Id, proto->Name[0].c_str()));
|
||||||
session->objmgr.Add(proto);
|
session->objmgr.Add(proto);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ void ItemProtoCache_WriteDataToCache(WorldSession *session)
|
|||||||
buf << proto->Unknown1;
|
buf << proto->Unknown1;
|
||||||
buf << proto->Unknown2; // Added in 1.12.x client branch
|
buf << proto->Unknown2; // Added in 1.12.x client branch
|
||||||
|
|
||||||
logdebug("ItemProtoCache: Saved %u [%s]",proto->Id, proto->Name[0].c_str());
|
DEBUG(logdebug("ItemProtoCache: Saved %u [%s]",proto->Id, proto->Name[0].c_str()));
|
||||||
uint32 size = buf.size();
|
uint32 size = buf.size();
|
||||||
fh.write((char*)&size,sizeof(uint32));
|
fh.write((char*)&size,sizeof(uint32));
|
||||||
fh.write((char*)buf.contents(),buf.size());
|
fh.write((char*)buf.contents(),buf.size());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user