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
Odeon
Novice


Joined: 17 Nov 2008
Posts: 30

PostPosted: Tue Feb 17, 2009 8:23 am   

Repeating a spell
 
Hi, I am using several times the same spell to kill a mob.
I would like to repeat the same spell several times.
Let's have a look :

Code:

64H 76M 61V >c 'chill touch' goblin
The magic drained you of 7 mana.
The atmosphere turns chilly as you miss the goblin!
The goblin screams, 'AAAAHHH! CHARGE!! BANZAI!!'.
You barely avoid the goblin's fist as he takes a swing at you!

64H 69M 61V excellent >
The goblin tries to hit you but you easily avoid the blow.
You tickle the goblin as you bludgeon him.

64H 69M 61V few scratches >c 'chill touch'
The magic drained you of 7 mana.
The atmosphere turns chilly as you miss the goblin!

64H 62M 61V few scratches >
The goblin screams, 'AAAAHHH! CHARGE!! BANZAI!!'.
The goblin tries to hit you but you easily avoid the blow.
The goblin misses a wild punch at you.
You barely bludgeon the goblin.
The goblin tickles you as he hits you.

62H 62M 61V few scratches >c 'chill touch'
The magic drained you of 7 mana.
The atmosphere turns chilly as you miss the goblin!

62H 55M 61V few scratches >
You barely avoid the goblin's fist as he takes a swing at you!
You bludgeon the goblin.
You duck under the goblin's fist as he takes a swing at you.


So here is the "drama" :
1) cast spell (here c 'chill touch')
2) wait one turn (you can't cast spells each turn - you have to wait one turn)
1) cast spell (the same one - c 'chill touch)
2) wait one turn
1) ...

So can i do it programatically ? It seems pretty repetitive so ad hoc for computers ;)

Thanks, Odeon

PS: editing title, i'm not constructing a bot :) but helping my in-game experience (so repetitive to push 5 times the "enter" key when it could be handled by computer)


Last edited by Odeon on Sat Feb 21, 2009 8:28 am; edited 1 time in total
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Feb 18, 2009 2:46 pm   
 
Yes, in principle it should be possible. It will probably not even be hard. The only trick is determining the passing of each 'turn'. Does a prompt mark the beginning of each turn? If not, can you identify some line or lines from the mud that determines a 'turn? Is a turn a specific length of time?
Reply with quote
Odeon
Novice


Joined: 17 Nov 2008
Posts: 30

PostPosted: Wed Feb 18, 2009 7:51 pm   
 
A turn :) well it's only a new prompt yep ("a prompt marks the beginning of each turn")
no timer, no specific length, it just requires some mana though (55M = 55Mana if it runs out of mana, it could stop casting)

so cast spell - wait one prompt - recast spell... - etc
I hope that's clearer Very Happy
Reply with quote
Odeon
Novice


Joined: 17 Nov 2008
Posts: 30

PostPosted: Sat Feb 21, 2009 8:07 am   
 
Here is an idea, but maybe it's not very well-thought :( Could you help me ?

@tempo = 1
@tempo_ini = 1

TRIGGER : (%d)H (%d)M (%d)V
#if (@tempo == 1) {@tempo = 2} {@tempo = 1}
//alternate between first and second "tempo" (first round - second round - first round - second ...)

#ONINPUT chill
--> launch "listener" class
--> @tempo_ini = @tempo //initialize initial tempo
--> #t+ chill_listener

chill_listener
--> if (@tempo =~ @tempo_ini) {cast 'chill'}

Can someone have a look ? Thanks
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Feb 23, 2009 4:36 pm   
 
Something like that could work, but I would rather do it with a multistate trigger. One thing I see about your idea is that you have no convenient way to turn it off when you are done combat. How do you intend to stop casting at the end of the fight? Is there an obvious line that we can trigger from, or do we have to have an alias to control it?

I'll poke at writing a multistate trigger to do this.
Reply with quote
Odeon
Novice


Joined: 17 Nov 2008
Posts: 30

PostPosted: Mon Feb 23, 2009 10:20 pm   
 
Thanks Rahab
You're right i need something to stop casting
so here is the end of the fight

Code:

64H 91M 67V few wounds >c 'chill touch'
Calm as ice you summon the destructive powers upon your enemy and speak, 'chill touch'.
You chill the goblin!
The magic drained you of 15 mana.

64H 76M 67V awful >
You barely bludgeon the goblin.
The goblin is stunned, but will probably regain consciousness again.

64H 76M 67V bleeding awfully >
Your relentless bludgeoning of the goblin finally results in his broken neck!
The goblin is dead!  R.I.P.
You gain 90 experience points for the kill..
Your blood freezes as you hear the goblin's death cry.
You get a little pile of gold coins from the corpse of the goblin.
There were 75 coins.


I think i could put the code in a class and manually put it on/off
but here are two conditions to stop it :
-> mob is dead
-> mana below 50 (i'll take care of the little mana left)

something may be easier
each time the mud parses (via a trigger)
The atmosphere turns chilly as you miss (*)! [the goblin]
or Calm as ice you summon the destructive powers upon your enemy and speak, 'chill touch'. [a successful chill touch]
just fire once more (and it will auto fire)

I hope that helps
Reply with quote
Torin
Novice


Joined: 16 Apr 2008
Posts: 37

PostPosted: Mon Feb 23, 2009 11:21 pm   
 
statusmsgs="bleeding awfully|awful|few wounds|few scratches|excellent" (fill this in with all NPC status messages)
spellmsgs="The atmosphere turns chilly as you miss|Calm as ice you summon the destructive powers upon your enemy and speak" (fill this in with all successful/fail spell messages)
fighting=0
casting=0
spell="chill touch" (put the name of whatever spell you want to cast during combat here)

TRIGGER: V (*)> (on prompt, on new line, trigger on trigger)
#if (%pos(%left(%-1,%eval(%len(%-1)-1)),@statusmsgs)>0) {#if (@fighting=0) {fighting=1}} {#if (@fighting=1) {fighting=0}}
#if (@fighting=1 and @casting=0) {casting=1;cast @spell}

TRIGGER: {@spellmsgs} (on new line, trigger on trigger)
#if (@casting=1) {casting=0}

Basically, it tracks combat via the status text in the prompt, and sets the fighting variable to 1 or 0 depending on whether you are fighting or not. If you are fighting, it checks to see if you are casting or not (1 or 0) and if not, it sets the @casting variable to 1 and casts a spell. When that spell finishes (success or fail via 2nd trigger), it sets @casting=0 and as long as you are still fighting (via the prompt trigger), it will cast again. This doesn't "wait" per se until the next round of combat to cast, as I assume your mud will automatically delay the casting of the next buffered spell. If that is not the case, you'd have to do it differently, probably cast via an alarm.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Feb 24, 2009 3:07 pm   
 
It sounds to me as if the mud does not delay the casting of a spell if you cast too soon, so Torin's code won't work. Something like that could work. I'll think about it some more and get back when I can.
Reply with quote
Torin
Novice


Joined: 16 Apr 2008
Posts: 37

PostPosted: Tue Feb 24, 2009 3:29 pm   
 
If it doesn't, then you simply put the casting of the spell in an alarm, instead of [trying to] casting it immediately.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Feb 24, 2009 3:44 pm   
 
I don't think an alarm is the correct solution, since turns are determined by prompts, not by time.
Reply with quote
Torin
Novice


Joined: 16 Apr 2008
Posts: 37

PostPosted: Tue Feb 24, 2009 3:51 pm   
 
Well, every mud I've ever played had time based turns and time based ticks, but I suppose any theory it could be different.

You could of course just wait to see some text from the next combat round, although I don't know what universal bit of text could be gathered for any combat. The ability to track that combat is going would remain the same, just the vessel in which you deliver the casting would change. The method of ensuring that you don't cast if you are already casting would remain the same. Since it is done on a prompt trigger, either method could work based on the specifics of how the mud works.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Feb 24, 2009 9:25 pm   
 
There definitely are muds out there which do not use tick-based combat. However, looking again at the text Odeon has provided, you're probably right about this one. It is tick/time based. So an alarm would indeed be the way to go, with another trigger or alias to turn it off. I'm still not sure about making a trigger to turn it off. I'm guessing that the status messages persist after the combat is over, until the wounds are healed. If that is the case, status messages won't tell us when combat ends. Odeon, can you tell is if that is true? Also, do you ever have to fight more than one opponent at a time? If you do, we also can't trigger off a death message, and we might be stuck using a separate alias to turn it off.
Reply with quote
Torin
Novice


Joined: 16 Apr 2008
Posts: 37

PostPosted: Tue Feb 24, 2009 11:08 pm   
 
I was under the impression that those status messages were the mob status, as they became worse and worse as combat ended and were very high at teh beginning of combat, and were not present at all when combat was over or before it had started.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Feb 25, 2009 1:48 pm   
 
Odeon hasn't shown us any prompts after the combat is over. Odeon, can you tell us what that status message is? Is it describing your own condition, or your opponent's?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Feb 25, 2009 5:06 pm   
 
If the status message is in fact the status of the opponent, here is some code that should work. I have tested it as far as I can. This is in XML form. You will have to add to @statusmsgs any other phrases that might appear as the opponent's status. It uses a simple multistate trigger instead of the variables Torin used to keep track of it's state:
Code:

<class name="spellcombat" id="162">
  <trigger name="combatprompt" priority="1560" trigontrig="false" prompt="true" enabled="false" id="156">
    <pattern>(%d)H (%d)M (%d)V (*)></pattern>
    <value>#say step 1
#if (!%ismember(%trim(%4),@statusmsgs)) {#state 0; #t- combatprompt}</value>
    <trigger trigontrig="false" prompt="true" enabled="false">
      <pattern>(%d)H (%d)M (%d)V (*)></pattern>
      <value>#say step 2
#if (%ismember(%trim(%4),@statusmsgs)) {
  cast @combatspell @combattarget
} {#t- combatprompt}</value>
    </trigger>
  </trigger>
  <var name="combatspell" id="158">chill touch</var>
  <var name="statusmsgs" id="159">bleeding awfully|awful|few wounds|few scratches|excellent</var>
  <alias name="chill" id="160">
    <value>#t+ combatprompt
#var combattarget %-1
cast @combatspell @combattarget</value>
  </alias>
  <var name="combattarget" usedef="true" id="161">goblin</var>
</class>
Reply with quote
Odeon
Novice


Joined: 17 Nov 2008
Posts: 30

PostPosted: Wed Feb 25, 2009 5:49 pm   
 
Thanks guys, i'll test it :)

-- Info : complete fight below -

Code:

<(---<    Night   >---------------------------------------<   Cloudy   >---)>
 <(                    A strange path in the Miden'Nir                    )>
<(-------------------------------------------------------------------------)>

   You come along a path which resembles to all others here. But after a
little time here you feel something different as a strange magical power
emanating from somewhere but don't know exactly where. Maybe if you continue
west and fighting some goblins you'll find answers to your questions.
[ Exits: E W ]
(Red Aura) A mountain goblin is wandering around mumbling to himself..
The goblin exclaims, 'Oh you found a little gem ! I want it !'

64H 106M 67V >c 'chill touch' goblin
Calm as ice you summon the destructive powers upon your enemy and speak, 'chill touch'.
You chill the goblin!
You failed.
The magic drained you of 15 mana.

64H 91M 67V few wounds >
You try to bludgeon the goblin who simply laughs at you.
The goblin screams, 'AAAAHHH! CHARGE!! BANZAI!!'.
You barely avoid the goblin's fist as he takes a swing at you!

64H 91M 67V few wounds >c 'chill touch'
Calm as ice you summon the destructive powers upon your enemy and speak, 'chill touch'.
You chill the goblin!
The magic drained you of 15 mana.

64H 76M 67V awful >
You barely bludgeon the goblin.
The goblin is stunned, but will probably regain consciousness again.

64H 76M 67V bleeding awfully >
Your relentless bludgeoning of the goblin finally results in his broken neck!
The goblin is dead!  R.I.P.
You gain 90 experience points for the kill..
Your blood freezes as you hear the goblin's death cry.
You get a little pile of gold coins from the corpse of the goblin.
There were 75 coins.

64H 76M 67V >e
You decide to leave this strange path and going back on the central way.

<(---<    Night   >---------------------------------------<   Cloudy   >---)>
 <(                             The Miden'Nir                             )>
<(-------------------------------------------------------------------------)>
Reply with quote
Odeon
Novice


Joined: 17 Nov 2008
Posts: 30

PostPosted: Wed Feb 25, 2009 8:05 pm   
 
Yeah, really great working ideas, i'll modify a bit to apply it to several spells (and mobs :)
but that's a wonderful foundation! Thanks Torin & Rahab :) Very Happy
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