|
Lorette Beginner
Joined: 08 Sep 2004 Posts: 23
|
Posted: Wed Oct 06, 2004 12:07 pm
Mob Stam tracking script (help needed please) |
Hi everyone
I'm trying to write a script that when I attack mobs, or they attack me, the mobs name, hp's and val are put into my status window (I have space for the stats of 6 mobs). I then want to keep track of all my hits against each mobile and deduct it from their hp.
I have started a database for the mobiles and can populate it fine with the name, hp and xp value of the mobs. The triggers below are what I use for a single mobile. This captures the name and uses #find to show the stats in my main screen and creates the variables from the find, but this can be spammy if I've attacked a few mobiles at once. It also seems to slow Zmud loads and creates delays in command input that could be fatal!. Also if another mob enters the room and attacks it resets all my variables, which is quite annoying.
#TR {You attack the ({@MobList}).} {#FIND {%1} Name}
#TR {The ({@MobList}) is about to attack you.} {#FIND {%1} Name}
#TR {(%d)%s(%*)%s(%d)%s(%d)} {#GAG;#VARIABLE DBnum {%1};#VARIABLE MobName {%2};#VARIABLE MobHP {%3};#VARIABLE MobVal {%4}}
#TR {you hit the ({@moblist}) ~<(%d)} {#VARIABLE @MyDam {%2};#Math MobDam {@MobHP - @MyDam}}
Here is some mud output that might help .
kill mob
You attack the troglodyte1.
You attack the troglodyte2.
You swing wildly and miss the troglodyte1.
The troglodyte1 hits you <1650/1900>
You hit the troglodyte2 <5>
The troglodyte2 hits you <1630/1900>
You demolish the troglodyte1 <20>
The troglodyte1 is dead. You gain 45 experience . <127695 xptnl>
You hit the troglodyte2 <2>
The troglodyte2 hits you <1610/1900>
The guard troglodyte17 is about to attack you.
You hit the guard troglodyte17 <2>
The guard troglodyte17 hits you <1157/1900>
You demolish the troglodyte2 <20>
The troglodyte2 is dead. You gain 45 experience . <127640 xptnl>
and so on until...
You demolish the guard troglodyte17 <20>
The guard troglodyte17 is dead. You gain 200 experience . <127440 xptnl>
So my questions are...
1. Can I populate my variables straight from the database instead of using #show and #gag, and if so how?
2. What would be the best way of keeping track of all the mobiles I'm fighting, I've tried creating new variables each time a mob joins the fight, but it got too confusing so I went back to what I have.
I'm quite new to Zmud and this is by far my most ambitious project and I don't know how to go about this. Anyone help? |
|
_________________ Lorette
Last edited by Lorette on Fri Oct 08, 2004 1:06 am; edited 2 times in total |
|
|
|
Thunderbuster Novice
Joined: 07 Nov 2001 Posts: 45 Location: USA
|
Posted: Wed Oct 06, 2004 3:43 pm |
Don't lose hope... I am working on it.
|
|
|
|
Lorette Beginner
Joined: 08 Sep 2004 Posts: 23
|
Posted: Thu Oct 07, 2004 6:58 am |
Ok,
I was able to fix one problem by adding a space at the end of each name in the database, now the database finds the correct mobile. Before If I did a find for troglodyte1, I would also find troglodytes 11-19, and as I was gagging all of these, this created the command lag.
Still confused on how to track the stats of more than one mobile though |
|
_________________ Lorette |
|
|
|
Lorette Beginner
Joined: 08 Sep 2004 Posts: 23
|
Posted: Fri Oct 08, 2004 11:08 am |
Hi again
I've given up on having the val of the mob in my script, it was too difficult for someone so inept as me to sort out so I have gone for a Record variable [@MobStack] with MobName and MobHp as key|value pairs. It all works nicely and keeps track of the correct hits on each mob.
Can anyone tell me how to display this information in my status window in this format
Name: <First name in @MobStack> HP: <First HP in @MobStack>
Name: <Second name in @mobStack> HP: <Second HP's in @MobStack>
Also I still don't understand how to get the information straight from the database instead of showing and gagging it on screen.
Thunderbuster, thanks for the reply. If your script works better than mine which seems likely, I'll happily change it all back
Thanks in advance for any help. |
|
_________________ Lorette |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Oct 08, 2004 10:36 pm |
#STW {Name:%expanddb( @MobStack, %{lf}Name:, " HP:")}
To get information directly from the database, you can use functions. Provided each name in your database is unique, the query below will only return one record. You would probably need to add a routine to handle names which aren't in the database.
#TR {You attack the ({@MobList}).} {#ADDK MobStack {%1} {%db( %query( "%1" = &Name), HP)}}
This is covered in greater detail in the helptopic Accessing Database Records, reached from the Help Contents under Getting Started, Introduction to the Database, Programming the Database. |
|
_________________ LightBulb
Senior member
Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious. |
|
|
|
Lorette Beginner
Joined: 08 Sep 2004 Posts: 23
|
Posted: Sun Oct 10, 2004 12:38 pm |
Thanks LightBulb, I'll try your suggestions and read the helpfiles.
|
|
_________________ Lorette |
|
|
|
Lorette Beginner
Joined: 08 Sep 2004 Posts: 23
|
Posted: Sun Oct 10, 2004 6:38 pm |
Hi again, now I'm going to complicate things a little. When a mobile flees from me, I want to add the Name and HP to another record variable @FleeStack, so when I attack it or it attacks me again, the modified HP is entered back into the stack, rather than the database HP.
So far I have a new trigger for when a mob flees
#TR {The ({@MobList}) has fled.} {#ADDKEY FleeStack {%1} {%db( @mobStack, %1)};#DELKEY MobStack {%1}}
This should add the mob to @FleeStack and remove it from @MobStack. And I've modified the attack trigger to
#TR {You attack the ({@MobList}).} {#IF %ismember( %1, @FleeStack) {#ADDKEY MobStack {%1} {%db( @FleeStack, %1)}} {#ADDKEY MobStack {%1} {%db( %query( %1 = &Name), HP)}}
This should check to see whether the mob is in @FleeStack first and if it is, add the @FleeStack stats, if not then add the DB stats. It doesn't work, so my logic is flawed somehow, any ideas? LightBulb, I had to remove the quotes from around the second %1 in your trigger to get it to work, I hope that wasn't what broke it.
Lastly, how would I colour just the mobs HP in my #STW? |
|
_________________ Lorette |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Oct 10, 2004 7:36 pm |
The reason it doesn't work is your using %ismember instead of %iskey when working with a record variable. You also should enclose the %1 in quotes there and put the whole expression in parenthesis. Replace '%ismember( %1, @FleeStack)' with '(%iskey( "%1", @FleeStack))'.
The lack of quotes in the %query should not cause problems unless a mob name contains a comma. Try using parenthesis, they should protect against the comma just as well. Although my testing shows no problems with quotes. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Lorette Beginner
Joined: 08 Sep 2004 Posts: 23
|
Posted: Sun Oct 10, 2004 9:24 pm |
Thanks for the help Vijilante
I've the pattern of the trigger to
#IF (%iskey( "%1", @FleeStack)) {
#ADDKEY MobStack {%1} {%db( @FleeStack, %1)}
#STWIN %ansi( white)Name:%expanddb( @MobStack, %{lf}Name:, " HP:")
} {
#ADDKEY MobStack {%1} {%db( %query( "%1" = &Name), HP)}
#STWIN %ansi( white)Name:%expanddb( @MobStack, %{lf}Name:, " HP:")
}
It finds the right mobile and HP from the database, the first time, but if the mobile is already in @FleeStack it still takes the hp from the database! I'm really close, I can feel it but I still need more help. I'm reading the helpfiles like mad but I'm not a programmer and its all getting a bit fuzzy. Anyone? |
|
_________________ Lorette |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Oct 11, 2004 2:40 am |
You have things backward in %iskey.
#IF (%iskey( @FleeStack, "%1")) {
You don't need the #STWIN command in the trigger. Once the window has been defined, it will update itself as the variable changes. To limit a color change to the HP, you'll need to make two color changes per line.
#STWIN {%ansi( white)Name:%expanddb( @MobStack, %ansi( white)%{lf}Name:, %char( 32)HP:%ansi( yellow))}
I used %char( 32) to provide the space before HP because the "s were showing after changing the colors. |
|
_________________ LightBulb
Senior member
Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious. |
|
|
|
Lorette Beginner
Joined: 08 Sep 2004 Posts: 23
|
Posted: Mon Oct 11, 2004 8:34 am |
Thanks for the help LightBulb and Vijilante, It works perfectly.
|
|
_________________ Lorette |
|
|
|
|
|