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
Etomyutikos
Newbie


Joined: 10 May 2008
Posts: 8

PostPosted: Tue Jun 17, 2008 9:45 pm   

[2.27] Access violation
 
Quote:
Access violation at address 00405e58 in module 'cMUD.exe'. Write of address 00d1b436.


I'm having trouble with this script. It's a relatively simple "hunting assistant." To use it, I first use an Alias <kUnpause>, not shown here, that Enables this Class. Then, using <kHunt>, I identify the mobs I want it to recognize. Then, I type in <kScan>, which Enables the <kTarget> Trigger, and use the MuD's command Scan.

Using the Scan output, <kTarget> will match all of the Scan output until it reaches the first instance of the mob I want, at which point it turns itself off, attacks (or moves to) the mob, and Enables the <kWatch> Trigger, which just repeats the <kScan> function.

Included here, I have a <kGate> Alias, which allows me to set a target to use with the MuD's Gate spell, and then, if used without argument, Gate to that target.

All of this was working fine until I tried to add in a means of auto-<kGate>-ing if the <kTarget> didn't find a match. To do that, I have the script create an Alarm <kAlarm>, which would overwrite itself if <kTarget> matched, otherwise it would <kGate>. And, subsequently, I updated from [2.26] to [2.27].

I did not try this Script in [2.27] before I added the <kAlarm>. Removing the <kAlarm> still gives the error, however.

The error doesn't happen immediately. I can usually get a couple rounds out of the script before it fumbles.

Here is the XML of the entire script (sans <kUnpause>, which is outside the Class):

Code:
<class name="kAssistance" enabled="false" id="820">
  <alias name="kScan" id="45">
    <value>#T+ kTarget
#T+ kGag
scan</value>
  </alias>
  <alias name="kHunt" id="793">
    <value>#IF ($target == clear)
  {
  #VAR kHuntList ""
  #SAY %ansi( high, green ) kHuntList cleared.%crlf
  }
    {
    #IF (%ismember( $target, @kHuntList))
      {
      }
        {
        #ADDITEM kHuntList $target
        #SAY %ansi( high, green ) %proper( $target ) added to hunt list.%crlf
        }
    }</value>
    <arglist>$target</arglist>
  </alias>
  <var name="kHuntList" type="StringList" sorted="true" usedef="true" id="795">imp</var>
  <alias name="kPause" id="823">
    <value>#T- {Killing|kAssistance}
#T- kTarget
#T- kWatch
#T+ kUnpause
#SAY %ansi( high, green ) kAssistance paused.%crlf</value>
  </alias>
  <trigger name="kWatch" priority="8970" enabled="false" id="897">
    <pattern>^{A|An|The} (*) is DEAD!!$</pattern>
    <value>#T- kWatch
kScan</value>
  </trigger>
  <trigger name="kBleed" id="912">
    <pattern>^You sure are BLEEDING!$</pattern>
    <value>kPause</value>
  </trigger>
  <var name="kGate" usedef="true" id="915">
    <value>anuwyn</value>
    <default>""</default>
  </var>
  <alias name="kGate" id="1022">
    <value>#IF ($target != "")
  {
  #VAR kGate $target
  #SAY %ansi( high, green ) kGate set to $target. %crlf
  }
    {
    #IF ($target == clear)
      {
      #VAR kGate ""
      }
        {
      cast gate @kGate
      kScan
        }
    }</value>
    <arglist>$target</arglist>
  </alias>
  <trigger name="kGag" priority="10320" enabled="false" id="1032">
    <pattern>^Looking around you see:$</pattern>
    <value>#SUB {%ansi( high, green ) kScanning...%crlf}
#GAGBLOCK
#T- kGag</value>
  </trigger>
  <trigger name="kTarget" priority="8710" enabled="false" id="1050">
    <pattern>^{a|an|the} (*), (*) (*).$</pattern>
    <value>$target=%1
