Whilst playing with MQ2 I noticed that the spawn captions were not always the mq captions (aka the one with con colors, LDR, etc...) but would change once brought within a certain range. After searching in vain for a simple fix i dove into the code. I found that the distance at which the captions update was hard coded at 80.0f... about half of the distance from when the captions fade in. So i decided to fix it :) At first I hacked the numbers and recompiled and tested settings but then i decided to make it better. In other words, allow the user to customize the distance at which it updates the MQCaptions.
So... Here's what i changed in my build:
I understand i include a larger section of code than i changed i just want to keep the chunks intact so there's no confusion as to what i changed.
<In MQ2Spawns.cpp>(@line 537)
Change:
Code: Select all
VOID UpdateSpawnCaptions()
{
// DebugSpew("UpdateSpawnCaptions()");
DWORD N;
DWORD Count=0;
for (N = 0 ; N < 120 ; N++)
{
if (PSPAWNINFO pSpawn=(PSPAWNINFO)EQP_DistArray[N].VarPtr.Ptr)
if (pSpawn!=(PSPAWNINFO)pTarget)
if (EQP_DistArray[N].Value.Float <=80.0f && gMQCaptions)
{
if (SetNameSpriteState(pSpawn,true))
{
SetNameSpriteTint(pSpawn);
Count++;
if (Count>=gMaxSpawnCaptions)
{
return;
}
}
}
else
{
return;
}
}
}
Code: Select all
VOID UpdateSpawnCaptions()
{
// DebugSpew("UpdateSpawnCaptions()");
DWORD N;
DWORD Count=0;
for (N = 0 ; N < 120 ; N++)
{
if (PSPAWNINFO pSpawn=(PSPAWNINFO)EQP_DistArray[N].VarPtr.Ptr)
if (pSpawn!=(PSPAWNINFO)pTarget)
if (EQP_DistArray[N].Value.Float <=(float)gSpawnCaptionDistance && gMQCaptions)
{
if (SetNameSpriteState(pSpawn,true))
{
SetNameSpriteTint(pSpawn);
Count++;
if (Count>=gMaxSpawnCaptions)
{
return;
}
}
}
else
{
return;
}
}
}
change:
Code: Select all
EQLIB_VAR BOOL gStringTableFixed;
EQLIB_VAR DWORD gMaxSpawnCaptions;
EQLIB_VAR BOOL gMQCaptions;
Code: Select all
EQLIB_VAR BOOL gStringTableFixed;
EQLIB_VAR DWORD gMaxSpawnCaptions;
EQLIB_VAR DWORD gSpawnCaptionDistance;
EQLIB_VAR BOOL gMQCaptions;
Change:
Code: Select all
DWORD gGameState = 0;
DWORD gMaxSpawnCaptions=30;
BOOL gMQCaptions=TRUE;
DWORD ThreadID = 0;
BOOL g_Loaded = FALSE;
Code: Select all
DWORD gGameState = 0;
DWORD gMaxSpawnCaptions=30;
DWORD gSpawnCaptionDistance=80;
BOOL gMQCaptions=TRUE;
DWORD ThreadID = 0;
BOOL g_Loaded = FALSE;
change:
Code: Select all
gMaxSpawnCaptions=GetPrivateProfileInt("Captions","Update",gMaxSpawnCaptions,Filename);
gMQCaptions = 1==GetPrivateProfileInt("Captions","MQCaptions",1,Filename);
Code: Select all
gMaxSpawnCaptions=GetPrivateProfileInt("Captions","Update",gMaxSpawnCaptions,Filename);
gSpawnCaptionDistance=GetPrivateProfileInt("Captions","Distance",gSpawnCaptionDistance,Filename);
gMQCaptions = 1==GetPrivateProfileInt("Captions","MQCaptions",1,Filename);
Change:
Code: Select all
VOID CaptionCmd(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR Arg1[MAX_STRING]={0};
GetArg(Arg1,szLine,1);
if (!Arg1[0])
{
SyntaxError("Usage: /caption <list|type <value>|update #|MQCaptions <on|off>>");
return;
}
if (!stricmp(Arg1,"list"))
{
WriteChatf("\ayPlayer1\ax: \ag%s\ax",gszSpawnPlayerName[1]);
WriteChatf("\ayPlayer2\ax: \ag%s\ax",gszSpawnPlayerName[2]);
WriteChatf("\ayPlayer3\ax: \ag%s\ax",gszSpawnPlayerName[3]);
WriteChatf("\ayPlayer4\ax: \ag%s\ax",gszSpawnPlayerName[4]);
WriteChatf("\ayNPC\ax: \ag%s\ax",gszSpawnNPCName);
WriteChatf("\ayPet\ax: \ag%s\ax",gszSpawnPetName);
WriteChatf("\ayCorpse\ax: \ag%s\ax",gszSpawnCorpseName);
return;
}
PCHAR pCaption=0;
if (!stricmp(Arg1,"Player1"))
{
pCaption=gszSpawnPlayerName[1];
} else if (!stricmp(Arg1,"Player2"))
{
pCaption=gszSpawnPlayerName[2];
} else if (!stricmp(Arg1,"Player3"))
{
pCaption=gszSpawnPlayerName[3];
} else if (!stricmp(Arg1,"Player4"))
{
pCaption=gszSpawnPlayerName[4];
} else if (!stricmp(Arg1,"Pet"))
{
pCaption=gszSpawnPetName;
} else if (!stricmp(Arg1,"NPC"))
{
pCaption=gszSpawnNPCName;
} else if (!stricmp(Arg1,"Corpse"))
{
pCaption=gszSpawnCorpseName;
} else if (!stricmp(Arg1,"Update"))
{
gMaxSpawnCaptions=atoi(GetNextArg(szLine));
if (gMaxSpawnCaptions<8)
gMaxSpawnCaptions=8;
if (gMaxSpawnCaptions>70)
gMaxSpawnCaptions=70;
WritePrivateProfileString("Captions","Update",itoa(gMaxSpawnCaptions,Arg1,10),gszINIFilename);
WriteChatf("\ay%d\ax nearest spawns will have their caption updated each pass.",gMaxSpawnCaptions);
return;
} else if (!stricmp(Arg1,"MQCaptions"))
{
gMQCaptions=(!stricmp(GetNextArg(szLine),"On"));
WritePrivateProfileString("Captions","MQCaptions",(gMQCaptions?"1":"0"),gszINIFilename);
WriteChatf("MQCaptions are now \ay%s\ax.",(gMQCaptions?"On":"Off"));
return;
}
else
{
MacroError("Invalid caption type '%s'",Arg1);
return;
}
strcpy(pCaption, GetNextArg(szLine));
WritePrivateProfileString("Captions",Arg1,pCaption,gszINIFilename);
ConvertCR(pCaption);
WriteChatf("\ay%s\ax caption set.",Arg1);
}
Code: Select all
VOID CaptionCmd(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR Arg1[MAX_STRING]={0};
GetArg(Arg1,szLine,1);
if (!Arg1[0])
{
SyntaxError("Usage: /caption <list|type <value>|update #(8-70)|distance #|MQCaptions <on|off>>");
return;
}
if (!stricmp(Arg1,"list"))
{
WriteChatf("\ayPlayer1\ax: \ag%s\ax",gszSpawnPlayerName[1]);
WriteChatf("\ayPlayer2\ax: \ag%s\ax",gszSpawnPlayerName[2]);
WriteChatf("\ayPlayer3\ax: \ag%s\ax",gszSpawnPlayerName[3]);
WriteChatf("\ayPlayer4\ax: \ag%s\ax",gszSpawnPlayerName[4]);
WriteChatf("\ayNPC\ax: \ag%s\ax",gszSpawnNPCName);
WriteChatf("\ayPet\ax: \ag%s\ax",gszSpawnPetName);
WriteChatf("\ayCorpse\ax: \ag%s\ax",gszSpawnCorpseName);
return;
}
PCHAR pCaption=0;
if (!stricmp(Arg1,"Player1"))
{
pCaption=gszSpawnPlayerName[1];
} else if (!stricmp(Arg1,"Player2"))
{
pCaption=gszSpawnPlayerName[2];
} else if (!stricmp(Arg1,"Player3"))
{
pCaption=gszSpawnPlayerName[3];
} else if (!stricmp(Arg1,"Player4"))
{
pCaption=gszSpawnPlayerName[4];
} else if (!stricmp(Arg1,"Pet"))
{
pCaption=gszSpawnPetName;
} else if (!stricmp(Arg1,"NPC"))
{
pCaption=gszSpawnNPCName;
} else if (!stricmp(Arg1,"Corpse"))
{
pCaption=gszSpawnCorpseName;
} else if (!stricmp(Arg1,"Update"))
{
gMaxSpawnCaptions=atoi(GetNextArg(szLine));
if (gMaxSpawnCaptions<8)
gMaxSpawnCaptions=8;
if (gMaxSpawnCaptions>70)
gMaxSpawnCaptions=70;
WritePrivateProfileString("Captions","Update",itoa(gMaxSpawnCaptions,Arg1,10),gszINIFilename);
WriteChatf("\ay%d\ax nearest spawns will have their caption updated each pass.",gMaxSpawnCaptions);
return;
} else if (!stricmp(Arg1,"Distance"))
{
gSpawnCaptionDistance=atoi(GetNextArg(szLine));
WritePrivateProfileString("Captions","Distance",itoa(gSpawnCaptionDistance,Arg1,10),gszINIFilename);
WriteChatf("Spawns as far away as \ay%d\ax will have their captions updated .",gSpawnCaptionDistance);
return;
} else if (!stricmp(Arg1,"MQCaptions"))
{
gMQCaptions=(!stricmp(GetNextArg(szLine),"On"));
WritePrivateProfileString("Captions","MQCaptions",(gMQCaptions?"1":"0"),gszINIFilename);
WriteChatf("MQCaptions are now \ay%s\ax.",(gMQCaptions?"On":"Off"));
return;
}
else
{
MacroError("Invalid caption type '%s'",Arg1);
return;
}
strcpy(pCaption, GetNextArg(szLine));
WritePrivateProfileString("Captions",Arg1,pCaption,gszINIFilename);
ConvertCR(pCaption);
WriteChatf("\ay%s\ax caption set.",Arg1);
}
Code: Select all
Distance=80
It seems to be working for me, if anyone is brave enough to try it on theirs let me know :)
-gnatch
<<Edit: was missing the V on the first VOID function



