|
atraeyu Novice
Joined: 29 Dec 2006 Posts: 41 Location: Chester, VT
|
Posted: Thu Dec 13, 2007 12:20 pm
Noob Question: Help with timed action |
I just got CMUD yetsterday. I want to make CMUD execute a series of commands every 60 seconds:
1. cast light
2. wait 5 seconds
3. cast regeneration
Any ideas? Thanks. As an additional question to extending the functionality, would it be possible to turn on some triggers right before step 2 and turn them off right after step 2? I.E:
Every 60 seconds:
1. cast light
2. enable triggers
a. if: "Your cast failed." or "Your spell fizzled."
3. Wait 5 seconds
4. cast regeneration
5. Triggers: Wait 5 seconds, cast regeneration
6. Disable Triggers on successful regeneration
7. Wait 60 seconds, go back to 1
Thanks! |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Thu Dec 13, 2007 12:35 pm |
First one
#ALARM castL *60 {cast light;#alarm castR +5 {cast regen}}
Just to check the 2nd part - you want to
cast light
if light fails, recast it
if light is successful, wait 5 seconds and cast regen
if regen fails, recast it
if regen is successful, wait 60 seconds and start again
In order to do the 2nd part could you let us know what messages you get when your castings are successful? |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
atraeyu Novice
Joined: 29 Dec 2006 Posts: 41 Location: Chester, VT
|
Posted: Thu Dec 13, 2007 1:06 pm |
Woot, the first one does the basic work, but it's not smart enough yet. :) Thank you so much!
If light succeeds, we'll see the the message "You light up the room."
If regeneration succeeds, we'll see the message "You cast regeneration."
Additionally, can I branch the fail causes on each? I.E.
cast light
if light fails ("You already have a light.")
wait 20 seconds and recast
if light fails ("Your cast failed." or "Your spell fizzled.")
wait 5 seconds and recast
if light fails ("You do not have enough mana.")
heal, wait 5 seconds, recast
if light successful ("You light up the room.") cast regen
if regen fails ("Your cast failed." or "Your spell fizzled.")
wait 5 seconds and recast
if regen fails ("You do not have enough mana.")
heal, wait 5 seconds, recast
if regen successful ("You cast regeneration.")
wait 120 seconds and cast light
****
1. Instead of a 60 second timer, I think it needs to be about 120 seconds.
2. Would it be possible to make it a random number of seconds between 100 and 140 instead of just 120?
Thank you!
Edited: Added the additional "wait 5 seconds, recast" after healing. Also added additional failing clause for when casting light. |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Thu Dec 13, 2007 2:12 pm |
I think this should work....
Code: |
#ALIAS castLight {#T+ castFails;#T+ castMana;#T+ lightExists;#T+ lightSuccess;#T+ regenSuccess;recast = castLight;cast light}
#ALIAS castRegen {recast = castRegen;cast regeneration}
#VAR recast {castLight}
#TR castFailed {Your {cast failed|spell fizzled}.} {#ALARM recast +5 {%exec(@recast)}}
#TR castMana {You do not have enough mana.} {heal;#ALARM recast +5 {%exec(@recast)}}
#TR lightExists {You already have a light.} {#ALARM recast +20 {castLight}}
#TR lightSuccess {You light up the room.} {#ALARM recast +5 {castRegen}}
#TR regenSuccess {You cast regeneration.} {#T- castFails;#T- castMana;#T- lightExists;#T- lightSuccess;#T- regenSuccess;#NOOP %alarm(castLight, %random(100,140)*1000)}
#ALARM castLight *120 {castLight} |
Upon successful casting regen it resets the alarm to fire randomly between 100 and 140 seconds. If for some reason the triggers have got confused or something didn't fire then it'll recast light in 120 seconds anyway which should get things moving again. |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
atraeyu Novice
Joined: 29 Dec 2006 Posts: 41 Location: Chester, VT
|
Posted: Thu Dec 13, 2007 2:30 pm |
Questions (Sorry to be such a pain, thank you so much for all your help):
1. I assume #T+ means "Enable Trigger" and #T- means "Disable Trigger."
2. You're doing some fancy-shmancy stuff recast, castLight & castRegen. I'm not sure exactly how it works. Can you explain that a little?
3. Is it possible to have more than one alarm at a time? Or are they always linked? I.E. there's just one global ALARM and each time we modify it, it resets it - so we won't have multiple things ticking at the same time? |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Thu Dec 13, 2007 3:03 pm |
Yep, T+ and T- enable and disable triggers
I'm using the recast variable stuff just to keep track of what we're currently casting. Since 'Your spell fails', or 'You're out of mana' messages don't identify which spell failed I'm making a note of them at the same time we cast them
so castLight is basically saying: Enable all the triggers. Remember that we're casting light. Cast light
then if the spell fails the '%exec(@recast)' bit is just saying to call the alias that's mentioned inside the recast variable, so it will either call castLight or castRegen
You can have as many alarms as you need. I've got two running in the example above which are being reused. the 'castLight' alarm is the approx 2 minute alarm that gets reset once regen went off fine. the recast alarm is just the 5 second pause that happens when something fails or to move onto casting regen once light went through successfully.
When using alarms it's best to name them, using #ALARM name +time {action}
that way you can delete the alarm, reset it, change the length of time til it next fires
You could have a bunch running at once though
#ALARM one +10 {#say runs once in 10 seconds}
#ALARM two *20 {#say runs every 20 seconds}
#ALARM three *30 {#say runs every 30 seconds}
So with those then on 10 seconds you'd see the first one
on 20 seconds you'd see the 2nd
on 30 you'd see the 3rd
on 40 you'd see the 2nd again
on 60 you'd see the 2nd and 3rd
and so on |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
atraeyu Novice
Joined: 29 Dec 2006 Posts: 41 Location: Chester, VT
|
Posted: Thu Dec 13, 2007 3:28 pm |
Awesome. Thanks! Here's another question for ya:
Right now castLight does "cast light." Let's say I want to make it either "cast light" or "levitate". How would I make it do one or the other?
Thanks! |
|
|
|
atraeyu Novice
Joined: 29 Dec 2006 Posts: 41 Location: Chester, VT
|
Posted: Thu Dec 13, 2007 3:59 pm |
atraeyu wrote: |
Awesome. Thanks! Here's another question for ya:
Right now castLight does "cast light." Let's say I want to make it either "cast light" or "levitate". How would I make it do one or the other?
Thanks! |
Nevermind, I got it with the #CASE command! |
|
|
|
atraeyu Novice
Joined: 29 Dec 2006 Posts: 41 Location: Chester, VT
|
Posted: Fri Dec 14, 2007 6:24 pm |
Problem with enabling/disabling triggers.
I have a class "AutoTrain" which contains an alias and three triggers (and other things that aren't relevant).
ALIAS: castRegen
TRIGGERS: manaFull, castFail, castSuccess. castFail is disabled by default.
castRegen enables castFail and casts regeneration:
#T+ {AutoTrain/castFail}
the castSuccess trigger disables the castFail trigger:
#T- {AutoTrain/castFail};
I have put #ECHO commands all throughout my triggers and aliases so I can see what is happening. The triggers are firing, but the castFail trigger is not being disabled/enabled. Any idea why?
Thanks. |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Fri Dec 14, 2007 6:38 pm |
As far as I know, you're supposed to imply towards stuff in classes (if you really have to) like that:
#t+/- "Autotrain|castFail"
That being said, unless you're disabling Autotrain Class all the time or something, it would be more sufficent to do
#t+/- castFail
instead.
Prog |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
atraeyu Novice
Joined: 29 Dec 2006 Posts: 41 Location: Chester, VT
|
Posted: Fri Dec 14, 2007 6:44 pm |
Hmm. I have another class that has triggers which contain the same name. It seemed to me that when I didn't specify the full path of the trigger I.E. the trigger castFail inside AutoTrain instead of castFail inside the class AutoShare, the wrong one got disabled ... but at least it disabled one.
|
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Fri Dec 14, 2007 6:55 pm |
Aha, that explains what you're trying to do.
In that case my first suggestion applies.
#t+/- "Autotrain|castFail"
Prog |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
atraeyu Novice
Joined: 29 Dec 2006 Posts: 41 Location: Chester, VT
|
Posted: Sat Dec 15, 2007 12:35 am |
Progonoi wrote: |
#t+/- "AutoTrain|castFail" |
Doesn't seem to work.
Neither does: #T- "AutoTrain/castFail"
or
#T- AutoTrain/castFail
or
#T- AutoTrain|castFail
... I'm not sure what I'm missing.
The trigger ID is "castFail" and it is inside the class "AutoTrain" |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Sat Dec 15, 2007 12:33 pm |
If it's a trigger ID that you're using, I'd recommend making sure the ID is unique and just doing #T- at_castFail to disable it. I was answering the question (in your other thread about this, which doesn't help, honestly) on the assumption that you were disabling the castFail class folder. Either of those two ways should work fine, but there may be a naming problem with using class folders and settings IDs in the same argument.
|
|
|
|
atraeyu Novice
Joined: 29 Dec 2006 Posts: 41 Location: Chester, VT
|
Posted: Sat Dec 15, 2007 12:56 pm |
You're solution is the one I've been using - to make sure I have unique ID's (even though the ID's are nested inside different classes). It's a good temporary solution, but I'd love to get it figured out so I can actually have triggers with the same ID's nested inside different classes (without them conflicting).
|
|
|
|
|
|