|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Wed Jul 18, 2007 5:25 pm
#if & #addkey variables (solved) |
Running a mock battle and having problems with determining the end of the battle.
Assigning a test variable for the purpose of...well, testing..
#addkey testing Trollemite {50}
#addkey testing Vitae {50}
Part of the whole script includes deciding whom is attacking whom and for how much damage. This is part of it and it works:
#add testing.@{CombatantB} {-@howmuchdamage}
Now, the problem is this, once CombatantB reaches 0 or less how do i get it to know?
#if (@testing.@{CombatantB}.##### <= 0) {end} {continue}
.##### represents whatever should go there i guess.
I've tried %key, %iskey, %rec & %val all to no success.
Of course, I could have that #if slightly convoluted and have my whole thought on that wrong.
I feel like I should know this somehow, but I don't know |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Wed Jul 18, 2007 5:57 pm |
I'm going to have to assume that the #addkey testing Trollemite {50} is the start damage. In which case you may want to use something like this:
#var Trollemite {%eval(%db(@testing.Trollemite)-@howmuchdamage)} - in place of #add testing.@{CombatantB} {-@howmuchdamage}
and
#IF (@Trollemite<=0) {end} {continue} - in place of #if (@testing.@{CombatantB}.##### <=0) {end} {continue}
Of course, if you want to remove the variable at the end, you can just use #unvar Trollemite.
I don't have zMUD in front of me, but I will tonight. It's touch and go right now, but give it a try and see if it works. Or don't. I'll just bug you on my flist later. :P
Charneus |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Wed Jul 18, 2007 6:12 pm |
#addkey testing Trollemite {50} is the start. Like starting with 50HP
I'm potentially going to have more than 2 Combatant's
I'm tracking everyones HP in the one var type created with #addkey so #add testing.@{CombatantB} {-@howmuchdamage} works much better than having separate variables for each combatant.
Hit me up on flist. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Jul 18, 2007 10:45 pm |
The problem, I think, is the implicit concatenation you're doing of the variable names. #add %concat("testing.",@CombatantB) whatever might give you better results.
|
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Thu Jul 19, 2007 1:40 pm |
Got it!
#if (%db( @testing, @{CombatantB})<= 0) {end} {continue} |
|
|
|
|
|