Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[TuT] Loot System Info


Gość Maxikk

Rekomendowane odpowiedzi

Opublikowano

Zapewne każdy z was chcę mieć loot system info na starszych wersjach tibi od teraz jest to możliwe poniżej pokaże wam jak zrobić taki system na swoim otsie :)

 

 

Otwieramy container.cpp i pod:

 

#include "container.h"

 

Dodajemy:

 

#include <sstream>

 

Na końcu pliku dodajemy:

 

std::string Container::getContentDescription()
{
   std::stringstream s;
   return getContentDescription(s).str();
}

std::stringstream& Container::getContentDescription(std::stringstream& s)
{
   bool begin = true;
   Container* container = dynamic_cast<Container*>(this);
   ContainerList::const_iterator it;
   ContainerList::const_iterator cit;
   for(it = container->getItems(); it != container->getEnd(); ++it)
   {

       if(!begin)
           s << ", ";
       else
           begin = false;

       s << (*it)->getLootDescription();

       if((*it)->isContainer()){ 
          Container* containerek = dynamic_cast<Container*>(*it);
         for(cit = containerek->getItems(); cit != containerek->getEnd(); ++cit){     

             if(!begin)
               s << ", ";
             else
               begin = false;

             s << (*cit)->getLootDescription();
         }
       }
    }
   if(begin)
       s << "nic";

   return s;
}

 

Zapisujemy i przechodzimy do container.h i pod:

 

ContainerList lcontained;

 

Dodajemy:

 

std::stringstream& getContentDescription(std::stringstream& s);

 

Następnie pod:

 

virtual double getWeight() const;

 

Dodajemy:

 

std::string getContentDescription();

 

Zapisujemy i przechodzimy do game.cpp i pod:

 

attackedCreature->dropLoot(lootcontainer);

 

Dodajemy:

 

          Monster* monster = dynamic_cast<Monster*>(attackedCreature);
         Player* atakujacy = dynamic_cast<Player*>(attacker);
           if(monster && atakujacy){
               std::stringstream ss;
             ss << "Twoj loot z " << monster->getName() << ": " << lootcontainer->getContentDescription() << ".";
             atakujacy->sendTextMessage(MSG_INFO, ss.str().c_str());
          }

 

Zapisujemy i przechodzimy do item.cpp i pod:

 

bool Item::isFluidContainer() const {
   return (items[id].isFluidContainer());
}

 

Dodajemy:

 

bool Item::isContainer() const {
   return items[id].isContainer();
}

 

Następnie pod:

 

double Item::getWeight() const {
   if(isStackable()){
       return items[id].weight * std::max(1, (int)count);
   }

   return items[id].weight;
}

 

Dodajemy:

 

std::string Item::getLootDescription() const
{
   std::stringstream s;
   std::string str;
   const Container* container;
   const ItemType& it = items[id];

     if(specialDescription){
        s << (*specialDescription);
        }
     else if(it.name.length()) {
            if(isStackable() && count > 1) {
              s << (int)count << " " << it.name << "s";
     }else {
     if(isWeapon() && (getAttack() || getDefense()))
     {
            s << article(it.name) << " (Atk:" << (int)getAttack() << " Def:" << (int)getDefense() << ")";
     }
     else if(getArmor())
     {
            s << article(it.name) << " (Arm:"<< (int)getArmor() << ")";
     }
     else if(isSplash()){
            s << article(it.name) << " z ";
           if(fluid == 0){
            s << items[1].name;
           }else{
            s << items[fluid].name;
           }
     }
     else if(it.isKey()){
            s << article(it.name) << " (Key:" << actionId << ")";
     }
     else if(it.isContainer() && (container = dynamic_cast<const Container*>(this))) {
            s << article(it.name) << " (Vol:" << container->capacity() << ")";
        }else{
            s << article(it.name);
     }
   }
 }
      str = s.str();
   return str;
}

 

Zapisujemy i przechodzimy do item.h i pod:

 

bool isFluidContainer() const;

 

Dodajemy:

 

bool isContainer() const;

 

Następnie pod:

 

bool decoration;

 

Dodajemy:

 

virtual std::string getLootDescription() const;

 

Zapisujemy i zamykamy następnie kompilujemy i cieszymy się loot info na swoim serwerze

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Zaloguj się poniżej.

Zaloguj się
×
×
  • Dodaj nową pozycję...