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

Feature Spells required certain level of skill

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,838
Solutions
18
Reaction score
617
Location
Poland
Hello!
I want release an modification to C++.
Works in TFS0.3.5pl1 / TFS0.3.6pl1. (and thinkin it works too on 0.4 and others)​

Information about this modification:
You can set level of skill what is required for use the spell by write in spells.xml in any spell one line (ex. club = "15") and player must have above= 15 club to use the spell.
It's perfect system for ot's like Dragon Ball, Naruto, Bleach and other anime.

Application (spells.xml):
<instant name="-----" words="-----" clubpoints="15" lvl="-" mana="-" aggressive="-" selftarget="-" exhaustion="----" event="script" value="----.lua"/>


1) Declare message:
- find (player.cpp):
case RET_TILEISFULL:
sendCancel("You cannot add more items on this tile.");
break;

- and add under this code (player.cpp):
PHP:
        case RET_NOTENOUGHSKILL:
            sendCancel("You do not have enough club fighting.");
            break;
( you can change the name of skill )

2) Declare the line (what is checking the skill) in spells.xml:
- find (spells.cpp):
if(readXMLInteger(p, "maglv", intValue) || readXMLInteger(p, "magiclevel", intValue))
magLevel = intValue;

- and add under this code (spells.cpp):
PHP:
	if(readXMLInteger(p, "club", intValue) || readXMLInteger(p, "clubpoints", intValue))
	 	clubpoints = intValue;

3) Add the main function:
- find (spells.cpp):
if((int32_t)player->getMagicLevel() < magLevel)
{
player->sendCancelMessage(RET_NOTENOUGHMAGICLEVEL);
g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
return false;
}

- add under this code (spells.cpp):
PHP:
	if((int32_t)player->getSkill(SKILL_CLUB, SKILL_LEVEL) <  clubpoints)
	{
		player->sendCancelMessage(RET_NOTENOUGHSKILL);
		g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
		return false;
	}

- find (spells.h):
int32_t getMagicLevel() const {return magLevel;}

- add under this code (spells.h):
PHP:
		uint32_t getSkill() const {return clubpoints;}

- find (spells.h):
int32_t magLevel;

- add under (spells.h):
PHP:
		int32_t clubpoints;

- find (thing.h):
RET_TILEISFULL = 64,

- add under (thing.h):
PHP:
	RET_NOTENOUGHSKILL = 65
(without a comma at end or with [if you have more declared messages])

4) Press Rebuild All (Ctrl+F11)
You must press -> "rebuild all", because you edited the *.h files and if you wont rebuild your project (not compile), you can get crashes and problems.

5) Done!
It's simple modification but may be usefull for any spells or spell formulas (ex. level*2 + clubpoints*2) ;)

Regards,
Fresh.
 
Last edited:
-D__CONSOLE__ -fexpensive-optimizations -O1

../player.cpp: In member function 'void Player::sendCancelMessage(ReturnValue) const':
../player.cpp:1157: error: 'RET_NOTENOUGHSKILL' was not declared in this scope

mingw32-make: *** [obj-console//player.o] Error 1

Help me ?


Edit: Fix ...

this is wrong
- find (thing.h):
RET_TILEISFULL = 64,
- add under (thing.h):
RET_NOTENOUGHTRAINPOINTS = 65

correct
- find (thing.h):
RET_TILEISFULL = 64,
- add under (thing.h):
RET_NOTENOUGHSKILL = 65
 
Last edited:
Yaa and add that some lines in 100+ spells ^_^
Its much comfortable. I dont like lua :ninja:
 
It seems to be that you made it only to work with club fighting

Also, you used the variable 'RET_NOTENOUGHSKILL' but you declared 'RET_NOTENOUGHTRAINPOINTS', that's why Cah_ZiN gots a compiling error

EDIT:

I made it to work in this way (NOTE: I made and tested this code on TFS 0.3.6pl1):
Code:
	<instant name="Light Healing" words="exura" lvl="9" [B][COLOR="#FF8C00"]skill="SKILL_AXE" skillValue="100"[/COLOR][/B] mana="20" aggressive="0" selftarget="1" exhaustion="1000" needlearn="0" event="script" value="healing/light healing.lua">

At player.cpp, After:
Code:
		case RET_TILEISFULL:
			sendCancel("You cannot add more items on this tile.");
			break;

Add:
Code:
		case RET_NOTENOUGHSKILL:
            sendCancel("You do not have the required skill points.");
            break;

Go to spells.cpp, after
Code:
	if(readXMLInteger(p, "maglv", intValue) || readXMLInteger(p, "magiclevel", intValue))
	 	magLevel = intValue;

Add:
Code:
	if(readXMLInteger(p, "skill", intValue) || readXMLInteger(p, "skillId", intValue))
	{
      	skill = (skills_t)intValue;   		                 
 		if(readXMLInteger(p, "skillValue", intValue))
			skillValue = intValue;
	}

Still on spells.cpp, find:
Code:
	if((int32_t)player->getMagicLevel() < magLevel)
	{
		player->sendCancelMessage(RET_NOTENOUGHMAGICLEVEL);
		g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
		return false;
	}

After it, add:
Code:
 	if((int32_t)player->getSkill((skills_t)skill, SKILL_LEVEL) <  skillValue)
    {
        player->sendCancelMessage(RET_NOTENOUGHSKILL);
        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
        return false;
    }

Now go to spells.h, find:
Code:
		int32_t magLevel;

After it, paste:
Code:
		int32_t skillValue;
		uint32_t skill;

Now go to things.h, find:
Code:
	RET_TILEISFULL = 64

Replace it with:
Code:
	RET_TILEISFULL = 64,
	RET_NOTENOUGHSKILL = 65

Press F+11 to rebuild the project and done!
 
Last edited:
All of that could be done with a checkPlayerSkill(skill, n) 050-function.lua implementation. (meaning not even 3 lines will be needed in the spells lua files)
 
Back
Top