• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Combat/PvP Zoning

cannot find -lboost-system-mgw-1_34_1
ld returned 1 exit status
F:\Documents and Settings\Paweł\Pulpit\TheForgottenServer 0.2.6 [Golden Warrior]\Forgotten Sources\Projekt\Makefile.win [Build Error] ["Forgotten] Error 1



I don't know but it doesn't work :/
 
cannot find -lboost-system-mgw-1_34_1
ld returned 1 exit status
F:\Documents and Settings\Paweł\Pulpit\TheForgottenServer 0.2.6 [Golden Warrior]\Forgotten Sources\Projekt\Makefile.win [Build Error] ["Forgotten] Error 1



I don't know but it doesn't work :/

Not a problem with the code at all. You're missing a library.<_<
 
#ifdef __COMBAT_ZONES__
if(g_game.loadCombatZones())
puts(":: Loaded Combat Zones!");
#endif //__COMBAT_ZONES__


How I must chagne it??
 
Last edited:
___-Refefresh-____


Can someone help me??

with this code??

#ifdef __COMBAT_ZONES__
if(g_game.loadCombatZones())
puts(":: Loaded Combat Zones!");
#endif //__COMBAT_ZONES__


How I must change it?? :)
 
___-Refefresh-____


Can someone help me??

with this code??

#ifdef __COMBAT_ZONES__
if(g_game.loadCombatZones())
puts(":: Loaded Combat Zones!");
#endif //__COMBAT_ZONES__


How I must change it?? :)

you don't change it at all?
 
I try to compile with TFS 0.2.8

I get the following error:

game.cpp: In member function `bool Game::loadCombatZones()':
game.cpp:4357: error: `DATA_DIRECTORY' is not a member of `ConfigManager'



This is the Line in game.cpp:
Code:
    xmlDocPtr doc = xmlParseFile(std::string(g_config.getString(ConfigManager::DATA_DIRECTORY) + "pvpzones.xml").c_str());
 
Last edited:
Fully TFS-compatible and working code of PVP ZONES.

1. Open combat.cpp, and find:
Code:
if(g_game.getWorldType() == WORLD_TYPE_NO_PVP)
Replace it with:
Code:
		if(g_game.getWorldType(
		#ifdef __PVP_ZONES__
		attacker, target
		#endif //__PVP_ZONES__
		) == WORLD_TYPE_NO_PVP)
Save and close the file.
2. Open game.cpp, and at bottom of the file add:
Code:
#ifdef __PVP_ZONES__
bool Game::loadCombatZones()
{
    xmlDocPtr doc = xmlParseFile(std::string("data/XML/pvpzones.xml").c_str());
    if(!doc)
        return false;
    xmlNodePtr root, zone, tiles;
    root = xmlDocGetRootElement(doc);
    if(xmlStrcmp(root->name,(const xmlChar*)"zones"))
    {
        puts("Malformed pvp zones file!");
        return false;
    }
    zone = root->children;
    while(zone)
    {
        if(!xmlStrcmp(zone->name,(const xmlChar*)"zone"))
        {
            tileflags_t pvplvl = TILESTATE_NONE;
            std::string strlvl;
            if(!readXMLString(zone, "pvp", strlvl))
            {
                puts("ERROR: pvp zone missing pvp level!");
                continue;
            }
            toLowerCaseString(strlvl);
            if(strlvl == "none" || strlvl == "no" || strlvl == "nopvp" || strlvl == "0")
                pvplvl = TILESTATE_NOPVPZONE;
            else if(strlvl == "yes" || strlvl == "normal" || strlvl == "pvp" || strlvl == "1")
                pvplvl = TILESTATE_PVPZONE;
            else if(strlvl == "enforced" || strlvl == "e" || strlvl == "pvp-enforced" || strlvl == "2")
                pvplvl = TILESTATE_PVPENFORCEDZONE;
            else
            {
                printf("ERROR: invalid pvp level: %s\n", strlvl.c_str());
                continue;
            }
            tiles = zone->children;
            while(tiles)
            {
                if(!xmlStrcmp(tiles->name,(const xmlChar*)"tile"))
                {
                   int x, y, z;
                   if(readXMLInteger(tiles,"x",x)
                      && readXMLInteger(tiles,"y",y)
                      && readXMLInteger(tiles,"z",z))
                   {
                          Tile* t = map->getTile(x, y, z);
                          if(t)
                              t->setFlag(pvplvl);
                   }
                }
                else if(!xmlStrcmp(tiles->name,(const xmlChar*)"tiles"))
                {
                   int tox, toy, toz, fromx, fromy, fromz;
                   if(readXMLInteger(tiles,"tox",tox)
                      && readXMLInteger(tiles,"toy",toy)
                      && readXMLInteger(tiles,"toz",toz)
                      && readXMLInteger(tiles,"fromx",fromx)
                      && readXMLInteger(tiles,"fromy",fromy)
                      && readXMLInteger(tiles,"fromz",fromz))
                   {
                        if(tox < fromx)
                            std::swap(tox, fromx);
                        if(toy < fromy)
                            std::swap(toy, fromy);
                        if(toz < fromz)
                            std::swap(toz, fromz);
                        for(int x = fromx; x <= tox; x++)
                        {
                           for(int y = fromy; y <= toy; y++)
                           {
                              for(int z = fromz; z <= toz; z++)
                              {
                                  Tile* t = map->getTile(x, y, z);
                                  if(t)
                                      t->setFlag(pvplvl);
                              }
                           }
                        }
                   }
                }
                tiles = tiles->next;
            }
        }
        zone = zone->next;
    }
    
    return true;
}
#endif //__PVP_ZONES__
Remember, to leave one empty line under it, then save and close the file.
3. Open game.h, and find:
Code:
WorldType_t getWorldType() const {return worldType;}
Replace it with:
Code:
		#ifndef __PVP_ZONES__
		WorldType_t getWorldType() const {return worldType;}
		#else
		WorldType_t getWorldType(const Creature* attacker = NULL, const Creature* target = NULL) const
		{
			if(!attacker || !target)
				return worldType;

			if(attacker->getPlayer() && target->getPlayer())
			{
				if(attacker->getTile()->hasFlag(TILESTATE_PVPENFORCEDZONE) && target->getTile()->hasFlag(TILESTATE_PVPENFORCEDZONE))
					return WORLD_TYPE_PVP_ENFORCED;
				else if(attacker->getTile()->hasFlag(TILESTATE_PVPZONE) && target->getTile()->hasFlag(TILESTATE_PVPZONE))
					return WORLD_TYPE_PVP;
				else if(attacker->getTile()->hasFlag(TILESTATE_NOPVPZONE) || target->getTile()->hasFlag(TILESTATE_NOPVPZONE))
					return WORLD_TYPE_NO_PVP;
			}
	        
	        return worldType;
	    }
		bool loadCombatZones();
		#endif //__PVP_ZONES__