$location=%2
$direction=%3
#IF %ismember( $target, @kHuntList)
  {
  #ALARM "kAlarm" +1
    {
    #SAY %ansi( high, green ) Target found.
    }
  #SWITCH ($location)
    ("right")
      {
      #T- kTarget
      #T+ kWatch
      ravage $target
      }
    ("nearby to the")
      {
      #T- kTarget
      #SEND $direction
      #ALARM +1
        {
        kScan
        }
      }
    ("not far")
      {
      #T- kTarget
      #LOOP 2 {$direction}
      #ALARM +1
        {
        kScan
        }
      }
  }
    {
    #ALARM "kAlarm" +2
      {
      kGate
      }
    }</value>
  </trigger>
</class>


The MuD's Scan command gives this output:

Quote:
Looking around you see:
an imp, not far north.
a raven, nearby to the east.
an imp, nearby to the west.
a raven, nearby to the west.
a demonic three-toed sloth, nearby to the west.
a raven, not far west.


In this particular instance, the script should move me one North, and <kScan>, at which point it would kill the Imp.

Any help would be much appreciated, primarily as it concerns the error. I have some ideas on how to redo the entire script, but I'd like very much to get this one working as is.

Thank you,

Etomyutikos
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jun 18, 2008 12:27 pm   
 
You haven't said what error happens. I'll try to figure out the logic, but it would be helpful if you could explain what happens when it goes wrong.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jun 18, 2008 12:45 pm   
 
One problem I see is in your ktarget trigger:
Code:
^{a|an|the} (*), (*) (*).$

How is the trigger supposed to know what you want in %2 instead of %3? It looks like you could use %w instead of * for %3. And is %1 always a single word? If so, the following might be better:
Code:
^{a|an|the} (%w), (*) (%w).$

Even better might be:
Code:
^{a|an|the} (%w), ({right|nearby to the|not far}) (%w).$

I don't think this is your problem, since I believe the trigger will correctly decide to put as much as possible in %2, but your version would be a lot slower and less efficient.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jun 18, 2008 1:04 pm   
 
Ok, another problem I see is with the alarms. In your ktarget trigger, it tries to move in a direction and sets a trigger to do a scan in 1 second. But if the movement doesn't happen fast enough, the scan could happen before the movement. This would lead to weird problems. You would do the initial scan, ktarget would send an order to move north, the alarm could fire prematurely, which again causes ktarget to send an order to move north and set another alarm. You could end up moving too far.

Is there some consistent way of telling when you have successfully moved? It might be better to put the kscan in a successful_move trigger instead of an alarm.
Reply with quote
Etomyutikos
Newbie


Joined: 10 May 2008
Posts: 8

PostPosted: Wed Jun 18, 2008 3:12 pm   
 
The error I quoted at the top of the post. It's an access violation error, locking up CMuD itself until I click "continue application." Even then, I have to pause the script, or the error happens incessantly.

As far as the Alarms to Scan: that hasn't been an issue. The script ran perfectly for quite a while. Only when I added in the <kAlarm>s did it start to err.

I do like the Trigger change, though it hasn't been a problem.

Quote:
Access violation at address 00405e58 in module 'cMUD.exe'. Write of address 00d1b436.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jun 18, 2008 4:27 pm   
 
Sorry. Somehow I glossed right over your first paragraph.

It usually is not a good idea to "Continue application" after an error like that. If the error box comes up, it means the application has very possibly gotten corrupted memory. If you continue, it is not guaranteed to run correctly, and can in fact mess up your session or packages. Of course, when using it on a live mud, there are times when you can't afford to simply quit and restart cmud.

Just because the movement beats the alarm some of the time does not mean it will happen all of the time. Even a little lag could cause the movement to delay for a second. And this may be a more serious problem than I suggested at first. Your trigger turns off kTarget before sending the direction, and kscan turns it back on. I assume this is because your trigger might fire from some of the messages that come when you enter a new room. If you get a 1 second lag that delays your movement, this trigger will be turned on when you enter the room, and I don't know what that will do.

