zMUD damage script

by Unknown

Back to Mechanic's Corner.

Unknown2007-11-14 11:26:40
Not that I've tried very many things, but I have no idea how to get a damage script to echo something onto the same line as the prompt itself. I've got Shorlen's free Aether navigation system and it does the exact same thing that I want to do, but, I have no idea how. If someone could either, explain this:

#if (%1!=@shiphull) {
#math shiphullchange %1-@shiphull
temp=%concat( @temp, "%ansi(15)/%ansi(%eval((@shiphullchange>0)*10+(@shiphullchange=0)*11+(@shiphullchange<0)*14))@shiphullchange hull%ansi(15)\\ ")
}

(No idea WTF this is or means, honestly ^)

Or tell me how to echo something like this onto the same line as the trigger itself. This is what I have so far:

#IF (@nar_new_health < @nar_old_health) {#SHOW %ansi( high, red)-/%eval( @nar_new_health - @nar_old_health)h\\-}

Unknown2007-11-14 18:22:48
It's a pretty simple script, though it may look complex. It just checks to see if the ship hull health has changed (%1 = current health obtained from trigger, @shiphull = stored health from last trigger). If there is a change, it calculates the numerical difference and builds a new prompt string that includes that difference in with the other prompt stuff.
Acrune2007-11-14 18:32:04
Tried #ECHOP instead of #SHOW?
Unknown2007-11-14 18:34:08
In my experience, #PSUB works better than #SAYP (or any other such command) for keeping the text on the same line as the triggered line, especially prompts.
Unknown2007-11-15 11:43:42
Just sort of wondering what part of the script actually puts the part next to the prompt that tells you how much you lost or gained. I understand the bit you mentioned, Zarquan, I just have no idea what parts of it puts the stuff there.
Unknown2007-11-15 11:46:55
Oh, forgot to add, too, PSUB actually removes the text that was there previously... Don't necessarily want to do that.
Forren2007-11-15 12:16:52
Are you looking for ship damage, or damage taken from a regular prompt (like from damage attacks)?
Unknown2007-11-15 12:21:59
The part of Shorlen's script that you quoted doesn't actually display any text in your MUD output window. It builds the string in the temp variable and I'm assuming there's a line later that you missed to do the actual output.

I know very well how PSUB works, and you would simply capture the prompt values and then rebuild the prompt your own way, inserting the hull health difference in the middle somewhere, before you replace the current prompt. Also, you can simply replace part of the prompt (hence, the P in PSUB) rather than the entire thing. I'd suggest looking at the examples in the help file and tinkering with it until you get the desired result.
Unknown2007-11-16 03:00:10
Forren: I'm after a damage attack. Basically Nezha was wondering how much damage his staff attack did and I made it up basically on a whim.

Zarquan: You're right. Later on in the trigger script there's a
"#PSUB @temp %x5"
that seems to do it. But I have no idea what "%x#" is, only had experience with "%#" and "%-#" before.
Forren2007-11-16 03:32:14
Here's some of what I do on prompt:

At the beginning of the prompt trigger:

#VAR currentHealth %1
#VAR currentMana %2
#VAR currentEgo %3

At the end:

#VAR oldHealth @currentHealth
#VAR oldMana @currentMana
#VAR oldEgo @currentEgo

Somewhere in the middle:

$hpChange = @currentHealth - @oldHealth
#if (@currentHealth > @oldHealth)
{

$hpChange = "+"$hpChange
}

$manaChange = @currentMana - @oldMana
#if (@currentMana > @oldMana)
{
$manaChange = "+"$manaChange
}

$egoChange = @currentEgo - @oldEgo
#if (@currentEgo > @oldEgo)
{

$egoChange = "+"$egoChange
}

#if ($hpChange != 0)
{
#SAYP %ansi(high,green)HP: $hpChange%ansi(high,cyan)|
}
#if ($manaChange != 0)
{
#SAYP %ansi(high,green)Mana: $manaChange%ansi(high,cyan)|
}
#if ($egoChange != 0)
{
#SAYP %ansi(high,green)Ego: $egoChange%ansi(high,cyan)|
}

