Magic Spell Checker

Hello.

So, I have numerous commands that cast magic spells...

There are a few rules which apply to all spell commands. For instance, you can't cast any spells on something which is somehow protected from magic (which would have an attribute like magic_resistant).

Can I add an attribute to a command, like spell_cmd, then check for the attribute in HandleSingleCommand or something? This way, if I had 20 spell commands, I wouldn't have to check for a magic resistant object in every script. I could just check for the attribute up front.

Something like this in HandleSingleCommand, maybe?

if (GetBoolean(GetObject(game.pov.currentcommandpattern.name), "spell_cmd"){
  if (GetBoolean(object, "spell_resistant")){
    msg ("You can't do that.")
    return (false)
  }
}
// Proceed with the normal script...

I see no reason why not.

Though it seems a little odd to do GetObject(game.pov.currentcommandpattern.name) rather than just using game.pov.currentcommandpattern.

I was actually wondering if (in a more general sense) it might be possible to have a lot of error messages generated by the parser. I can see the system in my head, but after ten minutes thinking, I still can't see a good way to describe it :S I already looked into allowing a command's scope to filter the list by attributes or similar; in this case, if the player tries a visible object that isn't in scope (for example if spell resistant items are excluded from the scope of spells), it could pull the appropriate error message or template out of a dictionary on the command object.


just some food for thought only

(doing a universal 'magic resistance' check is fine too, whatever magic system design you want to do)


a more complex magic system:

a fire dragon may 'absorb' fire damage (healing the fire dragon instead)

a fire sorcerer may 'reflect' fire damage (usually at half damage back upon you/attacker)

a fire lizard may 'nullify' fire damage (no damage done to the fire lizard: it has "immunity" to fire damage)

a fire genie may 'reduce' fire damage (the fire genie is "strong" against fire magic, usually half damage is only done to it)

and a human bandit may receive the 'normal' fire damage upon it

and/or you can have a fire imp actually being 'weak' to the fire damage as well (doing x1.5 or x2 or whatever extra damage to it)


and a 'water' monster would be "weak" to 'fire' damage (or it too can be protected from its opposing element: strong, immune, absorb, reflect) (or it can just receive the 'normal' damage to it as well)

and other (non-same and non-opposite) element damage types would do "normal" damage (or it too can be any of these as well: strong, immune, absorb, reflect, weak) to the monster


with this magic system... it might be better to use pixies' string dictionary design (see pixie's magic/spell library / I think this is included now in his combat library 3.0/2.0/whatever-version) for checking for opposing elements, and if have the same (or opposite, or: neither same nor opposite) element, then another check for which of these different magic effects, ie: OBJECT.magic_damage_effect_type_string_attribute = (one of these: normal, weak, strong, absorb, reflect, immune), it has...

then, if you're still able to do damage to it (or done back to yourself, in regards to 'reflect', lol), you can check if its (or your) fire resistance prevents it from 'hitting' (actually doing damage or not) it (or you): "resistance (like Armor Class/"AC") or magical_defense' in whether a physical hit actually hits/damages you or not)

then, you can check/determine how much actual damage is done to it (or you): "reduction/magic_defense or resistance" (determines how much you're actually damaged for)

meh, choose whatever terminology for the various things... not sure if there's any standard terminology... lol... so many rpgs... even D&D... isn't really the basis anymore of RPGs... due to just how many rpgs there are and their different systems/mechanics and unique terminologies... lol


I was hoping for a cool way to check spelling. Oh well...

For my combat library, I had a spell type that does all that sort of general stuff, and that then calls another script that belongs to the individual spell. I used objects to represent spells, rather than commands...

But that is okay, because commands are objects too! Not quite as easy, as the script attribute seems protected in some way, but you can do it.

First override ResolveNextName so it will call "prescript" if it exists, rather than "script". This is just the end of it:

  if (not GetBoolean(game.pov.currentcommandpattern, "isoops")) {
    // TO DO: game.unresolved* should be game.pov.unresolved*
    game.unresolvedcommand = null
    game.unresolvedcommandvarlist = null
    game.unresolvedcommandkey = null
  }
  if (HasScript(game.pov.currentcommandpattern, "script")) {
    if (HasScript(game.pov.currentcommandpattern, "prescript")) {
      do (game.pov.currentcommandpattern, "prescript", game.pov.currentcommandresolvedelements)
    }
    else {
      // This is the bit that actually runs the commands
      do (game.pov.currentcommandpattern, "script", game.pov.currentcommandresolvedelements)
    }
  }
  HandleNextCommandQueueItem
}

Now create a new type, and give it a "prescript" script attribute.

if (GetBoolean(object, "magic_resistant")) {
  msg ("The " + GetDisplayName(object) + " resists the spell.")
}
else {
  do (this, "script", game.pov.currentcommandresolvedelements)
}

Then give all your spells this type.

Note that all commands of the same type must use the same set of variables (object, text1, whatever).


When I was playing with the advanced scope script, I thought about being able to specify that the scope was limited to containers, or to objects in containers, or to objects with a specific attribute, or similar.

But now, I'm thinking that could better be represented by a dictionary.

I'm poking around to see if I can make it work. Basically, the parser goes through the keys in the dictionary, and removes objects that don't fit them from scope. If this means that there's no matching items in scope and the command falls back on secondaryscope, then the parser looks back to see which of these clauses (if any) removed that object from scope, and displays the appropriate message instead of running the script.

So the 'open' command could have a scopefilter dictionary with key "!isopen" and value "You can't open that", and key "isopen=true" with value "It's already open!". If there's multiple objects that match what the player typed, then Quest will assume the one that isn't filtered out by any of those criteria; and if there isn't one, it can display the error message without having to call the command's script.

I assume you can have a command inherit from a type which provides a dictionary :p
(the big stumbling block so far is trying to work out whether the dictionary keys should be the pattern that causes that message to display, or the pattern that allows the item to remain in scope)


I was hoping for a cool way to check spelling. Oh well...

Sorry! Didn't mean to get your hopes up. (I am still researching the SpellCheck settings. I theorize that there is a way Quest can disable the spellcheck if a language other than the dictionary's language is being used.)

UPDATE

Well, I don't know if SpellCheck can ignore languages other than English, Spanish, French, and German. This info seems to say it cannot:

https://blogs.msdn.microsoft.com/text/2009/10/02/custom-dictionaries/


For my combat library, I had a spell type that does all that sort of general stuff, and that then calls another script that belongs to the individual spell. I used objects to represent spells, rather than commands...

I think this is what I'm using... I thought this was what I was using... Maybe I just need to go through the code I've already got. (Hehehe.)


HK,

Oh, heck yeah! Lots of that stuff will be checked, too. (You listed a few I hadn't thought of. Well played!)


mrangel,

It sounds like you're cooking up some good code!


Log in to post a reply.

Support

Forums