P
Psycotic
UPDATE: Ok.. Make some significant changes to this. Added INI file with a few options, added the ability to change the range while in game, and to toggle it on and off without unloading. It now shrinks pets too (at the size specified in the INI file). It should load without crashing when you go to server/character select.. Added SKIP_PULSES so it will actually help with framerate issues if you multi-box. I think a few other changes, but can't think of 'em this late at night.
Any feedback is greatly appreciated.. Thanks!
Ok.. Here's my second plugin. Might come in useful on those cramped raids.. I want to add a list of non-shrinkable (i.e. for the MA/SA, etc) but haven't done that yet.. I'll see what I can do tonight.
And here's the MQ2AutoSize.ini file
Any feedback is greatly appreciated.. Thanks!
Ok.. Here's my second plugin. Might come in useful on those cramped raids.. I want to add a list of non-shrinkable (i.e. for the MA/SA, etc) but haven't done that yet.. I'll see what I can do tonight.
Rich (BB code):
// MQ2AutoSize.cpp : Automatically Shrink PC's within specific Range (Client Only!)
//
// version 0.9.4 (by Psycotic)
//
//////////////////////////////////////////////////////////////////////////////
// Usage:
// This plugin will automatically shrink everyone within range down to minimum
// allowed size. They will automatically resize back to normal when they move
// out of range. (Current range is set at 50' - adjust with Range settings in INI)
// NOTE: These effects are CLIENT SIDE ONLY!
//
// Commands:
// /autosize - Toggles AutoSizing on/off
// /autosizeall - Toggles AutoSizing for whole zone
// /autosize -range ## - Sets the range for AutoSize
//
// Known Issues/ToDo:
//
// - Add the ability to resize self (toggle)
//
//////////////////////////////////////////////////////////////////////////////
#include "../MQ2Plugin.h"
PreSetup("MQ2AutoSize");
#define SKIP_PULSES 5
long SkipPulse = 0;
long RANGE = 50;
bool AutoSizeOn=true;
bool AutoSizeAllOn=false;
bool ShrinkPets=true;
char ShrinkSize[MAX_STRING]="1";
char PetSize[MAX_STRING]="1";
char GrowSize[MAX_STRING]="0";
char psyTemp[MAX_STRING];
class SizeClass
{
public:
void SizeFunc(float);
};
// Offset: 1-18-2006
FUNCTION_AT_ADDRESS(void SizeClass::SizeFunc(float), 0x004C23DE );
VOID LoadConfig(VOID)
{
GetPrivateProfileString("Config","Range","NULL",psyTemp,MAX_STRING,INIFileName);
RANGE = atol(psyTemp);
GetPrivateProfileString("Config","Size","NULL",ShrinkSize,MAX_STRING,INIFileName);
GetPrivateProfileString("Config","PetSize","NULL",PetSize,MAX_STRING,INIFileName);
GetPrivateProfileString("Config","AutoSize",NULL,psyTemp,MAX_STRING,INIFileName);
if (!strcmp(psyTemp, "on"))
{
AutoSizeOn = true;
}
else
{
AutoSizeOn = false;
}
GetPrivateProfileString("Config","AutoSizeAll",NULL,psyTemp,MAX_STRING,INIFileName);
if (!strcmp(psyTemp, "on"))
{
AutoSizeAllOn = true;
}
else
{
AutoSizeAllOn = false;
}
GetPrivateProfileString("Config","ShrinkPets",NULL,psyTemp,MAX_STRING,INIFileName);
if (!strcmp(psyTemp, "on"))
{
ShrinkPets = false;
}
else
{
ShrinkPets = true;
}
}
VOID AutoSize(PSPAWNINFO pChar, PCHAR psyLine)
{
CHAR Arg1[MAX_STRING] = {0}; GetArg(Arg1,psyLine,1);
CHAR Arg2[MAX_STRING] = {0}; GetArg(Arg2,psyLine,2);
if ((!strcmp(Arg1, "-range")) && (strcmp(Arg2,"")))
{
RANGE = atoi(Arg2);
sprintf(psyTemp, "AutoSize: Range now set to %i", RANGE);
WriteChatColor(psyTemp, CONCOLOR_YELLOW);
}
else
if (AutoSizeOn)
{
AutoSizeOn = false;
WriteChatColor("AutoSize (Range) now disabled!", CONCOLOR_YELLOW);
}
else
{
AutoSizeOn = true;
AutoSizeAllOn = false;
WriteChatColor("AutoSize (Range) now enabled!", CONCOLOR_YELLOW);
WriteChatColor("AutoSize (AllZone) now disabled!", CONCOLOR_YELLOW);
}
}
VOID Size(PSPAWNINFO pChar, CHAR Size[MAX_STRING])
{
PSPAWNINFO Char = (PSPAWNINFO)pChar;
PSPAWNINFO pSpawn = (PSPAWNINFO)pSpawnList;
if ((strcmp(pChar->DisplayedName, GetCharInfo()->pSpawn->DisplayedName) != 0))
{
((SizeClass*)Char)->SizeFunc((float)atof(Size));
}
}
VOID ReSizeAll(CHAR DoSize[MAX_STRING], CHAR DoPetSize[MAX_STRING])
{
PSPAWNINFO pSpawn = (PSPAWNINFO)pSpawnList;
while (pSpawn)
{
if ((pSpawn->Type == SPAWN_PLAYER) && (pSpawn->Type != SPAWN_CORPSE))
{
Size(pSpawn, DoSize);
}
if ((GetSpawnType(pSpawn)==PET) && (!ShrinkPets))
{
Size(pSpawn, DoPetSize);
}
pSpawn = pSpawn->pNext;
}
}
VOID AutoSizeAll(PSPAWNINFO pChar, PCHAR psyLine)
{
if (AutoSizeAllOn)
{
AutoSizeAllOn = false;
ReSizeAll("0", "0");
WriteChatColor("AutoSize (AllZone) now disabled!", CONCOLOR_YELLOW);
}
else
{
AutoSizeAllOn = true;
AutoSizeOn = false;
WriteChatColor("AutoSize (AllZone) now enabled!", CONCOLOR_YELLOW);
WriteChatColor("AutoSize (Range) now disabled!", CONCOLOR_YELLOW);
ReSizeAll(ShrinkSize, PetSize);
}
}
PLUGIN_API VOID OnPulse(PSPAWNINFO pChar, PCHAR psyLine)
{
float Dist;
if (SkipPulse == SKIP_PULSES)
if ((!AutoSizeAllOn) && (gGameState==GAMESTATE_INGAME))
{
SkipPulse = 0;
PSPAWNINFO pSpawn = (PSPAWNINFO)pSpawnList;
while (pSpawn)
{
if ((pSpawn->Type == SPAWN_PLAYER) && (pSpawn->Type != SPAWN_CORPSE))
{
Dist = GetDistance(GetCharInfo()->pSpawn,pSpawn);
if ((Dist <= RANGE) && (AutoSizeOn))
{
Size(pSpawn, ShrinkSize);
}
else
{
if (Dist <= (RANGE+50))
{
Size(pSpawn, "0");
}
}
}
if ((GetSpawnType(pSpawn)==PET) && (!ShrinkPets))
{
Dist = GetDistance(GetCharInfo()->pSpawn,pSpawn);
if ((Dist <= RANGE) && (AutoSizeOn))
{
Size(pSpawn, PetSize);
}
else
{
if (Dist <= (RANGE+50))
{
Size(pSpawn, "0");
}
}
}
pSpawn = pSpawn->pNext;
}
}
SkipPulse++;
}
PLUGIN_API VOID InitializePlugin(VOID)
{
AddCommand("/autosize",AutoSize);
AddCommand("/autosizeall",AutoSizeAll);
sprintf(psyTemp, "AutoSize Loaded");
WriteChatColor(psyTemp, CONCOLOR_YELLOW);
LoadConfig();
}
PLUGIN_API VOID ShutdownPlugin(VOID)
{
RemoveCommand("/autosize");
RemoveCommand("/autosizeall");
ReSizeAll("0", "0");
}
Rich (BB code):
# "Range" is the radius in feet that will be shrunk
# "Size" is the size they will be shrunk down to
# "AutoSize" on = will shrink everyone within "Range"
# "AutoSizeAll" on = will shrink everyone in zone upon zone-in
# "ShrinkPets" = Toggle to shrink pets along with PC's
[Config]
Range=50
Size=2
PetSize=1
AutoSize=on
AutoSizeAll=off
ShrinkPets=on
Last edited:

