Problem with MUD progs

Posted by Kris on Wed 21 Mar 2001 11:57 AM — 25 posts, 86,191 views.

USA #0
The problem is with the Rupina mob, in the fight 99 prog. The intent is to have her difficulty based upon the level of the player she's fighting. Also, against higher levels that do more damage, I want her to restore herself every round. However, she's not restoring herself, and some of the commands don't seem to be getting executed. I've been testing her with a level 20 character. It gave me error messages about needing brackets so, at least as far as I assumed, I went ahead and put in opening and closing brackets to the if statements. That only made things worse. These mob progs don't seem to conform to any programming language I've ever heard of. And there are no help files whatsoever that specifically deal with syntax such as this. Could you take a look at this for me please? It's been bugging me for weeks. Thanks :)


mpechoat $n Rupina looks at you with her sad, lonely, silent eyes......
mpechoaround $n Rupina gazes into $n's eyes......
mpechoat $n
mpechoaround $n
mpechoat $n A horrible feeling of guilt passes over your soul.....
mpforce $n yell I do not deserve to live anymore!  Forgive me, Rupina!
mpecho
mpechoat $n You scream with emotional agony!!
mpechoaround $n $n sobs like a little girl....
if level($n) <= 5
{
mpdamage $n 5 15 lethal
endif
}
if level($n) <=10
{
if level($n) > 5
{
mpdamage $n 15 30 lethal
endif
}
endif
}
if level($n) <= 20
{
if level($n) > 10
{
mpdamage $n 30 60 lethal
mprestore rupina 80
endif
}
endif
}
if level($n) <= 30
{
if level($n) > 20
{
mpdamage $n 60 100 lethal
mprestore rupina 100
endif
}
endif
}
if level($n) <= 40
{
if level($n) > 30
{
mpdamage $n 100 200 lethal
mprestore rupina 100
endif
}
endif
}
if level > 40
{
mpdamage $n 500 2000 lethal
mprestore rupina 100
endif
}
mpechoat $n You scream with emotional agony!!
mpechoaround $n $n sobs like a little girl....
Australia Forum Administrator #1
There seem to me to be three problems with this fight program:

If does not use curly brackets

This IF statement ends with an ENDIF. The braces are not used, unlike C.

Blank lines cause the program to terminate

I found that if I left blank lines in the program anything after the blank line would not be executed.

mpdamage has a different syntax

As far as I can tell from the code, mpdamage simply specifies who to damage and by how many HP, eg.


mpdamage $n 60


Here is my amended program that appears to work:


mpechoat $n Rupina looks at you with her sad, lonely, silent eyes......
mpechoaround $n Rupina gazes into $n's eyes......
mpechoat $n
mpechoaround $n
mpechoat $n A horrible feeling of guilt passes over your soul.....
mpforce $n yell I do not deserve to live anymore!  Forgive me, Rupina!
mpecho
mpechoat $n You scream with emotional agony!!
mpechoaround $n $n sobs like a little girl....
if level($n) <= 5
  mpdamage $n 5
endif
if level($n) <=10
 if level($n) > 5
   mpdamage $n 15
 endif
endif
if level($n) <= 20
 if level($n) > 10
   mpdamage $n 30 
   mprestore rupina 80
 endif
endif
if level($n) <= 30
  if level($n) > 20
    mpdamage $n 60 
    mprestore rupina 100
  endif
endif
if level($n) <= 40
  if level($n) > 30
    mpdamage $n 100 
    mprestore rupina 100
  endif
endif
if level($n) > 40
  mpdamage $n 500
  mprestore rupina 100
endif
mpechoat $n You scream with emotional agony!!
mpechoaround $n $n sobs like a little girl....
USA #2
I don't get it. I'm totally lost. Now, with the code you provided, -nothing- happens, save that "Rupina looks at you with her blah blah lonely blah eyes...."
I also had a test mob prog on there, which was intended to see if mprestore really works. It used to work, but now, even though I didn't alter it in ANY way, it just returns "Huh?" when it reaches the mprestore command. I have no idea what's going on, save that something is really really screwed up.
Australia Forum Administrator #3
Well, I don't know what you have done, but here is my log:


<52hp 100m 120mv>
kill rupina
You miss Rupina.

<52hp 100m 117mv>
You wound Rupina!
Rupina scratches you.
Rupina looks at you with her sad, lonely, silent eyes......

A horrible feeling of guilt passes over your soul.....
You yell 'I do not deserve to live anymore! Forgive me, Rupina!'

You scream with emotional agony!!
You scream with emotional agony!!

<46hp 100m 114mv>
You injure Rupina!
Rupina grazes you.
Rupina looks at you with her sad, lonely, silent eyes......

A horrible feeling of guilt passes over your soul.....
You yell 'I do not deserve to live anymore! Forgive me, Rupina!'

You scream with emotional agony!!
You scream with emotional agony!!

<40hp 100m 111mv>


You can see that Rupina's HP is going down about 6 each time (one for the fight, and 5 from the mob prog I imagine).

USA #4
When I copied your example, I forgot to delete the spaces between each line (didn't even notice they were there). Like you said, it stopped execution after the first blank line, and worked after I fixed that.
How do I get the mobhere if statement to work? Here is a test greet prog I have for Rupart:
if mobhere(Rupina)
say Ruuuuppppiiiinnnnaaaaa!!!!
endif
It gives me the following error message when the greet prog activates:
Log: [*****] BUG: Unknown ifcheck, Mob #20101.
I've tried as many variations on the "if mobhere(Rupina)" line as I could possibly think of, but again the mob progs.doc file isn't very helpful at all. This is the information it provides:
"mobhere name Is a NPC with this name in the room"
Ok, so I know what mobhere does. Kinda funny how it assumes that you don't know what it is, yet you would know how to use it. I have no idea how to get the syntax on that to work.
Australia Forum Administrator #5
Try:


if mobinroom(99)
.. blah blah ..
end if


Where 99 is your mob vnum.
USA #6
Still won't work.... It doesn't give me the error message now, but the if statement still isn't firing. Rupina's mob vnum is 20102, and this is my code:

if mobinroom(20102)
say Ruuuuppppiiiinnnnaaaaa!!!!
endif

What am I doing wrong?
Australia Forum Administrator #7
Ah I see. I didn't actually test it. :)

You need to say:


if mobinroom(20102) >= 1


The if check "mobinroom" returns the number of mobs in that room.

Type "help ifchecks" into SMAUG and you will see what all the if checks do. Here is an extract from it:


IFCHECKS
VALUE CHECKS (If check == #/string/vnum)
Ifcheck        Question                      Ifcheck    Question
------------   ---------------------------   ---------  ------------------
Hitprcnt       Percentage of hit/max_hit?    Sex        Sex?
Deity          Name of deity?  (STRING)      Name       Name?  (STRING)
Level          Experience level?             Inroom     Room #?  (VNUM)
Objtype        Type of Object?               Str        # of strength?
Objval#        Value# equal to this?         Int        # of intelligen
Number         Is its vnum equal to this?    Wis        # of wisdom?
Position       Position #?                   Dex        # of dexterity?
Clan           Clan name?  (STRING)          Con        # of constituti
Race           Race name?  (STRING)          Cha        # of charisma?
Mobinarea      Is mob in area?               Mobinworld Does mob exist?
Mobinroom      How many of mob?  (VNUM)      Lck        # of luck?
Guild          Guild name?  (STRING)         Goldamt    # of gold ya go
Class          Class name?  (STRING)         Favor      # of favor?
Mobinvislevel  Level of invis?               Economy    # of economy?
Council        Member of council?            Hps        # of hps?
Mana           # of mana?                    Mortal      *Not In Use*
------------   ---------------------------   ---------  ------------------
 
Value checks can use == (equals) > (greater than) < (less than) 
and ! (not).  Combine for:  != (not equal) >= (greater than or equal).

USA #8
WOOHOO! It works now! :)
......
......
Now, how do I put delays in the mob programs? I.E. I can get Rupina to respond to what Rupart may say, but it's kinda dumb if suddenly the screen is spammed with like a 5 minute conversation all in the period of a millisecond or so. Like, maybe a second or three after one action, before the other mob's action will fire? That would allow me to have various mobs discussing the weather too, which would be kinda fun :)
Australia Forum Administrator #9
Not sure about doing that.

One way is to do something like lower the probability a mob program will fire.

eg. rand_prog with a randomness of 20%


See the mob "Silvina" in the area newacad.are

Amended on Sun 25 Mar 2001 02:49 AM by Nick Gammon
USA #10
for some reason, mppeace doesn't seem to work on mobs at all. The mob in combat couldn't do it to anyone, so I had it force another mob to do it. The mob was able to get the player to peace, but the mob that he was fighting was not 'in that room'; in other words, not a valid target. So I tried mppurge and just have the mob invoke a copy of itself before it did so. However, this specific mob is a shop mob, and when you invoke it, it doesn't retain any of its special qualities. How should I tackle this problem?
Australia Forum Administrator #11
Did you try:


mppeace all



Apparently that stops all in the room from fighting.
USA #12
Here is a copy of the mob prog:

yell I do not wish to fight you, $n! If you are troubled, just talk to me and we can try to work it out! :)
mprestore $n 100
mpechoat $n Eric chants some strange words and heals your wounds.
mpechoaround $n Eric chants some strange words at $n and an aura of healing briefly envelops $m.
mprestore self 4550
mpecho Eric mutters some strange words to himself and an aura of healing briefly envelops him.
tell $n Why did you attack me? Have I offended you somehow? If so, I hope we can work this out peacefully
mppeace all


Problem is, now Eric's the only one that sits down, and the fight continues until I die. I tried also putting in an mppeace $n, but then I was the only one who sat down. I tried just putting in like 10 mppeace things in hopes of one of them working, but no effect.
Australia Forum Administrator #13
Hmmm - that one had me puzzled for a while, but I worked it out.

The problem is, although you don't say it, I gather you have put this program into the "fight_prog".

Now if you look at the log carefully:


<2590hp 3000m 3090mv>
Your pierce misses Eric.
Eric brushes you.
You dodge Eric's attack.
Eric's kick misses you.
Eric brushes you.
You parry Eric's attack.
Eric brushes you.
Eric chants some strange words and heals your wounds.
Eric mutters some strange words to himself and an aura of healing briefly envelops him.
Eric tells you 'Why did you attack me? Have I offended you somehow? If so, I hope we can work this out peacefully '
Log: Eric: mppeace all
Eric sits down.

Eric brushes you.
Eric brushes you.
Eric's kick brushes you.
You dodge Eric's attack.
Eric's kick misses you.
Eric's kick scratches you.


The line I have put in bold shows that peace does briefly descend, but as it happens inside the fight program, that the fight must effectively start up again.

I have been trying to work out a way around this, which isn't too easy. One idea worth trying would be to have a second mob in the room (maybe invisible) that when it detects a fight does the "mppeace all".

It could have a rand_prog 50, and in it do:


if isfight(Eric)
mppeace all
endif


I haven't tested this, but something along those lines should work.

Instead of Eric you might have to put Eric's vnum.

Amended on Sat 07 Apr 2001 12:51 AM by Nick Gammon
USA #14
I tried that, once with Eric and once with his vnum. Both times, whenever the rand_prog fired, I got
Log: [*****] BUG: Unknown ifcheck, Mob #20204.
(20204 is the vnum of the invissed mob you suggested I use)

I followed the exact syntax you specified.
Australia Forum Administrator #15
Hmm - it seems I had the syntax a bit wrong. Try:


if isfight($i) == 21009


This will allow the check, however there is a problem.

This test, I think, checks to see if the nominated mob is fighting the nominated person.

However if you put the test on the invisible mob, then it won't be fighting anyone, also you won't know which person to check against.

I tried:


if numfighting($i) > 0


But you have a similar problem. Also, it seems that random checks are not performed during a fight.

There must be a way around it, does anyone else know of a method?

#16
Now, looking at your program, I can see a lotta little things that simply wont work out. First off, random is not supposed to trigger in a FIGHT because simply put, if it did, this could cause problems. You need to use a FIGHT program, mpedit add fight 100, works kinda like a random program, triggers 100% of the time, each round in the fight. Now, obviously the player is still fighting, and the mob sits down(as was observerd in your program). What would probably be better to do is, mpforce $n sit, sit. Or, even better, make a transfer room, this would be an empty room vnums, you could even use vnum 1, and add into your program, mptrans $n 1, mptrans $n. And, as an added precaution, add onto that something like, sit, then add a check for later, say on a greet, stand, so that your mob actually stands up.

Could also do something like, mpinvis, mppeace all. And then the fight wont continue(provided the mob is a higher level than the player) because the player can't see the mobile, I think.

Or, you could trans the MOB and the PLAYER to seprate rooms, and back, then add a secretive flag to your mobile *chuckle*

Also, someone mentioned something about pausing in mprogs, that would be "mpsleep" or "mppause" and it is not stock smaug, what it does it delays the program for X rounds, and there is a working snippet somewhere.

