One target spell

After several years working with Quest, I have been using Pixie's combat lib and decided it was time to figure out a one target attack spell. Now when the player 'Learns'...let's say a fire spell, I added some lines to the end of the 'Learn' script for that spell.

if (this.parent = spells_known) {
  msg ("<br>Er, you already know that one!")
}
else if ((game.pov.intelligence + game.pov.magicbonus) < this.level) {
  msg ("<br>That spell is way out of your league. Perhaps if you were more intelligent...")
}
else if (OkayToLearn(this)) {
  do (this, "dolearn")
  SetInventory2 (GetDirectChildren (spells_known))
  foreach (object, AllObjects ()) {
      if (DoesInherit(object, "monster")) {
        object.displayverbs = Split("Look at;Attack;Cast Ignis", ";")
    }
  }
}

The last part of the code will add 'Cast Ignis'(which is Latin for fire and the alias for my fire_ball spell) to the drop down display verbs for all monsters in the game.

I thought this was the best way to do a one target spell. Player clicks on which ever target they want and since the spell is learned they simply select the verb from the drop down hyper link verbs. If they learn more attack spells they will be added also. There should only be a few so it won't get too cluttered.

Now that it is added to each monster I can write a function or command to do the damage (haven't yet).

Any ideas on this or comments welcome! Any code examples will help to because my pain meds make it tougher to focus anymore.

I know this is small potatoes for most coders on here but it's big ta do'ins for me.


its a good start for what you're doing: practicing the basics of spell/magic/casting coding

(if you were to have lots of spells... you wouldn't want a verb button for every one of them, you just want a 'cast' verb, and let its scripting do all of the handling it)


The verb for every spell will work better for hyperlinks than the panes on the right, which will look a bit poor when you have a dozen spells.

There is an issue with the code; if the player has already learnt a spell, that verb will already be added. When you add this verb, you will lose the earlier one.


There is an issue with the code; if the player has already learnt a spell, that verb will already be added. When you add this verb, you will lose the earlier one.

I was going to comment on that.

Instead of:
object.displayverbs = Split("Look at;Attack;Cast Ignis", ";")
I think you want
object.displayverbs = ListCombine(object.displayverbs, Split("Cast Ignis"))


The verb being added by a script is good. However I found that it will only work if the monster has 'Cast Ignis' as a verb. I am stumped on the coding to add the verb to each monster as I did the display verb. If that makes sense.

I can manually add it to each monster with a flag check as to whether the spell is learned or not, to stop the player from typing it in, but I was hoping to add to the learn verb so it adds the 'Cast Ignis' verb automatically.

I can't figure out if I can use a command in the display verbs drop down instead of a verb. It is beyond me.

It's a forum search and piece together for me. I am not seeing that anyone has tried to do this.
Would a global verb 'cast ignis be feasable or does each monster need to have it. I'm good with commands but haven't got the verb thing figured out completely. I see them in the commands.xml from combatlib but they a something completely different.

Thanks for the coding and advice!


However I found that it will only work if the monster has 'Cast Ignis' as a verb.

Verbs are for an action which does something different depending which object you use it on.

I'm thinking that Ignis will cause damage, basically doing the same for any monster. In this case you probably want a command, which allows you to have one piece of code that can be used for any object.

'displayverbs' only controls what appears on the menu; when you click them, the command is sent to Quest just like the player typed it. They don't have to be verbs.


A Verb is actually just a Script Attribute with extra code fluff to give it: its verb button (in the panes on the right side) and hyperlink (in the big text box on the left side) functionality, and also its functionality as a special sub Command

A Verb is also a special sub Command:

its just like a Command, except it automatically passes its parent Object to the internal Command handling of/for it, and also its scripting is dependent upon each Object (as a Verb is a Script Attribute), meaning that for each Object that has the Verb (the Script Attribute), you can give it, its own unique scripting, unlike a (normal) Command.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums