What's new

Poziomy potwor?w

Status
Not open for further replies.

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
~~monster.cpp~~


W??czamy monster.cpp i szukamy:
PHP:
hideName = mType->hideName, hideHealth = mType->hideHealth;

Pod tym doklejamy:
PHP:
randomDamage = monsterLevel = 10;

Szukamy:
PHP:
void Monster::dropLoot(Container* corpse)

I podmieniamy ca?? funkcj? na:
PHP:
void Monster::dropLoot(Container* corpse)
{
	if(corpse && lootDrop == LOOT_DROP_FULL)
		mType->dropLoot(corpse, randomDamage);
}

Nast?pnie szukamy funkcji:
PHP:
bool Monster::getCombatValues(int32_t& min, int32_t& max)

I podmieniamy j? z:
PHP:
bool Monster::getCombatValues(int32_t& min, int32_t& max)
{
	if(!minCombatValue && !maxCombatValue)
		return false;

	double multiplier;
	if(maxCombatValue > 0) //defense
		multiplier = g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE);
	else //attack
		multiplier = g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK);

	min = (int32_t)(minCombatValue * multiplier + (minCombatValue * randomDamage / 10));
	max = (int32_t)(maxCombatValue * multiplier + (maxCombatValue * randomDamage / 10));
	return true;
}

Nast?pnie w??czamy monster.h i pod:
PHP:
int32_t targetChangeCooldown;

Doklejamy:
PHP:
int32_t randomDamage;
int32_t monsterLevel;

Oraz pod:
PHP:
void removeList() {autoList.erase(id);}
Dodajemy:
PHP:
void doMonsterSetCombatValues(int32_t randomStats) {randomDamage = randomStats;}
void doMonsterSetLevel(int32_t newLevel) {monsterLevel = newLevel;}
virtual int32_t getMonsterLevel() const {return monsterLevel;}


~~spawn.cpp~~


Szukamy funkcji:
PHP:
bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, bool startup /*= false*/)

I podmieniamy j? na:
PHP:
bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, bool startup /*= false*/)
{
	int32_t normHealth = mType->health, normMaxHealth = mType->healthMax, normExp = mType->experience, normDef = mType->defense, normArm = mType->armor;
    int32_t maxLevelValue = mType->maxLevel;
	if(g_config.getNumber(ConfigManager::MAX_MONSTER_LEVEL) > 0)
		maxLevelValue = std::max(maxLevelValue , g_config.getNumber(ConfigManager::MAX_MONSTER_LEVEL));
    
	int32_t monsterLevel = random_range(5, maxLevelValue + 5);
        
	mType->health = (uint64_t)std::ceil(mType->health * monsterLevel / 10);
    mType->healthMax = (uint64_t)std::ceil(mType->healthMax * monsterLevel / 10);
    mType->experience = (uint64_t)std::ceil(mType->experience * monsterLevel / 10);
    mType->defense = (uint64_t)std::ceil(mType->defense * monsterLevel / 10);
    mType->armor = (uint64_t)std::ceil(mType->armor * monsterLevel / 10);
    
    Monster* monster = Monster::createMonster(mType);
    monster->doMonsterSetCombatValues(monsterLevel - 10);
    monster->doMonsterSetLevel(monsterLevel - 5);
	
    mType->health = normHealth;
    mType->healthMax = normMaxHealth;
    mType->experience = normExp;
    mType->defense = normDef;
    mType->armor = normArm;
	
    if(!monster)
		return false;

	if(startup)
	{
		//No need to send out events to the surrounding since there is no one out there to listen!
		if(!g_game.internalPlaceCreature(monster, pos, false, true))
		{
			delete monster;
			return false;
		}
	}
	else
	{
		if(!g_game.placeCreature(monster, pos, false, true))
		{
			delete monster;
			return false;
		}
	}

	monster->setSpawn(this);
	monster->addRef();

	monster->setMasterPosition(pos, radius);
	monster->setDirection(dir);

	spawnedMap.insert(SpawnedPair(spawnId, monster));
	spawnMap[spawnId].lastSpawn = OTSYS_TIME();
	return true;
}


~~configmanager.cpp~~


Szukamy:
PHP:
m_confDouble[RATE_MONSTER_DEFENSE] = getGlobalDouble("rateMonsterDefense", 1);

I pod tym dodajemy:
PHP:
m_confNumber[MAX_MONSTER_LEVEL] = getGlobalNumber("maxMonsterLevel", 10);

Za? w configmanager.h, pod:
PHP:
BAN_MONTHLY_LIMIT,

Dodajemy:
PHP:
MAX_MONSTER_LEVEL,


~~monsters.cpp~~


I ostatnia cz???. Szukamy:
PHP:
race = RACE_BLOOD;

I nad tym dodajemy:
PHP:
maxLevel = 10;

Znajdujemy:
PHP:
if(readXMLInteger(root, "experience", intValue))
	mType->experience = intValue;

I pod tym dodajemy:
PHP:
if(readXMLInteger(root, "maxLevel", intValue))
	mType->maxLevel = intValue;

Szukamy:
PHP:
void MonsterType::dropLoot(Container* corpse)

I zamieniamy ca?? funkcj? na:
PHP:
void MonsterType::dropLoot(Container* corpse, int32_t randomDamage)
{
    Item* tmpItem = NULL;
	for(LootItems::const_iterator it = lootItems.begin(); it != lootItems.end() && !corpse->full(); ++it)
	{
		if((tmpItem = createLoot(*it, randomDamage)))
		{
			if(Container* container = tmpItem->getContainer())
			{
				if(createChildLoot(container, (*it), randomDamage))
					corpse->__internalAddThing(tmpItem);
				else
					delete container;
			}
			else
				corpse->__internalAddThing(tmpItem);
		}
	}

	corpse->__startDecaying();
	uint32_t ownerId = corpse->getCorpseOwner();
	if(!ownerId)
		return;

	Player* owner = g_game.getPlayerByID(ownerId);
	if(!owner)
		return;

	LootMessage_t message = lootMessage;
	if(message == LOOTMSG_IGNORE)
		message = (LootMessage_t)g_config.getNumber(ConfigManager::LOOT_MESSAGE);

	if(message < LOOTMSG_PLAYER)
		return;

	std::stringstream ss;
	ss << "Loot of " << nameDescription << ": " << corpse->getContentDescription() << ".";
	if(owner->getParty() && message > LOOTMSG_PLAYER)
		owner->getParty()->broadcastMessage((MessageClasses)g_config.getNumber(ConfigManager::LOOT_MESSAGE_TYPE), ss.str());
	else if(message == LOOTMSG_PLAYER || message == LOOTMSG_BOTH)
		owner->sendTextMessage((MessageClasses)g_config.getNumber(ConfigManager::LOOT_MESSAGE_TYPE), ss.str());
}

Potem ni?ej szukamy:
PHP:
Item* MonsterType::createLoot(const LootBlock& lootBlock)

I podmieniamy ca?? funkcj? na
PHP:
Item* MonsterType::createLoot(const LootBlock& lootBlock, int32_t randomDamage)
{
	uint16_t item = lootBlock.ids[0], random = Monsters::getLootRandom() + (Monsters::getLootRandom() * randomDamage / 10);
	if(lootBlock.ids.size() > 1)
		item = lootBlock.ids[random_range((size_t)0, lootBlock.ids.size() - 1)];

	Item* tmpItem = NULL;
	if(Item::items[item].stackable)
	{
		if(random < lootBlock.chance)
			tmpItem = Item::CreateItem(item, (random % lootBlock.count + 1));
	}
	else if(random < lootBlock.chance)
		tmpItem = Item::CreateItem(item, 0);

	if(!tmpItem)
		return NULL;

	if(lootBlock.subType != -1)
		tmpItem->setSubType(lootBlock.subType);

	if(lootBlock.actionId != -1)
		tmpItem->setActionId(lootBlock.actionId);

	if(lootBlock.uniqueId != -1)
		tmpItem->setUniqueId(lootBlock.uniqueId);

	if(!lootBlock.text.empty())
		tmpItem->setText(lootBlock.text);

	return tmpItem;
}

Troch? ni?ej znajdujemy:
PHP:
bool MonsterType::createChildLoot(Container* parent, const LootBlock& lootBlock)

I podmieniamy ca?? funkcj? na:
PHP:
bool MonsterType::createChildLoot(Container* parent, const LootBlock& lootBlock, int32_t randomDamage)
{
	LootItems::const_iterator it = lootBlock.childLoot.begin();
	if(it == lootBlock.childLoot.end())
		return true;

	Item* tmpItem = NULL;
	for(; it != lootBlock.childLoot.end() && !parent->full(); ++it)
	{
		if((tmpItem = createLoot(*it, randomDamage)))
		{
			if(Container* container = tmpItem->getContainer())
			{
				if(createChildLoot(container, (*it), randomDamage))
					parent->__internalAddThing(container);
				else
					delete container;
			}
			else
				parent->__internalAddThing(tmpItem);
		}
	}

	return !parent->empty();
}


~~monsters.h~~


Szukamy:
PHP:
void dropLoot(Container* corpse);
Item* createLoot(const LootBlock& lootBlock);
bool createChildLoot(Container* parent, const LootBlock& lootBlock);

I zamieniamy na:
PHP:
void dropLoot(Container* corpse, int32_t randomDamage);
Item* createLoot(const LootBlock& lootBlock, int32_t randomDamage);
bool createChildLoot(Container* parent, const LootBlock& lootBlock, int32_t randomDamage);

Znajdujemy:
PHP:
lightLevel, lightColor, changeTargetSpeed, changeTargetChance;

I zamieniamy na:
PHP:
lightLevel, lightColor, changeTargetSpeed, changeTargetChance, maxLevel;

OPCJONALNIE POZIOM PRZY NAZWIE POTWORA
~~protocolgame.cpp~~


Szukamy:
PHP:
void ProtocolGame::AddCreature(NetworkMessage_ptr msg, const Creature* creature, bool known, uint32_t remove)

W tej funkcji znajdujemy:
PHP:
msg->AddString(creature->getHideName() ? "" : creature->getName());

I zamieniamy na:
PHP:
std::stringstream ss;
ss << creature->getName();
if(creature->getMonster())
	ss << " [L. " << creature->getMonster()->getMonsterLevel() << "]";
msg->AddString(creature->getHideName() ? "" : ss.str());


S??wko wyja?nienia. Ilo?? poziom?w danego potwora mo?na dodawa? na dwa sposoby. Indywidualnie dla ka?dego potwora z osobna, sposobem takim - ko?o experience="xxx" dodajemy maxLevel="xx", gdzie 'xx' to maksymalny poziom. Poziom pierwszy potwora os?abia go o 50%, poziom dziesi?ty wzmacnia o 50%. Jeden poziom to 10% wi?cej/mniej si?y. Wi?cej hp, expa, wi?ksze obra?enia i co tam tylko mo?na. Drugi spos?b to ustawienie w config.lua maksymalnego poziomu dla wszystkich potwor?w za pomoc?:
PHP:
maxMonsterLevel = xx
Bazowo jest ustawione 10 poziom?w.


Je?li czego? zapomnia?em napisa?, wkrad?a si? liter?wka czy cokolwiek innego, pisa?.
 

SanninStory

https://www.twitch.tv/sdrn
Joined
Oct 13, 2012
Messages
1,778
Reaction score
119
Odp: Poziomy potwor?w

?wietny skrypt.
Kiedy? go szuka?em i niestety nie znalaz?em.
Du?o si? napisa?e? ;P

Dzi?kuj? i Pozdrawiam.
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: Poziomy potwor?w

130 odwiedzaj?cych, jeden komentarz, zero skarg, ?e s? b??dy, kt?re s?.
Od?wie?am.
 

Dantez

Moim sekretem jest ciasto
Joined
May 22, 2008
Messages
1,206
Reaction score
202
Odp: Poziomy potwor?w

U mnie prawie 1600 odwiedzin, 6 miesi?cy, same pozytywne komentarze, a nie dzia?a?o poprawnie :D

Dobre, tylko wed?ug mnie w z?ym miejscu ^^
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: Poziomy potwor?w

Ju? poprawi?em. Powinno dzia?a? dobrze. Wszyscy wychwalaj? pomys?, ale nikomu nie chce si? tego testowa?. To jest to.

Z?ym miejscu? To gdzie powinno to by??

#down
Jedyna r??nica jaka b?dzie, to taka, ?e podczas r?cznego tworzenia potwor?w b?d? one otrzymywa? poziomy. Mo?na tak zrobi?, ale to ju? ka?dy indywidualnie wykona.
Poprawiony b??d.
 
Last edited:

Dantez

Moim sekretem jest ciasto
Joined
May 22, 2008
Messages
1,206
Reaction score
202
Odp: Poziomy potwor?w

Monster* Monster::createMonster(MonsterType* mType)

I b??d:
PHP:
ss << creature->getName() << (creature->getMonster ? creature->getMonster->getMonsterLevel() : "");

@up
O to mi chodzi?o.
 
Last edited:

zolty1

New User
Joined
Dec 3, 2011
Messages
1
Reaction score
1
Odp: Poziomy potwor?w

mam ten b??d

../monster.cpp: In member function `virtual void Monster::dropLoot(Container*)':
../monster.cpp:1294: error: no matching function for call to `MonsterType::dropLoot(Container*&, int32_t&)'
../monsters.h:89: note: candidates are: void MonsterType::dropLoot(Container*)

make.exe: *** [obj//monster.o] Error 1

Execution terminated
 

Matt

Banned
Joined
May 9, 2013
Messages
595
Reaction score
46
Odp: Poziomy potwor?w

Spr?buj zamieni? randomDamage na (*randomDamage)
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: Poziomy potwor?w

Poprawione wszystko. Teraz dzia?a poprawnie.
 

SanninStory

https://www.twitch.tv/sdrn
Joined
Oct 13, 2012
Messages
1,778
Reaction score
119
Odp: Poziomy potwor?w

Mam pytanie.
Czy da?o by rad? zrobi? wersj? kt?ra dawa?a by lvle dla okre?lonych potwor?w?
Bez dodawania notki w monster.xml?

Pozdrawiam.
 

SanninStory

https://www.twitch.tv/sdrn
Joined
Oct 13, 2012
Messages
1,778
Reaction score
119
Odp: Poziomy potwor?w

Siema.

Po dodaniu skryptu do Source mam ten b??d, Log z Kompilacji:


Usun??em spacje mi?dzy funkcjami, ale dalej jest co? nie tak.

Towarzysze, pomo?ecie ?

@Edit,
Dobra upora?em si? z tym.
Nale?a?o usun?? przerwy mi?dzy kilkoma funkcjami, kt?re stworzy? tag [LUA] na tnet.

Pozdrawiam.
 
Last edited:

She

Active User
Joined
Nov 6, 2008
Messages
71
Reaction score
0
Odp: Poziomy potwor?w

Taki b??d przy kompilacji:

Code:
  In member function 'virtual bool Monster::getCombatValues(int32_t&, int32_t&)': 
1226 \monster.cpp 'RATE_MONSTER_DEF' is not a member of 'ConfigManager' 
1228 \monster.cpp 'RATE_MONSTER_ATT' is not a member of 'ConfigManager' 
1228 \monster.cpp *** [obj//monster.o] Error 1

Jaka? podpowiedz ? :p

@Edit,
Ju? wszystko okej
 
Last edited:
Status
Not open for further replies.
Top