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
Ghedemonas
Novice


Joined: 15 Aug 2007
Posts: 39

PostPosted: Fri May 09, 2008 10:15 pm   

Matching triggers containing variables in variables
 
Hi, some other CMUD question arose:

I have a Trigger #tr {{@fightdamagedone}} {#say hit}
#var fightdamagedone is {@monster} (I tried also {{@monster}}
#var monster is {test}

what can I do to get the trigger to fire when "test" appears?

Thanks in advance

Ghedemonas
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri May 09, 2008 10:25 pm   
 
First I just have to say #TR {{@monster}} {#SAY hit} will work.

Perhaps you can explain why you think you need the extra layer of indirection?
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Ghedemonas
Novice


Joined: 15 Aug 2007
Posts: 39

PostPosted: Sat May 10, 2008 11:35 am   
 
Sure:

I have different damage patterns that I want to catch with one trigger, i.e.:

A hits B.
A hits B hard.
A yelps in pain as B hits him.

I made the above trigger for that (Pattern: ^{@Fightdamagedone}$) and put all damage lines in the variable @fightdamagedone - having separate triggers for each possible damagemessage would be cumbersome.

In the variable @Fightdamagedone, the damage message contains changing parts (A and B could be either Players, Monsters or "You")
I use separeate variables for that (for example @A and @B) which I then can match with other variables ... (for example if a friend is hit, that is colored differently than if I hit a monster.)

So now I want the Trigger to fire if a) the General damage message and b) @A and @B are matching other variables ...

Now I have the general setup done

Trigger:
<trigger priority="223830" id="22383">
<pattern>{@FightDamageDone}</pattern>
<value>#col violet
#say hit FightDamageDone</value>
</trigger>

Variable @FightDamagedone contains for example the element You hit @Monster
Variable @Monster contains Dwarven Prisoner.

The Trigger does not fire for the pattern You hit Dwarven Prisoner BUT it hits on the pattern You hit @Monster
.. This seems as if the @Monster variable is used "as is" without expanding it.

... hope that explains it not too complicated ... :)


Last edited by Ghedemonas on Sat May 10, 2008 11:40 am; edited 1 time in total
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat May 10, 2008 2:08 pm   
 
I think I would need to see the full contents of FightDamageDone in order to suggest a proper alternative.

I am also somewhat concerned about how frequently these other variables change. Changing a variable that is used for triggerring causes a compile of the trigger. While it is a fast operation, it does become drastically slower as the size of the pattern increases. You might get more overall speed by using multiple seperate triggers for the underlying variables, and in some cases doing a secondary parsing within script can be faster.

Probably the easiest way for me to produce a full solution to your problem is to have the full script you currently use and some example lines it should match.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Ghedemonas
Novice


Joined: 15 Aug 2007
Posts: 39

PostPosted: Sat May 10, 2008 3:12 pm   
 
here are some lines ...
- The sub-variables (Players and Monsters and FightDamageDone) are very stable and only change when I encounter new lines/monsters/players.
- The each game round, there can easily be up to 100 lines in a battle with 3+players ....

