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


Joined: 08 May 2017
Posts: 4

PostPosted: Mon Dec 05, 2022 4:09 pm   

trigger to send an emote if health drops below a certain level
 
Hello! I'm a complete noob when it comes to using all the tools cmud provides so I wanted to see if I could get some help to make it do what I'm envisioning.
1. If my characters health drops below a set percentage, it fires off an emote. possibly 1 of a range of like 3 or so. I'd also need it to only do it once so it doesn't spam combat, or spam me to death. Perhaps once and then disable, re enable upon rising above a set amount of health.

I'm able to configure my in game prompt like so <%h/%HHp %m/%Mmana %v/%Vmv etc> %h being current hp and %H being maximum hp.
side note, there's a module addon with a table of variables in it, one of which is for current hp. I'm using that variable to save me from duplicating work, though if I need to do something else I'm willing to give it a go. Thanks for any suggestions!

This is what I'm using so far, but it's not matching anything: {<(%d)/(%d)HP< 500} {#If (%1<=700) {emote yadda yadda}
Reply with quote
shalimar
GURU


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

PostPosted: Mon Dec 05, 2022 4:49 pm   
 
A multistate trigger might be the easiest method:
Code:

#TR {@health < 722} {#SEND %item(@emotelist, %random(1, %numitems(@emotelist)))} {} {expression}
#COND {@health > 1000} {} {expression}


Something like that should do it.
The first state does all the work, though you will have to populate your emotelist variable.
The second state is only there to keep the first from firing til the health is high enough.
Adjust values as needed.

(Edited to fix the code.)
_________________
Discord: Shalimarwildcat

Last edited by shalimar on Tue Dec 06, 2022 1:17 pm; edited 1 time in total
Reply with quote
numbah79
Newbie


Joined: 08 May 2017
Posts: 4

PostPosted: Mon Dec 05, 2022 5:47 pm   
 
am I creating like a 3 entry database for @emotelist? or something different? {expression} is the type of entry in the bottom of the trigger window, correct? and those two sets of empty brackets in the #cond statement, do I need to fill those in? sorry, I'm really new to this stuff!

or is this the relevant info for emotelist?
#VAR Greeting %case(%random(1,4),"Hi","Hello","Hiya","Hail")
Assigns a random greeting to the Greeting variable


what I've done is to create a variable, and set the type as a string list and each entry is emote yada, emote yada1, emote yada 2, etc. however, after doing this, when I refreshed my character in game, it spammed my first emote five times. so I've input something wrong somewhere!
Reply with quote
shalimar
GURU


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

PostPosted: Mon Dec 05, 2022 7:06 pm   
 
The code i provided can and should be entered directly from the command line.

The empty brackets are purposeful.

%case is another way to accomplish the same thing, but I never noticed that function before.

You created @emotelist right.
I presume it spammed you because you tried to edit one of your existing triggers instead of inputting my code from the command line.
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


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

PostPosted: Tue Dec 06, 2022 1:16 pm   
 
Oh, turns out you are right, I did put an extra set of empty brackets on the condition.

That is where the class name goes on a basic trigger.
As a trigger state, you can't define that.
_________________
Discord: Shalimarwildcat
Reply with quote
numbah79
Newbie


Joined: 08 May 2017
Posts: 4

PostPosted: Wed Dec 07, 2022 5:06 pm   
 
Okay, so I cleaned up my attempts, replaced them with your two entries, adjusted the health values to identical numbers, managed to drop below the level, and the triggers did not fire. The only thing I can think of is that the @health variable may not be picked up. I pulled that variable from an MSDP package for the MUD, and thought I'd save myself some time and use a variable that was already there. If I need to use a clean one, how would I go about doing that? And secondly, If I wanted two, could I duplicate those triggers for a lower health level as well? or would the #cond fail since there's one defined for a higher hp level?

Thanks for assisting again!

Would I be trying to pull numbers from the prompt with the #setp(rompt) help file?
If you're trying to catch just one part of the prompt to create a variable with it, with the %d, can you end the 'setprompt' trigger with just the one entry? or do you need to catch the entire prompt, hp, mana, mv, etc for it to work properly?

*edit*
I created a new variable using setprompt, switched out @health for @hp in both of your triggers, and it still did not fire.
Reply with quote
shalimar
GURU


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

PostPosted: Wed Dec 07, 2022 9:19 pm   
 
You can trigger on a partial line, just make sure the trigger is set to capture the prompt rather than the default new line.

#TR {(%d)/(%d)HP} {health=%1;maxHealth=%2} {} {prompt}

That should define the variable for you.

You can have as many expression triggers as you want.
Each can have multiple conditions (though no need for that here).
Conditions are attached to their parent trigger and won't affect other triggers unless you tell them to.
_________________
Discord: Shalimarwildcat
Reply with quote
numbah79
Newbie


Joined: 08 May 2017
Posts: 4

PostPosted: Thu Dec 08, 2022 2:40 pm   
 
Good morning, I've added the prompt trigger, checked the variables, and they are updating correctly, but the emote trigger is still failing to fire.

Here's a my exact prompt
<445/715Hp 328/399mv *none*><no opponent/no opponent standing/><><forest (outside)>

I can shoot you some screenshots of my cmud trigger list on discord if you'd like , maybe you can pinpoint what's wrong?
Reply with quote
shalimar
GURU


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

PostPosted: Thu Dec 08, 2022 2:52 pm   
 
Sure thing, I can take a look.
_________________
Discord: Shalimarwildcat
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