Skip to content

Commit

Permalink
aeiou
Browse files Browse the repository at this point in the history
  • Loading branch information
visexual committed Sep 2, 2021
1 parent 15aaac2 commit f0bbfe4
Show file tree
Hide file tree
Showing 15 changed files with 316 additions and 16 deletions.
1 change: 1 addition & 0 deletions PackageScript
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ CopyFiles('gamedata/sigsegv', 'addons/sourcemod/gamedata/sigsegv',
'tfbot_locomotion.txt',
'tfbot_vision.txt',
'tfbot_behavior.txt',
'fugue.txt',
]
)

Expand Down
21 changes: 21 additions & 0 deletions gamedata/sigsegv/custom_attributes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1909,4 +1909,25 @@
"effect_type" "positive"
}

// this doesn't work :rage:
"4505"
{
"name" "custom canteen cond"
"attribute_class" "custom_canteen_cond"
//"attribute_type" "string"
"description_string" ""
"description_format" "value_is_additive"
"hidden" "1"
"effect_type" "positive"
"stored_as_integer" "1"
}
"4506"
{
"name" "can bhop"
"attribute_class" "can_bhop"
"description_string" "Can bunnyhop"
"description_format" "value_is_addtive"
"hidden" "1"
"effect_type" "positive"
}
}
56 changes: 56 additions & 0 deletions gamedata/sigsegv/fugue.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"Games" {
"#default" {
"#supported" {
engine "tf2"
}

"sigsegv" {
"addrs" {
"CTFPlayer::PlayerRunCommand" {
type "sym"
sym "_ZN9CTFPlayer16PlayerRunCommandEP8CUserCmdP11IMoveHelper"
}
"CTFPlayer::Regenerate" {
type "sym"
sym "_ZN9CTFPlayer10RegenerateEb"
}
"CTFGameMovement::PreventBunnyJumping" {
type "sym"
sym "_ZN15CTFGameMovement19PreventBunnyJumpingEv"
}
"CGameMovement::Accelerate" {
type "sym"
sym "_ZN13CGameMovement10AccelerateER6Vectorff"
}
"CGameMovement::AirAccelerate" {
type "sym"
sym "_ZN13CGameMovement13AirAccelerateER6Vectorff"
}
"CBaseCombatCharacter::SetAmmoCount" {
type "sym"
sym "_ZN20CBaseCombatCharacter12SetAmmoCountEii"
}
"CTFPowerupBottle::Use" {
type "sym"
sym "_ZN16CTFPowerupBottle3UseEv"
}
"CTFPowerupBottle::AllowedToUse" {
type "sym"
sym "_ZN16CTFPowerupBottle12AllowedToUseEv"
}
"CTFPowerupBottle::GetNumCharges" {
type "sym"
sym "_ZNK16CTFPowerupBottle13GetNumChargesEv"
}
"CTFPowerupBottle::SetNumCharges" {
type "sym"
sym "_ZN16CTFPowerupBottle13SetNumChargesEh"
}
"CTFGameRules::CanUpgradeWithAttrib" {
type "sym"
sym "_ZN12CTFGameRules20CanUpgradeWithAttribEP9CTFPlayeritP22CMannVsMachineUpgrades"
}
}
}
}
}
1 change: 1 addition & 0 deletions src/gameconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static const char *const configs[] = {
"sigsegv/debugoverlay",
"sigsegv/client",
"sigsegv/convars",
"sigsegv/fugue",
nullptr,
};

Expand Down
90 changes: 86 additions & 4 deletions src/mod/attr/custom_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,26 @@ namespace Mod::Attr::Custom_Attributes
return ret;
}

