Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
ChrisD
Beginner


Joined: 18 Oct 2000
Posts: 18

PostPosted: Fri Dec 02, 2005 9:24 am   

Multiple triggers on one line (some buggy behavior?)
 
In this PK mud I play on, enemies are shown as:

+* A Troll *+

If they're stronger, they have an adjective describing how much stronger:

+* A greater Troll *+

And if they've evolved into a stronger race, the race name will change:

+* An Ogre *+

In the spam of PK, it can often be difficult to figure out who's doing what to whom, and who the important targets are. Therefore, I came up with a script to do some coloring and so on to make it easier to assimilate information. The gist is that "adjective'd" characters will receive an asterisk or two extra, and evolved characters will receive parenthesis around their races to denote strength.

Here's the output of a simple debug alias that echos the text:



I think it looks pretty sharp and I'm pleased with how it came out.

There's a problem, however. If I have more than one "adjective'd" item on a line, things get all kinds of broke, and I have no idea where to start or what might be causing it. Example:



This is simply an echo of the following text:

+* A lesser Troll *+ bashes +* A greater Lich *+, knocking him to the ground!

Below is the code (I've actually edited it a bit for readability - I've left the IF statements separate. In practice, I nest them for processing speed).

Help?


Triggers:

Code:

(~+~*) ({a|an}) (%w) (~*~+)

setRaceName %3
setRaceColor %3
#sub {%concat( %ansi(white,bold), "+*", " ", @raceColor, %2, " ", @raceName, " ", %ansi(white,bold), "*+"}
#BEEP 48


Code:

(~+~*) ({a|an}) (%w)-(%w) (~*~+)

setRaceName %concat( %3, "-", %4)
setRaceColor %concat( %3, "-", %4)
#sub {%concat( %ansi(white,bold), "+*", " ", @raceColor, %2, " ", @raceName, " ", %ansi(white,bold), "*+"}
#BEEP 48


Code:

(~+~*) ({a|an}) (%w) (%w)-(%w) (~*~+)

setRaceName %concat( %4, "-", %5)
setRaceColor %concat( %4, "-", %5)
setRaceSize %3
#sub {%concat( %ansi(white,bold), "+", @raceSize, " ", @raceColor, %2, " ", %3, " ", @raceName, " ", %ansi(white,bold), @raceSize, "+"}
#BEEP 48


Code:

(~+~*) ({a|an}) (%w) (%w) (~*~+)

setRaceName %4
setRaceColor %4
setRaceSize %3
#sub {%concat( %ansi(white,bold), "+", @raceSize, " ", @raceColor, %2, " ", %3, " ", @raceName, " ", %ansi(white,bold), @raceSize, "+"}
#BEEP 48



Aliases:

Code:

setRaceSize

#if (%1="greater") {raceSize= "**"} {#if (%1="Elite") {raceSize="***"} {#if (%1="Champion") {raceSize="****"} {raceSize= "*"}}}


Code:

setRaceName

#if (%1="Human") {raceName="Human"}
#if (%1="Dragonkin") {raceName="Dragonkin"}
#if (%1="Centaur") {raceName="Centaur"}
#if (%1="Dark-Elf") {raceName="Dark-Elf"}
#if (%1="Atomie") {raceName="Atomie"}
#if (%1="Stone-Giant") {raceName="Stone-Giant"}
#if (%1="Troll") {raceName="Troll"}
#if (%1="Gnome") {raceName="Gnome"}
#if (%1="Dwarf") {raceName="Dwarf"}
#if (%1="Githyanki") {raceName="(Githyanki)"}
#if (%1="Revenant") {raceName="(Revenant)"}
#if (%1="Half-Elf") {raceName="(Half-Elf)"}
#if (%1="Halfling") {raceName="(Halfling)"}
#if (%1="Rock-Giant") {raceName="(Rock-Giant)"}
#if (%1="Ogre") {raceName="(Ogre)"}
#if (%1="Hobbit") {raceName="(Hobbit)"}
#if (%1="Ancient") {raceName="(Ancient)"}
#if (%1="Dragon") {raceName="((Dragon))"}
#if (%1="Lich") {raceName="((Lich))"}
#if (%1="Shadow") {raceName="((Shadow))"}
#if (%1="Buckawn") {raceName="((Buckawn))"}
#if (%1="Colossus") {raceName="((Colossus))"}
#if (%1="Titan") {raceName="((Titan))"}
#if (%1="Reaver") {raceName="((Reaver))"}
#if (%1="Angel") {raceName="((Angel))"}


Code:

setRaceColor

