• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

powermanager.mac

Fenix8452

Member
Joined
Sep 2, 2006
RedCents
101¢
Ok, not sure if its intentional or not, but right now power sources are only draining while NOT in active combat. Me, I'm kinda lazy and generally forget to pull my power sources out when I go afk or am tweaking my UI or any number of stupid things I do.

I remember at one point someone asking about some plugin that manages power supplies and only leaves them equipped while in combat to extend the life. This sounded easy enough to me, so I wrote a VERY ugly and quick macro to do the same thing... sorta.

Anyway, there is is.

Rich (BB code):
|PowerManager.mac
|Author: Fenix
|(10-27-08)		First version and attempt
|
|
|	Ideally, this should swap out the power supply indicated in the variables into place only
|while actually in combat, to prevent the burnout of a power supply.  As of right now in the game
|a power supply only drains while OUT of combat, so if this is used correctly it should make a single
|power supply last exponentially longer than it would if just left plugged in.

|This REQUIRES the use of the mq2exchange plugin.

#turbo
#Event InCombat			"Auto attack is on."
#Event OutOfCombat		"Auto attack is off."
#Event EXP				"You gain experience#*#"
#Event EXP				"You gain party experience#*#"
#Event EXP				"You gain raid experience#*#"

Sub Main

|Edit this to reflect the name of the power supply you want to use, spelling is important
/declare PowerSupply	string	outer	Translucent Energeian Elemental Orb


/declare incombat		bool	outer	FALSE

:Start

/doevents
/call InstallPower
/delay 2s
/goto :Start
/return

Sub InstallPower
/if (${incombat}) {
	/squelch /exchange "${PowerSupply}" powersource
}
/if (!${incombat}) {
	/squelch /unequip powersource
}
/return

Sub Event_EXP
/if (${Me.Combat}) /varset incombat TRUE
/if (!${Me.Combat}) /varset incombat FALSE
/return

Sub Event_InCombat
/varset incombat TRUE
/return

Sub Event_OutOfCombat
/varset incombat FALSE
/return

I do intend on improving this quite a bit, and I fully realize that its coded like complete crap. The point is, I play a melee character, and I solo alot, and this works extremely well for that. I put in a delay only so it didn't try to eat the CPU alive, not sure if its really needed or not.

Ideally, this works in a group and should work in a raid environment. I can just run it in the background and simply play as I normally would. I've run this as long as 3 hours without it going wrong.

Some bugs I do have so far, I carry two power sources of the same name, and it will continuosly swap them for some reason if thats the case. Not sure if thats noticable at all to any authority figure.

Is there a better way to detect if the player is in combat? The Me.Combat function only seems to return true if auto attack is on, not when something is agro on the character. If I could figure out a better way to detecting that, this would be more useful for pure casters that are unlikely to ever melee.

Right now, as is, this effectively drains a power source for a max of 2 seconds for every kill the player engages in, and should average 1 second. Since my drain rate is only 5 per second, this will retain my single power supply that I got for 10 orux for 200,000 total kills, roughly, if I kept this running all the time.

Thoughts?
 
Nice mac Fenix, Thanks

This as a plugin would be the cats ass. - Id swear there was one (didint work well for casters if I can remember right because melee is never on) but cant find any remnants of it. --CURSES SEARCH-- Maybe I was toking too much back then too so might have been a dream.

.....Edit.....

Might not have made the shift over from redguides..That makes more sense..I'm gonna stick with that.
 
If I can wrap my head around it, I might attempt to make this an actual plugin. I'll have to brush up on my C++ skills, but the concept really isn't that hard. Its more that I seem to have smoked away my ability to recall how to compile properly. The code is honestly the easier part for me.
 
Either at redguides or mmobugs somebody had made a powersource manager plugin based on my original tribute manager plugin.

Unfortunately, I haven't had the time to maintain that plugin with wife and work (although it's tempting to fix it now that they fixed the tribute value of Mass Enchant Silver).

Here's the latest source I could find to tribute manager (which most likely doesn't compile with current MQ2) if you want to use it as a starting point.

Rich (BB code):
// MQ2TributeManager.cpp : Defines the entry point for the DLL application.
//

// MQ2TributeManager
// Manages tribute for you based on combat status
// Author: alt228

#include "../MQ2Plugin.h"

enum TributeMode
{
	TributeMode_Manual,
	TributeMode_Auto,
	TributeMode_OffWhenExpired,
	TributeMode_Unused
};

enum CombatState
{
	CombatState_COMBAT,
	CombatState_DEBUFFED,
	CombatState_COOLDOWN,
	CombatState_ACTIVE,
	CombatState_RESTING
};

PreSetup("MQ2TributeManager");

//defaults
TributeMode mode = TributeMode_Manual;
int tributeFudge = 2000;

VOID SetTributeStatus(bool tributeOn)
{
	if( tributeOn )
	{
		if( !(bool)*pTributeActive )
		{
			DebugSpewAlways("MQ2TributeManager::Turning on tribute");
			DoCommand( (PSPAWNINFO)pCharSpawn, "/notify TributeBenefitWnd DowngradeButton leftmouseup" );
		}
	}
	else
	{
		if( (bool)*pTributeActive )
		{
			DebugSpewAlways("MQ2TributeManager::Turning off tribute");
			DoCommand( (PSPAWNINFO)pCharSpawn, "/notify TributeBenefitWnd DowngradeButton leftmouseup" );
		}
	}
}

