• 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/C++] Change how instant spells are cast

xMikePortnoy

The Answer Lies Within
Joined
Jan 25, 2013
Messages
72
Reaction score
5
Location
São Paulo - Brazil
My question is kinda simple: i want to change the way spells work so that the players must speak "castspell <spell words>" instead of speaking "<spell words>" in the chat to cast a spell. What parts of the code should i change in order to achieve this? I don't need the code line by line, just which classes/functions i should edit. I found some functions related to casting spells in the InstantSpell,CombatSpell,BaseSpell classes but i didn't find where these functions are actually called.

Thanks in advance!
 
If your tfs version is 1.+ then you just need to go to the spells.xml and change the "words" used to cast the spell...

Here is an example:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<spells>
        <instant group="attack" spellid="62" name="Annihilation" words="exori gran ico" lvl="110" mana="300" prem="1" range="1" needtarget="1" blockwalls="1" needweapon="1" exhaustion="30000" groupcooldown="4000" needlearn="0" script="attack/annihilation.lua">
                <vocation name="Knight"/>
                <vocation name="Elite Knight"/>
        </instant>

Then you just need to change the words "exori gran ico" to "castspell exori gran ico" or whatever you wanna call it
 
Last edited by a moderator:
Thanks! It works, but if the player says for example "castspell potato", it will be sent in the chat like a normal message. I would like to reserve the word "castspell" so if the player says "castspell potato" it will say that the spell "potato" doesn't exist, or the player hasn't learnt it. That's why i wanna change the C++ engine. Also, i wouldn't need to change the XML for 100+ spells if i change the engine.
 
Last edited:
Thanks! It works, but if the player says for example "castspell potato", it will be sent in the chat like a normal message. I would like to reserve the word "castspell" so if the player says "castspell potato" it will say that the spell "potato" doesn't exist, or the player hasn't learnt it. That's why i wanna change the C++ engine. Also, i wouldn't need to change the XML for 100+ spells if i change the engine.
Kinda hard to change the engine if you don't even specify which are you using right?
https://otland.net/threads/read-before-creating-a-support-thread.18402/

#5. Post the server (and version) you are using; knowing the server beforehand will help people support you faster in case the server you are using doesn't have a feature.
 
Thanks! It works, but if the player says for example "castspell potato", it will be sent in the chat like a normal message. I would like to reserve the word "castspell" so if the player says "castspell potato" it will say that the spell "potato" doesn't exist, or the player hasn't learnt it. That's why i wanna change the C++ engine. Also, i wouldn't need to change the XML for 100+ spells if i change the engine.
Well firstly you don't need to edit 100 spells. Just do a Replace Search and replace words=" with words="castspell

And to hide "castspell" just create a talkaction called "castspell" (without parameters) and return false and send your message from there. I'm not sure it will work but I think so (maybe will override spells that way, but try it).
 
Well firstly you don't need to edit 100 spells. Just do a Replace Search and replace words=" with words="castspell

And to hide "castspell" just create a talkaction called "castspell" (without parameters) and return false and send your message from there. I'm not sure it will work but I think so (maybe will override spells that way, but try it).
I was gonna comment the exact same thing yesterday.
To fix the spells breaking, you can have a check in the talkaction. if not Spell(words) then dosomething
 
Back
Top