Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Xantor
Newbie


Joined: 30 Jul 2012
Posts: 4

PostPosted: Thu Aug 02, 2012 1:59 pm   

Need help with Identify Spell capture
 
First let me say that I am severely programming challenged.
I am trying to capture the identify spell output and regurgitate it to whom ever handed me the eq item.
The response (tell/gtell/say) does not matter as long as the info is sent.

That being said, here is a sample of the output from a piece of armor, a potion and a wand/staff:


Object 'sword flaming threadslayer' type weapon, extra flags anti-evil flame spell_weapon.
Weight 5, value 1512, level 13.
Damage is 4 to 15 (average 9).
Weapon casts the spell 'shocking grasp' on hits.
Affects armor class by -5.
Affects strength by 1.
Affects constitution by -1.
Affects save vs breath by -2.
Affects damage roll by 3.

Object 'potion' type potion, extra flags magic.
Weight 1, value 5850, level 20.
Level 3 spells of: 'dispel magic' 'dispel magic' 'dispel magic'.

Object 'Horn Mistral' type staff, extra flags hum magic bless hover.
Weight 5, value 7840, level 27.
Has 7(7) charges at level 26 'control weather'.
Affects intelligence by 2.
Affects save vs spell by -10.
Affects moves by -50.
Affects mana by 45

Any assistance would be appreciated and remember please explain why this works, I might just learn something and bother you less.

Thanks in advance for your time and effort.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Aug 02, 2012 2:36 pm   
 
If you just want to spit out the the complete text you get from the identify spell, with no modification, and no storing of the information yourself, then we don't need to know what text you get from a successful identify spell. What we need to know are:

What text do you get when you receive the object to be identified?
How do you know that you are supposed to identify the given object for the giver?
Do you want any limitation on who can ask this service of you?
Do you want any limitations on _when_ you will do this service? (in the middle of battle, while casting other spells)
What command do you need to type to execute the identify spell?
What is the mud prompt you get when all of the output from the identify spell is finished?
What is the syntax of the say command you want to use to share the information with the giver?
Do you want to give the object back to the giver afterward?
What happens if you don't have enough mana for a spell?
Are there any circumstances (like Confusion or Paralysis) that would prevent you from casting the spell?
What happens if the spell is cast but fails?
What message do you get if an object is unidentifiable?
Is it possible for someone to fake giving you an object to identify, causing you to cast a spell on an object you don't have (or on one of your own objects?)?
What do you want to happen in any of these error cases?

I would personally be very wary of having an automated script do something like this, unless I very carefully set up the criteria for when the identify would occur. If your mud is very competive, it would be very easy for someone to take advantage of your scripts. Imagine, for example, someone using emotes to simulate giving you a sword to identify. It triggers the spell sequence, causing you to Identify your own sword and give it to them! Imagine an enemy giving you an object to identify, causing you to interrupt your MegaDeath spell and start an Identify spell? It would be much safer to simply write an alias which executes the spell and repeates the output out loud. Then you can execute the alias manually when you want to do the service. But if you don't want to handle it manually with an alias, you will have to consider and share the answers to all the questions above. The identify/tell part is easy; the tricky part is handling all the problems.
Reply with quote
Xantor
Newbie


Joined: 30 Jul 2012
Posts: 4

PostPosted: Thu Aug 02, 2012 10:14 pm   
 
Thanks for the quick response

What text do you get when you receive the object to be identified? Player gives you a fork.
How do you know that you are supposed to identify the given object for the giver? Caracter is a drone...follows and spells and id's only
Do you want any limitation on who can ask this service of you? limitations controlled by group tell
Do you want any limitations on _when_ you will do this service? (in the middle of battle, while casting other spells) Will only be used when resting/mana sufficent
What command do you need to type to execute the identify spell? alias exists - id %1
What is the mud prompt you get when all of the output from the identify spell is finished? hp/hp m/Mana xp/xp align gold
What is the syntax of the say command you want to use to share the information with the giver? Just repeat info verbatium will work
Do you want to give the object back to the giver afterward? give item player
What happens if you don't have enough mana for a spell? id will wait until mana sufficient
Are there any circumstances (like Confusion or Paralysis) that would prevent you from casting the spell? Able to wait until any adverse issues resolved
What happens if the spell is cast but fails? needs to be recast, will handle manually
What message do you get if an object is unidentifiable? non existent
Is it possible for someone to fake giving you an object to identify, causing you to cast a spell on an object you don't have (or on one of your own objects?)? No
What do you want to happen in any of these error cases? Will handle manually

