• 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 Capacity Overloaded

sn3ejk

This account is inactive.
Joined
Nov 16, 2011
Messages
2,121
Solutions
1
Reaction score
145
Capacity Overloaded
"Less Tibia, more RPG."




I've been playing alot Skyrim lately, and I had this idea to use the same capacity system for OpenTibia as Skyrim has. The players will now have infinite capacity, but when they carry more items than their capacity actually should be, they will be walking slower than normal.

tEES4-M.png


  • config.lua
    Below
    Lua:
    	playerFollowExhaust = 0
    Add
    Lua:
    	capacityOverload = 0.75
  • configmanager.cpp
    Below
    PHP:
    	m_confNumber[FOLLOW_EXHAUST]			= getGlobalNumber("playerFollowExhaust", 2000);
    Add
    PHP:
    	m_confDouble[CAPACITY_OVERLOAD]		= getGlobalDouble("capacityOverload", 0.75);
  • configmanager.h
    Below
    PHP:
    			FORMULA_MAGIC,
    Add
    PHP:
    			CAPACITY_OVERLOAD,
  • player.cpp
    Replace
    PHP:
    	windowTextId = nextExAction = 0;
    For
    PHP:
    	windowTextId = nextExAction = capacityOverload = 0;
    &&&
    Replace function
    PHP:
    void Player::updateInventoryWeight()
    For
    PHP:
    void Player::updateInventoryWeight()
    {
    	inventoryWeight = 0.00;
    	if(hasFlag(PlayerFlag_HasInfiniteCapacity)
    		|| !g_config.getBool(ConfigManager::USE_CAPACITY))
    		return;
    
    	for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
    	{
    		if(Item* item = getInventoryItem((slots_t)i))
    			inventoryWeight += item->getWeight();
    	}
    	
    	if (inventoryWeight >= capacity && !capacityOverload)
    	{
    		capacityOverload = (int32_t)(getSpeed() * g_config.getDouble(ConfigManager::CAPACITY_OVERLOAD));
    		g_game.changeSpeed(this, -capacityOverload);
    	}
    	else if (inventoryWeight < capacity && capacityOverload)
    	{
    		g_game.changeSpeed(this, capacityOverload);
    		capacityOverload = 0;
    	}
    }
    &&&
    Replace function
    PHP:
    bool Player::hasCapacity(const Item*, uint32_t) const
    For
    PHP:
    bool Player::hasCapacity(const Item*, uint32_t) const
    {
    	return true;
    }
    &&&
    Replace function
    PHP:
    void Player::onThink(uint32_t interval)
    For
    PHP:
    void Player::onThink(uint32_t interval)
    {
    	Creature::onThink(interval);
    	int64_t timeNow = OTSYS_TIME();
    	if(timeNow - lastPing >= 5000)
    	{
    		if (capacityOverload)
    		{
    			g_game.addMagicEffect(getPosition(), MAGIC_EFFECT_POFF);
    			sendCancel("Your capacity is overloaded!");
    		}
    	
    		lastPing = timeNow;
    		if(hasClient())
    			client->sendPing();
    		else if(g_config.getBool(ConfigManager::STOP_ATTACK_AT_EXIT))
    			setAttackedCreature(NULL);
    	}
    
    	if((timeNow - lastPong) >= 60000 && !getTile()->hasFlag(TILESTATE_NOLOGOUT)
    		&& !isConnecting && !pzLocked && !hasCondition(CONDITION_INFIGHT))
    	{
    		if(hasClient())
    			client->logout(true, true);
    		else if(g_creatureEvents->playerLogout(this, false))
    			g_game.removeCreature(this, true);
    	}
    
    	messageTicks += interval;
    	if(messageTicks >= 1500)
    	{
    		messageTicks = 0;
    		addMessageBuffer();
    	}
    		
    	
    	if(lastMail && lastMail < (uint64_t)(OTSYS_TIME() + g_config.getNumber(ConfigManager::MAIL_ATTEMPTS_FADE)))
    		mailAttempts = lastMail = 0;
    }
  • player.h
    Below
    PHP:
    		int32_t shieldBlockCount;
    Add
    PHP:
    		int32_t capacityOverload;
 
Reminds me of my cap system I did once.
Seems to be a cool way to do it aswell.
 
Thanks for all comments.
If anyone has any idea for update, please write.
 
Thanks for all comments.
If anyone has any idea for update, please write.

do so it affects your regeneration time too, to go slower. And even bigger cooldown for spells, all in all it is a nice system but sadly not many players will feel comfortable with :(
 
I dont know if im right, beacouse I only take a look on the code, but dont you think that speed should be decreased more with function like
f(x) = 1/x <- x would be this crossed cap like you have 200 cap, but your items weights 220 so your speed will be -> basespeed * f(x)
It sample formula but I hope you get my point xD -> The more items you put on yourself, and when you cross 0 cap the more speed you loose until you put them off.
 
@up
You gain and loss the same value - always, cuz this value is in variable.
 
But its kinda wierd dont you think? It should be like, the more stuff you carry the more speed you loss..
 
Awesome idea! I remember when i first time played Skyrim, i was like "wtf why can't i run, why do i walk so slow"
 
If u turning off cap limit someone can easy crash your ots btw. Just turn on bot for night to buying infinite bags for 10gp or some foods and after that try to relog several times and mysql will jump to 100% cpu cos he will try to save too manny items. Thats why every ots right now have cap limit.
 
Here is what you should do:
1. Commit it to latest.
2. Add to the config "useOverload = false".
3. Put a beer on your hand.
4. Take some chugs.
5. ?????
6. Mark gets Madz!!!
 
Back
Top