#if (%1="Human") {raceColor= %ansi( black, bold)}
#if (%1="Dragonkin") {raceColor= %ansi( green, bold)}
#if (%1="Githyanki") {raceColor= %ansi( green, bold)}
#if (%1="Dragon") {raceColor= %ansi( green, bold)}
#if (%1="Centaur") {raceColor= %ansi( cyan, bold)}
#if (%1="Revenant") {raceColor= %ansi( cyan, bold)}
#if (%1="Lich") {raceColor= %ansi( cyan, bold)}
#if (%1="Dark-Elf") {raceColor= %ansi( brown)}
#if (%1="Half-Elf") {raceColor= %ansi( brown)}
#if (%1="Shadow") {raceColor= %ansi( brown)}
#if (%1="Atomie") {raceColor= %ansi( yellow, bold)}
#if (%1="Halfling") {raceColor= %ansi( yellow, bold)}
#if (%1="Buckawn") {raceColor= %ansi( yellow, bold)}
#if (%1="Stone-Giant") {raceColor= %ansi( red, bold)}
#if (%1="Rock-Giant") {raceColor= %ansi( red, bold)}
#if (%1="Colossus") {raceColor= %ansi( red, bold)}
#if (%1="Troll") {raceColor= %ansi( magenta, bold)}
#if (%1="Ogre") {raceColor= %ansi( magenta, bold)}
#if (%1="Titan") {raceColor= %ansi( magenta, bold)}
#if (%1="Gnome") {raceColor= %ansi( blue, bold)}
#if (%1="Hobbit") {raceColor= %ansi( blue, bold)}
#if (%1="Reaver") {raceColor= %ansi( blue, bold)}
#if (%1="Dwarf") {raceColor= %ansi( magenta)}
#if (%1="Ancient") {raceColor= %ansi( magenta)}
#if (%1="Angel") {raceColor= %ansi( magenta)}
Reply with quote
ChrisD
Beginner


Joined: 18 Oct 2000
Posts: 18

PostPosted: Mon Dec 05, 2005 7:13 am   
 
I did see that I wasn't closing my ()'s for the %concat(), but that didn't fix it.

I think it has something to do with multiple triggers on one line - anyone have more info about this? Processing order when two triggers fire on one line?
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Mon Dec 05, 2005 3:46 pm   
 
Indeed you are going to have a reparse issue. Might be able to add a condition for that trigger option.
Quote:

reparse execute new trigger pattern on same line as before
(only usable with #COND)


I think for speed you'd want to change your triggers to have one for the mob standing there and one for the mobs fighting.

Here is an idea I'd have that would touch up what you did:

This trigger assumes you have a space before the lines where you have a mobile interacting with another mobile:
#TRIGGER {^({@RacesSeen})} {#SUB %ansi(bold,white)%item(@RacesSub,%ismember(%1,@RacesSeen);#BEEP 48} "" {reparse}
#COND { ({@RacesSeen})} {#SUB %char(32)%ansi(bold,white)%item(@RacesSub,%ismember(%1,@RacesSeen);#BEEP 48}


To make variables RacesSeen and RacesSub use alias RaceSubMaker from below:

#CLASS {TempVariableMaker}
#ALIAS RaceSubMaker {#VAR RacesSub "";#VAR RacesSeen "";#FORALL @Races {#FORALL @RacesEvolution {#VAR TempRacesSeen %trim( {%j %i});#IF ( %ismember( %copy( %lower( @TempRacesSeen), 1, 1), "a|e|i|o|u")) {#VAR TempRacesSeen %concat( "An ", @TempRacesSeen)} {#VAR TempRacesSeen %concat( "A ", @TempRacesSeen)};#ADDITEM RacesSeen %concat( "+* ", @TempRacesSeen, " *+");#IF (%ismember( %i, @RacesStr1)) {#VAR TempRacesSeen %replace( @TempRacesSeen, %i, %concat( "(", %i, ")"))};#IF (%ismember( %i, @RacesStr2)) {#VAR TempRacesSeen %replace( @TempRacesSeen, %i, %concat( "((", %i, "))"))};#ADDITEM RacesSub %concat( "+", %item( @RacesEvolutionSub, %ismember( %j, @RacesEvolution)), " %ansi( ", %item( @RacesColour, %ismember( %i, @Races)), ", bold)", @TempRacesSeen, " %ansi( white, bold)", %item( @RacesEvolutionSub, %ismember( %j, @RacesEvolution)), "+")}}}
#VAR Races {Human|Dragonkin|Githyanki|Dragon|Centaur|Revenant|Lich|Dark-Elf|Half-Elf|Shadow|Atomie|Halfling|Buckawn|Stone-Giant|Rock-Giant|Colossus|Troll|Ogre|Titan|Gnome|Hobbit|Reaver|Dwarf|Ancient|Angel}
#VAR RacesColour {black|green|green|green|cyan|cyan|cyan|brown|brown|brown|yellow|yellow|yellow|red|red|red|magenta|magenta|magenta|blue|blue|blue|magenta|magenta|magenta}
#VAR RacesStr1 {Githyanki|Revenant|Half-Elf|Halfling|Rock-Giant|Ogre|Hobbit|Ancient}
#VAR RacesStr2 {Dragon|Lich|Shadow|Buckawn|Colossus|Titan|Reaver|Angel}
#VAR RacesEvolutionSub {*|*|**|***|****}
#VAR RacesEvolution {|lesser|greater|Elite|Champion}
#VAR TempRacesSeen {A Champion ((Angel))}
#CLASS 0
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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