Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Kagemusha
Newbie


Joined: 16 Dec 2006
Posts: 5

PostPosted: Fri Mar 16, 2007 8:38 pm   

Help with ordered killing
 
Hi folks,

I've been beating my head and the help files on this one, but I'm not ending up with anything that even starts to seem like it would work.

Here's the deal, I want to kill all the mobs in a room, but I want to kill the mobs in a given order.

example (the mob list):

A large rat scurries about here.
A goblin child is playing in all the garbage.
A goblin citizen is rummaging in some trash.

what I want to do:
I want to kill the citizen first, then the child, then the rat.

Any suggestions on how to handle this?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Mar 16, 2007 9:25 pm   
 
I could produce a whole bunch of suggestions. First though we need more information. You should paste walking into a room and then into another so we can be rather cetain to have all the text surrounding the mobs. Next you should also tell us what commands are actually used to differentiate which goblin we are attacking, perhaps just show some examples of attacking and failing to attack and whatever else you can think of that might be useful. We can never have to much information.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Mar 16, 2007 9:38 pm   
 
Code:


#va MobsToKill {rat|child|citizen}
#trigger {A large rat scurries about here.} {kill %item(@MobsToKill,1)}
#trigger {A goblin child is playing in all the garbage.} {kill %item(@MobsToKill, 2)}
#trigger {A goblin citizen is rummaging in some trash. } {kill %item(@MobsToKill, 3)}




