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


Joined: 30 Oct 2004
Posts: 127

PostPosted: Mon Jan 10, 2011 7:44 pm   

Multistate Trigger just ....stops?
 
I just recently made a trigger system to restore all guards within a city, and part of that is a multistate to capture the guards in the room.

This trigger is a multistate trigger that grabs the initial line ^Number of objects: (%d)
Now, I have a second line trigger for ^(*)$ to capture the full line. I've tried setting it to manual state or within 1 and just having it do #STATE 1 when a guard line is caught, then #STATE 0 when the prompt is captured (which is where the trig would end).

Now, I run this system, it captures perfectly fine for about 10 rooms and then magically stops. Nothing has changed, but it's almost like the trigger is broken. I can't reset it, I can't use #STATE to restore it to its first state. If I delete the trigger and remake it exactly as it is, it once again works for a random length of time and disables itself again. Thing is, this worked for like ....days and then all of a sudden its like it doesn't want to reset to state 0....any help would be appreciated as I'm baffled why this isn't working.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jan 11, 2011 1:21 pm   
 
The most likely cause is that it gets stuck in a different state, but the #STATE command should fix that. Perhaps if you give us the actual code, and the exact steps you have tried to reset it.
Reply with quote
talonnb
Apprentice


Joined: 30 Oct 2004
Posts: 127

PostPosted: Tue Jan 11, 2011 11:24 pm   
 
Unforatunately it's a pretty big pile of code for it. But I've used #STATE and #SET as I've seen in other threads, to no avail. But the weird thing is, without changing anything, its magically started working today without disabling itself so ....I dunno. Thanks anyhow
Reply with quote
talonnb
Apprentice


Joined: 30 Oct 2004
Posts: 127

PostPosted: Wed Jan 19, 2011 9:50 pm   
 
Reviving this thread because I still can't find the issue and it's bothersome.

Basically the trigger fires properly about 20-100 times, then magically stops working. I figured it was something to do with my code disabling it or changing the state to an improper state....this doesn't seem to be the case

I put an ID to it, and I do #echo %state(IDNAME) and it shows 0 which is the first trigger in the state if I remember correctly. So this means the original trigger, which in this case is "^Number of objects: (%d)" , should fire no problem off "Number of objects: 1" no problem, but for some reason it doesn't.

I've searched for similar trigs, I've tried '#SET' to reset it, no change. But randomly, without me running the program for a while, I can start it randomly just to see if it's started working, and it does! Sometimes for a random amount of times as listed above, and sometimes it makes it through the 600 steps that the system does.....so I don't understand.
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Wed Jan 19, 2011 11:22 pm   
 
Have you exported the XML for the package then imported back into a clean session to test for corruption? This would be a good starting place if you have not already done so.

It sounds like you have a trigger that fires and then runs one huge script all from that one trigger? If that is the case, perhaps the next step if the export/import doesn't work, would be to break down the script into smaller sections. This would allow you to use a combination of the other settings in CMUD, giving more control over the script should it malfunction and more debug information. You could use aliases or events, that say added 1 to a variable each time one of these settings were fired or raised. This would give you a defined place to look for the problem if it persisted. You could do the debug variable thing within the large script too. I could be misunderstanding your implementation of the system you have though.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
talonnb
Apprentice


Joined: 30 Oct 2004
Posts: 127

PostPosted: Wed Jan 19, 2011 11:57 pm   
 
Well, the trigger isn't too massive, it just is a lot of if/switches to do what's required, based on the lines below

The first line trigger is about 60 lines, which is just more about resetting variables from the previous' rooms capture so nothing terribly complicated. The multistate, which I set to manual as well so I could control them better is about 140 lines of code, which has a lot of #delitem, and #send commands for dealing with the items in the room based on what they are....Do I need to split this up? Cause I like code to be a little cleaner by keeping it all together. And also, I did try the export/import option. Exported, deleted it out of Cmud, deleted the package file, remade the package file in Cmud, imported back in and saved. Once again, it would work for a bit, then stopped working again....so I don't know

Code Follows, in case I'm missing something:

State 0 Trig: ^Number of objects: (%d)
Code
Code:
#if (@GuardCheckerWait=0) {
  #var HighGuardsAllowed 0
  #var guards ""
  #var HighGuards ""
  #var HighMages ""
  #var MedGuards ""
  #var LowGuards ""
  #var LowMages ""
  #var HighMagesAllowed 0
  #var LowGuardsAllowed 0
  #var LowMagesAllowed 0
  #var MedGuardsAllowed 0
  #var HighGuardsRoom 0
  #var HighMagesRoom 0
  #var MedGuardsRoom 0
  #var LowMagesRoom 0
  #var LowGuardsRoom 0
  #var MissLowGuard 0
  #var MissMedGuard 0
  #var MissHighGuard 0
  #var MissHighMage 0
  #var MissLowMage 0
  #if (%gmcp.room.info.area="Enorian") {
  #switch (%gmcp.room.info.num=2096 or %gmcp.room.info.num=2056 or %gmcp.room.info.num=2120 or %gmcp.room.info.num=2165 or %gmcp.room.info.num=1518 or %gmcp.room.info.num=2070 or %gmcp.room.info.num=2118 or %gmcp.room.info.num=2197 or %gmcp.room.info.num=2094 or %gmcp.room.info.num=2082 or %gmcp.room.info.num=2064 or %gmcp.room.info.num=2213 or %gmcp.room.info.num=2098 or %gmcp.room.info.num=2174 or %gmcp.room.info.num=2108 or %gmcp.room.info.num=2269 or %gmcp.room.info.num=16240 or %gmcp.room.info.num=2237 or %gmcp.room.info.num=2184 or %gmcp.room.info.num=2225 or %gmcp.room.info.num=2140 or %gmcp.room.info.num=2146 or %gmcp.room.info.num=2164 or %gmcp.room.info.num=2194 or %gmcp.room.info.num=2058 or %gmcp.room.info.num=2215 or %gmcp.room.info.num=2122 or %gmcp.room.info.num=35479 or %gmcp.room.info.num=2172 or %gmcp.room.info.num=2124 or %gmcp.room.info.num=2232 or %gmcp.room.info.num=2300 or %gmcp.room.info.num=2235 or %gmcp.room.info.num=2207 or %gmcp.room.info.num=2087 or %gmcp.room.info.num=2091 or %gmcp.room.info.num=2073 or %gmcp.room.info.num=2187 or %gmcp.room.info.num=12031 or %gmcp.room.info.num=2201 or %gmcp.room.info.num=16235 or %gmcp.room.info.num=16252 or %gmcp.room.info.num=2148 or %gmcp.room.info.num=2147 or %gmcp.room.info.num=1524 or %gmcp.room.info.num=2167 or %gmcp.room.info.num=35407 or %gmcp.room.info.num=2240 or %gmcp.room.info.num=2259 or %gmcp.room.info.num=2264 or %gmcp.room.info.num=2244) {
    //Enorian Checkpoints! 50 Currently
    #var HighGuardsAllowed 2
    #var HighMagesAllowed 2
    #var MedGuardsAllowed 1
    }
    (%gmcp.room.info.num=2049 or %gmcp.room.info.num=2113 or %gmcp.room.info.num=16249) {
    //1st level Enorian entrances
    #var HighGuardsAllowed 3
    #var HighMagesAllowed 2
    }
    (%gmcp.room.info.num=2051 or %gmcp.room.info.num=2112 or %gmcp.room.info.num=16248) {
    //2nd level Enorian entrances
    #var HighGuardsAllowed 2
    #var HighMagesAllowed 3
    }
    (%gmcp.room.info.num=2052 or %gmcp.room.info.num=2111 or %gmcp.room.info.num=16247) {
    //3rd level Enorian entrances
    #var MedGuardsAllowed 3
    #var LowMagesAllowed 2
    }
    {#var LowGuardsAllowed 1}
  }
  #if (%gmcp.room.info.area="the Ancient Heartwood") {
    #switch (%gmcp.room.info.num=9999) {
    //Duiran's Checkpoints
    }
      (%gmcp.room.info.num=8888) {
      //Duiran's Entrances
      }
      {#var LowGuardsAllowed 1}
    }
  } {
  #wait 1000
  #var GuardCheckerWait 0
  ih guard
  }
