Raised This Month: $51 Target: $400
 12% 

FF2 [SOLVED] Help - How do I freely adjust the speed of my boss?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LordHotPocketHomicide
Member
Join Date: Aug 2016
Location: This Realm of Existence
Old 08-15-2020 , 14:39   [SOLVED] Help - How do I freely adjust the speed of my boss?
Reply With Quote #1

Edit: this issue has since been solved; turns out all I had to do was use SDKHooks' pre-think. Huge thanks to BatFoxKid for telling me about this.


(OLD) Hello again, folks. I've been studying SourcePawn on/off for a few months now, and recently, I decided I would write my first sub-plugin. Things have been going somewhat smoothly, but I cannot, for the life of me, figure out how to change the boss' max speed on the fly; despite all of my attempts, the plugin refuses to change the hale's speed. If anybody is willing to help, my source code is below. I've also been having slight problems with detecting when the hale uses rage.

Code:
#define DEBUG

#define PLUGIN_NAME           "zerofuse_modeswitch"
#define MODESWITCH			  "ff2_modeswitch"
#define PLUGIN_AUTHOR         "Lord ''HotPocket'' Homicide, with help from Nolo001"
#define PLUGIN_DESCRIPTION    "Early work; allows Zerofuse to switch between offensive and defensive states, with a special rage ability depending on which state he's in."
#define PLUGIN_VERSION        "1.0"
#define PLUGIN_URL            ""
#define MAXTF2PLAYERS 36

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <freak_fortress_2>
#include <tf2items>
#include <tf2_stocks>
#include <morecolors>
#include <ff2_dynamic_defaults>

#pragma semicolon 1

public Plugin myinfo =
{
	name = PLUGIN_NAME,
	author = PLUGIN_AUTHOR,
	description = PLUGIN_DESCRIPTION,
	version = PLUGIN_VERSION,
	url = PLUGIN_URL
};

int currentState = 0;
int zerofuse;
bool onCooldown = false;

public void OnPluginStart()
{
	HookEvent("arena_round_start", itBegins);
}

public void itBegins(Event hEvent, const char[] sEvName, bool bDontBroadcast)
{
	for(int client = 1; client <= MaxClients; client++)
	{
		if (IsValidClient(client) && FF2_GetBossIndex(client) != -1)
		{
			if (FF2_HasAbility(FF2_GetBossIndex(client), PLUGIN_NAME, MODESWITCH))
			{
				zerofuse = client;
				HookEvent("player_death", player_killed);
				AddCommandListener(zerofuse_rage, "+reload");
				SDKHook(zerofuse, SDKHook_OnTakeDamage, OnTakeDamage);
				currentState = 0;
				Menu zerofuse_menu = new Menu(modeswitch);
				zerofuse_menu.SetTitle("Use your demonic essence to change your form (30s Cooldown):");
				zerofuse_menu.AddItem("option1", "Wrath");
				zerofuse_menu.AddItem("option2", "Protection");
				zerofuse_menu.AddItem("option3", "Balance (No cooldown required)");
				zerofuse_menu.ExitButton = false;
				zerofuse_menu.Display(client, MENU_TIME_FOREVER);
				CreateTimer(5.0, zerofuseMenu, zerofuse_menu, TIMER_FLAG_NO_MAPCHANGE || TIMER_REPEAT);
			}
		}
	}
}
public modeswitch(Menu zerofuse_menu, MenuAction action, int client, int param)
{
	if (action == MenuAction_Select)
	{
		switch(param)
		{
			case 0:
			{
				if (onCooldown == false && currentState != 1)
				{
					CPrintToChatAll("{orange}[Zerofuse] {default}Zerofuse has entered a state of {red}wrath!");
					currentState = 1;
					TF2_RemoveAllWeapons(zerofuse);
					SetEntPropFloat(zerofuse, Prop_Send, "m_flMaxspeed", 440.0);
					TF2_AddCondition(zerofuse, TFCond_SpeedBuffAlly, 999.0, 0);
					FF2_SpawnWeapon(zerofuse, "tf_weapon_knife", 356, 99, 3, "2 ; 2.25 ; 107 ; 0.5 ; 326 ; 2.5 ; 67 ; 0.7 ; 65 ; 0.7 ; 206 ; 0.5 ; 252 ; 0.85", true);
					onCooldown = true;
					CreateTimer(30.0, cooldown, _, TIMER_FLAG_NO_MAPCHANGE);
				}
				else
				{
					CPrintToChat(zerofuse, "{orange}[Zerofuse]{default} You {red}cannot{default} currently switch to this mode.");
				}
				DisplayMenu(zerofuse_menu, zerofuse, MENU_TIME_FOREVER);		
			}
			case 1:
			{
				if (onCooldown == false && currentState != 2)
				{
					if (currentState == 1)
					{
						TF2_RemoveCondition(zerofuse, TFCond_SpeedBuffAlly);
					}
					SetEntPropFloat(zerofuse, Prop_Send, "m_flMaxspeed", 320.0);
					CPrintToChatAll("{orange}[Zerofuse] {default}Zerofuse has entered a {green}defensive{default} state!");
					currentState = 2;
					TF2_RemoveAllWeapons(zerofuse);
					FF2_SpawnWeapon(zerofuse, "tf_weapon_knife", 727, 77, 3, "252 ; 0.30 ; 60 ; 0.6 ; 62 ; 0.6 ; 64 ; 0.6 ; 66 ; 0.6", true);
					onCooldown = true;
					CreateTimer(30.0, cooldown, _, TIMER_FLAG_NO_MAPCHANGE);
				}
				else
				{
					CPrintToChat(zerofuse, "{orange}[Zerofuse]{default} You {red}cannot{default} currently switch to this mode.");
				}
				DisplayMenu(zerofuse_menu, zerofuse, MENU_TIME_FOREVER);
			}
			case 2:
			{
				if (currentState != 0)
				{
					if (currentState == 1)
					{
						TF2_RemoveCondition(zerofuse, TFCond_SpeedBuffAlly);
					}
					SetEntPropFloat(zerofuse, Prop_Send, "m_flMaxspeed", 370.0);
					CPrintToChatAll("{orange}[Zerofuse] {default}Zerofuse has entered a state of {blue}balance.");
					currentState = 0;
					TF2_RemoveAllWeapons(zerofuse);
					FF2_SpawnWeapon(zerofuse, "tf_weapon_knife", 4, 50, 3, "2 ; 1.75 ; 252 ; 0.5", true);
				}
				else
				{
					CPrintToChat(zerofuse, "{orange}[Zerofuse]{default} You {red}cannot{default} currently switch to this mode.");
				}
				DisplayMenu(zerofuse_menu, zerofuse, MENU_TIME_FOREVER);
			}
		}
	}
}