Just a side note: This is a non-pk exploratory mud. No threat exists that will prevent this from happening. The reason for the automation is that there are large numbers of id's done when we are on an eq run and the repetition of typing distracts from the play not to mention who gave what when.

Your assistance is appreciated and thanks again
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Aug 03, 2012 1:46 am   
 
When I asked for the syntax of the say command, I actually meant what is the format of the command? say so-and-so? @say "such-and-such"? tell whoever this-and-that? Not all muds use the same commands. For now, I will assume it is: say so-and-so.

I'm not sure what you mean by "limitations controlled by group tell". How can the script tell whether a particular person can get an identify? Is there some command? Or will the character have a list of allowed player names? Or will he do it every time that he is given something? For now, I will just assume he will always do it.

For the prompt, I'm going to assume that the prompt looks something like this: "100/100 100/100 100/100 neutral 256>". If that's not quite right, please give an example of what it actually looks like.

Here is a start that might be sufficient for you. Cut and paste the following commands into the command line. You can cut and paste them all at the same time:
Code:

#VAR giver {}
#VAR target {}
#VAR output {}

#TRIGGER {(*) gives you {a|an|the} (*)} {
#T+ Identify
#VAR giver %1
#VAR target %2
id @target
}

#CLASS Identify
#CLASS 0

#TRIGGER {^%d/%d %d/%d %d/%d *>} {
#T- Identify
#FORALL @output {
  #SAY %i
}
#SEND give @target @giver
#VAR giver {}
#VAR target {}
#VAR output {}
} Identify prompt disable

#TRIGGER {(*)} {
#ADDITEM output %i
} Identify


Now, the explanation. The first three #VAR commands simply create some blank variables that we will need.

The first trigger has a pattern that waits for a message indicating someone has given something.
When this trigger fires, it turns on (enables) a class named Identify (which we will create in a moment)
The trigger then sets the variables @giver and @target so that we can give the object back again later.
Then the trigger sends the alias to cast the identify spell.

The next command creates the class named Identify. Think of it as a folder or directory for scripts. Every new script after this will be created inside Identify by default.
The next command sets the current class to default, which means that any new scripts after this will be created by default in your session window instead of the Identify class.

The next trigger has a pattern watching for your prompt, which means that the output of the identify spell has finished.
When the trigger fires, it turns off (disables) the class Identify. Since this trigger and the next trigger are both inside Identify, this effectively turns both of these triggers off as well. The script of this trigger will continue executing, but neither of these triggers will fire again as a result of the following commands.
Then the trigger loops through all the values of @output, and for each one executes a command which "says" it out loud.
Then it sends to the mud the command to give the target object back to the giver.
Then the trigger sets the variables @target, @giver, and @output back to blank (this is probably unnecessary, but good policy).
The words after the closing brace mean that this trigger is created inside the Identify class, turns it into a "Trigger on Prompt" trigger, and sets the trigger to be normally disabled.

The next trigger will match every line that it sees.
After every line, it will add the line to the variable @output. This is all the stuff that the previous trigger will say out loud once it sees the prompt.
The word after the closing brace means that this trigger is created inside the Identify class.
Note that since this trigger was created after the prompt trigger, it has a higher priority number, which means it executes _after_ the prompt trigger. This is important because that means the prompt trigger turns this trigger off before it starts saying the identify output. If this trigger were still active, it would go into an infinite loop, repeating what it sees itself saying. We could also manually change the priority number of any script we want to make it execute before or after others.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net