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


Joined: 24 Apr 2011
Posts: 2

PostPosted: Sun Apr 24, 2011 6:45 am   

Stumped on this Code
 
I am working on making a set of triggers for auto-group attacking the past couple days, and have been stumped on getting it to work right.

What I'm trying to get it to do is when I enter a room, it reads all the creatures that are in that room, store them in a list, and kill them from top to bottom. An example of what the MUD output of a room description:
Code:
Name of the Room
   Room description room description room description room description
room description room description room description room description
room description room description room description room description
room description room description
Exits:   north, south, west
CreatureName1 is standing here.


On the bottom lines below the exits is the list of creature(s) in the room. There are times when there are multiple creatures in the same room, and is displayed like:
Code:
[x2] CreatureName1 is standing here.
CreatureName2 is here, doing something.


I've come up with this so far as to getting the number and names of creatures in a room:
Code:
#var counter
#var TargetList

#trigger {^CreatureName1 is standing here.} {#var TargetList %additem( "CreatureName1", @TargetList)}
#trigger {~[(%d)~] CreatureName1 is standing here.} {
   #var counter %1
   #while (@counter > 0) {
      #var TargetList %additem( "CreatureName1", @TargetList)
      counter = @counter - 1
      }
   }
#trigger {^CreatureName2 is here, doing something.} {#var TargetList %additem( "CreatureName2", @TargetList)}
#trigger {~[(%d)~] CreatureName2 is here, doing something.} {
   #var counter %1
   #while (@counter > 0) {
      #var TargetList %additem( "CreatureName2", @TargetList)
      counter = @counter - 1
      }
   }


I've also came up with this to label what to kill:
Code:
#if (%numitems( @TargetList)>0) {
  #var target %pop( TargetList)
  kill @target
  tell group whack @target
  }


What I need help with is coming up with a way so when I walk into a room, it gets the list of creatures, and starting with the first one, attack it, tell the group to kill it, without it double-sending the commands if there's multiple creature names in the room. I'm just not sure how to put them together. Sad
Reply with quote
rom_512
Newbie


Joined: 24 Apr 2011
Posts: 2

PostPosted: Sun Apr 24, 2011 7:22 am   
 
I forgot to mention that if there's not a legal target that you're telling the MUD to kill, you get the following message:
Code:
There is nobody here called 'command at what you said to kill' which you can hit.



If there's a way to set it up that when that is read it resets the trigger, it would be greatly appreciated. :)
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