The main target I have is to make clusters of messages that I can handle individually. e.g.
- when gathering experience with others I do not need to see their battle spam as it does not affect me (#gagging it)
- as soon as they attack me or my allies I'd be very interested to see it (#col red)
... those are just ideas of what can be done ....

The script I currently use is having one trigger per attack type, very rough and generic (e.g. "You hit *", "* hits you *") ... very basic ... so the "concept" I gave above is what I have atm for the new trigger ...

Variable
A layer of ice encrusts @A's body as @B deep freeze{s|} him.
@A screams in horror as {his|her|its} flesh dissolves into pools of blood.
@A writhes in agony as @B bore through him with your weapon.
@A writhes in anguish as @B slit{s|} him open.
@A staggers around as your poison takes its toll.
@A dodges @B 's attack.
@A jumps @B with a brawling attack.
@A punches @B in the head with a glancing blow, causing him to stumble briefly.
@A punctures a huge hole into Talanthis's body.
@A tears @B encased in a suit of solid ice up with a wicked looking blade.
@A tears viciously into Talanthis with his weapon.
... There will be some collecting of lines with that ...

Sample Lines (there areprobably seveal hundreds? of those in the mud ...
A layer of ice encrusts Darsh the High Champion's body as you deep freeze him.
Darsh the High Champion screams in horror as his flesh dissolves into pools of blood.
Darsh the High Champion writhes in agony as you bore through him with your weapon.
Darsh the High Champion writhes in anguish as you slit him open.
Dwarven Prisoner staggers around as your poison takes its toll.
Kalibarr dodges Talanthis's attack.
Kalibarr jumps Talanthis with a brawling attack.
Kalibarr punches Talanthis in the head with a glancing blow, causing him to stumble briefly.
Kalibarr punctures a huge hole into Talanthis's body.
Kalibarr tears Talanthis encased in a suit of solid ice up with a wicked looking blade.
Kalibarr tears viciously into Talanthis with his weapon.
Kalibarrs movements are stifled by the overwhelming presence of Barbizon surrounding Talanthis.
Murdock falls back before the onslaught of Talanthis's hamstring.
Murdock screams in agony as Talanthis incinerates his entire body.
Murdock's Circle of Destruction absorbs some of the damage.
One of your images is hit by Darsh the High Champion, and dissipates! 5 mirror images remain.
Ozone jets out of Murdock as Talanthis electrocutes him.
Talanthis dodges Kalibarr's attack.
Talanthis slashes cleanly into Murdock, causing him to wince in agonizing pain.
Talanthis tears viciously into Murdock with his weapon.
Talanthis weaves around the attack, dodging some of the damage.
The Circle of Destruction shifts and blocks some of the damage
You cut Dwarven Prisoner.
You finish a spell sending 5 columns of deep purple sizzling and freezing acid at Darsh the High Champion.
You fling the wand towards Darsh the High Champion, sending the Ice Shard flying!
You hit Dwarven Prisoner hard.
You hit Dwarven Prisoner.
You hurl a Baneful Red Potion at Talanthis.
You shard Darsh the High Champion
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun May 11, 2008 2:02 am   
 
I am going to have to ask one of the other Gurus or experts to answer this. I got myself injured in some recent festivities and can barely manage to type this.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Ghedemonas
Novice


Joined: 15 Aug 2007
Posts: 39

PostPosted: Sun May 11, 2008 10:56 am   
 
Thanks Vijilante - I wish for a fast recovery and that it is not too bad!
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Sun May 11, 2008 1:02 pm   
 
I can't get nested stringlists to work.
I can't get wildcards in the stringlist to work in the trigger pattern.
There might be a regex solution, but I don't know it.

However, the &var syntax does work in stringlists. The following script tested perfectly. I hope it helps you. I thought there was a way to use the &var syntax to go directly to local variables, but I can't figure out how, nor find it in the help file. It may not be possible, but if it is then this could, obviously, be shortened further. I am making a point of using local vars here, because in your actual situation the stringlists are very long, so you could definitely use the performance boost.
Code:

<class name="StringlistRecursion" id="1">
  <var name="monsters" type="StringList" id="2">Darsh the high champion|Dwarven prisoner</var>
  <var name="fightLines" type="StringList" id="3">You hit &amp;a hard.|&amp;a screams in horror as his flesh dissolves into pools of blood.</var>
  <trigger priority="40" id="4">
    <pattern>{@fightlines}</pattern>
    <value>$a=@a
$monsters=@monsters
#IF (%ismember($a, $monsters)) {#SAY Monster}</value>
  </trigger>
  <var name="a" id="5">Darsh the High Champion</var>
</class>

Note: I'm not completely comfortable with the xml view yet, so the "&amp;" is worrying me. In the actual variable, I'm typing: "&a" only. For some reason this shows "&amp;" in the xml view.
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun May 11, 2008 2:22 pm   
 
The "&amp;" is just the xml way of saying "&" no worries there.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Ghedemonas
Novice


Joined: 15 Aug 2007
Posts: 39

PostPosted: Sun May 11, 2008 4:20 pm   
 
Thanks for that ... I'll take a look in it and post what I find outspeedwise and such!
Reply with quote
Ghedemonas
Novice


Joined: 15 Aug 2007
Posts: 39

PostPosted: Fri Jun 20, 2008 9:41 pm   
 
Ok, that i smy first try with no nested variables ... clumsy but working :)
Next will come a nested one with the code provided by Caled ...

^{@{Damages.AHitsB_Advance}|}{| }({You|you|Your|your|@Monsters|@Who_list}){'s |s | }{@{Damages.AHitsB_Main}}{'s |s | |}({you|your|@Monsters|@Who_list}){|'s |s | }{@{Damages.AhitsB_Rear}|}

^{@{Damages.BHitsA_Advance}|}{| }({You|you|Your|your|@Monsters|@Who_list}){'s |s | }{@{Damages.BHitsA_Main}}{'s |s | |}({you|your|@Monsters|@Who_list}){|'s |s | }{@{Damages.BHitsA_Rear}|}

^{@{Damages.ANoHit_Advance}|}{| }({You|you|Your|your|@Monsters|@Who_list}){'s |s | }{@{Damages.NoHit_Main}}{'s |s | |}({you|your|@Monsters|@Who_list|}){|'s |s | }{@{Damages.NoHit_Rear}|}


#NOOP PLAYER HITS:
#if (%ismember(%1,@Who_list)) {
#if (%ismember(%2,@Monsters)) {#col @Color.DamageOthers} {
#if (%ismember(%2,@Who_list)) {#col @Color.DamageOthers} {
#if ((%2 = "you") OR (%2 = "your")) {#col @Color.DamageTaken} {
}}}

} {

#NOOP MONSTER HITS:
#if (%ismember(%1,@Monsters)) {
#if (%ismember(%2,@Monsters)) {#col @Color.DamageOthers} {
#if (%ismember(%2,@Who_list)) {#col @Color.DamageOthers} {
#if ((%2 = "you") OR (%2 = "your")) {#col @Color.DamageTaken} {
}}}

} {

#NOOP YOU HIT:
#if ((%1 = "you") OR (%1 = "your") OR (%1 = "You") OR (%1 = "Your")) {
#if (%ismember(%2,@Monsters)) {#col @Color.DamageDone} {
#if (%ismember(%2,@Who_list)) {#col @Color.DamageDone} {
#if ((%2 = "you") OR (%2 = "your")) {#say %ansi(white)You hit Yourself!} {
}}}

} {

#NOOP UNRECOGNISED MONSTER
#say Monster is unrecognised

}}}
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