Casting Spells at targets.

I’ve developed a couple of spells for my combat extension but I’m having trouble making it so the player cast them. I’ve been experimenting for a while but I can’t make it work. What I want to have is a simple system where the player or any NPC can pick a target and cast a spell they know at them. What I’m trying to get it to do is this:

  • Player clicks a hyperlink called “cast spell at goblin”

  • player gets a menu to choose the spell

  • player clicks the spell and it fires at the target

But at the moment the process I’m trying for is it, doesn’t work too well. Has anyone got any ideas?

[code]Target is a thing that varies.

Casting is an action applying to one visible thing. Understand “Cast [something]” or “Magic [something]” or “Enchant [something]” and “Cast at [something]” or “Magic on [something]” or “Cast Spell at [something]” as Casting.

Sorcery is an action applying to nothing. Understand “Magic” and “cast spell” and “cast magic” as Sorcery.

Check Casting: [Cast a spell AT something]
If the player is not Mage:
Say “You don’t know magic yet!”;
reject the player’s command;

Check Sorcery: [Cast a directionless spell]
If the player is not Mage:
Say “You don’t know magic yet!”;
reject the player’s command;

A thing can be MagicKnown. A thing is usually NOT MagicKnown.

Sparking-Missile-Known is a truth state that varies. Sparking-Missile-Known is true.

Carry out Casting:
Now the noun is Target;
Say “[paragraph break]-------------------------------------------------------------[line break]”;
If Sparking-Missile-Known is true:
Say “[o]Sparking Missile[x] (Ranged attack spell - normal damage)”;

Sparking Missile is an action applying to nothing. Understand “Sparking Missile” as Sparking Missile.

Check Sparking Missile: [Cast a spell AT something]
If the player is not Mage or Sparking-Missile-Known is false:
Say “You don’t know that magic yet!”;
reject the player’s command;

Carry out Sparking Missile:
Say “WOOSH!”;[/code]

edit: ignore the following if you actually want the command to be “cast spell” instead of “cast [spell name]”. I guess I failed to understand your intent (silly me).
[rant]If you want to cast something on something, there should be TWO nouns: the spell, and the thing you’re casting it on. If you tell I7 that casting applies to just one thing, it reads “CAST [spell name]” and stops there. If you try to specify a target, it won’t grok, because you never told it that spells require targets. Poor confused parser.

One solution is to cut down to one noun (the target) and just make the spell name a verb. For instance:

Laboratory is a room.

The dull gray rock is a thing carried by the player.

Frotzing [alternately, 'casting frotz'] is an action applying to one visible thing.  Understand "frotz [something]" or "cast frotz on [something]" as frotzing. [or, 'as casting frotz']

Carry out frotzing something (called the lightbulb):
	say "[The lightbulb] glows!";
	now the lightbulb is lit.

Test frotz with "x rock / frotz rock / x rock".

but that’s just lazy ol’ me, I’m used to typing two-word commands for pretty much everything. (“Rematch” was a hell of a puzzler for me because it’s a one-move game that requires, let’s just say, a much longer command.)

If you wanted to be nice about it, you could implement “Cast” as a separate action, applying to TWO things. See example 127, “Technological Terror” in the documentation for a nice demo of how to implement a new verb with two nouns. It shows you how to SHOOT FOO WITH BAR, but you could modify this to CAST FOO ON BAR.[/rant]
p.s. Also, that trailing semicolon at the end is going to make the software blorf, but I’m assuming that’s not the end of the command :wink: