Last active
May 12, 2017 14:11
-
-
Save twist84/ae6619a7eb8293f22aa901459e0a6cc9 to your computer and use it in GitHub Desktop.
WeaponOffset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ModuleWeapon.hpp" | |
#include "../ElDorito.hpp" | |
#include "../Blam/BlamNetwork.hpp" | |
#include "../Blam/BlamObjects.hpp" | |
#include "../Blam/Math/RealVector3D.hpp" | |
#include "../Blam/Tags/Items/Weapon.hpp" | |
namespace | |
{ | |
bool VariableWeaponOffsetIUpdate(const std::vector<std::string>& Arguments, std::string& returnInfo) | |
{ | |
auto session = Blam::Network::GetActiveSession(); | |
if (!session || !session->IsEstablished()) | |
{ | |
returnInfo = "Not available: A game session is not active"; | |
return false; | |
} | |
using Blam::Math::RealVector3D; | |
using Blam::Tags::TagInstance; | |
using Blam::Tags::Items::Weapon; | |
auto offsetI = Modules::ModulePlayer::Instance().VarWeaponOffsetI->ValueFloat; | |
auto *weapon = TagInstance(0x151E).GetDefinition<Blam::Tags::Items::Weapon>(); | |
weapon->FirstPersonWeaponOffset.I = offsetI; | |
std::stringstream ss; | |
ss << "Set weapon offset I to " << offsetI; | |
returnInfo = ss.str(); | |
return true; | |
} | |
bool VariableWeaponOffsetJUpdate(const std::vector<std::string>& Arguments, std::string& returnInfo) | |
{ | |
auto session = Blam::Network::GetActiveSession(); | |
if (!session || !session->IsEstablished()) | |
{ | |
returnInfo = "Not available: A game session is not active"; | |
return false; | |
} | |
using Blam::Math::RealVector3D; | |
using Blam::Tags::TagInstance; | |
using Blam::Tags::Items::Weapon; | |
auto offsetJ = Modules::ModulePlayer::Instance().VarWeaponOffsetJ->ValueFloat; | |
auto *weapon = TagInstance(0x151E).GetDefinition<Blam::Tags::Items::Weapon>(); | |
weapon->FirstPersonWeaponOffset.J = offsetJ; | |
std::stringstream ss; | |
ss << "Set weapon offset J to " << offsetJ; | |
returnInfo = ss.str(); | |
return true; | |
} | |
bool VariableWeaponOffsetKUpdate(const std::vector<std::string>& Arguments, std::string& returnInfo) | |
{ | |
auto session = Blam::Network::GetActiveSession(); | |
if (!session || !session->IsEstablished()) | |
{ | |
returnInfo = "Not available: A game session is not active"; | |
return false; | |
} | |
using Blam::Math::RealVector3D; | |
using Blam::Tags::TagInstance; | |
using Blam::Tags::Items::Weapon; | |
auto offsetK = Modules::ModulePlayer::Instance().VarWeaponOffsetK->ValueFloat; | |
auto *weapon = TagInstance(0x151E).GetDefinition<Blam::Tags::Items::Weapon>(); | |
weapon->FirstPersonWeaponOffset.K = offsetK; | |
std::stringstream ss; | |
ss << "Set weapon offset k to " << offsetK; | |
returnInfo = ss.str(); | |
return true; | |
} | |
} | |
namespace Modules | |
{ | |
ModuleWeapon::ModuleWeapon() : ModuleBase("Weapon") | |
{ | |
VarWeaponOffsetI = AddVariableFloat("Offset.I", "weap_off_i", "The I offset", eCommandFlagsArchived, 0.0f, VariableWeaponOffsetIUpdate); | |
VarWeaponOffsetI->ValueFloatMin = -5.0f; | |
VarWeaponOffsetI->ValueFloatMax = 5.0f; | |
VarWeaponOffsetJ = AddVariableFloat("Offset.J", "weap_off_j", "The J offset", eCommandFlagsArchived, 0.0f, VariableWeaponOffsetJUpdate); | |
VarWeaponOffsetJ->ValueFloatMin = -5.0f; | |
VarWeaponOffsetJ->ValueFloatMax = 5.0f; | |
VarWeaponOffsetK = AddVariableFloat("Offset.K", "weap_off_k", "The K offset", eCommandFlagsArchived, 0.0f, VariableWeaponOffsetKUpdate); | |
VarWeaponOffsetK->ValueFloatMin = -5.0f; | |
VarWeaponOffsetK->ValueFloatMax = 5.0f; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ModuleBase.hpp" | |
namespace Modules | |
{ | |
class ModuleWeapon : public Utils::Singleton<ModuleWeapon>, public ModuleBase | |
{ | |
public: | |
Command* VarWeaponOffsetI; | |
Command* VarWeaponOffsetJ; | |
Command* VarWeaponOffsetK; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ModuleWeapon.hpp" | |
#include "../ElDorito.hpp" | |
#include "../Blam/BlamObjects.hpp" | |
#include "../Blam/Math/RealVector3D.hpp" | |
#include "../Blam/Tags/Tags.hpp" | |
#include "../Blam/Tags/TagInstance.hpp" | |
#include "../Blam/Tags/Items/Weapon.hpp" | |
using namespace Blam::Weapon; | |
namespace Patches | |
{ | |
namespace Weapon | |
{ | |
void ApplyAfterTagsLoaded() | |
{ | |
using Blam::Math::RealVector3D; | |
using Blam::Tags::TagInstance; | |
using Blam::Tags::Items::Weapon; | |
std::uint16_t weaponTagIndex = 0x151E; // 0x151E = tag index for Assault Rifle | |
auto *weapon = TagInstance(weaponTagIndex).GetDefinition<Blam::Tags::Items::Weapon>(); | |
weapon->FirstPersonWeaponOffset.I = Modules::ModulePlayer().VarWeaponOffsetI->ValueFloat; | |
weapon->FirstPersonWeaponOffset.J = Modules::ModulePlayer().VarWeaponOffsetJ->ValueFloat; | |
weapon->FirstPersonWeaponOffset.K = Modules::ModulePlayer().VarWeaponOffsetK->ValueFloat; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <string> | |
#include <vector> | |
namespace Patches | |
{ | |
namespace Weapon | |
{ | |
void ApplyAfterTagsLoaded(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment