* use correct check for proper M2 version (hope there isn't any model with 8.1.0.0 version), fix this in stuffextract to allow extracting textures from new model files
* implement speed change opcodes * fixed texturing of remaining gameobjects (requires reextracting of scp, models and textures) * new defscript command "getobjectpos,guid <x/y/z/o>" (if guid is empty - use my guid)
This commit is contained in:
parent
ebc0ea6ee2
commit
84e3c1d868
Binary file not shown.
@ -54,6 +54,7 @@ void DefScriptPackage::_InitDefScriptInterface(void)
|
|||||||
AddFunc("gui",&DefScriptPackage::SCGui);
|
AddFunc("gui",&DefScriptPackage::SCGui);
|
||||||
AddFunc("sendwho",&DefScriptPackage::SCSendWho);
|
AddFunc("sendwho",&DefScriptPackage::SCSendWho);
|
||||||
AddFunc("getobjectdist",&DefScriptPackage::SCGetObjectDistance);
|
AddFunc("getobjectdist",&DefScriptPackage::SCGetObjectDistance);
|
||||||
|
AddFunc("getobjectpos",&DefScriptPackage::SCGetPos);
|
||||||
AddFunc("switchopcodehandler",&DefScriptPackage::SCSwitchOpcodeHandler);
|
AddFunc("switchopcodehandler",&DefScriptPackage::SCSwitchOpcodeHandler);
|
||||||
AddFunc("opcodedisabled",&DefScriptPackage::SCOpcodeDisabled);
|
AddFunc("opcodedisabled",&DefScriptPackage::SCOpcodeDisabled);
|
||||||
AddFunc("spoofworldpacket",&DefScriptPackage::SCSpoofWorldPacket);
|
AddFunc("spoofworldpacket",&DefScriptPackage::SCSpoofWorldPacket);
|
||||||
@ -1201,6 +1202,31 @@ DefReturnResult DefScriptPackage::SCAddDBPath(CmdSet &Set)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefReturnResult DefScriptPackage::SCGetPos(CmdSet &Set)
|
||||||
|
{
|
||||||
|
WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession();
|
||||||
|
if(!ws)
|
||||||
|
{
|
||||||
|
logerror("Invalid Script call: SCGetPos: WorldSession not valid");
|
||||||
|
DEF_RETURN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64 guid = DefScriptTools::toUint64(Set.arg[0]);
|
||||||
|
Object* obj = ws->objmgr.GetObj(guid ? guid : ws->GetGuid());
|
||||||
|
if (!obj || !obj->IsWorldObject())
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (Set.defaultarg == "x")
|
||||||
|
return DefScriptTools::toString( ((WorldObject*)obj)->GetX() );
|
||||||
|
else if (Set.defaultarg == "y")
|
||||||
|
return DefScriptTools::toString( ((WorldObject*)obj)->GetY() );
|
||||||
|
else if (Set.defaultarg == "z")
|
||||||
|
return DefScriptTools::toString( ((WorldObject*)obj)->GetZ() );
|
||||||
|
else if (Set.defaultarg == "o")
|
||||||
|
return DefScriptTools::toString( ((WorldObject*)obj)->GetO() );
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
void DefScriptPackage::My_LoadUserPermissions(VarSet &vs)
|
void DefScriptPackage::My_LoadUserPermissions(VarSet &vs)
|
||||||
{
|
{
|
||||||
static char *prefix = "USERS::";
|
static char *prefix = "USERS::";
|
||||||
|
|||||||
@ -50,6 +50,7 @@ DefReturnResult SCOpcodeDisabled(CmdSet&);
|
|||||||
DefReturnResult SCSpoofWorldPacket(CmdSet&);
|
DefReturnResult SCSpoofWorldPacket(CmdSet&);
|
||||||
DefReturnResult SCLoadDB(CmdSet &Set);
|
DefReturnResult SCLoadDB(CmdSet &Set);
|
||||||
DefReturnResult SCAddDBPath(CmdSet &Set);
|
DefReturnResult SCAddDBPath(CmdSet &Set);
|
||||||
|
DefReturnResult SCGetPos(CmdSet &Set);
|
||||||
|
|
||||||
|
|
||||||
void my_print(const char *fmt, ...);
|
void my_print(const char *fmt, ...);
|
||||||
|
|||||||
@ -80,7 +80,7 @@ DEBUG(logdebug("Trying to open file %s",MeshFile->getFileName()));
|
|||||||
|
|
||||||
|
|
||||||
MeshFile->read(&header,sizeof(ModelHeader));
|
MeshFile->read(&header,sizeof(ModelHeader));
|
||||||
if (header.version[0] != 4 && header.version[1] != 1 && header.version[2] != 0 && header.version[3] != 0) {
|
if ((header.version[0] < 4 || header.version[0] > 7) || header.version[1] != 1 || header.version[2] != 0 || header.version[3] != 0) {
|
||||||
printf("Wrong header! File version doesn't match or file is not a M2 file.");
|
printf("Wrong header! File version doesn't match or file is not a M2 file.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,7 +81,13 @@ void DrawObject::_Init(void)
|
|||||||
uint32 displayid = gotempl->displayId;
|
uint32 displayid = gotempl->displayId;
|
||||||
SCPDatabase *gdi = _instance->dbmgr.GetDB("gameobjectdisplayinfo");
|
SCPDatabase *gdi = _instance->dbmgr.GetDB("gameobjectdisplayinfo");
|
||||||
if (gdi && displayid)
|
if (gdi && displayid)
|
||||||
|
{
|
||||||
modelfile = std::string("data/model/") + gdi->GetString(displayid,"model");
|
modelfile = std::string("data/model/") + gdi->GetString(displayid,"model");
|
||||||
|
std::string texturef = gdi->GetString(displayid,"path");
|
||||||
|
if (strcmp(gdi->GetString(displayid,"texture"), "") != 0)
|
||||||
|
texture = std::string("data/texture/") + gdi->GetString(displayid,"texture");
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(logdebug("GAMEOBJECT: %u - %u", _obj->GetEntry(), displayid));
|
DEBUG(logdebug("GAMEOBJECT: %u - %u", _obj->GetEntry(), displayid));
|
||||||
} else {
|
} else {
|
||||||
DEBUG(logdebug("GAMEOBJECT UNKNOWN: %u", _obj->GetEntry()));
|
DEBUG(logdebug("GAMEOBJECT UNKNOWN: %u", _obj->GetEntry()));
|
||||||
@ -105,8 +111,11 @@ void DrawObject::_Init(void)
|
|||||||
|
|
||||||
//cube->getMaterial(0).DiffuseColor.setAlpha(opacity);
|
//cube->getMaterial(0).DiffuseColor.setAlpha(opacity);
|
||||||
cube->setName("OBJECT");
|
cube->setName("OBJECT");
|
||||||
cube->getMaterial(0).setFlag(video::EMF_LIGHTING, true);
|
if (cube->getMaterialCount())
|
||||||
cube->getMaterial(0).setFlag(video::EMF_FOG_ENABLE, true);
|
{
|
||||||
|
cube->getMaterial(0).setFlag(video::EMF_LIGHTING, true);
|
||||||
|
cube->getMaterial(0).setFlag(video::EMF_FOG_ENABLE, true);
|
||||||
|
}
|
||||||
|
|
||||||
text=_smgr->addTextSceneNode(_guienv->getBuiltInFont(), L"TestText" , irr::video::SColor(255,255,255,255),cube, irr::core::vector3df(0,5,0));
|
text=_smgr->addTextSceneNode(_guienv->getBuiltInFont(), L"TestText" , irr::video::SColor(255,255,255,255),cube, irr::core::vector3df(0,5,0));
|
||||||
if(_obj->IsPlayer())
|
if(_obj->IsPlayer())
|
||||||
|
|||||||
@ -303,6 +303,26 @@ OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const
|
|||||||
{MSG_MOVE_FALL_LAND, &WorldSession::_HandleMovementOpcode},
|
{MSG_MOVE_FALL_LAND, &WorldSession::_HandleMovementOpcode},
|
||||||
{MSG_MOVE_TELEPORT_ACK, &WorldSession::_HandleTelePortAckOpcode},
|
{MSG_MOVE_TELEPORT_ACK, &WorldSession::_HandleTelePortAckOpcode},
|
||||||
|
|
||||||
|
// set speed opcodes
|
||||||
|
{MSG_MOVE_SET_WALK_SPEED, &WorldSession::_HandleSetSpeedOpcode},
|
||||||
|
{MSG_MOVE_SET_RUN_SPEED, &WorldSession::_HandleSetSpeedOpcode},
|
||||||
|
{MSG_MOVE_SET_RUN_BACK_SPEED, &WorldSession::_HandleSetSpeedOpcode},
|
||||||
|
{MSG_MOVE_SET_SWIM_SPEED, &WorldSession::_HandleSetSpeedOpcode},
|
||||||
|
{MSG_MOVE_SET_SWIM_BACK_SPEED, &WorldSession::_HandleSetSpeedOpcode},
|
||||||
|
{MSG_MOVE_SET_TURN_RATE, &WorldSession::_HandleSetSpeedOpcode},
|
||||||
|
{MSG_MOVE_SET_FLIGHT_SPEED, &WorldSession::_HandleSetSpeedOpcode},
|
||||||
|
{MSG_MOVE_SET_FLIGHT_BACK_SPEED, &WorldSession::_HandleSetSpeedOpcode},
|
||||||
|
|
||||||
|
// force set speed opcodes
|
||||||
|
{SMSG_FORCE_WALK_SPEED_CHANGE, &WorldSession::_HandleForceSetSpeedOpcode},
|
||||||
|
{SMSG_FORCE_RUN_SPEED_CHANGE, &WorldSession::_HandleForceSetSpeedOpcode},
|
||||||
|
{SMSG_FORCE_RUN_BACK_SPEED_CHANGE, &WorldSession::_HandleForceSetSpeedOpcode},
|
||||||
|
{SMSG_FORCE_SWIM_SPEED_CHANGE, &WorldSession::_HandleForceSetSpeedOpcode},
|
||||||
|
{SMSG_FORCE_SWIM_BACK_SPEED_CHANGE, &WorldSession::_HandleForceSetSpeedOpcode},
|
||||||
|
{SMSG_FORCE_TURN_RATE_CHANGE, &WorldSession::_HandleForceSetSpeedOpcode},
|
||||||
|
{SMSG_FORCE_FLIGHT_SPEED_CHANGE, &WorldSession::_HandleForceSetSpeedOpcode},
|
||||||
|
{SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE, &WorldSession::_HandleForceSetSpeedOpcode},
|
||||||
|
|
||||||
{SMSG_COMPRESSED_UPDATE_OBJECT, &WorldSession::_HandleCompressedUpdateObjectOpcode},
|
{SMSG_COMPRESSED_UPDATE_OBJECT, &WorldSession::_HandleCompressedUpdateObjectOpcode},
|
||||||
{SMSG_UPDATE_OBJECT, &WorldSession::_HandleUpdateObjectOpcode},
|
{SMSG_UPDATE_OBJECT, &WorldSession::_HandleUpdateObjectOpcode},
|
||||||
{SMSG_CAST_FAILED, &WorldSession::_HandleCastResultOpcode},
|
{SMSG_CAST_FAILED, &WorldSession::_HandleCastResultOpcode},
|
||||||
@ -1004,6 +1024,127 @@ void WorldSession::_HandleMovementOpcode(WorldPacket& recvPacket)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldSession::_HandleSetSpeedOpcode(WorldPacket& recvPacket)
|
||||||
|
{
|
||||||
|
uint64 guid;
|
||||||
|
float x, y, z, o, speed;
|
||||||
|
uint32 unk32, movetype;
|
||||||
|
uint8 unk8;
|
||||||
|
|
||||||
|
switch(recvPacket.GetOpcode())
|
||||||
|
{
|
||||||
|
case MSG_MOVE_SET_WALK_SPEED:
|
||||||
|
movetype = MOVE_WALK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSG_MOVE_SET_RUN_SPEED:
|
||||||
|
movetype = MOVE_RUN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSG_MOVE_SET_RUN_BACK_SPEED:
|
||||||
|
movetype = MOVE_WALKBACK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSG_MOVE_SET_SWIM_SPEED:
|
||||||
|
movetype = MOVE_SWIM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSG_MOVE_SET_SWIM_BACK_SPEED:
|
||||||
|
movetype = MOVE_SWIMBACK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSG_MOVE_SET_TURN_RATE:
|
||||||
|
movetype = MOVE_TURN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSG_MOVE_SET_FLIGHT_SPEED:
|
||||||
|
movetype = MOVE_FLY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSG_MOVE_SET_FLIGHT_BACK_SPEED:
|
||||||
|
movetype = MOVE_FLYBACK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
logerror("MSG_MOVE_SET speed change unkown case error, opcode %u !", recvPacket.GetOpcode());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
guid = recvPacket.GetPackedGuid();
|
||||||
|
recvPacket >> unk32;
|
||||||
|
recvPacket >> unk8;
|
||||||
|
recvPacket >> unk32; /* getMSTime()*/
|
||||||
|
recvPacket >> x >> y >> z >> o;
|
||||||
|
recvPacket >> unk32;
|
||||||
|
recvPacket >> speed;
|
||||||
|
|
||||||
|
Object *obj = objmgr.GetObj(guid);
|
||||||
|
if(obj && obj->IsUnit())
|
||||||
|
{
|
||||||
|
((Unit*)obj)->SetSpeed(movetype, speed);
|
||||||
|
((Unit*)obj)->SetPosition(x, y, z, o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldSession::_HandleForceSetSpeedOpcode(WorldPacket& recvPacket)
|
||||||
|
{
|
||||||
|
uint64 guid;
|
||||||
|
uint32 unk32, movetype;
|
||||||
|
float speed;
|
||||||
|
uint8 unk8;
|
||||||
|
|
||||||
|
switch(recvPacket.GetOpcode())
|
||||||
|
{
|
||||||
|
case SMSG_FORCE_WALK_SPEED_CHANGE:
|
||||||
|
movetype = MOVE_WALK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SMSG_FORCE_RUN_SPEED_CHANGE:
|
||||||
|
movetype = MOVE_RUN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SMSG_FORCE_RUN_BACK_SPEED_CHANGE:
|
||||||
|
movetype = MOVE_WALKBACK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SMSG_FORCE_SWIM_SPEED_CHANGE:
|
||||||
|
movetype = MOVE_SWIM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SMSG_FORCE_SWIM_BACK_SPEED_CHANGE:
|
||||||
|
movetype = MOVE_SWIMBACK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SMSG_FORCE_TURN_RATE_CHANGE:
|
||||||
|
movetype = MOVE_TURN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SMSG_FORCE_FLIGHT_SPEED_CHANGE:
|
||||||
|
movetype = MOVE_FLY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE:
|
||||||
|
movetype = MOVE_FLYBACK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
logerror("MSG_FORCE_ speed change unkown case error, opcode %u !", recvPacket.GetOpcode());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
guid = recvPacket.GetPackedGuid();
|
||||||
|
recvPacket >> unk32;
|
||||||
|
if (movetype == MOVE_RUN)
|
||||||
|
recvPacket >> unk8;
|
||||||
|
recvPacket >> speed;
|
||||||
|
|
||||||
|
Object *obj = objmgr.GetObj(guid);
|
||||||
|
if(obj && obj->IsUnit())
|
||||||
|
{
|
||||||
|
((Unit*)obj)->SetSpeed(movetype, speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WorldSession::_HandleTelePortAckOpcode(WorldPacket& recvPacket)
|
void WorldSession::_HandleTelePortAckOpcode(WorldPacket& recvPacket)
|
||||||
{
|
{
|
||||||
uint32 unk32,time;
|
uint32 unk32,time;
|
||||||
|
|||||||
@ -134,6 +134,8 @@ private:
|
|||||||
void _HandleMessageChatOpcode(WorldPacket& recvPacket);
|
void _HandleMessageChatOpcode(WorldPacket& recvPacket);
|
||||||
void _HandleNameQueryResponseOpcode(WorldPacket& recvPacket);
|
void _HandleNameQueryResponseOpcode(WorldPacket& recvPacket);
|
||||||
void _HandleMovementOpcode(WorldPacket& recvPacket);
|
void _HandleMovementOpcode(WorldPacket& recvPacket);
|
||||||
|
void _HandleSetSpeedOpcode(WorldPacket& recvPacket);
|
||||||
|
void _HandleForceSetSpeedOpcode(WorldPacket& recvPacket);
|
||||||
void _HandlePongOpcode(WorldPacket& recvPacket);
|
void _HandlePongOpcode(WorldPacket& recvPacket);
|
||||||
void _HandleTradeStatusOpcode(WorldPacket& recvPacket);
|
void _HandleTradeStatusOpcode(WorldPacket& recvPacket);
|
||||||
void _HandleGroupInviteOpcode(WorldPacket& recvPacket);
|
void _HandleGroupInviteOpcode(WorldPacket& recvPacket);
|
||||||
|
|||||||
@ -495,10 +495,19 @@ bool ConvertDBC(void)
|
|||||||
// TODO: add check for wmo model files ?
|
// TODO: add check for wmo model files ?
|
||||||
if(doModels)
|
if(doModels)
|
||||||
modelNames.insert(NameAndAlt(value)); // we need to extract model later, store it
|
modelNames.insert(NameAndAlt(value)); // we need to extract model later, store it
|
||||||
|
|
||||||
std::string fn = _PathToFileName(value);
|
std::string fn = _PathToFileName(value);
|
||||||
if(stricmp(fn.c_str()+fn.length()-4, "mdx"))
|
if(stricmp(fn.c_str()+fn.length()-4, "mdx"))
|
||||||
fn = fn.substr(0,fn.length()-3) + "m2";
|
fn = fn.substr(0,fn.length()-3) + "m2";
|
||||||
GameObjectDisplayInfoStorage[id].push_back(std::string(GameObjectDisplayInfoFieldNames[field]) + "=" + fn);
|
GameObjectDisplayInfoStorage[id].push_back(std::string(GameObjectDisplayInfoFieldNames[field]) + "=" + fn);
|
||||||
|
|
||||||
|
std::string texture = value.substr(0,value.length()-3) + "blp";
|
||||||
|
if (mpq.FileExists((char*)texture.c_str()))
|
||||||
|
{
|
||||||
|
if(doTextures)
|
||||||
|
texNames.insert(NameAndAlt(texture));
|
||||||
|
GameObjectDisplayInfoStorage[id].push_back("texture=" + NormalizeFilename(texture));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -943,7 +952,7 @@ void FetchTexturesFromModel(ByteBuffer& bb)
|
|||||||
|
|
||||||
bb.read((uint8*)&header, sizeof(header));
|
bb.read((uint8*)&header, sizeof(header));
|
||||||
|
|
||||||
if (header.version[0] != 4 || header.version[1] != 1 || header.version[2] != 0 || header.version[3] != 0) {
|
if ((header.version[0] < 4 || header.version[0] > 7) || header.version[1] != 1 || header.version[2] != 0 || header.version[3] != 0) {
|
||||||
//printf("Not M2 model file!");
|
//printf("Not M2 model file!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user