ID:138476
 
Well I finally got my spell system working, and my ordering thing works now thanx to Tom. Now I'm having problems making it so you can actually cast the spells in your spellbook. Basically what a spell or ability is as of now is an obj inside a list such as magespells, priestspells, or abilities. When I try using set src in usr.magespells I get an error. My cast verb doesn't come up when I right click the spell in the spellbook. Do I need to set the src differently? I was able to cast it with the call proc, but this is cumbersome and doesn't allow me to specify targets or use my multiple ways of casting thing.
I tried this code and it seems to work fine... hope it helps.

mob
var
list/spells


verb
cast(spell/mySpell in usr.spells)
mySpell.Cast()


New()
. = ..()
spells = new /list()
spells += new /spell/Fireball
spells += new /spell/Light


spell
var/name

Fireball
name = "Fireball"
Light
name = "Light"

proc/Cast()
world << "[usr] just cast a [name] spell!"
In response to Guy T.
On 7/22/00 9:00 am Guy T. wrote:
I tried this code and it seems to work fine... hope it helps.

I think he was talking about the set src function. Set src can only be used in certain ways (see the src var of verbs in the documentation). You would be best to do it Guy's way and have it as a mob verb instead of an object verb. Note that you can always move spells into your contents and then refuse to show spells in the inventory pane by changing the behavior of Stat(). Then "set src in usr" would work, and usr.magespells would still contain the references to these objects.

(If Dantom has time, I humbly and quietly request as a feature "set src" may be used with any defined reference, list, or list of references, not simply the ones given.)


In response to Spuzzum
(If Dantom has time, I humbly and quietly request as a feature "set src" may be used with any defined reference, list, or list of references, not simply the ones given.)

It'd be a nice feature, but it seems like this could also be an invitation to disaster! I could be all wrong, but here's how I *think* it works.

The client has to be aware of the potential src values constantly. If you have, say, a SaveStone that creates a verb "save" with set src = view(5) so anyone nearby can save the game, that means a quick response time is needed. You don't want to walk within 5 spaces of the stone and then wait a few seconds for the verb to appear in your panel; it should be almost instantaneous. In DM, it is indeed almost instantaneous, and the reason (I assume) is because "set src" has to use a list that the client is already using (and the list might even be specially optimized for quick update across the network).

Now, if you create some list that may mean a lot to the server but means nothing to the client--let's say, for example, you build a list of evil PC's who can use a take_hostage verb--then, in order to check whether a given verb should be active, the client would have to be constantly checking the server to see how the list of evil PC's is changing. In many cases this might not take up too much bandwidth, but if the list gets real long or you have a screen with 10 different objects all using custom-src verbs, then your game will update at about 5 frames per minute and your modem is going to melt in protest.

Or maybe not. Like I said, this is all just my speculation. Still, it makes a kind of sense to me...

(Also see Dan's message about expansion from last night. You can use this feature to get a lot of extra mileage out of verbs--though without an implementation of your suggestions for "set src", you're always going to have the opportunity for situations where someone can see a verb, but when he goes to use it, you just have to tell him "Sorry, this isn't for you." Small price to pay for snappy response time, though!)
On 7/22/00 8:28 am DerDragon wrote:
Well I finally got my spell system working, and my ordering thing works now thanx to Tom. Now I'm having problems making it so you can actually cast the spells in your spellbook. Basically what a spell or ability is as of now is an obj inside a list such as magespells, priestspells, or abilities. When I try using set src in usr.magespells I get an error. My cast verb doesn't come up when I right click the spell in the spellbook. Do I need to set the src differently? I was able to cast it with the call proc, but this is cumbersome and doesn't allow me to specify targets or use my multiple ways of casting thing.


I don't know if you are showing the spells in the panels, but if you are, you might need to do

set src in world

to get the verbs to show up.
In response to Guy T.
let's say, for example, you build a list of evil PC's who can use a take_hostage verb

Hmm, that's not a particularly sensible example, since the list in question refers to what can provide accessibility to the verb rather than who can use the verb. Oh well... I guess I need a few hours away from the computer. :)
In response to Deadron
set src in world

Huh. I thought I had put that in my post, but on second reading I guess I must've deleted it in favor of the set src in usr thing. Oh well ;-)