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
Elstone
Newbie


Joined: 02 Jun 2010
Posts: 3

PostPosted: Fri Oct 15, 2010 6:48 am   

Alias with or list
 
May I please have help in fixing this alias? It works but it generates 11 prompts and 11 notifications that the target is not found in that location. I know there has to be a better way but as a novice with this, the #IF and || OR and trues and false examples confused me and did not help me to understand. I read many forum posts before asking but was unable to locate a forum thread explaining this. Thank you.

<alias name="gax" id="1290">
<value>bthrow axe at %1 east
bthrow axe at %1 northeast
bthrow axe at %1 southeast
bthrow axe at %1 west
bthrow axe at %1 northwest
bthrow axe at %1 southwest
bthrow axe at %1 north
bthrow axe at %1 south
bthrow axe at %1 in
bthrow axe at %1 out
bthrow axe at %1 up
bthrow axe at %1 down</value>
</alias>

Thank you again.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Oct 15, 2010 7:37 am   
 
Do you by chance know what direction the creature is in when you start throwing, or just throwing randomly until you hit something? If the former, how do you know what direction? If the latter, how do you know when you've hit something?
_________________
Asati di tempari!
Reply with quote
Elstone
Newbie


Joined: 02 Jun 2010
Posts: 3

PostPosted: Fri Oct 15, 2010 3:41 pm   
 
For ax-grab alias gax ~ No, do not know the direction in advance.
Throwing randomly till it grabs the adventurer. Once grabbed they are with me.
The line for fail is: You don't see your target in that direction.
The succeed line is: You whip your handaxe towards <targetname> and it returns moments later, dragging him with it.

There is a slightly different alias too that gives similar effect. Left off the other directions in example below, just included enough to show how I set it up.
<alias name="tax" id="1152">
<value>throw axe east at @target
throw axe northeast at @target
throw axe down at @target</value>
</alias>
For throw-ax alias tax ~ Do not know direction in advance.
Fail: I don't see any such adventurer in that direction.
Succeed: You cock back your arm and throw a throwing axe <direction> at <targetname>.

Thank you for taking the time to look this over.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sun Oct 17, 2010 2:26 am   
 
Try this on for size. It could probably be simplified a bit, but since I don't how you'd use it I tried to make it as robust as possible it creates a class that does all the checks to see if you hit your target or not. If you miss, it tries again. The rest of the stuff are maintenance variables to make it work easier.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="AxeThrow" copy="yes">
    <trigger priority="10" copy="yes">
      <pattern>Succeed: You cock back your arm and throw a throwing axe</pattern>
      <value>#echo success
resetAxeThrow
#T- AxeThrow</value>
    </trigger>
    <var name="Dirs" type="StringList" copy="yes">
      <value>east|northeast|southeast|west|northwest|southwest|north|south|in|out|up|down</value>
      <json>["east","northeast","southeast","west","northwest","southwest","north","south","in","out","up","down"]</json>
    </var>
    <var name="curDir" type="Integer" copy="yes">
      <value>2</value>
      <default>1</default>
    </var>
    <trigger priority="50" copy="yes">
      <pattern>I don't see any such adventurer in that direction.</pattern>
      <value>#ADD curDir 1
#IF (@curDir < 13)
{
  #IF (@throwType == "tax") {tax} {gax}
} {
  #ECHO  Unable to hit @target in any direction
  resetAxeThrow
}
</value>
    </trigger>
    <var name="target" usedef="true" copy="yes"/>
    <var name="throwType" type="Literal" copy="yes">gax</var>
    <alias name="resetAxeThrow" copy="yes">
      <value>curDir=1
target=%null
throwType=%null</value>
    </alias>
  </class>
  <alias name="gax" copy="yes">
    <value>#T+ AxeThrow
#if (%1 != %null) {target=%1}
throwType="gax"
bthrow axe at @target %item(@Dirs, @curDir) </value>
  </alias>
  <alias name="tax" copy="yes">
    <value>#T+ AxeThrow
throwType="tax"
throw axe %item(@Dirs, @curDir) at @target
</value>
  </alias>
</cmud>
_________________
Asati di tempari!
Reply with quote
Elstone
Newbie


Joined: 02 Jun 2010
Posts: 3

PostPosted: Sun Oct 17, 2010 2:48 am   
 
Got it copied to test.
Many thanks. That was a lot of work and definately over my head. Learning but no where near able to do that yet!
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