On another note, your logic for the kgate alias is wrong. In that alias, your first #if sets @kGate if $target is not null. If $target is null, you then test whether $target is "clear", which of course it can't be. That almost certainly is not causing your problem, but does mean you can't clear @kGate.

An error like yours means something serious is wrong, possibly even a bug in cmud. If your problem is not due to the alarm timing, I'll probably have to turn you over to the real gurus. I'm fine at figuring out code logic, but others are better at the deep guts. Smile
Reply with quote
Etomyutikos
Newbie


Joined: 10 May 2008
Posts: 8

PostPosted: Wed Jun 18, 2008 4:31 pm   
 
Thanks for your help, though. I didn't notice the kGate issue; most likely some misplaced brackets.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Jun 18, 2008 5:25 pm   
 
By the way, the full report is much more useful than just that one line. You can save the whole thing to a file and then paste it into the forums inside [code] tags.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Etomyutikos
Newbie


Joined: 10 May 2008
Posts: 8

PostPosted: Thu Jun 19, 2008 8:13 am   
 
It's a new Access Violation, but the error happened the same way. I wasn't able to reproduce the exact same Violation.

Code:
date/time         : 2008-06-19, 04:08:29, 731ms
computer name     : MyComp
user name         : Admin <admin>
registered owner  : Etomyutikos
operating system  : Windows XP Service Pack 2 build 2600
system language   : English
system up time    : 2 days 4 hours
program up time   : 3 hours 24 minutes
processors        : 2x Intel(R) Pentium(R) 4 CPU 2.40GHz
physical memory   : 176/512 MB (free/total)
free disk space   : (C:) 24.41 GB
display mode      : 1024x768, 32 bit
process id        : $7fc
allocated memory  : 25.07 MB
executable        : cMUD.exe
exec. date/time   : 2008-06-12 17:32
version           : 2.27.0.0
compiled with     : BCB 2006/07
madExcept version : 3.0h
contact name      : Etomyutikos
contact email     : fake@notreal.com
callstack crc     : $00000003, $21edb53f, $21edb53f
exception number  : 1
exception class   : EAccessViolation
exception message : Access violation at address 00000003. Read of address 00000003.