DETOUR_DECL_MEMBER(void, CTFPlayer_PlayerRunCommand, CUserCmd* cmd, IMoveHelper* moveHelper)
{
CTFPlayer* player = reinterpret_cast<CTFPlayer*>(this);
int bunnyhop = 0;
CALL_ATTRIB_HOOK_INT_ON_OTHER(player, bunnyhop, can_bhop);
if(!bunnyhop){
CTFWeaponBase* weapon = player->GetActiveTFWeapon();
if(weapon){
CALL_ATTRIB_HOOK_INT_ON_OTHER(weapon, bunnyhop, can_bhop);
}
}
if(bunnyhop && player->IsAlive() && (cmd->buttons & 2) /*&& (player->GetFlags() & 1) */ && (player->GetGroundEntity() == nullptr)){
// Vector velocity = player->GetAbsVelocity();
// velocity.z = 267.0;
// player->SetAbsVelocity(velocity);
cmd->buttons &= ~2;
}
DETOUR_MEMBER_CALL(CTFPlayer_PlayerRunCommand)(cmd, moveHelper);
}

struct CustomModelEntry
{
CHandle<CTFWeaponBase> weapon;
Expand Down Expand Up @@ -1594,15 +1614,26 @@ namespace Mod::Attr::Custom_Attributes
bool entityme_player = entityme->IsPlayer();
bool entityhit_player = entityhit->IsPlayer();

if (!entityme_player || (!entityhit_player && !entityhit->IsBaseObject()))
int not_solid = 0;
CALL_ATTRIB_HOOK_INT_ON_OTHER( entityme, not_solid, not_solid_to_players);

if (!entityme_player || ((not_solid != 2) && !entityhit_player && !entityhit->IsBaseObject()))
return true;

if ((not_solid == 2) && (
!strcmp(entityhit->GetClassname(), "obj_sentrygun") ||
!strcmp(entityhit->GetClassname(), "obj_dispenser") ||
!strcmp(entityhit->GetClassname(), "obj_teleporter")
)){
return true;
}

bool me_collide = true;
bool hit_collide = true;

auto entry = should_hit_entity_cache.find(entityme);
if (entry == should_hit_entity_cache.end()) {
int not_solid = 0;
not_solid = 0;
CALL_ATTRIB_HOOK_INT_ON_OTHER( entityme, not_solid, not_solid_to_players);
me_collide = not_solid == 0;
should_hit_entity_cache[entityme] = me_collide;
Expand All @@ -1617,7 +1648,7 @@ namespace Mod::Attr::Custom_Attributes
if (entityhit_player) {
auto entry = should_hit_entity_cache.find(entityhit);
if (entry == should_hit_entity_cache.end()) {
int not_solid = 0;
not_solid = 0;
CALL_ATTRIB_HOOK_INT_ON_OTHER( entityhit, not_solid, not_solid_to_players);
hit_collide = not_solid == 0;
should_hit_entity_cache[entityhit] = hit_collide;
Expand Down Expand Up @@ -3052,11 +3083,62 @@ namespace Mod::Attr::Custom_Attributes
OnAttributesChange(mgr);
}*/

THINK_FUNC_DECL(AfterUsedCanteen)
{
reinterpret_cast<CTFPowerupBottle*>(this)->m_bActive = false;
}

DETOUR_DECL_MEMBER(bool, CTFPowerupBottle_Use)
{
bool ret = DETOUR_MEMBER_CALL(CTFPowerupBottle_Use)();
DevMsg("do");
if(!ret){
CTFPowerupBottle* canteen = reinterpret_cast<CTFPowerupBottle*>(this);
int cond = 0;
CALL_ATTRIB_HOOK_INT_ON_OTHER(canteen, cond, custom_canteen_cond);
DevMsg("cond: %d", cond);
if((cond != 0) && !canteen->m_bActive && (canteen->GetNumCharges() > 0) && canteen->AllowedToUse()){
// can't be bothered setting up refunds
float duration = 0;
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER(canteen, duration, powerup_duration);
DevMsg("duration: %f", duration);
CTFPlayer* player = ToTFPlayer(canteen->GetOwnerEntity());
int extra = 0;
if(!player){
DevMsg("non null player");
CALL_ATTRIB_HOOK_INT_ON_OTHER(player, extra, canteen_specialist);
// or stranges
player->m_Shared->AddCond((ETFCond)cond, duration + extra, player);
CWeaponMedigun* medigun = NULL;
CTFPlayer* target = NULL;
if(player->IsPlayerClass(TF_CLASS_MEDIC)){
medigun = dynamic_cast<CWeaponMedigun*>(player->GetActiveWeapon());
if(medigun){
target = ToTFPlayer( medigun->GetHealTarget() );
if (target){
target->m_Shared->AddCond((ETFCond)cond, duration + extra, player);
}
}
}

}
canteen->SetNumCharges(canteen->GetNumCharges() - 1);
canteen->m_bActive = true;
THINK_FUNC_SET(canteen, AfterUsedCanteen, gpGlobals->curtime + duration + extra);
DevMsg("done");
ret = true;
}
}
return ret;
}

class CMod : public IMod, public IModCallbackListener, public IFrameUpdatePostEntityThinkListener
{
public:
CMod() : IMod("Attr:Custom_Attributes")
{
MOD_ADD_DETOUR_MEMBER(CTFPlayer_PlayerRunCommand, "CTFPlayer::PlayerRunCommand");
MOD_ADD_DETOUR_MEMBER(CTFPowerupBottle_Use, "CTFPowerupBottle::Use");
MOD_ADD_DETOUR_MEMBER(CTFPlayer_CanAirDash, "CTFPlayer::CanAirDash");
MOD_ADD_DETOUR_MEMBER(CWeaponMedigun_AllowedToHealTarget, "CWeaponMedigun::AllowedToHealTarget");
MOD_ADD_DETOUR_MEMBER(CWeaponMedigun_HealTargetThink, "CWeaponMedigun::HealTargetThink");
Expand Down Expand Up @@ -3364,4 +3446,4 @@ namespace Mod::Attr::Custom_Attributes
[](IConVar *pConVar, const char *pOldValue, float flOldValue){
s_Mod.Toggle(static_cast<ConVar *>(pConVar)->GetBool());
});
}
}
12 changes: 12 additions & 0 deletions src/mod/etc/mapentity_additions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,18 @@ namespace Mod::Etc::Mapentity_Additions
}
return true;
}
else if (stricmp(szInputName, "$RefillAmmo") == 0) {
CTFPlayer* player = ToTFPlayer(ent);
for(int i = 0; i < 7; ++i){
player->SetAmmoCount(player->GetMaxAmmo(i), i);
}
return true;
}
else if(stricmp(szInputName, "$Regenerate") == 0){
CTFPlayer* player = ToTFPlayer(ent);
player->Regenerate(true);
return true;
}
}
else if (ent->GetClassname() == point_viewcontrol_classname) {
if (stricmp(szInputName, "$EnableAll") == 0) {
Expand Down
52 changes: 48 additions & 4 deletions src/mod/mvm/extended_upgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "stub/tfweaponbase.h"
#include "stub/econ.h"
#include "stub/gamerules.h"
#include "stub/misc.h"
#include "util/iterate.h"
#include "util/misc.h"
#include "mod/pop/common.h"
Expand All @@ -11,6 +12,10 @@
#include "stub/strings.h"
#include "stub/tf_objective_resource.h"

namespace Mod::Pop::PopMgr_Extensions {
bool ExtendedUpgradesNoUndo();
}

namespace Mod::MvM::Extended_Upgrades
{

Expand Down Expand Up @@ -128,6 +133,9 @@ namespace Mod::MvM::Extended_Upgrades
int allow_wave_max = 9999;
std::string required_weapons_string = "";
bool show_requirements = true;
//std::string on_upgrade_output = "";
std::map<std::string, float> on_upgrade_outputs = {};
bool force_enable = false;
};

std::vector<UpgradeInfo *> upgrades;
Expand Down Expand Up @@ -214,7 +222,7 @@ namespace Mod::MvM::Extended_Upgrades
int upgrade_id = strtol(info, nullptr, 10);
if (upgrade_id < 1000)
BuyUpgrade(upgrades[upgrade_id], this->slot, this->player, false, false);
else if (upgrade_id == 1000) {
else if ((upgrade_id == 1000) && (!Mod::Pop::PopMgr_Extensions::ExtendedUpgradesNoUndo())) {
DevMsg("Undoing %d %d\n", extended_upgrades_start_index, CMannVsMachineUpgradeManager::Upgrades().Count());
for (int i = extended_upgrades_start_index; i < CMannVsMachineUpgradeManager::Upgrades().Count(); i++) {
int cur_step;
Expand Down Expand Up @@ -290,6 +298,12 @@ namespace Mod::MvM::Extended_Upgrades
}
}

void Parse_OnUpgradeOutputs(KeyValues* kv, std::map<std::string, float>& outputs){
FOR_EACH_SUBKEY(kv, subkey) {
outputs[subkey->GetName()] = subkey->GetFloat();
}
}

int GetSlotFromString(const char *string) {
int slot = -1;
if (V_stricmp(string, "Primary") == 0)
Expand Down Expand Up @@ -424,6 +438,13 @@ namespace Mod::MvM::Extended_Upgrades
}
}
}
else if (FStrEq(subkey2->GetName(), "OnUpgrade")) {
//upgradeinfo->on_upgrade_output = subkey2->GetString();
Parse_OnUpgradeOutputs(subkey2, upgradeinfo->on_upgrade_outputs);
}
else if (FStrEq(subkey2->GetName(), "ForceEnable")) {
upgradeinfo->force_enable = true;
}
}