Save and close the file.
4. Open player.cpp, and find:
Code:
if(g_config.getString(ConfigManager::EXPERIENCE_FROM_PLAYERS) == "yes")
Replace it with:
Code:
	if(g_config.getString(ConfigManager::EXPERIENCE_FROM_PLAYERS) == "yes"
	#ifdef __PVP_ZONES__
	|| g_game.getWorldType(attacker, this) == WORLD_TYPE_PVP_ENFORCED
	#endif //__PVP_ZONES__
    )
Save and close the file.
5. Open otserv.cpp, and find:
Code:
	std::cout << ">> Loading raids" << std::endl;
	#ifndef __CONSOLE__
	SendMessage(gui.statusBar, WM_SETTEXT, 0, (LPARAM)">> Loading raids");
	#endif
	Raids::getInstance()->loadFromXml();
	Raids::getInstance()->startup();
Add above it:
Code:
	#ifdef __PVP_ZONES__ //Modified by Elf
	std::cout << ">> Loading PVP zones" << std::endl;
	#ifndef __CONSOLE__
	SendMessage(gui.statusBar, WM_SETTEXT, 0, (LPARAM)">> Loading PVP zones");
	#endif
	g_game.loadCombatZones();
	#endif //__PVP_ZONES__
Save and close the file.
5. Open tile.h, and find:
Code:
	TILESTATE_MAGICFIELD = 8192
If You dont have it, then find:
Code:
	TILESTATE_POSITIONCHANGE = 4096
Add after it:
Code:
	#ifdef __PVP_ZONES__
	,
	TILESTATE_PVPENFORCEDZONE = [color=red]XXX[/color]
	#endif //__PVP_ZONES__
And replace the XXX with last item value (example: 4096) * 2.
(Eg. If last item was TILESTATE_POSITIONCHANGE with value 4096, then Your XXX value will be 8192. Else, if it was 8192, then Your value will be 16384).
Save and close the file.

6. Now add -D__PVP_ZONES__ to C++ compiler paramaters (for *nix, edit Makefile and add to FLAGS) and compile the server.

7. Usage:
Zones are stored in data/XML/pvpzones.xml instead of data/pvpzones.xml.
For more, read this link.


######### All credits go to Nate, for impressive piece of code. #########​
(@ I would be thankfull, if You would mention about it somewhere)
 
Last edited:
Its An awesome script but i get an error while compiling

Code:
else if(!xmlStrcmp(tiles->name,(const xmlChar*)"tiles"))
Code:
4513 H:\Documents and Settings\Administrator\Desktop\SVN\0.2\game.cpp expected constructor, destructor, or type conversion before '(' token
Code:
tiles = tiles->next;
Code:
4543 H:\Documents and Settings\Administrator\Desktop\SVN\0.2\game.cpp expected constructor, destructor, or type conversion before '=' token
Code:
4544 H:\Documents and Settings\Administrator\Desktop\SVN\0.2\game.cpp expected declaration before '}' token
 
Back
Top