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
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 185

PostPosted: Sun Dec 22, 2024 2:49 pm   

Help with a capture
 
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger name="moo" priority="36" repeat="true" regex="true" copy="yes">
    <pattern>\s+Defenses\s+</pattern>
    <value>//-=] Defenses
// -=]  Je:     [||||||....]  Kardon: [||||||....]  [=-
// -=]  Doon:   [||||||....]  Shoufa: [||||||....]  [=-
// -=]  Bekkar: [||||||....]  Algode: [||||||....]  [=-
// -=]  Cair:   [|||||.....]  Era:    [||||||....]  [=-
// -=]  Sorda:  [||||||....]  Rahien: [||||||....]  [=-

#print works for defense hook</value>
    <trigger type="Loop Lines" param="20" repeat="true">
      <pattern>(%w)~:%s~[(*)~]</pattern>
      <value>//Je:     [||||||....]
#IF %match(%1, "Je") {#print je captured}
//#print %1 %2


%remove(@testvar1,".")
testvar1=%replace(%2, "|", "1")
testvar=%max(@testvar1)


testvar2=%replace(%2, ".", "2")
#show %max(@testvar1)

</value>
    </trigger>
  </trigger>
</cmud>



as you can see ive tried to work this out, but am stuck with how to first change the "|" and "." to a numerical value, then add them up...

my plan is once these are numberical values i can subtract them and get a remainder and use an action to change my damage type to the lowest ac this monster has...
some help would be much appreciated! thanks!!!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4702
Location: Pensacola, FL, USA

PostPosted: Sun Dec 22, 2024 5:57 pm   
 
I would try changing your pattern to be more explicit
Code:
<trigger priority="526790" repeat="true" id="52679">
  <pattern>(%w):%s~[([|])([.])~]</pattern>
  <value>$name=%1
$bar=%len(%2)
$dot=%len(%3)
$diff=($bar-$dot)
#SWITCH $name
  ("Je") {do this}
  ("Kardon") {etc}
</value>
</trigger>


Something like this may be closer to what you need.
Without knowing more of how you use the data so collected, I can't offer more suggestions.
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4702
Location: Pensacola, FL, USA

PostPosted: Sun Dec 22, 2024 6:29 pm   
 
If $name are the potential damage types, you would want to construct a variable database

#ADDKEY mobDefenses $name $diff

(this variable should be reset in the first state (0) to a null value)
mobDefenses=%null

Which could then be polled for the highest/lowest value in a new third state of your trigger.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 185

PostPosted: Sun Dec 22, 2024 6:56 pm   
 
hmmm and yes its based on mob weaknesses and to change the damage types accordingly...


$bar=%len(%2)
$dot=%len(%3)
diff=($bar-$dot)
#show $bar $dot
#print @diff

this is exaclty what i needed for getting raw numbers to then produce the next part (shalimar once again coming through:P)
sooo now i need to work on the #switch for which damage types work best for what.

it gets much more complicated becaus ei only have 4 different damage types, and need to reconcile that against what the specific monster is weakest to, so i may not have the best damage but have to go with 2nd or 3rd or just be able to do any damage.


Last edited by chris123zugg on Sun Dec 22, 2024 7:14 pm; edited 1 time in total
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4702
Location: Pensacola, FL, USA

PostPosted: Sun Dec 22, 2024 7:04 pm   
 
I swapped things up a bit with the dbVar orginization and updated your trigger with all three states:

Code:
<trigger name="moo" priority="36" regex="true" id="52677">
  <pattern>\s+Defenses\s+</pattern>
  <value>mobDefenses=%null</value>
  <trigger repeat="true">
    <pattern>(%w)~:%s~[([|])([.])~]</pattern>
    <value>#STATE 1
$name=%1
$bar=%len(%2)
$dot=%len(%3)
$diff=($bar-$dot)
$diffList=%db(@mobDefenses, $diff)
#ADDITEM $diffList $name
#ADDKEY mobDefenses $diff $diffList</value>
  </trigger>
  <trigger>
    <pattern>*</pattern>
    <value>#SHOWDB @mobDefenses</value>
  </trigger>
</trigger>
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 185

PostPosted: Sun Dec 22, 2024 7:28 pm   
 
Hmm it created the trigger, but isnt recording to db you made in the trigger <--- i forgot to turn triggers back on, but its not recording each dmg type to dbvar...


2: Je|Kardon|Doon|Shoufa|Bekkar|Algode|Cair|Era|Sorda|Rahien is the return of #showdb mobDefenses... its not recording each name|difference... and i need to use an #IF to call up the one that is the "highest" number which would be the biggest difference, though that wouldnt be 100% accurate because the "|" or "." could be the greater of the two,m so it has to be the lowest "|" of akk the others to be thew weakest defense there


Last edited by chris123zugg on Sun Dec 22, 2024 7:50 pm; edited 1 time in total
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4702
Location: Pensacola, FL, USA

PostPosted: Sun Dec 22, 2024 7:47 pm   
 
it might be the ~ in front of the :, not sure why that got in there

its also possible that all the #SHOWs and #PRINTs from your trigger are throwing mine off, im not using loop lines, but resetting the trigger state
If there are any line gaps between the expected states that needs to be allowed for by knowing the maximum gap
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4702
Location: Pensacola, FL, USA

PostPosted: Sun Dec 22, 2024 7:56 pm   
 
Oh so you are looking for the lowest of either bars or dots?
That requires a different structuring to track both stats instead of just the disparity.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 185

PostPosted: Sun Dec 22, 2024 7:57 pm   
 
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger name="moo" priority="36" regex="true" copy="yes">
<pattern>\s+Defenses\s+</pattern>
<value>mobDefenses=%null</value>
<trigger repeat="true">
<pattern>(%w)~:%s~[([|])([.])~]</pattern>
<value>#STATE 1
$name=%1
$bar=%len(%2)
$dot=%len(%3)
$diff=($bar-$dot)
$diffList=%db(@mobDefenses, $diff)
#ADDITEM $diffList $name
#ADDKEY mobDefenses $diff $diffList
#show $diff</value>
</trigger>
<trigger>
<pattern>*</pattern>
<value>#SHOWDB @mobDefenses</value>
</trigger>
</trigger>
</cmud>
thi sis your directly from the one you posted, i didnt not add anythig to it whatsoever...

the other one i was posting wass mine, i just cut/pasted some of your stuff into

yours does capture the first instance of the capture,. but doesnt capture within line ( the second one, and its also not capturing to dbvar you have in there at all)
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4702
Location: Pensacola, FL, USA

PostPosted: Sun Dec 22, 2024 8:08 pm   
 
I didn't see you post any other full triggers

But the output you show is more than a single line worth of capture.

So im not sure what you are currently working with that is giving you effective output.

We need to be on the same page and furthering the same code.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 185

PostPosted: Sun Dec 22, 2024 8:20 pm   
 
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger name="moo" priority="36" regex="true" copy="yes">
<pattern>\s+Defenses\s+</pattern>
<value>mobDefenses=%null</value>
<trigger repeat="true">
<pattern>(%w)~:%s~[([|])([.])~]</pattern>
<value>#STATE 1
$name=%1
$bar=%len(%2)
$dot=%len(%3)
$diff=($bar-$dot)
$diffList=%db(@mobDefenses, $diff)
#ADDITEM $diffList $name
#ADDKEY mobDefenses $diff $diffList
#show $diff</value>
</trigger>
<trigger repeat="true">
<pattern>*</pattern>
<value>#SHOWDB @mobDefenses</value>
</trigger>
</trigger>
</cmud>
This is what i copy/pasted from your example above... this is all im using
It does capture the first example of the capture, but doesnt capture all of them


-=] Je: [||||||....] Kardon: [||||||....] [=-
2
2: Je

-=] Doon: [||||||....] Shoufa: [||||||....] [=-
-=] Bekkar: [||||||....] Algode: [||||||....] [=-
-=] Cair: [||||||....] Era: [||||||....] [=-
-=] Sorda: [||||||....] Rahien: [||||||....] [=-

this is what it does for your trigger.
i apologize if i confused things with my own build
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4702
Location: Pensacola, FL, USA

PostPosted: Sun Dec 22, 2024 8:31 pm   
 
You are quite alright, just part of the process.
However, if mine isn't working, i don't need to see mine again, I need to see how you edited yours to get good results.

Remove as many of the #SHOWs and #PRINTs as you can, they are useful for error testing, but once you know you have a good value, it's just clutter.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 185

PostPosted: Sun Dec 22, 2024 8:39 pm   
 
Oh right, i added ther "loop lines 25" and "whithin line" to make it search far enough to capture all the instances, and withink lines to force it to look again on each of the 25 lines, though i only counted 9 lines, it seems to stop checking if i didnt add that length of lines (not sure if im just not comprehending how that works.
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 185

PostPosted: Sun Dec 22, 2024 8:42 pm   
 
2: Je|Kardon|Bekkar|Algode|Sorda
0: Doon|Shoufa|Era|Rahien
-2: Cair

is the output which is whats needed, so it just needed to bbe changed to loop lines and within line to correctly grab it all.

thanks again shalimar! Now i just need to work on using the dbvar results to change damage types to do the right dmg!
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 185

PostPosted: Sun Dec 22, 2024 9:01 pm   
 
-=] Je: [||||||....] Kardon: [||||||....] [=-
-=] Doon: [||||||....] Shoufa: [||||||....] [=-
-=] Bekkar: [||||||....] Algode: [||||||....] [=-
-=] Cair: [|||||.....] Era: [||||||....] [=-
-=] Sorda: [||||||....] Rahien: [||||||....] [=-

so if the results are for cair/doon/algode are the lowest or also are the same as other others being 0 difference or less, i would simply use that damage type, now if its lowest for any other types je, kardon, shoufa etc, i would always use cair
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4702
Location: Pensacola, FL, USA

PostPosted: Sun Dec 22, 2024 9:28 pm   
 
$low=%item(%sort(%dbkeys(@mobDefenses)),1)
//gets the lowest value key
$list=%db(@mobDefenses, $low)
//gets the list associated with that key
$excludeList="this|that|the other"
#FORALL $excludeList {#DELITEM $list %i}
//gets rid of all the options you don't want to even consider, in one go
$item=%item($list,%random(1, %numitems($list)))
//picks one member from said list, all things being equal
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 185

PostPosted: Tue Dec 24, 2024 5:19 pm   
 
$excludeList="this|that|the other"
#FORALL $excludeList {#DELITEM $list %i}
//gets rid of all the options you don't want to even consider, in one go
$item=%item($list,%random(1, %numitems($list)))
//picks one member from said list, all things being equal

the excludelist, do i add the damage types i dont care about instead of "this|that"theother"?
then when you have pick a random one, how would i say choose whichever is lowest from the list and then assign 1 or 2 based on the lowest?

i basically only use cair/doon depending.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4702
Location: Pensacola, FL, USA

PostPosted: Tue Dec 24, 2024 7:57 pm   
 
if you only really care about two of the damage types, i would just only store data on thoses two $names, then the existing syntax still applies

rather than the exclude method (a blacklist) lets try a whitelist instead:

#IF (%ismember($name, "Cair|Doon") {
$diffList=%db(@mobDefenses, $diff)
#ADDITEM $diffList $name
#ADDKEY mobDefenses $diff $diffList
}
_________________
Discord: Shalimarwildcat
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