Using a pre-set variable string list and %item was the first idea I got (And sorry, brain not really running in full capability atm :P) though I have never used %item that way myself and hence it might not work at all. But in case its a exact room (ie, you're not encountering those mobs nowhere else other than in this particular room) it could ideally work.
Kill is for initiating fight when you see the mob's desc. You can use whatever else attack spell or skill or else you have in your mud. %item is for taking a certain number of item from the pre-set list, in that case from the list I called MobsToKill. If it sees the rat, and as its the first in the list, it will kill it, same goes for everything else.

However, if you need it elsewhere than only in one room, some additions need to made and as Vij pointed out, we'd really need more info.


Prog
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Mar 16, 2007 11:20 pm   
 
That's still not going to work, progonoi; it'll send kill rat first. If you reversed the list, it'd work, but it wouldn't be dynamic for different mobs and rooms. To get it to do that, you're going to have to compile a full list of the mobs in a room first. Then you'll need a list of the priority order that you want to kill the mobs in and run through each item in that list checking to see if there are any of them in the room. Once a match is found, the script stops and kills that one mob, and if there's no match it just kills the first thing it found in the room.

The actual processing is pretty easy to carry out, but in order to populate the list of mobs in the room properly we'd need to see at least one whole room.

Code:
#var MobsInRoom {rat|child|citizen}
#var MobKillOrder {citizen|child|rat}
#var MatchFound 0
#alias korder {#var MatchFound 0;#forall @MobKillOrder {#if (%ismember(%i,@MobsInRoom) AND !@MatchFound) {kill %i;#var MatchFound 1};#if (!@MatchFound) {kill %item(@MobsInRoom,1)}}


I leave it up to you whether you want to change the %item to %pop and add a %delitem to the #forall so that the mob is deleted from the list when kill is sent.
Reply with quote
shalimar
GURU


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

PostPosted: Sat Mar 17, 2007 12:08 am   
 
#VAR primarytarget {array}
#VAR secondarytarget {array}
#VAR tertiarytarget {array}


#ALIAS killmob {#IF (@primarytarget) {kill %pop(primarytaget)} {#IF (@secondarytarget) {kill %pop(secondarytaget)} {#IF (@tertiarytarget) {kill %pop(tertiarytaget)}}}}
_________________
Discord: Shalimarwildcat
Reply with quote
Kagemusha
Newbie


Joined: 16 Dec 2006
Posts: 5

PostPosted: Sat Mar 17, 2007 6:54 am   
 
Room example 1:

A Small Goblin Cottage
Filth covers everything in this small cottage. Trash is littered all over, and mixed in with clothes that are strewn on the floor. Old pieces of food are
left all over for the rats to feed on. The sight is just unbearable and the smell is even worse. The only way out is to head back west.
Exits: west
A goblin scavenger is here searching for discarded items.
A goblin child runs through the town muttering foul language.
A goblin child is playing in all the garbage.
A goblin citizen is rummaging in some trash.


Room example 2:

A Small Park
Leaves and scattered pieces of trash surround your feet as you walk through this small park. The wind is cool and crisp, but when it blows, the stench of
the city becomes even more unbelievable. The park looks to be a safe place for the goblin children to play, and it almost sets you at ease.
Exits: east, south, west
A goblin citizen stares at you muttering under her breath.
A goblin scavenger is here searching for discarded items.
A goblin child peeks out from behind a tall tree.
A goblin child is playing some goblin games here.



Room example with existing triggers active:

Fear Street
Trash is piled high all over the streets in the small city. It is a very gloomy area, overcast, and gives you an eerie feeling. Deep in the shadows, it
feels as though dozens of goblin eyes are staring at you... keeping watch over you. This is hardly what would be considered a friendly place, and the feeling
of hatred from the townspeople overpowers you. To the north is the butcher's shop, and to the south is a medium-sized goblin home.
Exits: north, east, south, west
A goblin citizen is here taking a walk.
disarm citizen
tell group k citizen
A large rat scurries about here.
kill rat
tell group k rat
A goblin child runs through the town muttering foul language.

H 317 M 115 E 281 1237 5310 Your quick move pulls a goblin citizen's pointy goblin spear from her hands!

H 317 M 115 E 261 1237 5310 You tell the group 'k citizen'

H 317 M 115 E 261 1237 5310 A large rat's arm is boldly thumped by your morning star.
A large rat screams with agony!

H 317 M 115 E 261 1237 5310 [Opponent: large rat] [Opponent diag: bruised]You tell the group 'k rat'

H 317 M 115 E 261 1237 5310 [Opponent: large rat] [Opponent diag: bruised]
A goblin citizen nudges your legs ineptly.
A large rat meekly bites your legs.
A goblin citizen ducks quickly and tries to recover her weapon.
A goblin citizen fumbles and fails to retrieve her weapon.
A large rat's arm is boldly thumped by your morning star.
A large rat screams with agony!

H 309 M 115 E 261 1237 5310 [Opponent: large rat] [Opponent diag: scraped]
A goblin child leaves east.

H 309 M 115 E 261 1237 5310 [Opponent: large rat] [Opponent diag: scraped]
A large rat whimpers loudly as you have its legs cruelly flogged.
A large rat screams with agony!

H 309 M 115 E 261 1237 5310 [Opponent: large rat] [Opponent diag: bleeding]
A large rat meekly bites your arm.

H 302 M 115 E 261 1237 5310 [Opponent: large rat] [Opponent diag: bleeding]
A goblin citizen ducks quickly and tries to recover her weapon.
A goblin citizen manages to retrieve her pointy goblin spear
A large rat meekly takes a bite of your head.

H 295 M 115 E 261 1237 5310 [Opponent: large rat] [Opponent diag: bleeding]
A large rat looks surprised as you competently thump its chest with your morning star.
A large rat screams with agony!
A goblin citizen wields a pointy goblin spear two-handedly.
A goblin citizen tries a fancy move, but you counter and cause her to drop
her pointy goblin spear!.
A large rat meekly bites your stomach.

H 288 M 115 E 261 1237 5310 [Opponent: large rat] [Opponent diag: gushing]
Your morning star mashes a large rat's skull, and kills it instantly.
A large rat is dead!
You receive 320 experience points.
Your blood freezes as you hear a large rat's death cry.
A goblin citizen nudges your skull ineptly.

H 287 M 115 E 261 1237 4990 [Opponent: goblin citizen] [Opponent diag: healthy]
A goblin citizen looks surprised as you competently thump her chest with your morning star.
A goblin citizen screams with agony!

H 287 M 115 E 261 1237 4990 [Opponent: goblin citizen] [Opponent diag: bruised]
A goblin citizen's arm is boldly thumped by your morning star.
A goblin citizen screams with agony!
A goblin citizen makes three steps of the old boxing art and nudges your arm ineptly.

H 286 M 115 E 261 1237 4990 [Opponent: goblin citizen] [Opponent diag: scraped]
A goblin citizen nudges your legs ineptly.
A goblin citizen ducks quickly and tries to recover her weapon.
A goblin citizen manages to retrieve her pointy goblin spear
A goblin citizen looks surprised as you competently thump her chest with your morning star.
A goblin citizen screams with agony!

H 285 M 115 E 261 1237 4990 [Opponent: goblin citizen] [Opponent diag: bleeding]
A goblin citizen whimpers loudly as you have her legs boldly thumped.
A goblin citizen screams with agony!
A goblin citizen wields a pointy goblin spear two-handedly.
A goblin citizen fumbles with her pointy goblin spear!

H 285 M 115 E 261 1237 4990 [Opponent: goblin citizen] [Opponent diag: gushing]
Your morning star mashes a goblin citizen's skull, and kills her instantly.
A goblin citizen is dead!
You receive 320 experience points.
Your blood freezes as you hear a goblin citizen's death cry.



I use 7 different triggers defined to diferent states of what mob is doing what and don't have a trigger set at all for a child because basically everything assists the child so they must go last. In addition to the mobs shown here are also guards which need to die absolutely first because they have the hardest hit and assist everything else.

The way things are now, I end up disarming most of the mobs and getting hit by all that have been disarmed in addition to the rat which is first to appear on the mob list.

I'm trying to give all information I can think of so here comes a bit of brain spew that might give some insight as to what I want to accomplish.

This particular zone is composed of wandering mobs so as I walk through I could come upon any of the mobs in various numbers and various orders. If the room mobs list shows a child, a citizen, and a guard in that order with the guard last, I want to kill the guard first, then the citizen, then the child, providing one of the previous has not wandered into the room during melee. Esentially, I want to take them out 1 at a time then look at the room again and pick off the next in line. My main issue is how do I get zMud to kill a guard that is listed last before it kills anything else in the list.

Also, note I am providing this info before trying any of the presented solutions, because I am here a now and that is when it is easiest to post :). and I need to look at the syntax stuff because I like to understand what does what and why.