public Action zerofuse_rage(int client, const char[] command, int argc)
{
	int bossIndex = FF2_GetBossIndex(zerofuse);
	if (FF2_GetBossCharge(bossIndex, 0) == 100)
	{
		if (currentState == 2)
		{
			int liveReds = 0;
			for (liveReds = 0; client < MaxClients ; client++)
			{
				if (GetClientTeam(client) == 2)
				{
					liveReds++;
				}
			}
			int numHacked = 0;
			int hackTarget = GetRandomInt(1, MaxClients);
			for(int canBeHacked = (liveReds/4); numHacked < canBeHacked; hackTarget = GetRandomInt(1, MaxClients))
			{
				if (IsValidClient(hackTarget) && FF2_GetBossIndex(hackTarget) == -1)
				{
					ChangeClientTeam(hackTarget, 3);
					numHacked++;
				}
			}
		}
	}
}
public Action cooldown(Handle cooldownTimer, any data)
{
	onCooldown = false;
	return Plugin_Continue;
}

public Action zerofuseMenu(Handle zerofuseMenuCheck, Menu zerofuse_menu)
{
	DisplayMenu(zerofuse_menu, zerofuse, MENU_TIME_FOREVER);
	return Plugin_Continue;
}

public Action player_killed(Event hEvent, const char[] sEvName, bool bDontBroadcast)
{
	int victim = hEvent.GetInt("userid");
	if (FF2_GetBossIndex(victim) == -1 && currentState == 2)
	{
		FF2_SetBossHealth(0, (FF2_GetBossHealth(0)) + 1000);
	}
}

public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon,
        Float:damageForce[3], Float:damagePosition[3], damagecustom)
{
    if (victim > 0 && victim <= MaxClients && damagecustom == TF_CUSTOM_BACKSTAB)
    {
    	if (victim == zerofuse && currentState == 1)
    	{
    		TF2_AddCondition(attacker, TFCond_MarkedForDeath, 5.0, 0);
    		TF2_IgnitePlayer(attacker, zerofuse, 5.0);
    	}
        return Plugin_Continue;
    }
    return Plugin_Continue;
} 

stock bool IsValidClient(int client, bool replaycheck=true, bool onlyrealclients=true) //Function borrowed from Nolo001, credit goes to him.
{
	if(client<=0 || client>MaxClients)
	{
		return false;
	}

	if(!IsClientInGame(client))
	{
		return false;
	}

	if(GetEntProp(client, Prop_Send, "m_bIsCoaching"))
	{
		return false;
	}

	if(replaycheck)
	{
		if(IsClientSourceTV(client) || IsClientReplay(client))
		{
			return false;
		}
	}
	
	//if(onlyrealclients)                    Commented out for testing purposes
	//{
	//	if(IsFakeClient(client))
	//		return false;
	//}
	
	return true;
}
__________________
Professional retard. I might borrow some code, but I always try to give credit when I do! If you've noticed I've borrowed some of your code, and you have a problem with that, please add me on Steam and let me know so I can correct the problem as soon as possible!

Last edited by LordHotPocketHomicide; 08-16-2020 at 01:11. Reason: I found the solution.
LordHotPocketHomicide is offline
LordHotPocketHomicide
Member
Join Date: Aug 2016
Location: This Realm of Existence
Old 08-16-2020 , 01:08   Re: Help - How do I freely adjust the speed of my boss?
Reply With Quote #2

Problem solved! Turns out the secret ingredient was using SDKHooks' pre-think. Once I discovered that, I had things taken care of within 10 minutes.
__________________
Professional retard. I might borrow some code, but I always try to give credit when I do! If you've noticed I've borrowed some of your code, and you have a problem with that, please add me on Steam and let me know so I can correct the problem as soon as possible!
LordHotPocketHomicide is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode