• 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!

[TFS] 2008-02-01 weakness/resistance

Lejjo

New Member
Joined
Sep 21, 2007
Messages
78
Reaction score
1
What is this code?
With this code you can choose if a certaine vocation should take more or less damage from different type of damage. I will explaine more at the end of this post, after the code part.

Start of the code:
game.cpp

Add...
Code:
        Player* targetPlayer = target->getPlayer();
        if(targetPlayer)
        {
            healthChange = -healthChange;
			
        	switch (combatType)
        	{
                case COMBAT_FIREDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getFireDamage() ) / 100;
                     break;
                case COMBAT_ENERGYDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getEnergyDamage() ) / 100;
                     break;
                case COMBAT_EARTHDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getEarthDamage() ) / 100;
                     break;
                case COMBAT_DROWNDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getDrownDamage() ) / 100;
                     break;
                case COMBAT_PHYSICALDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getPhysicalDamage() ) / 100;
                     break;
                case COMBAT_DEATHDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getDeathDamage() ) / 100;
                     break;
                case COMBAT_ICEDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getIceDamage() ) / 100;
                     break;
                case COMBAT_HOLYDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getHolyDamage() ) / 100;
                     break;
            }
        

            healthChange = -healthChange;
            
            if ( healthChange == 0 )
               return false;  
        }

...under
Code:
bool Game::combatChangeHealth(CombatType_t combatType, Creature* attacker, Creature* target, int32_t healthChange)
{
	const Position& targetPos = target->getPosition();

	if(healthChange > 0)
	{
		if(target->getHealth() <= 0)
			return false;
		
		if(attacker && target && attacker->defaultOutfit.lookFeet == target->defaultOutfit.lookFeet && g_config.getString(ConfigManager::CANNOT_ATTACK_SAME_LOOKFEET) == "yes" && combatType != COMBAT_HEALING)
			return false;

		target->changeHealth(healthChange);
	}
	else{
		SpectatorVec list;
		getSpectators(list, targetPos, true);

		if(!target->isAttackable() || Combat::canDoCombat(attacker, target) != RET_NOERROR)
		{
			addMagicEffect(list, targetPos, NM_ME_POFF);
			return true;
		}

		if(attacker && target && attacker->defaultOutfit.lookFeet == target->defaultOutfit.lookFeet && g_config.getString(ConfigManager::CANNOT_ATTACK_SAME_LOOKFEET) == "yes" && combatType != COMBAT_HEALING)
			return false;



player.h

Add...
Code:
		uint32_t getFireDamage() const {return vocation->getFireDamage();}
		uint32_t getEnergyDamage() const {return vocation->getEnergyDamage();}
		uint32_t getEarthDamage() const {return vocation->getEarthDamage();}
		uint32_t getDrownDamage() const {return vocation->getDrownDamage();}
		uint32_t getPhysicalDamage() const {return vocation->getPhysicalDamage();}	
		uint32_t getDeathDamage() const {return vocation->getDeathDamage();}
		uint32_t getIceDamage() const {return vocation->getIceDamage();}
		uint32_t getHolyDamage() const {return vocation->getHolyDamage();}

...under
Code:
uint32_t getAttackSpeed() const {return vocation->getAttackSpeed();}


vocation.cpp

Add...
Code:
                    if(readXMLInteger(p, "fireDamage", intVal)){
                    	voc->fireDamage = intVal;
                    }
                    if(readXMLInteger(p, "energyDamage", intVal)){
                        voc->energyDamage = intVal;
                    }
                    if(readXMLInteger(p, "earthDamage", intVal)){
                        voc->earthDamage = intVal;
                    }
                    if(readXMLInteger(p, "drownDamage", intVal)){
                        voc->drownDamage = intVal;
                    }
                    if(readXMLInteger(p, "physicalDamage", intVal)){
                        voc->physicalDamage = intVal;
                    }
                    if(readXMLInteger(p, "deathDamage", intVal)){
                        voc->deathDamage = intVal;
                    }
                    if(readXMLInteger(p, "iceDamage", intVal)){
                        voc->iceDamage = intVal;
                    }
                    if(readXMLInteger(p, "holyDamage", intVal)){
                        voc->holyDamage = intVal;
                    }

...under
Code:
					if(readXMLInteger(p, "fromvoc", intVal)){
						voc->fromVocation = intVal;
					}



Add...
Code:
	fireDamage = 100;
    energyDamage = 100;
    earthDamage = 100;
    drownDamage = 100;
    physicalDamage = 100;
    deathDamage = 100;
    iceDamage = 100;
    holyDamage = 100;

...under
Code:
	fromVocation = 0;


vocation.h

Add...
Code:
		uint32_t getFireDamage() const {return fireDamage;}
		uint32_t getEnergyDamage() const {return energyDamage;}
		uint32_t getEarthDamage() const {return earthDamage;}
		uint32_t getDrownDamage() const {return drownDamage;}
		uint32_t getPhysicalDamage() const {return physicalDamage;}
		uint32_t getDeathDamage() const {return deathDamage;}
		uint32_t getIceDamage() const {return iceDamage;}
		uint32_t getHolyDamage() const {return holyDamage;}

...under
Code:
		uint32_t getFromVocation() const {return fromVocation;}



Add...
Code:
		uint32_t fireDamage;
        uint32_t energyDamage;
        uint32_t earthDamage;
        uint32_t drownDamage;
        uint32_t physicalDamage;
        uint32_t deathDamage;
        uint32_t iceDamage;
        uint32_t holyDamage;

...under
Code:
		uint32_t attackSpeed;
End of the code:

Rebuild all and now you can add:
Don't mind my vocation, its my custom vocation, concentrate on the red parts.
Code:
	<vocation id="125" name="Lycanthropy (Braindeath)" description="a lycanthropy transformed into a braindeath" gaincap="10" gainhp="5" gainmana="30" gainhpticks="5" gainhpamount="15" gainmanaticks="2" gainmanaamount="15" manamultiplier="2.1" attackspeed="1800" soulmax="200" gainsoulticks="6000" fromvoc="12" basespeed="220" [COLOR="Red"]physicalDamage="130" energyDamage="80" fireDamage="90" poisonDamage="90" drownDamage="110"[/COLOR]>

Explanation
If you put 100 then the damage he/she gets will be normal.
If you put 200 then the damage he/she gets will be double.
If you put 50 then the damage he/she gets will be halved.
If you put 0 then the damage he/she gets will be 0 (total imune).
If you don't write anything (as you can see, I don't have holy/ice/death damage) then the damage he/she gets will be normal.

Please leave a comment :)
And if there is a better way to do this, please tell me then. Still learning :)

Yours,
Kadj
 
very good but, i w8 for tala create it for monsters too x)!, i belive that doesn't have it for monsters but very good for the vocations x)!
 
not working here

it doesn't makes any difference on the attack =\

edit: forgot about it, I understood badly :X
 
Last edited:
does it mean that with this code i can make on a ot for example that druid attacks frost dragon more with exori flam then with exori vis? For example?:D
 
Yep, but he will hits other monsters like frost dragon...
 
ye then it sucks...
cause i want to have a effect like on real tibia. So druid attacks a frost dragon more with exori flam then with exori vis for example.

Can someone help me?
 
Maybe I'm wrong, but doesn't player inherit from creature? Did You conisdered moving the code to creature code and making an excellent way of doing monster weakness/immunity thing from it?
 
Maybe I'm wrong, but doesn't player inherit from creature? Did You conisdered moving the code to creature code and making an excellent way of doing monster weakness/immunity thing from it?

Monsters weakness/resistance are already done in The Forgotten Server.
 
is it possible to make a spell like this which increases your resistance to fire for 50 percent as example?
What is this code?
With this code you can choose if a certaine vocation should take more or less damage from different type of damage. I will explaine more at the end of this post, after the code part.

Start of the code:
game.cpp

Add...
Code:
        Player* targetPlayer = target->getPlayer();
        if(targetPlayer)
        {
            healthChange = -healthChange;
			
        	switch (combatType)
        	{
                case COMBAT_FIREDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getFireDamage() ) / 100;
                     break;
                case COMBAT_ENERGYDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getEnergyDamage() ) / 100;
                     break;
                case COMBAT_EARTHDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getEarthDamage() ) / 100;
                     break;
                case COMBAT_DROWNDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getDrownDamage() ) / 100;
                     break;
                case COMBAT_PHYSICALDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getPhysicalDamage() ) / 100;
                     break;
                case COMBAT_DEATHDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getDeathDamage() ) / 100;
                     break;
                case COMBAT_ICEDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getIceDamage() ) / 100;
                     break;
                case COMBAT_HOLYDAMAGE:
                     healthChange = ( healthChange * targetPlayer->getHolyDamage() ) / 100;
                     break;
            }
        

            healthChange = -healthChange;
            
            if ( healthChange == 0 )
               return false;  
        }