I'm leaving this post here and going to take a look at Fang's code because it seems to make the most sense as far as reordering the order, but I need to familiarize myself with some of the commands and such used. At least it is a direction :).

Thanks to all for your suggestions and maybe my samples will help with some clarity.
I will post again with result of my tinkerings.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Mar 17, 2007 7:10 am   
 
You can't delete it, but you can edit it so it contains nothing. Makes it a bit less spammy. I don't think my code needs any adaptation to work with this text, besides changing the two instances of "kill" to whatever alias you use to disarm/kill/tell group etc and setting up the MobKillOrder variable with all the mobs you might meet. You just need some triggers to populate the lists right.

#var AutoKill 0
#trig {^Exits:} {#var MobsInRoom "";#if (@AutoKill) {#alarm +0.5 korder}}
#trig {A goblin scavenger is here searching for discarded items.} {#var MobsInRoom %additem(@MobsInRoom,scavenger)}
#alias AutoKill {#if (@AutoKill) {#var AutoKill 0;#say AutoKill off.} {#var AutoKill 1;#say AutoKill on.}}

and so on for all the other mobs in the room. If you use the automapper, you could also use the OnRoomEnter special alias (look it up) instead of the ^Exits: trigger. I also added some code to turn it on and off in red - delete it if you don't want it.

EDIT: Changed #additem to %additem to allow duplicates.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Mar 17, 2007 8:50 am   
 
Ahh...information. Now add a little bit of overkill and a whole mess of script off the top of my head. Just copy and paste into the command line and you should be fine.

#CLASS AutoKiller
#VAR AutoKill {0} {0}
#VAR MobsDetected {} {}
#VAR Verbs {is|peeks|scurries|runs}
#VAR MobActions {}
#VAR MobMovement {}
#VAR MobKeywords {}
#VAR MobOrder {}
#VAR MobName {} {}
#REGEX "MobCap" {^Exits: (?:north|east|south|west|[, ])*$} {MobsDetected=""}
#COND {} {#IF (%line="") {#STATE MobCap 0;MobsDetected=%sort(@MobsDetected);#IF (%item(@MobsDetected,1)="000") {#DELITEM MobsDetected {000};#SHOW Warning in MobCap: Unknown mob was recorded, no actions being taken for such mobs.};KillMobs} {#IF (%regex(%line,%concat("(?:A|An|The) (.*?) (?:",@Verbs,")"),MobName)) {MobName=%db(@MobKeywords,@MobName);MobsDetected=%additem(%rightback(%concat("000",%ismember(@MobName,@MobOrder),3),@MobsDetected)} {#SHOW Error in MobCap: Line did not match to known verb patterns}}} {looplines|param=20}
#ALIAS KillMobs {#IF (%-1="Remove") {#DELITEM MobsDetected {%item(@MobsDetected,1)}};MobName=%item(@MobOrder,%item(@MobsDetected,1));#IF (@MobName) {#EXECUTE {%db(@MobActions,@MobName) @MobName}}}
#TRIGGER {Don't really know, has something to do with MobMovement} {#NOOP Might want to add them, might want to remove em. You figure it out.}
#TRIGGER {Don't really know, has something to do with failing an attack} {#IF (@AutoKill) {KillMobs Remove}}
#TRIGGER {^You receive %d experience points.$} {#IF (@AutoKill) {KillMobs Remove}}
#BUTTON 999 "Autokill: %if(@AutoKill,On,Off)" {AutoKill=%eval(!@AutoKill)}
#CLASS 0
#ADDKEY MobActions {citizen=disarm|guard=disarm|child=kill|rat=kill|Vijilante=hug}
#ADDKEY MobKeywords {goblin citizen=citizen|goblin child=child|large rat=rat|scary zMud Guru=Vijilante}
MobOrder="guard|citizen|child|rat"

Hopefully I didn't miss any parenthesis or braces. For the most part it allows that you can put many of the matching characteristics out into variables. This will be of benefit if at some point you use the mapper and want to assign different values based on zones. I defined most of the variables based on the information you have provided, and also tossed in a few triggers to give you an idea about some of the things that are missing. You mentioned that the mobs roam, so there is a chance they will walk out after you have entered the room. It is horribly inefficient to relook between each mob and for all enter and exit events. I used to use a system that did a relook if it dumped a large number of mobs from the list on a failed attack, another strategy is to do the relook only when the list becomes empty. Both will work better then looking everytime. Also note the simple method in which aggressive mobs like the 'scary zMud Guru' can be handled. A small hug here and there is a wonderful pacifier.

Also I left out the group messages. Generally speaking there are 2 types of followers that you will have. Those that really help with the kill and those that are just leeching of you. In both cases they should either trigger off your attacks or use some sort of mud side 'autoassist'. Again it is a speed thing to not send the extra commands doing that group message.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Tue Mar 20, 2007 10:05 am   
 
Just a couple of slight edits to Vijilante's script:

Code:
#class AutoKiller
#var AutoKill {0} {0}
#addkey MobActions {citizen=disarm|guard=disarm|child=kill|rat=kill|Vijilante=hug}
#var MobName {}
#var MobVerbs {is|runs|stares|peeks|scurries}
#var MobKillOrder {guard|citizen|scavenger|rat|child}
#var MobsToKill {"A goblin scavenger is here searching for discarded items.|A goblin child runs through the town muttering foul language.|A goblin child is playing in all the garbage.|A goblin citizen is rummaging in some trash.|A large rat scurries about here."}
#trig {Exits:} {#T+ CheckForMobs;MobsDetected=%null}
#cond {^$} {#T- CheckForMobs;#if (!%null(@MobsDetected)) {SortMobs;KillMobs} {#ECHO There are no mobs in this room for you to kill.}} {within|param=20}
#trig "CheckForMobs" {{@MobsToKill}} {MobFound=%null;#noop %match(%line,"(%w) {@MobVerbs}",MobFound);#VAR MobsDetected {%additem(%lower(@MobFound),@MobsDetected)}}
#BUTTON 999 "Autokill: %if(@AutoKill,On,Off)" {AutoKill=%eval(!@AutoKill)}
#alias SortMobs {#var SortedMobList {%null};#var SortList {%countlist(@MobsDetected)};#forall @MobKillOrder {#if !%null(@SortList.%i) {#loop @SortList.%i {#var SortedMobList {%additem(%i,@SortedMobList)}}}}}
#alias killmobs {MobName=%null;#if (%lower(%-1) =~ "remove") {#delnitem SortedMobList 1};#if (!%null(@SortedMobList)) {MobName=%item(@SortedMobList,1);#if (%iskey(@MobActions,@MobName)) {#EXECUTE {%db(@MobActions,@MobName) @MobName}} {kill @MobName}} {#ECHO There are no mobs here to kill.}}
#trigger {Don't really know, has something to do with MobMovement} {#NOOP Might want to add them, might want to remove em. You figure it out.}
#trigger {Don't really know, has something to do with failing an attack} {#IF (@AutoKill) {KillMobs Remove}}
#trigger {^You receive %d experience points.$} {#IF (@AutoKill) {KillMobs Remove}}
#class 0


In case you might want to know (might come in handy in the future), I used %countlist to sort the list in order of killing priority. %countlist counts the number of times a string occurs in a list. It adds these to a dbvariable in the form Key=String, Val=# of occurences. Because of this, you can retrieve from this variable in the order you specify, adding the same number of strings to a new list, in the new order. What Vijilante has said is still true of this script, and that you may want to manipulate the list if, for example, new mobs enter the room or attacks fail etc. The most common occurence would be new mobs entering. I have included a sample of how you could add a mob to your kill list, and then reorder.

Example triggering text: "A goblin child strides in from the east."
Code:
#trig {(%w) %w in from*{above|below|east|west|north|south}.} {#var MobsDetected {%additem(%1,@SortedMobList)};SortMobs}
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Tue Mar 20, 2007 10:26 am   
 
Actually, scratch that edit. Vijilante, your script is brilliant. Compiling a list that instead of names, points to which keyword to use...genius.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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