VOID TributeManagerCmd(PSPAWNINFO characterSpawn, PCHAR line)
{
	bool syntaxError = false;
	if (line[0]==0)
	{
		syntaxError = true;
	}
	
	bool setMode = false;
	TributeMode newMode = TributeMode_Unused;

	bool setStatus = false;
	bool newStatus = true;

	bool showStatus = false;

    CHAR thisArg[MAX_STRING] = {0};
	int argNumber = 1;
	bool moreArgs = true;

	while(moreArgs && argNumber<10 )
	{
		DebugSpewAlways("MQ2TributeManager:: GetArg(%i)", argNumber);
		GetArg(thisArg,line,argNumber);
		argNumber++;

	
		if( !thisArg || (strlen(thisArg)==0) )
		{
			moreArgs = false;
		}
		else if(stricmp(thisArg,"on") == 0)
		{
			setStatus = true;
			newStatus = true;
		}
		else if(stricmp(thisArg,"off") == 0)
		{
			setMode = true;
			newMode = TributeMode_OffWhenExpired;
		}
		else if(stricmp(thisArg,"forceoff") == 0)
		{
			setStatus = true;
			newStatus = false;
			setMode = true;
			newMode = TributeMode_Manual;
		}
		else if(stricmp(thisArg,"auto") == 0)
		{
			setMode = true;
			newMode = TributeMode_Auto;
		}
		else if(stricmp(thisArg,"manual") == 0)
		{
			setMode = true;
			newMode = TributeMode_Manual;
		}
		else if(stricmp(thisArg,"show") == 0)
		{
			showStatus = true;
		}
		else
		{
			syntaxError = true;
		}
	}

	if( syntaxError )
	{
		SyntaxError("Usage: /tribute <auto|manual|on|off|forceoff|show>");
		return;
	}

	if( setStatus )
	{
		SetTributeStatus(newStatus);
	}

	if( setMode )
	{
		mode = newMode;
	}

	if( showStatus )
	{
		if( mode == TributeMode_Manual )
		{
			WriteChatColor("Tribute mode: manual");
		}
		else if( mode == TributeMode_Auto )
		{
			WriteChatColor("Tribute mode: automatic");
		}
		else if( mode == TributeMode_OffWhenExpired )
		{
			WriteChatColor("Tribute mode: off when expired");
		}

		if( gGameState == GAMESTATE_INGAME )
		{
			DebugSpewAlways("MQ2TributeManager:: Active Favor Cost: %i", pEQMisc->GetActiveFavorCost());
			DebugSpewAlways("MQ2TributeManager:: Combat State: %i", (CombatState)((PCPLAYERWND)pPlayerWnd)->CombatState);
			DebugSpewAlways("MQ2TributeManager:: Tribute Active: %i", *pTributeActive);
			DebugSpewAlways("MQ2TributeManager:: Current Favor: %i", GetCharInfo()->CurrFavor);
			DebugSpewAlways("MQ2TributeManager:: Tribute Timer: %i ms", GetCharInfo()->TributeTimer);
		}
	}


}

// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
	DebugSpewAlways("Initializing MQ2TributeManager");
	AddCommand("/tribute",TributeManagerCmd);
}

// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
	DebugSpewAlways("Shutting down MQ2TributeManager");
	RemoveCommand("/tribute");
}


// This is called every time MQ pulses
PLUGIN_API VOID OnPulse(VOID)
{
	if( gGameState != GAMESTATE_INGAME )
	{
		return;
	}

	if( mode == TributeMode_Auto )
	{
		CombatState combatState = (CombatState)((PCPLAYERWND)pPlayerWnd)->CombatState;
		bool inCombat = false;
		if( combatState == CombatState_COMBAT )
		{
			inCombat = true;
		}

		int activeFavorCost = pEQMisc->GetActiveFavorCost();
		PCHARINFO myCharInfo = GetCharInfo();

		if( (inCombat) && (!*pTributeActive) && (activeFavorCost <= myCharInfo->CurrFavor) && (pEQMisc->GetActiveFavorCost() > 0) )
		{
			//activate tribute
			SetTributeStatus(true);
		}
		else if( (!inCombat) && (*pTributeActive) && (myCharInfo->TributeTimer < tributeFudge) )
		{
			SetTributeStatus(false);
		}
	}
	else if( mode == TributeMode_OffWhenExpired )
	{
		if( (bool)*pTributeActive == false )
		{
			mode = TributeMode_Manual;
			return;
		}

		if( GetCharInfo()->TributeTimer < tributeFudge )
		{
			mode = TributeMode_Manual;
			SetTributeStatus(false);
		}

	}

}
 
A very big thank you, I will use it as a starting point and see if I can muddle through it a bit. Now I guess I'm off to find a quick and dirty tutorial of how to properly compile and see if I can dig but my tools I had for it.

redcent incoming!
 
powermanager.mac

Users who are viewing this thread

Back
Top
Cart