• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Feature Outfit Quests!

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,667
Solutions
125
Reaction score
1,114
Location
Germany
GitHub
slawkens
WARNING:
After some tests, I see it isnt working correctly. Player cant wear any outfits in some cases. So. USE AT YOUR OWN RISK, or wait until I'll fix it ^_^

NOTICE:
If you're using TFS 0.3 then this code is already included. Just leave this topic. ;P

Based on storagevalues.

Eq. if player have storage value (40000 + looktype) (Eq. 40128 for citizen) == 1 and in outfits.xml addon is set to only from quest available then he will be able to wear it. Else, if quest isnt set to available only from quest, then all are avaible to wear it (of course if have premium or addons if setted).

Outfit.cpp
After:
PHP:
new_outfit->premium = outfit.premium;
Add:
PHP:
new_outfit->quest = outfit.quest;

Change:
PHP:
bool OutfitList::isInList(uint32_t looktype, uint32_t addons, bool playerPremium, int32_t playerSex) const
To:
PHP:
bool OutfitList::isInList(uint32_t looktype, uint32_t addons, bool playerPremium, int32_t playerSex, int32_t playerStorage) const

In same function, change:
PHP:
						if((*it)->premium && playerPremium || !(*it)->premium)
							return true;
To:
PHP:
						if((*it)->premium && playerPremium || !(*it)->premium)
						{
							if((*it)->quest && playerStorage || !(*it)->quest)
								return true;
						}
						return false;

After:
PHP:
	//build default outfit lists
	outfit.addons = 0;
Add:
PHP:
outfit.quest = false;

After:
PHP:
						if(readXMLInteger(p, "enabled", intVal))
							outfitEnabled = (intVal == 1);
Add:
PHP:
						if(readXMLInteger(p, "questOnly", intVal))
							outfit.quest = (intVal == 1);
						else
							outfit.quest = false;

Outfit.h
After:
PHP:
	uint32_t looktype;
	uint32_t addons;
Add:
PHP:
	uint32_t quest;

Change:
PHP:
	bool isInList(uint32_t looktype, uint32_t addons, bool playerPremium, int32_t playerSex) const;
To:
PHP:
	bool isInList(uint32_t looktype, uint32_t addons, bool playerPremium, int32_t playerSex, int32_t playerStorage) const;

protocolgame.cpp
Change:
PHP:
		OutfitListType::const_iterator it, it_;
		for(it = global_outfits.begin(); it != global_outfits.end(); ++it)
		{
			if((*it)->premium && !player->isPremium())
				count_outfits--;
		}
To:
PHP:
		OutfitListType::const_iterator it, it_;
		for(it = global_outfits.begin(); it != global_outfits.end(); ++it)
		{
			int32_t value;
			player->getStorageValue((40000 + (*it)->looktype), value);
			if(((*it)->premium && !player->isPremium()) || ((*it)->quest && !(value==1)))
				count_outfits--;
		}

Change:
PHP:
		for(it = global_outfits.begin(); it != global_outfits.end() && (count_outfits > 0); ++it)
		{
			if((*it)->premium && player->isPremium() || !(*it)->premium)
			{
				addedAddon = false;
				msg->AddU16((*it)->looktype);
				msg->AddString(Outfits::getInstance()->getOutfitName((*it)->looktype));
				//TODO: Try to avoid using loop to get addons
				for(it_ = player_outfits.begin(); it_ != player_outfits.end(); ++it_)
				{
					if((*it_)->looktype == (*it)->looktype)
					{
						msg->AddByte((*it_)->addons);
						addedAddon = true;
						break;
					}
				}
				if(!addedAddon)
					msg->AddByte(0x00);
				count_outfits--;
			}
		}
To:
PHP:
		for(it = global_outfits.begin(); it != global_outfits.end() && (count_outfits > 0); ++it)
		{
			if((*it)->premium && player->isPremium() || !(*it)->premium)
			{
				int32_t value;
				player->getStorageValue((40000 + (*it)->looktype), value);

				if((*it)->quest && (value == 1) || !(*it)->quest)
				{
					addedAddon = false;
					msg->AddU16((*it)->looktype);
					msg->AddString(Outfits::getInstance()->getOutfitName((*it)->looktype));
					//TODO: Try to avoid using loop to get addons
					for(it_ = player_outfits.begin(); it_ != player_outfits.end(); ++it_)
					{
						if((*it_)->looktype == (*it)->looktype)
						{
							msg->AddByte((*it_)->addons);
							addedAddon = true;
							break;
						}
					}
					if(!addedAddon)
						msg->AddByte(0x00);
					count_outfits--;
				}
			}
		}

player.cpp
Change:
PHP:
	return m_playerOutfits.isInList(_looktype, _addons, isPremium(), getSex());
To:
PHP:
	int32_t value;
	getStorageValue(40000 + _looktype, value);
	return m_playerOutfits.isInList(_looktype, _addons, isPremium(), getSex(), value);

Change:
PHP:
		if(!global_outfits.isInList(looktype, addons, isPremium(), getSex()))
To:
PHP:
		int32_t value;
		getStorageValue(40000 + looktype, value);
		if(!global_outfits.isInList(looktype, addons, isPremium(), getSex(), value))


Now, if you want to be some outfits was enabled only from quests you must add to outfits.xml: questOnly="1". All outfits are default set to questOnly="0".

Now, create any lua script with: setPlayerStorageValue(cid, 40129, 1) (129 - hunter outfit)
 
Last edited:
errorfr6.jpg


I think you forgot something on the tutorial ^^
 
Last edited:
I didn't understand the quests.xml part. Like:

<quest name="Annihilator Quest" startstorageid="40128" startstoragevalue="1" questOnly="1">
<mission name="The Reward (Choose)" storageid="2020" startvalue="1" endvalue="1">
<missionstate id="1" description="You defeated many diabolic creatures with your 3 friends and chose between: magic sword, demon armor, stonecutter axe or annihilation bear!"/>
</mission>
</quest>

so the player would won the 128 outfit?
 
Last edited:
Aaa, sry. Not quests.xml but outfits.xml. :p Fixed.

#Edit

Hmm, so actually add 2x storage value, becouse i dont see another way to save it.
 
Last edited:
I got modified TFS with Evolution features which are more friendly. Can some one help me to implement this ?:)
 
i cannot find player.cpp, outfits.cpp and such :D
I never worked with c++ and so on. could someone help/explain me where to find it.
 
Code:
player.cpp: In member function `bool Player::canWear(uint32_t, uint32_t)':
player.cpp:3301: error: no matching function for call to `Player::getStorageValue(unsigned int, int32_t&)'
player.cpp:749: note: candidates are: bool Player::getStorageValue(uint32_t, uint32_t&) const

player.cpp: In member function `void Player::genReservedStorageRange()':
player.cpp:3331: error: no matching function for call to `Player::getStorageValue(unsigned int, int32_t&)'
player.cpp:749: note: candidates are: bool Player::getStorageValue(uint32_t, uint32_t&) const

make.exe: *** [player.o] Error 1

Execution terminated

why me god why me :'(
 
3146 C:\Users\Mateusz\Desktop\C++\0.2\protocolgame.cpp a function-definition is not allowed here before '{' token
C:\Dev-Cpp\TheForgottenServer\project\Makefile.win [Build Error] [../../../Users/Mateusz/Desktop/C++/0.2/protocolgame.o] Error 1

What's this?? :? i can't compile
 
i do this 4-5x and i seen always error

@EDIT
ALL OK :}
THX
 
Last edited:
Back
Top