Main ($ce4):
00000003 +0000 ???
004be79c +002c cMUD.exe     Controls             TWinControl.MainWndProc
0047c3e0 +0014 cMUD.exe     Classes              StdWndProc
7e4196c2 +000a USER32.dll                        DispatchMessageA
004461a5 +023d cMUD.exe     madExcept            HandleException
0044c64a +003a cMUD.exe     madExcept            InterceptAHandleExcept
004be7d7 +0067 cMUD.exe     Controls             TWinControl.MainWndProc
7c90eaf5 +0009 ntdll.dll                         KiUserExceptionDispatcher
00db3b9d +0015 cMUD.exe     PrefDat    9097   +1 PrefRec.GetName
00daa674 +02c4 cMUD.exe     PrefDat    5106  +37 FindInClass
00daa89c +009c cMUD.exe     PrefDat    5160  +14 PkgData.FindHash
00dac455 +0075 cMUD.exe     PrefDat    5885   +5 PkgData.FindAction
00dac504 +0078 cMUD.exe     PrefDat    5902   +6 PkgData.DefineTrigger
00d328b3 +01d3 cMUD.exe     MAIN      15649  +21 TMUDForm.MakeAction
00d4645c +00a0 cMUD.exe     MAIN      19404  +12 TMUDForm.ExecCommand
00dc3505 +00a9 cMUD.exe     CodeExec    914   +9 ExecMUDCommand
00dc93bf +044b cMUD.exe     CodeExec   2549  +45 DoDefault
00dca467 +0f2f cMUD.exe     CodeExec   2819 +254 HandleCom
00dcb9f1 +0609 cMUD.exe     CodeExec   3231 +108 TCodeExec.InternalExecute
00dc2612 +0072 cMUD.exe     CodeExec    483   +9 TCodeExec.Execute
00dc9be0 +06a8 cMUD.exe     CodeExec   2651  +86 HandleCom
00dcb9f1 +0609 cMUD.exe     CodeExec   3231 +108 TCodeExec.InternalExecute
00dc2612 +0072 cMUD.exe     CodeExec    483   +9 TCodeExec.Execute
00dc98a3 +036b cMUD.exe     CodeExec   2596  +31 HandleCom
00dcb9f1 +0609 cMUD.exe     CodeExec   3231 +108 TCodeExec.InternalExecute
00dc254b +005f cMUD.exe     CodeExec    459   +8 TCodeExec.Execute
00db925c +0098 cMUD.exe     PrefDat   11129   +8 TCacheNode.Execute
00db554a +024e cMUD.exe     PrefDat    9567  +41 PrefRec.InternalExecute
00db5793 +001f cMUD.exe     PrefDat    9623   +2 PrefRec.Execute
00d129f5 +0151 cMUD.exe     MAIN       6282  +14 TMUDForm.ExecThread
00d1b888 +04f0 cMUD.exe     MAIN       9105  +96 TMUDForm.ExecTrig
00d19110 +126c cMUD.exe     MAIN       8290 +331 TMUDForm.HandleTrigger
00d1798f +000f cMUD.exe     MAIN       7785   +1 TMUDForm.UserOutNewLine
00a593ed +0039 cMUD.exe     term       8994   +3 TTerm.DoTriggerLine
00a57df0 +0218 cMUD.exe     term       8564  +34 HandleNewLine
00a585e4 +06e4 cMUD.exe     term       8688 +104 TTerm.PutText
00a58ba3 +0053 cMUD.exe     term       8794   +2 TTerm.Add
00d018dd +00b1 cMUD.exe     MAIN       1605   +8 TMUDForm.OutputStr
00d01bb2 +00d6 cMUD.exe     MAIN       1686  +25 TMUDForm.NextMUDLine
00d02065 +0019 cMUD.exe     MAIN       1763   +4 TMUDForm.DoNextLine
004bb06f +02bb cMUD.exe     Controls             TControl.WndProc
004bf073 +04fb cMUD.exe     Controls             TWinControl.WndProc
004a15d3 +0553 cMUD.exe     Forms                TCustomForm.WndProc
004be79c +002c cMUD.exe     Controls             TWinControl.MainWndProc
0047c3e0 +0014 cMUD.exe     Classes              StdWndProc
7e4196c2 +000a USER32.dll                        DispatchMessageA
004a9748 +00fc cMUD.exe     Forms                TApplication.ProcessMessage
004a9782 +000a cMUD.exe     Forms                TApplication.HandleMessage
004a9a77 +00b3 cMUD.exe     Forms                TApplication.Run
00e497e0 +0088 cMUD.exe     CMUD        348  +20 initialization
7c91312f +0069 ntdll.dll                         RtlUnicodeStringToAnsiString
7c812b94 +00b6 kernel32.dll                      GetVersionExA
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Jun 19, 2008 4:44 pm   
 
Looks like some other script/trigger is running. You might want to keep the Script Debugger window open so that you can see what trigger is firing when you get this crash.

According to the crash dump, CMUD was executing a trigger which was calling some command to create another trigger. And I don't see anything like that in the script that you posted above.
Reply with quote
Etomyutikos
Newbie


Joined: 10 May 2008
Posts: 8

PostPosted: Thu Jun 19, 2008 5:52 pm   
 
The Script Debugger showed nothing firing save that one script. If I've got the timing down right, it seems to happen when about the time <kTarget> disables itself, and a <kAlarm> fires or overwrites itself. I'm not sure exactly, but it always seems to happen in the middle of a Scan output.
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