if (upgradeinfo->attributeDefinition == nullptr) {
Expand Down Expand Up @@ -704,6 +725,27 @@ namespace Mod::MvM::Extended_Upgrades
g_hUpgradeEntity->PlayerPurchasingUpgrade(player, override_slot, attr, downgrade, true, false);
}
from_buy_upgrade_free = false;
//if(upgrade->on_upgrade_output != ""){
for(const auto& [output, delay] : upgrade->on_upgrade_outputs){
char param_tokenized[2048] = "";
V_strncpy(param_tokenized, output.c_str(), sizeof(param_tokenized));
if(strcmp(param_tokenized, "") != 0){
char *target = strtok(param_tokenized,",");
char *action = NULL;
char *value = NULL;
if(target != NULL)
action = strtok(NULL,",");
if(action != NULL)
value = strtok(NULL,"");
if(value != NULL){
CEventQueue &que = g_EventQueue;
variant_t actualvalue;
string_t stringvalue = AllocPooledString(value);
actualvalue.SetString(stringvalue);
que.AddEvent(STRING(AllocPooledString(target)), STRING(AllocPooledString(action)), actualvalue, delay, player, player, -1);
}
}
}
}
//if (!free)
// player->RemoveCurrency(cost);
Expand Down Expand Up @@ -735,6 +777,7 @@ namespace Mod::MvM::Extended_Upgrades
auto upgrade = upgrades[i];
char disabled_reason[255] = "";
bool enabled = IsValidUpgradeForWeapon(upgrade, item, player, disabled_reason, sizeof(disabled_reason));
if (upgrade->force_enable) enabled = true;
if (enabled) {
int cur_step;
bool over_cap;
Expand Down Expand Up @@ -777,9 +820,10 @@ namespace Mod::MvM::Extended_Upgrades
}
}

ItemDrawInfo info1("Undo upgrades");
menu->AppendItem("1000", info1);

if(!Mod::Pop::PopMgr_Extensions::ExtendedUpgradesNoUndo()){
ItemDrawInfo info1("Undo upgrades");
menu->AppendItem("1000", info1);
}
/*if (upgrades.size() == 1) {
ItemDrawInfo info1(" ", ITEMDRAW_NOTEXT);
menu->AppendItem(" ", info1);
Expand Down
Loading

0 comments on commit f0bbfe4

Please sign in to comment.