Thread: Better LFF+Who
View Single Post
  #2  
Unread 11-23-2007, 09:05 AM
Sorane Sorane is offline
The Undying
 
Join Date: Oct 2007
Posts: 31
Hi!

I did an example implementation of this feature. The source-code would be free for Turbine to have (actually I am posting the core-function at the lower
part of this mail) if they want to use it!!! Of course they would need to make
some small changes to make it work with the source-code of LOTRO (I just made up things like an example-player-class to illustrate how a /who function could get implemented). I believe it would not be much work on their half needed to integrate it into the game.

Note that I also still have C++ implementations of a Damagemeter and of
a XML Character writer which I would give to Turbine if they would want them!

And yes, I know this is a bit weird, posting Source-Code to Turbine ;-) But as long-time-game-developer and long-time-addon-coder I just *had*
to do it ;-)))

I am assuming for my source-code-example:

- There is a global list of online players somewhere (I used a STL-Map in my example)
- There are functions to get a conditioned list (like: "Give me all players between lvl 47 and Lvl 50 in Rivendell")

My example works like this:

/who P=Misty*+Trollsh*+Bree C=Guardian+Hunter+Minstrel L=45-50 K=Fellowship_of_the_Song+The_Shadows F=NI+NF MAX=3

This chat line would output up to 3 people who match the conditions:
- Are in an area who's name Starts with "Misty" or will "Trollsh* or are in Bree
- Are Guardians, Hunters or Minstrels
- Are of Lvl 45-50
- Are either in the Kinship Fellowship of the Song (Blanks need to be entered
as _ in my who function) or in the Kinship The Shadows
- Are not in an instance and not in a fellowship

You can of course skip parameters (including the MAX parameter).

Core-Source-Code of my example is below (A complete Project, compilable with VC++ is available at http://www.file-upload.net/download-...mple.zip.html).

It would be great if Turbine would take up my idea and implement my example into a new feature for LOTRO I think !!! (And yes, I would love an addon-interface for LOTRO ;-) I loved coding addons for that other game hehe).

And this is how the Chat Output of my function could look:

Eldamo <Hunter Lvl 50,Elf> - Trollshaws
Ryalin <Minstrel Lvl 50,Dwarf> - Trollshaws
Sorane <Guardian Lvl 50,Human> - Misty Mountains
---------------------------------

Found: 3 Players.



Sorane


#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <vector>
using namespace std;
using std::string;

#include "player.h"
#include "utils.h"
#include "finders.h"

/*
who - The main code of the /who functionality
p - The global player list
line - The string of the /who command

max - will return the max number of characters to output
result - the list of players (could be more than max !!!) matching the conditions
*/
map<string,Player*> who(map<string,Player*> p,string line, int& max)
{
string str; // Helper String
map<string,Player*> selection; // Selection of Players found which match the parameters

// Get the part right of "/who ")

string command(line.begin() + line.find_first_of(" "), line.end());

command = command.substr(1,command.length()-1);

selection = p;

// or are there several like "/who Guardian+Minstrel P=Misty*+Trolls* L=45-50 G=Fellowship_of* F=NF

// Does the player look for people in a certain position (like: /who P=Misty*+Trollshaws)

if (command.find("P=")!=string::npos)
{
// Extract the positions the player looks for people in

str = string(command.begin()+command.find("P="), command.end());
if (str.find_first_of(" ")!=string::npos) str = string(str.begin()+command.find("P="),str.begin()+ str.find_first_of(" "));
str = str.substr(2,command.length()-3);

// Select the Players from "selection" which match the condition
// "Is currently at one of the positions matching "str"

selection = FindPlayersAtPositions(selection, str);
}
if (command.find("L=")!=string::npos)
{
// Extract the the levels we look for

str = string(command.begin()+command.find("L="), command.end());
if (str.find_first_of(" ")!=string::npos) str = string(str.begin()+str.find("L="),str.begin()+str. find_first_of(" "));
str = str.substr(2,command.length()-3);

selection = FindPlayersWithLevels(selection, str);
}
if (command.find("K=") !=string::npos)
{
// Extract the Kinship names we look for

str = string(command.begin()+command.find("K="), command.end());
if (str.find_first_of(" ")!=string::npos) str = string(str.begin()+str.find("K="),str.begin()+str. find_first_of(" "));
str = str.substr(2,command.length()-3);

selection = FindPlayersInKinship(selection, str);
}
if (command.find("F=") !=string::npos)
{
// Extract the Kinship names we look for

str = string(command.begin()+command.find("F="), command.end());
if (str.find_first_of(" ")!=string::npos) str = string(str.begin()+str.find("F="),str.begin()+str. find_first_of(" "));
str = str.substr(2,command.length()-3);

selection = FindPlayersWithFlags(selection, str);
}
if (command.find("C=") !=string::npos)
{
// Extract the Kinship names we look for

str = string(command.begin()+command.find("C="), command.end());
if (str.find_first_of(" ")!=string::npos) str = string(str.begin()+str.find("C="),str.begin()+str. find_first_of(" "));
str = str.substr(2,command.length()-3);

selection = FindPlayersWithClass(selection, str);
}
if (command.find("MAX=") !=string::npos)
{
// Extract the Kinship names we look for

str = string(command.begin()+command.find("MAX="), command.end());
if (str.find_first_of(" ")!=string::npos) str = string(str.begin()+str.find("MAX="),str.begin()+st r.find_first_of(" "));
str = str.substr(4,command.length()-5);

max = atoi(str.c_str());
}

return selection;
}


/*
output_who_to_chat - Outputs the result of the who command

max - Max Number of characters to output
p - The selection list to output
*/
void output_who_to_chat(int max,map<string,Player*> p)
{
map<string,Player*>::iterator it;
char temp[255];
int size;
int i;

size = p.size();
i = 0;

for(it = p.begin();it!=p.end();it++)
{
if (i>=max) break;
ChatOutput("\n");
ChatOutput(it->second->name);
ChatOutput(" <");
ChatOutput(ClassConvert(it->second->classtype));
ChatOutput(" Lvl ");
sprintf(temp,"%d",it->second->level);
ChatOutput(temp);
ChatOutput(",");
ChatOutput(RaceConvert(it->second->racetype));
ChatOutput("> - ");
ChatOutput(it->second->position);
i++;
}
ChatOutput("\n---------------------------------\n\n");
ChatOutput("Found: ");
sprintf(temp,"%d",size);
ChatOutput(temp);
ChatOutput(" Players.\n\n");
}
Reply With Quote