#state GuardSystem 1


State 1 Trigger: ^(*)$
Code:
Code:
$capture=%replace( %1, """, "")
$roomnum=%gmcp.room.info.num;
#switch (%begins( $capture, "H:")) {
  //Guard Verify will walk each room and check if the appropriate numbers are there
  #switch (@programs.guardprog=1) {
    #if (@GuardCheckerStep>@GuardCheckerMax) {#Call @GuardStep(End)}
    #if (@HighGuardsRoom>0) {
      #switch (@HighGuardsRoom>@HighGuardsAllowed) {
   $counter=@HighGuardsAllowed
        #while ($counter>0) {
          $counter=$counter-1
          #if (@programs.orderguard=1) {#send {order %item( @HighGuards, 1) guard}}
          #delnitem @HighGuards 1
          }
   #forall @HighGuards {#additem Guards %i}
   }
        (@HighGuardsRoom=@HighGuardsAllowed) {
   #if (@programs.orderguard=1) {#forall @HighGuards {#send {order %i guard}}}
   #var HighGuards ""
   }
        (@HighGuardsRoom<@HighGuardsAllowed) {
   #if (@programs.orderguard=1) {#forall @HighGuards {#send {order %i guard}}}
   #var MissHighGuard @HighGuardsAllowed-@HighGuardsRoom
   }
      } {#var MissHighGuard @HighGuardsAllowed}
    #if (@HighMagesRoom>0) {
      #switch (@HighMagesRoom>@HighMagesAllowed) {
   $counter=@HighMagesAllowed
        #while ($counter>0) {
          $counter=$counter-1
          #if (@programs.orderguard=1) {#send {order %item( @HighMages, 1) guard}}
          #delnitem @HighMages 1
          }
   #forall @HighMages {#additem Guards %i}
   }
        (@HighMagesRoom=@HighMagesAllowed) {
   #if (@programs.orderguard=1) {#forall @HighMages {#send {order %i guard}}}
   #var HighMages ""
   }
        (@HighMagesRoom<@HighMagesAllowed) {
   #if (@programs.orderguard=1) {#forall @HighMages {#send {order %i guard}}}
   #var MissHighMage @HighMagesAllowed-@HighMagesRoom
   }
      } {#var MissHighMage @HighMagesAllowed}
    #if (@MedGuardsRoom>0) {
      #switch (@MedGuardsRoom>@MedGuardsAllowed) {
   $counter=@MedGuardsAllowed
        #while ($counter>0) {
          $counter=$counter-1
          #if (@programs.orderguard=1) {#send {order %item( @MedGuards, 1) guard}}
          #delnitem @MedGuards 1
          }
   #forall @MedGuards {#additem Guards %i}
   }
        (@MedGuardsRoom=@MedGuardsAllowed) {
   #if (@programs.orderguard=1) {#forall @MedGuards {#send {order %i guard}}}
   #var MedGuards ""
   }
        (@MedGuardsRoom<@MedGuardsAllowed) {
   #if (@programs.orderguard=1) {#forall @MedGuards {#send {order %i guard}}}
   #var MissMedGuard @MedGuardsAllowed-@MedGuardsRoom
   }
      } {#var MissMedGuard @MedGuardsAllowed}
    #if (@LowMagesRoom>0) {
      #switch (@LowMagesRoom>@LowMagesAllowed) {
   $counter=@LowMagesAllowed
        #while ($counter>0) {
          $counter=$counter-1
          #if (@programs.orderguard=1) {#send {order %item( @LowMages, 1) guard}}
          #delnitem @LowMages 1
          }
   #forall @LowMages {#additem Guards %i}
   }
        (@LowMagesRoom=@LowMagesAllowed) {
   #if (@programs.orderguard=1) {#forall @LowMages {#send {order %i guard}}}
   #var LowMages ""
   }
        (@LowMagesRoom<@LowMagesAllowed) {
   #if (@programs.orderguard=1) {#forall @LowMages {#send {order %i guard}}}
   #var MissLowMage @LowMagesAllowed-@LowMagesRoom
   }
      } {#var MissLowMage @LowMagesAllowed}
    #if (@LowGuardsRoom>0) {
      #switch (@LowGuardsRoom>@LowGuardsAllowed) {
   $counter=@LowGuardsAllowed
        #while ($counter>0) {
          $counter=$counter-1
          #if (@programs.orderguard=1) {#send {order %item( @LowGuards, 1) guard}}
          #delnitem @LowGuards 1
          }
   #forall @LowGuards {#additem Guards %i}
   }
        (@LowGuardsRoom=@LowGuardsAllowed) {
   #if (@programs.orderguard=1) {#forall @LowGuards {#send {order %i guard}}}
   #var LowGuards ""
   }
        (@LowGuardsRoom<@LowGuardsAllowed) {
   #if (@programs.orderguard=1) {#forall @LowGuards {#send {order %i guard}}}
   #var MissLowGuard @LowGuardsAllowed-@LowGuardsRoom
   }
      } {#var MissLowGuard @LowGuardsAllowed}
    #if (@MissHighGuard>0 or @MissHighMage>0 or @MissMedGuard>0 or @MissLowMage>0 or @MissLowGuard>0) {#additem MissingGuards {%gmcp.room.info.num HG:@MissHighGuard MG:@MissMedGuard LG:@MissLowGuard HM:@MissHighMage LM:@MissLowMage}}
    }
    (@programs.guardprog=2) {
    //part of the system that picks up missing guards in the barracks
    }
    #if (@GuardCheckerStep<=@GuardCheckerMax) {#Call @GuardStep(MoveNext)} {#Call @GuardStep(End)}
    #state
  }
  (%match( $capture, "peacemaker(%d)(%s)a peacemaker of Enorian.", $guardnum) or %match( $capture, "longbowman(%d)(%s)a longbowman.", $guardnum)) {
  #var HighGuardsRoom @HighGuardsRoom+1
  #additem HighGuards $guardnum
  #gag
  #STATE GuardSystem 1
  }
  (%match( $capture, "chaplain(%d)(%s)a solemn chaplain.", $guardnum) or %match( $capture, "ranger(%d)(%s)an Eleusian ranger.", $guardnum)) {
  #var HighMagesRoom @HighMagesRoom+1
  #additem HighMages $guardnum
  #gag
  #STATE GuardSystem 1
  }
  (%match( $capture, "missionary(%d)(%s)a bright-eyed missionary.", $guardnum) or %match( $capture, "scout(%d)(%s)a wilderness scout.", $guardnum)) {
  #var MedGuardsRoom @MedGuardsRoom+1
  #additem MedGuards $guardnum
  #gag
  #STATE GuardSystem 1
  }
  (%match( $capture, "intercessor(%d)(%s)an argent intercessor.", $guardnum) or %match( $capture, "wolfine(%d)(%s)a marked wolfine.", $guardnum)) {
  #var LowMagesRoom @LowMagesRoom+1
  #additem LowMages $guardnum
  #gag
  #STATE GuardSystem 1
  }
  (%match( $capture, "guardian(%d)(%s)a zealous guardian.", $guardnum) or %match( $capture, "peltast(%d)(%s)a peltast.", $guardnum)) {
  #var LowGuardsRoom @LowGuardsRoom+1
  #additem LowGuards $guardnum
  #gag
  #STATE GuardSystem 1
  }
  {#STATE}
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Jan 20, 2011 1:27 pm   
 
You have a #WAIT in the first state. This could be the problem. #WAIT puts this thread into the background. which means that this trigger could accidentally fire twice before it finishes. That could mess you up badly. Do you actually need the #WAIT? You are multithreading here without any protection against thread collisions.
Reply with quote
talonnb
Apprentice


Joined: 30 Oct 2004
Posts: 127

PostPosted: Thu Jan 20, 2011 10:59 pm   
 
Yes, but that #wait only fires if I walk too fast in the program, which happens very rarely. Now I haven't confirmed it, but I'm pretty sure I never got to that point where it was walking too fast. ((this is more just a lag protection program)) I can try changing that to an alarm, but not sure that'll change things
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