[VC | III]Add weapon spawn for peds
This commit is contained in:
parent
f042cced9a
commit
87b63204e2
@ -228,17 +228,26 @@ void PedPage::SpawnPed(std::string& cat, std::string& name, std::string& model)
|
|||||||
ped->m_nPedFlags.bPedIsBleeding = m_Spawner.m_bPedBleed;
|
ped->m_nPedFlags.bPedIsBleeding = m_Spawner.m_bPedBleed;
|
||||||
ped->m_nWeaponAccuracy = m_Spawner.m_nAccuracy;
|
ped->m_nWeaponAccuracy = m_Spawner.m_nAccuracy;
|
||||||
ped->m_fHealth = m_Spawner.m_nPedHealth;
|
ped->m_fHealth = m_Spawner.m_nPedHealth;
|
||||||
#ifdef GTASA
|
|
||||||
if (m_Spawner.m_nWeaponId != 0)
|
if (m_Spawner.m_nWeaponId != 0)
|
||||||
{
|
{
|
||||||
int model = 0;
|
int model = 0;
|
||||||
|
#ifdef GTASA
|
||||||
Command<Commands::GET_WEAPONTYPE_MODEL>(m_Spawner.m_nWeaponId, &model);
|
Command<Commands::GET_WEAPONTYPE_MODEL>(m_Spawner.m_nWeaponId, &model);
|
||||||
|
#else
|
||||||
|
model = static_cast<int>(m_Spawner.m_nWeaponId);
|
||||||
|
m_Spawner.m_nWeaponId = weaponPage.GetWeaponType(model);
|
||||||
|
#endif
|
||||||
CStreaming::RequestModel(model, PRIORITY_REQUEST);
|
CStreaming::RequestModel(model, PRIORITY_REQUEST);
|
||||||
CStreaming::LoadAllRequestedModels(false);
|
CStreaming::LoadAllRequestedModels(false);
|
||||||
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, m_Spawner.m_nWeaponId, 999);
|
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, m_Spawner.m_nWeaponId, 999);
|
||||||
}
|
|
||||||
|
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(model);
|
||||||
|
#ifdef GTA3
|
||||||
|
Command<Commands::SET_CURRENT_PLAYER_WEAPON>(0, weaponType);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PedPage::Draw()
|
void PedPage::Draw()
|
||||||
|
@ -143,17 +143,19 @@ static void ClearPlayerWeapon(eWeaponType weaponType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WeaponPage::GetWeaponModel(eWeaponType weaponType)
|
||||||
|
{
|
||||||
|
int rtn = CallAndReturn<int, BY_GAME(NULL, 0x4418B0, 0x430690)>(weaponType); // int __cdecl CPickups::ModelForWeapon(int a1)
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
// Implementation of opcode 0x605 (CLEO)
|
// Implementation of opcode 0x605 (CLEO)
|
||||||
static eWeaponType GetWeaponTypeFromModel(int model)
|
eWeaponType WeaponPage::GetWeaponType(int model)
|
||||||
{
|
{
|
||||||
eWeaponType weaponType = WEAPONTYPE_UNARMED;
|
eWeaponType weaponType = WEAPONTYPE_UNARMED;
|
||||||
|
|
||||||
for (size_t i = 0; i < 37; i++)
|
for (size_t i = 0; i < 37; i++)
|
||||||
{
|
{
|
||||||
|
if (GetWeaponModel(static_cast<eWeaponType>(i)) == model)
|
||||||
int temp = CallAndReturn<int, BY_GAME(NULL, 0x4418B0, 0x430690)>(i); // int __cdecl CPickups::ModelForWeapon(int a1)
|
|
||||||
|
|
||||||
if (temp == model)
|
|
||||||
{
|
{
|
||||||
weaponType = (eWeaponType)i;
|
weaponType = (eWeaponType)i;
|
||||||
break;
|
break;
|
||||||
@ -217,7 +219,7 @@ void WeaponPage::GiveWeaponToPlayer(std::string& rootkey, std::string& name, std
|
|||||||
CStreaming::RequestModel(iModel, PRIORITY_REQUEST);
|
CStreaming::RequestModel(iModel, PRIORITY_REQUEST);
|
||||||
CStreaming::LoadAllRequestedModels(false);
|
CStreaming::LoadAllRequestedModels(false);
|
||||||
|
|
||||||
eWeaponType weaponType = GetWeaponTypeFromModel(iModel);
|
eWeaponType weaponType = GetWeaponType(iModel);
|
||||||
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, weaponType, m_nAmmoCount);
|
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, weaponType, m_nAmmoCount);
|
||||||
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(iModel);
|
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(iModel);
|
||||||
#ifdef GTA3
|
#ifdef GTA3
|
||||||
|
@ -58,6 +58,12 @@ public:
|
|||||||
void GiveWeaponToPlayer(std::string& weaponType);
|
void GiveWeaponToPlayer(std::string& weaponType);
|
||||||
#else
|
#else
|
||||||
void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name);
|
void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name);
|
||||||
|
|
||||||
|
// Returns weapon model from weaponType
|
||||||
|
int GetWeaponModel(eWeaponType weaponType);
|
||||||
|
|
||||||
|
// Returns weaponType from model
|
||||||
|
eWeaponType GetWeaponType(int weaponModel);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user