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


Joined: 28 Nov 2010
Posts: 9

PostPosted: Sat Jan 22, 2011 8:59 pm   

Help with coding
 
Hey guys, I'm not a programmer by any means and as such am having difficulty figuring out how to do something.

Basically what i'm trying to do is create a function to check which of my spells have fallen during combat and cast them automatically after i leave combat.

I've got a trigger set up that when a mob dies it runs function spellcheck, and in the spellcheck function it checks the variables of which spells return a 1 (still on the character) or 0 which ones have fallen, with corresponding triggers to each spell falling. So the function then looks for spells that return 0's and re-casts them, but i cant have the function fire off all the casts at the same time, so I tried setting up a loop to do 1 at a time until they're all up, but CMUD doesn't like it. Anyone have any other ideas?

Thanks in advance for the insight!
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Sat Jan 22, 2011 9:22 pm   
 
In my experience one of the simplest ways to do this is set up a db variable where the key is the name of the spell you use when casting it, and the value reflecting it's state 0 or 1. Once you get your current triggers set up to work with the db var, you can use the #loopdb command to search through the variable and recast the spells using an alias or when the mob dies in your case.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
Treluk
Newbie


Joined: 28 Nov 2010
Posts: 9

PostPosted: Sat Jan 22, 2011 10:00 pm   
 
Okay, i started it off with

Code:

#LOOPDB @spells {#IF (%val = 0) {cast %key;#VAR spell %key;#DELKEY @spells %key 0}}


and this is what happens

Quote:

cast armor
cast shield
cast displace
cast fly
cast infra
cast sanc


It works, but isn't there a way to do it 1 at a time, or spaced out so it doesnt flag my character as a spammer?

EDIT: Btw, the reason for the #VAR spell %key is to update the script with the last cast spell, incase the spell casts it can recast. In this case it automatically tries to recast the last spell in the database (obviously, because it spits out all the spells at the same time).
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Sat Jan 22, 2011 10:26 pm   
 
Code:
#LOOPDB @spells {#IF (%val = 0) {cast %key;#VAR spell %key;#DELKEY @spells %key 0;#wait 1000}}

Adding a #wait at the end, will allow a pause and shouldn't cause any problems if you aren't doing much else in the trigger. The number after #wait represents the number of ms to pause the script. Just adjust the value to what is needed.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
Treluk
Newbie


Joined: 28 Nov 2010
Posts: 9

PostPosted: Sat Jan 22, 2011 10:45 pm   
 
Oh I'm an idiot, LOL. I'll try this, thanks :)
Reply with quote
tsenzouken
Newbie


Joined: 15 Jan 2011
Posts: 5
Location: US

PostPosted: Mon Jan 24, 2011 9:44 pm   
 
Is there any way to pause the script but let other things interject commands? For example, if the above code might cause

cast armor
(pause)
cast shield
...etc.

But if I lose concentration, I want it to do this:
cast armor
[text from mud: You lost your concentration!]
cast armor
(pause)

I have a trigger that recasts on concentration loss by using a variable which is populated with whatever spell is being cast, but it wouldn't work in this case because the @WAIT pauses output for everything.
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Tue Jan 25, 2011 5:20 am   
 
@tsenzouken
If you changed the #wait to a #waitfor {unique text here} and had a trigger for the successful cast of each spell, that echoed the unique text, that should solve your problems. Of course there are other ways to do it but that's a good starting place that requires minimal effort.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
tsenzouken
Newbie


Joined: 15 Jan 2011
Posts: 5
Location: US

PostPosted: Tue Jan 25, 2011 6:51 am   
 
Thanks!
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