TFS 0.X Who cast the field/wall

maikons

Member
Joined
Aug 1, 2015
Messages
151
Reaction score
8
I saw a server that shows who call fire fields, energy field, poison field, magic wall, wild grow onLook

Like on this IMG:


Did someone know how to do it?
What can i change on spells.lua to monsters and players, could you guys gave me a base in one spell?
 

pudim

Well-Known Member
Joined
Jul 11, 2009
Messages
27
Reaction score
8
Funny thing, I own the server on those pics.This is done on the server's sources not on lua.
 
OP
M

maikons

Member
Joined
Aug 1, 2015
Messages
151
Reaction score
8
Funny thing, I own the server on those pics.This is done on the server's sources not on lua.
really!? gz, i saw in some topic, idk where, just saved the imgs
its a really nice detail to a server

is your server 0.4?

could you give a way? would be better do on LUA stuff?
 

pudim

Well-Known Member
Joined
Jul 11, 2009
Messages
27
Reaction score
8
really!? gz, i saw in some topic, idk where, just saved the imgs
its a really nice detail to a server

is your server 0.4?

could you give a way? would be better do on LUA stuff?
You probably saw it on on other forums since I didn't post it here(yet).
It's not 0.4, but it could be done in 0.4 no problems.The better option is to do it on c++, on lua you'd have to basicall re-write how a spell works, since you do not have the object needed(fields) to edit the fields at hand.Either that or you'd have to parse checking the area for the item created, getting their respectives uids, and then changing their description. Neither of these are very good solutions.

Since I use it on my server I can't give it away, but it's not something hard to do by any means.
 

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
You probably saw it on on other forums since I didn't post it here(yet).
It's not 0.4, but it could be done in 0.4 no problems.The better option is to do it on c++, on lua you'd have to basicall re-write how a spell works, since you do not have the object needed(fields) to edit the fields at hand.Either that or you'd have to parse checking the area for the item created, getting their respectives uids, and then changing their description. Neither of these are very good solutions.

Since I use it on my server I can't give it away, but it's not something hard to do by any means.
Actually that isn't true at all this feature does not require source edits at least not in 1.3. Shouldn't be too hard to do as a script in 0.x either. We don't always need to touch the sources everytime we want to add something original.
 

pudim

Well-Known Member
Joined
Jul 11, 2009
Messages
27
Reaction score
8
Actually that isn't true at all this feature does not require source edits at least not in 1.3. Shouldn't be too hard to do as a script in 0.x either. We don't always need to touch the sources everytime we want to add something original.
Something as simple as a 15 line on the sources could turn out to be a much bigger(and complex) solution on lua, specially on area-based spells.That's why I said c++ is the better option
 

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
Something as simple as a 15 line on the sources could turn out to be a much bigger(and complex) solution on lua, specially on area-based spells.That's why I said c++ is the better option
15 lines is a lot of code to use in C++ for something that can be done 1 to 3 lines in lua :)
 

pudim

Well-Known Member
Joined
Jul 11, 2009
Messages
27
Reaction score
8
I work long hours and i don't have access to a pc. Sorry if this is an inconvenience for you.
It really isn't as the problem itself wasn't presented by me, I'd just like to see this 1-3 lines of miraculous code =]
 

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
It really isn't as the problem itself wasn't presented by me, I'd just like to see this 1-3 lines of miraculous code =]
I bet you would ;)
As requested in 1.3 in player.lua right below this line
Lua:
function Player:onLook(thing, position, distance)
    local description = "You see " .. thing:getDescription(distance)
Place this (not tested ;) ) (it's 1 line ;) )
Lua:
description = (Tile(thing:getPosition()):hasFlag(TILESTATE_MAGICFIELD) and thing:hasAttribute(ITEM_ATTRIBUTE_OWNER)) and (description.."\nCasted By "..thing:getAttribute(ITEM_ATTRIBUTE_OWNER)..".\n") or description
 
Last edited:

pudim

Well-Known Member
Joined
Jul 11, 2009
Messages
27
Reaction score
8
The problem wasn't presented on tfs 1.3, it was on tfs 0.4 =)

Using the same logic, and using an exist onLook creaturescript, you'd have to add an if, one new function to print on the screen the new description and a return false to stop sending the 'normal' look message.

that would be 4+ lines =]

Apart from this it should work fine for 1.3, well done =)
#edit

I said 15 lines on c++ but it's actually just 4 xP
 

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
Ok now I got it working!
I at least tested it this time :)
Lua:
description = ( Tile(thing:getPosition()):hasFlag(TILESTATE_MAGICFIELD) and thing:hasAttribute(ITEM_ATTRIBUTE_OWNER) ) and (description.."\nCasted by "..Creature(thing:getAttribute(ITEM_ATTRIBUTE_OWNER)):getName() .. ".")  or description
Code:
22:14 You see a magic forcefield.
Item ID: 1387
Position: 95, 112, 7
Code:
22:15 You see a fire field.
Casted by Fire Elemental.
Item ID: 1487
Decays to: 1488
Position: 101, 116, 4
Code:
22:19 You see a fire field.
Casted by Dragon Lord.
Item ID: 1487
Decays to: 1488
Position: 95, 116, 7
 
Last edited:

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
The problem wasn't presented on tfs 1.3, it was on tfs 0.4 =)

Using the same logic, and using an exist onLook creaturescript, you'd have to add an if, one new function to print on the screen the new description and a return false to stop sending the 'normal' look message.

that would be 4+ lines =]

Apart from this it should work fine for 1.3, well done =)
#edit

I said 15 lines on c++ but it's actually just 4 xP
What gave me the hint was this section of code in combat.cpp
C++:
        Item* item = Item::CreateItem(itemId);
        if (caster) {
            // owner of field
            item->setOwner(caster->getID());
        }
What that told me was that since a player can get a skull or get a frag from killing another player or gain experience from killing/helping kill player/monster that they own the field and should have an attribute of ownership assigned to it.

I only wrote the 1.3 version because that is what I am using and I made it in 1.3 because that is what I said it could be made in a script as and possibly 0.x but idk. Haven't had much luck working in 0.x.
 
Last edited:
Top