|
nastasim Beginner
Joined: 08 Jun 2004 Posts: 10
|
Posted: Sun Jun 13, 2004 8:14 pm
Spell Settng and #IF Statements |
Hi All, I use a complicated (to me anyway :)) Alias with a monster #IF statement to come up with the spell I want to cast at the Leaders target. What I have (mainly) is lists of mobs
(for example ListFire) that I want to cast a certain spell type on.
When I find new mobs, or ones that don't work (*seems to enjoy*) my default spell type (phys), I add them to the appropriate list. It has worked well.
Now I added a line (for Water spells) and ZMUD does not like it!! I can't see where I went wrong. The alias name is Type and I am including the "bad" script with ZMUD error noted, and then the version that worked.
I have two main questions - the first is where did I go wrong?!
The other is methodology - is this hard to work/hard to read #IF the best way to do spell setting based on target name? If there is a better way, I sure would appreciate hearing about it!
Here is the "new" script that ZMUD takes exception with:
#IF (@target=colossus) {ss coly}
{#if (%ismember( @target, @ListDead)) {ss dead}
{#if (%ismember( @target, @ListPhys)) {ss phys}
{#if (%ismember( @target, @ListFire)) {ss fire}
{#if (%ismember( @target, @ListCold)) {ss cold}
{#if (%ismember( @target, @ListAcid)) {ss acid}
{#if (%ismember( @target, @ListWater)) {ss Water}
{#if (%ismember( @target, @ListLigh)) {ss ligh}
{#if (%ismember( @target, @ListPois)) {ss pois}
{#if (@target=wolf) {ss wolf
spellchecker
#if (@stone=0){stone}}
{ss phys}}}}}}}}}}
Here is the line and error that ZMUD calls out:
{#if (%ismember( @target, @ListDead)) {ss dead}
^ syntax error
Here is the "original" alias script that works:
#IF (@target=colossus) {ss coly} {#if (%ismember( @target, @ListDead)) {ss dead} {#if (%ismember( @target, @ListPhys)) {ss phys} {#if (%ismember( @target, @ListFire)) {ss fire} {#if (%ismember( @target, @ListCold)) {ss cold} {#if (%ismember( @target, @ListAcid)) {ss acid} {#if (@target=wolf) {
ss wolf
spellchecker
#if (@stone=0) {stone}
} {#if (%ismember( @target, @ListLigh)) {ss ligh} {#if (%ismember( @target, @ListPois)) {ss pois} {ss phys}}}}}}}}}
Thank you for looking!
Mario |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Jun 13, 2004 11:44 pm |
The problem is with where you chose to break your lines, and one or 2 minor things. zMud wants to see opening braces at the end of a line, and you forgot a space. Corrections below:
#IF (@target="colossus") {ss coly} {
#if (%ismember( @target, @ListDead)) {ss dead} {
#if (%ismember( @target, @ListPhys)) {ss phys} {
#if (%ismember( @target, @ListFire)) {ss fire} {
#if (%ismember( @target, @ListCold)) {ss cold} {
#if (%ismember( @target, @ListAcid)) {ss acid} {
#if (%ismember( @target, @ListWater)) {ss Water} {
#if (%ismember( @target, @ListLigh)) {ss ligh} {
#if (%ismember( @target, @ListPois)) {ss pois} {
#if (@target="wolf") {ss wolf
spellchecker
#if (@stone=0) {stone}} {
ss phys}}}}}}}}}}
As to methadology the if-else chain is a classic. It is used because of speed and the only way to go faster is to put more frequently encountered mobs in an earlier if. I believe speed is what you are looking for here so it is the way to go. At eleven #IF's it isn't that unwieldy.
If you need further improvments in speed use a new first if checking a record variable (see %iskey, %db, and #EXEC in the help). Then populate the variable with #ADDKEY {@target} {commands} after you have already sent the command to the mud. The variable would likely get quite large during a long mud session so you would want a way to remove things from the record after a little while. Basically it creates a recently used list for quicker lookup. Whether the effort involved in making it is worth the small speed gain would depend on how you mud.
Another method that might also provide a faster speed, but makes data maintainence harder is to use a record variable with @target as the keys and simple numbers as the values. You can then do something like this
#IF (%iskey(@TargetList,@target)!="") {
#CASE (%db(@TargetList,@target)) {[/i]commands[/i]}
} {
ss phys
}
As I say it is harder to maintain your data. Alternately you could use a second conversion to get a number and put something more descriptive to you in your record variable:
#CASE (%ismeber(%db(@TargetList,@target),@ListNumber)) {[/i]commands[/i]} |
|
|
|
|
|
|
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
|
|