Messy way to do it, but it's what I currently have.
Unknown2007-11-16 12:43:14
The %x# syntax gives you the position of the %# match, and that's how #PSUB knows where to put the text being subbed. It's all in the help file.
Unknown2007-11-16 15:43:04
I think I did it, here's what I got:

#CLASS {Palisade|Combat|Test Prompt}
#REGEX "tpr_full" {^(\\d+)h\\, (\\d+)m\\, (\\d+)e\\, (\\d+)p(?:\\, \\d+en)?(?:\\, \\d+w)? (.*?)(?:\\\\)?\\-} {
temp=%concat( @temp, "%5")
#IF (%1 != @newhealth) {
#MATH healthchange (%1 - @newhealth)
temp=%concat( @temp, " %ansi(15)/%ansi(%eval((@healthchange>0)*10+(@healthchange=0)*11+(@healthchange<0)*14))@healthchange h%ansi(15)\\")
}
#IF (%2 != @newmana) {
#MATH manachange (%2 - @newmana)
temp=%concat( @temp, " %ansi(15)/%ansi(%eval((@manachange>0)*10+(@manachange=0)*11+(@manachange<0)*14))@manachange m%ansi(15)\\")
}
#IF (%3 != @newego) {
#MATH egochange (%3 - @newego)
temp=%concat( @temp, " %ansi(15)/%ansi(%eval((@egochange>0)*10+(@egochange=0)*11+(@egochange<0)*14))@egochange e%ansi(15)\\")
}
#PSUB @temp %x5
temp=""
newhealth=%1
newmana=%2
newego=%3
}
#CLASS 0

This seems to work very well. It subs over variable %5 (which in this trigger is the erlx at the end) but puts the same variable in temp so when there's no change, it doesn't seem to do anything different. But when it does, it neatly slots the change in health/ego/mana in between the erlx and the -. Had a problem for a while where I'd copy the #IF for health, and change it all to say, mana, but it would calculate the difference between mana and health, not mana and old mana.... Found out I forgot to change the #IF (%1 != mana) to #IF (%2 != mana) which, as you can see, is rather important... Was just about to post this when I realised, hehe. Ended up copying the trigger name from Zarquan's Palisade, and the rest of it from Shorlen's old Aethercraft system. I have no idea where Shorlen reset the temp variable though.
Unknown2007-11-16 15:52:53
Interesting how you got the prompt trigger from Palisade. Is that something I posted? Do I know you? Huh? ... And, what's with the (?:\\\\)? part of the pattern?
Unknown2007-11-17 05:18:26
Dunno, copied it from your prompt in Palisade|Combat.
Unknown2007-11-17 05:32:23
Ergh, strange, it worked, then I lost it somewhere (disappeared when I put the Palisade prompt trigger back), I had to put it back in and it stopped working...
Namely, instead of putting "elrxkdb" (which would be %5), it puts " elrxkdb " (with spaces on each side).
Secondly, it's executing the #IF's even if the parameters aren't correct...

So normally I get:
"4078h, 2856m, 3069e, 10p, 16730en, 12470w elrxkdb-"
And when it's enabled I get:
"4078h, 2856m, 3069e, 10p, 16730en, 12470w elrxkdb /0 h\\ /0 m\\ -".
I think that's kind of strange. I've been looking over it for a while now...
Ego doesn't seem to do this.
Unknown2007-11-17 05:39:41
Nevermind, redid it -again- from what I posted and it seems to work. Strange thing is, there's absolutely no difference between what I had when it was screwing up, and what I have now...
Xenthos2007-11-17 06:04:13
QUOTE(Narallen @ Nov 17 2007, 12:18 AM) 458760
Dunno, copied it from your prompt in Palisade|Combat.

That's what he was asking, if you're someone who bought the system from him under another name. I guess he likes to know his customers.
Unknown2007-11-24 23:38:33
well, if you're selling the system, wouldn't you want to make sure it's not getting passed around to friends?
Unknown2007-11-28 02:07:18
Don't worry Zarquan, I'm a previous customer. I'll PM you with details.

EDIT: Nevermind, can't PM you. I'll send you an email, or, something.