...under
Code:
bool Game::combatChangeHealth(CombatType_t combatType, Creature* attacker, Creature* target, int32_t healthChange)
{
	const Position& targetPos = target->getPosition();

	if(healthChange > 0)
	{
		if(target->getHealth() <= 0)
			return false;
		
		if(attacker && target && attacker->defaultOutfit.lookFeet == target->defaultOutfit.lookFeet && g_config.getString(ConfigManager::CANNOT_ATTACK_SAME_LOOKFEET) == "yes" && combatType != COMBAT_HEALING)
			return false;

		target->changeHealth(healthChange);
	}
	else{
		SpectatorVec list;
		getSpectators(list, targetPos, true);

		if(!target->isAttackable() || Combat::canDoCombat(attacker, target) != RET_NOERROR)
		{
			addMagicEffect(list, targetPos, NM_ME_POFF);
			return true;
		}

		if(attacker && target && attacker->defaultOutfit.lookFeet == target->defaultOutfit.lookFeet && g_config.getString(ConfigManager::CANNOT_ATTACK_SAME_LOOKFEET) == "yes" && combatType != COMBAT_HEALING)
			return false;



player.h

Add...
Code:
		uint32_t getFireDamage() const {return vocation->getFireDamage();}
		uint32_t getEnergyDamage() const {return vocation->getEnergyDamage();}
		uint32_t getEarthDamage() const {return vocation->getEarthDamage();}
		uint32_t getDrownDamage() const {return vocation->getDrownDamage();}
		uint32_t getPhysicalDamage() const {return vocation->getPhysicalDamage();}	
		uint32_t getDeathDamage() const {return vocation->getDeathDamage();}
		uint32_t getIceDamage() const {return vocation->getIceDamage();}
		uint32_t getHolyDamage() const {return vocation->getHolyDamage();}

...under
Code:
uint32_t getAttackSpeed() const {return vocation->getAttackSpeed();}


vocation.cpp

Add...
Code:
                    if(readXMLInteger(p, "fireDamage", intVal)){
                    	voc->fireDamage = intVal;
                    }
                    if(readXMLInteger(p, "energyDamage", intVal)){
                        voc->energyDamage = intVal;
                    }
                    if(readXMLInteger(p, "earthDamage", intVal)){
                        voc->earthDamage = intVal;
                    }
                    if(readXMLInteger(p, "drownDamage", intVal)){
                        voc->drownDamage = intVal;
                    }
                    if(readXMLInteger(p, "physicalDamage", intVal)){
                        voc->physicalDamage = intVal;
                    }
                    if(readXMLInteger(p, "deathDamage", intVal)){
                        voc->deathDamage = intVal;
                    }
                    if(readXMLInteger(p, "iceDamage", intVal)){
                        voc->iceDamage = intVal;
                    }
                    if(readXMLInteger(p, "holyDamage", intVal)){
                        voc->holyDamage = intVal;
                    }

...under
Code:
					if(readXMLInteger(p, "fromvoc", intVal)){
						voc->fromVocation = intVal;
					}



Add...
Code:
	fireDamage = 100;
    energyDamage = 100;
    earthDamage = 100;
    drownDamage = 100;
    physicalDamage = 100;
    deathDamage = 100;
    iceDamage = 100;
    holyDamage = 100;

...under
Code:
	fromVocation = 0;


vocation.h

Add...
Code:
		uint32_t getFireDamage() const {return fireDamage;}
		uint32_t getEnergyDamage() const {return energyDamage;}
		uint32_t getEarthDamage() const {return earthDamage;}
		uint32_t getDrownDamage() const {return drownDamage;}
		uint32_t getPhysicalDamage() const {return physicalDamage;}
		uint32_t getDeathDamage() const {return deathDamage;}
		uint32_t getIceDamage() const {return iceDamage;}
		uint32_t getHolyDamage() const {return holyDamage;}

...under
Code:
		uint32_t getFromVocation() const {return fromVocation;}



Add...
Code:
		uint32_t fireDamage;
        uint32_t energyDamage;
        uint32_t earthDamage;
        uint32_t drownDamage;
        uint32_t physicalDamage;
        uint32_t deathDamage;
        uint32_t iceDamage;
        uint32_t holyDamage;

...under
Code:
		uint32_t attackSpeed;
End of the code:

Rebuild all and now you can add:
Don't mind my vocation, its my custom vocation, concentrate on the red parts.
Code:
	<vocation id="125" name="Lycanthropy (Braindeath)" description="a lycanthropy transformed into a braindeath" gaincap="10" gainhp="5" gainmana="30" gainhpticks="5" gainhpamount="15" gainmanaticks="2" gainmanaamount="15" manamultiplier="2.1" attackspeed="1800" soulmax="200" gainsoulticks="6000" fromvoc="12" basespeed="220" [COLOR="Red"]physicalDamage="130" energyDamage="80" fireDamage="90" poisonDamage="90" drownDamage="110"[/COLOR]>

Explanation
If you put 100 then the damage he/she gets will be normal.
If you put 200 then the damage he/she gets will be double.
If you put 50 then the damage he/she gets will be halved.
If you put 0 then the damage he/she gets will be 0 (total imune).
If you don't write anything (as you can see, I don't have holy/ice/death damage) then the damage he/she gets will be normal.

Please leave a comment :)
And if there is a better way to do this, please tell me then. Still learning :)

Yours,
Kadj
 
Hey can you say me how to do this on sword,fist,magic damage ? I'm testing many of things but i cant do this :<
 
Back
Top