|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 1:35 pm
Trigger to create Triggers? |
So ive tried it every way I know how and I am just not having luck... I JUST Made the switch to Cmud so I don' t know if its different or what.
Example:
#trigger {You lead your party into combat against (*).} {#trigger {into combat against %1} {#var npcnum}}
The basic premise is I want the trigger to capture every time I party attack something. I want it to capture what I am attacking and MAKE another trigger for attacking that specific room. The idea here is that it will make dozens of new triggers for a specific area on the game. The triggers it makes are supposed to be there to count the npcs in each room, in this example say the original string is 'You lead your party into combat against four dogs, a wolf, and three rats.'
The problem I am having is that once I put a 'grouping' element around the %1, such as "" or () or {}, it is simply putting the %1 in rather than the captured value. But if I don't include a grouping element it puts in the captured value just fine, but them it uses the different values as the pattern and value, rather than the specific ones i want of course.
If there is an easier way to 'count' the npcs in rooms when they are very random any ideas would rock too!
Thanks! |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Sep 24, 2010 4:05 pm |
You can form the inner trigger pattern dynamically using %concat:
Code: |
#trigger {You lead your party into combat against (*).} {#trigger %concat("into combat against (",%1,")") {#var npcnum}} |
That will expand %1 to it's captured value before creating the new trigger.
However, the idea of making lots and lots of triggers like that seems really inefficient. Maybe somebody else can suggest a better way to handle this using a database variable to keep track of the count for each npc with a single trigger. Something like:
Code: |
#trigger {You lead your party into combat against (*).} {#addkey npclist %1 (@npclist.%1 + 1)} |
or something like that. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 6:09 pm |
Well Zugg's post answers your question, but in desire to make a more efficient script, I'm curious as to what you want it to do? You want to make it so that when you attack a mob it takes that mobs name and sees how many are in the room and attacks all the ones in the room?
|
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 6:15 pm |
Thank you Zugg that does help my original trigger work like i wanted it to.
Chamenas - My goal is to make it count the npcs in room and count down as they die so it knows when they are all cleared out. The problem is there are many different types of npcs and some rooms with 1 of a type and some with 6... so there are tons of possible combo's. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 6:21 pm |
Can you give some examples of the information you'd see? I think this can easily be done without making a ton of triggers.
|
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 6:31 pm |
You lead your party into battle against three trolls, two black mages, and a wolf.
Is an exmaple of the party attack string. |
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 6:37 pm |
One problem I noticed with Zugg's solution is... it keeps using the first part as the id instead of the pattern... so if i used that I Would also need a way to make it come up with random id numbers or else it'll just keep recreating the same trigger over and over.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 6:40 pm |
What's the maximum number of any one type of mob that can be in a room? And what echo do you get when a mob dies?
|
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 6:41 pm |
The most ive seen at once is 6 of any given type at a time... most in a room total has been 8. 'dealt the death blow' is what I go off of when they die.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 7:02 pm |
There's no mob name in 'dealt the death blow' ?
|
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 7:08 pm |
Well there is... whichever mob you kill... but I can just use that one for if anything dies... I dont need to know how many trolls are left, and how many orcs are left.. just how many in general.
dealth the death blow to umber hulk. For instance. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 7:27 pm |
Oh, okay, so you're not tracking it specifically by mob type then? That changes things. Do you need to reattack mobs in the room, is that why you keep the name?
|
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 7:30 pm |
No, keeping the name is the only way I know how to count how many there are lol
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 7:34 pm |
Hmm, so in the example posted above, are there 6 mobs or 3? I count 6 mobs, but I don't know how your MUD functions and if "groups" of a single type of mobs are considered "one" mob.
|
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 7:44 pm |
They are all considered seperate mobs so there are 6
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 7:51 pm |
This is what I have so far:
Code: |
<class name="Party Attack" id="49">
<trigger priority="500" id="50">
<pattern>You lead your party into combat against (*)</pattern>
<value>$npc_list=%replace( %1, ". ", "")
$npc_list=%replace( $npc_list, ".", "")
$npc_list=%replace( $npc_list, ", and ", "|")
$npc_list=%replace( $npc_list, ", ", "|")
#FORALL $npc_list {
#SWITCH (%word( %i, 1)="a" || %word( %i, 1)="an") {#ADD curr_mobs 1}
(%word( %i, 1)="two") {#ADD curr_mobs 2}
(%word( %i, 1)="three") {#ADD curr_mobs 3}
(%word( %i, 1)="four") {#ADD curr_mobs 4}
(%word( %i, 1)="five") {#ADD curr_mobs 5}
(%word( %i, 1)="six") {#ADD curr_mobs 6}
}</value>
</trigger>
<var name="curr_mobs" id="51">0</var>
<trigger priority="520" id="52">
<pattern>dealt the death blow</pattern>
<value>#IF (@curr_mobs) {curr_mobs=(@curr_mobs - 1)}</value>
</trigger>
</class>
|
|
|
_________________ Listen to my Guitar - If you like it, listen to more
Last edited by chamenas on Fri Sep 24, 2010 8:18 pm; edited 1 time in total |
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 8:02 pm |
Wow lotta stuff i never heard of using lol... now i gotta figure how to transfer that to cmud lol.
I tried just copy/pasting it all into the class folder but it erases all but the first line when I save. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 8:14 pm |
That's odd, are you copy and pasting it to the XML portion? Alternatively, you can save it as a .xml file in any text editor (like Notepad) and then Import it through the File menu in the package editor.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 8:19 pm |
Made a quick change and updated the post with the XML, to protect the variable from going into negatives.
|
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 8:40 pm |
Hrmm still does nothing when I try and copy/paste or import as an xml
Basically I want it to move and attack after the counter reaches 0 of course. My move alias is usually 'p' and killit monsters. Preferably without having to 'killit monsters' every time something dies until it gives me the message that there are no monsters in the room. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 9:03 pm |
I havent actually added anything for it to move after it reaches 0, since I wasn't sure what you wanted exactly. What I would do is add an #IF statement directly after the first one in the trigger where it counts down. From there you can have it move and attack or expand on however you might want to do that. I'm unsure of your exact setup for knowing where you are, where the next rooms are, and how to attack. I can certainly help you with the proper information.
|
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 9:11 pm |
Ya I think I can figure out how to move it if i could just get it to input right so it'll run lol
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Sep 24, 2010 9:15 pm |
I'm utterly confused by how it would not be working, it should import just fine. Try this, step for step:
1. copy and paste the stuff in the code box into notepad
2. Go to "File -> Save As..."
3. Delete what's in the field and type "Party Attack.xml"
4. Save it
5. Open up CMUD
6. Double click on your session to open it
5. Click on "Settings" from your toolbar
6. In the Package Editor click on "File -> Import XML"
7. Find the XML file you saved and select it, then hit the "open" button
Voila |
|
|
|
ekhart Novice
Joined: 28 Aug 2008 Posts: 31
|
Posted: Fri Sep 24, 2010 9:29 pm |
Ya I dnno, does nothing though... maybe the id number? im not sure.
I guess if i can figure out where each trigger starts/stops etc I could just make them by hand with the same info. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Sep 24, 2010 9:40 pm |
You don't even need to use an external XML file...this is *really* easy:
1) Copy the stuff in the white code box above into the clipboard. That is: select everything in the white area starting with <class... and ending in </class> Select it in your web browser, then right-click and select Copy
2) Run CMUD and select your session icon and click the "Open Offline" action to open your session.
3) Click the "Settings" button in the main toolbar to open the settings editor.
4) Right-click in the tree view area on the left side of the screen. Select the Paste option in the menu.
This is the standard way to copy XML settings from the forum into your copy of CMUD. No need to save or anything like that. This will create a class folder called "Party Attack" with two triggers and a variable within it. |
|
|
|
|
|