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


Joined: 08 Mar 2010
Posts: 4
Location: Avalon: The Legend Lives

PostPosted: Mon Mar 08, 2010 11:07 pm   

Tracking/Scenting Script with small issue
 
I've made a track/scent script to move towards a target that nearly 90% works... the problem I'm having is when you are actually in the same room with the target....

Here is the code:
Code:
#ALIAS sc
SCENT @T
#TRIGGER {You twitch your nostrils and pick up the scent leading %2.} {scMove=%2} {#CW Orange}
@scMove


scent is an ability in the MUD I'm writing this for that allows you to see the next direction towards a target. (Example orc)

so by typing scent orc, it will say: You twitch your nostrils and pick up the scent leading north

I made a trigger, as you can see, that will detect the direction the mud tells you to go, then loads it into a variable (@scMove).

When you arrive at the target it displays a separate message: You are overcome by the immediate scent. <@t> is right before you.

I tried to make another #TRIGGER within my code, however what would happen was this:

sc
You twitch your nostrils and pick up the scent lead west
west
<enter new area where @t is located>
sc
You are overcome by the immediate scent. <@t> is right before you.
sc
west
<enter new area>

Now... there are two ways I can think to solve this, but I don't know how to write the code to do so...

1. A bit of code that detects if @t is in the room, this disabling the SC function temporarily.
2. Somehow loading that the @t is in the room, altering the variable to not process a direction.

Thanks for the assistance, sorry if it's confusing at all.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Mar 09, 2010 2:37 am   
 
Code:

------------------------>1)scent orc
|                                |
|                                |
|                               \|/
|    a)not here<-----2)what was found----->b)here
|    |
|    |
|   \|/
3)move

#alias hunt($target) {
  Target = $target
  scent @target
}
#trigger {You twitch your nostrils and pick up the scent leading (%w).} {
  NextDir = %1
}
#trigger {You are overcome by the immediate scent. @target is right before you.} {
  //stuff to do when you find your target
}
#trigger {[b]your prompt goes here[/b]} {
  //other stuff to do in your prompt
  #if (@NextDir != "") {
    #send @NextDir
    scent @target
  }
  //other stuff to do in your prompt
} {nocr|prompt}


I don't think you need the @scMove variable to store the direction to move, but in the spirit of your line of thinking I included such a variable and made a prompt trigger so that that variable can be evaluated and sent, thereby starting the cycle over.
_________________
EDIT: I didn't like my old signature
Reply with quote
AnatoleFarmond
Newbie


Joined: 08 Mar 2010
Posts: 4
Location: Avalon: The Legend Lives

PostPosted: Tue Mar 09, 2010 4:35 pm   
 
First off, thanks for assisting me on this code.
However, after running it and tweaking it some I'm still coming up with a few bugs.

Code:

#ALIAS sc
scent @t
#TRIGGER {You twitch your nostrils and pick up the scent leading (%w)} {nextDir = %1}
#TRIGGER {You are overcome by the immediate scent.} {nextDir=0}
#TRIGGER {yet the winds bespeak of no new scent} {nextDir=0}
#IF (@nextDir=%1) {#SEND @nextDir}
#IF (@nextDir=0) {#ABORT}
{nocr|prompt}


1) I failed to mention in my first post that @t is a variable from another #ALIAS that records my target, so therefore this code doesn't need a target capture coded into it, as it can draw that variable.

2) I also noticed something else that is impairing the code, and tried to figure it in. There is a spam block on the ability so you can't use it in rapid succession, the game will say: Your nostrils flare to trace the scent of @t, yet the winds bespeak of no new scent

The reason I took out the @t from the triggers is because the creatures sometimes have quite lengthy names, and I didn't want to confuse the code.
For example orc will target the following:
a young orc scout
an orc guard
an orc archer
Durgash, captain of the orc guards
etc....

But this is mainly for player combat, so having the code discern between those is unimportant.

3) when the variables loaded with the direction it stores it perfectly fine, however, it won't fire the direction until the next time to alias in input.

Here's an example:
Quote:

INPUT: sc
SENT TO MUD:scent Jim
SCENT TO MUD: [here it displays whatever is loaded into the @nextDir]
DISPLAY: You twitch your nostrils and pick up a scent leading west


Now... if say, southwest was loaded into the variable prior to me sending the command SC, then the mud at this point would try to move southwest.

Is there a way to make the variable fire the direction that is detected when you hit sc, rather than the time you did it beforehand?

I hope this makes sense. -chuckle-
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Mar 09, 2010 7:48 pm   
 
Quote:

#IF (@nextDir=%1) {#SEND @nextDir}


You're misunderstanding the role that %1 plays. %1...%99 only refer to captured elements in a trigger pattern, and they only apply to the current trigger pattern. Trigger patterns prior to and after this trigger do not exist, and therefore you cannot refer to them via %1...%99. In multi-state trigger situations, you can refer to captured elements in previous states using the %t1...%t99 variables:

#trigger {this is a test.} {#print %1} <--prints a blank line

#trigger {this is a (%w).} {#print %1} <--prints the word matched by %w

#trigger {this is a &%wvarname.} {#print %1} <--prints the word matched by &%wvarname

#trigger {this is a (test).} {}
#condition {All hands to your (battlestations).} {#print %1 %t1} <--prints "battlestations test"

This is probably why your trigger fails, because in the #IF command you're comparing @NextDir to a blank. Since @NextDir is not a blank, it'll never send @NextDir.
_________________
EDIT: I didn't like my old signature
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