Also, I realise I covered some stuff Nick went over.... but hey, you seemed a bit lost Nick :P *chuckle*

-Larthos the SUPER builder :P
Australia Forum Administrator #17
I appreciate advice from the experts - MUD progs are not something I do every day. :)
#18
Kris,
I would highly suggest reading Herne's building
guide. It is a little old now, but will give you the
basics of mobprogs, etc.... He is one of our better builders for Realms of Despair and wrote this guide in 1997, I just visited the link to make sure it is uptodate and it has a nice interface too it now, so he may have updated some of the stuff since 1997.
Here it is:

http://webhome.idirect.com/~helspawn/smaug.html
USA #19
One thing: I want my pet to have some mob progs going on (i.e. a rand_prog that makes it meow occasionally). However, the fact that it's a pet and thus under a charm-type spell disables the mobprog. Where in the source code would I be able to disable that, so that being under a charm effect doesn't negate a mob prog?
Australia Forum Administrator #20
Near the start of mprog_driver in mud_prog.c the relevant lines are:


  if IS_AFFECTED( mob, AFF_CHARM )
    return;
USA #21
I tried disabling those two lines, but the mob progs still won't activate if the mob is charmed. Was I supposed to alter them in some other way?
#22
Just a thought from the early thing about random programs in fights, well, you can make a fight program "random" by using the IF RAND ifcheck, and make a big fight program.

Somethng like this:

if rand(50)
mpecho $I launches into a series of attacks
mpechoat $n $I jabs you with $l weapon
mpechoaround $n $I jabs $n with $l weapon
mpdamage $n 6
mpechoat $n $I slams into you with $l body
mpechoaround $n $I slams into $s with $l body
mpdamage $n 4
mpechoat $n $I whips the end of his Tar Bandol across your cheek
mpechoaround $n $I whips the end of $l Tar Bandol across $n's cheek
mpdamage $n 7
mpechoat $n $I lifts up off the ground, and brings $l hooves down on your feet
mpechoaround $n $I lifts up over $n, and comes down on $n's feet
mpdamage $n 10
else
if rand(25)
mpechoat $n $I lunges at you with $l Tar Bandol!
mpecoaround $n %I lunges at $n with $I's Tar Bandol!
mpdamage $n 25
else
if rand(1)
mpechoat $n $I screams in furry!
mpechoat $n $I hooks you with $l Tar Bandol....
mpechoat $n $I swings around and gives you a massive kick in the ribs.
mpechoat $n The force of the blow knocks you out...
mpechoaround $n $I screams in furry!
mpechoaround $n $I hooks $n with $l Tar Bandol....
mpechoaround $n $I swings around and gives $n a mighty kick into $s ribs.
mpechoaround $n $n is knocked out from the might blow from $I.
mpechoaround $n $I carts $n off to the local jail.
mptrans $n 5441
mpat $n mpechoat $n You wake up as a bucket of water is splashed across your face.
endif
endif
endif


Will not trigger all the nifty stuff at once, and it will be used at a fight 100, using rand in it, regulates what attacks my guard will use to hurt players. I hope someone finds this handy :P

-Larthos
USA #23
Ok first off, I removed that reference like Nick suggested, but mob progs on charmed mobs, like pets, still won't work. He suggested that I look for another mention of that ifcheck, but I could find none. Could someone please help me on this??
Second, I'm having some problems with a roomprog. I made a board in Shanbar Square, and added a quill pen to that room. I at first thought a copy would reset there if someone took it (I don't want players hoarding the pen to keep other players from posting, but I like having to use the pen because it adds a bit of realism to it). When it didn't, I decided to just have a rand_prog 99 room program use the ovnumhere(vnum) ifcheck, and if ovnumhere(vnum of pen) == 0, then rpoload(vnum of pen). It still didn't work. After much debugging, I found that my ifcheck was indeed firing, but the rpoload command wasn't doing a bloody thing. I tried using mpoload for the room prog, but also no effect. I tried getting creative with rpforce, rpat, etc, but none of those seem to do anything, either! Am I using these wrong or something? I could very easily do this with a mobprog, but these room progs are either extremely buggy or I'm going about this entirely the wrong way! Could someone please tell me what I need to do with this? Thanks :)
USA #24
I was just wondering if anyone has had a chance to read the previous post on this subject. I am still totally stumped on this, and would really appreciate some help, if someone has any ideas what may be the problem. If not, perhaps if you could refer me to someone who would be able to help, that'd be good too. Thanks =)