Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: Healing scripts not working.

  1. #1
    Join Date
    Apr 2012
    Location
    ON A BOAT, MOTHERF--
    Posts
    2,700

    Default Healing scripts not working.

    I've been having the occasional hang-up with healing scripts, for some odd reason; happened before, but it apparently fixed itself... not sure what I did, but it's back again.

    The issue seems to come from it not recognizing APPRAISE, maybe? It seems to hang up on that part without actually doing the healing, and I'd then have to kill the script to run it again... same deal. I was using ;heal mostly, but I've tried a couple of other with similar results. Any thoughts?

    Apparently the issue is not inherent only to me, someone else mentioned having a problem that sounded identical recently.
    Wyrom: Crux already died for our sins.
    SEND[Kenstrom] Behold Dark Cruxophim, Blood Reaver and Weaver of Shadows, eater of Rooks, corruptor of orphans, flayer of flesh...but won't read a letter from some dying woman's diary, haha.
    Thadston says, "Stand down Baron, and your men. Or I swear to Koar, Liabo, Lornon, Cruxophim, I will release your daughter and watch her die right here."
    Stormyrain evenly asks, "Did you just make Cruxophim a god?"
    --Order of the Shadow--
    --carrion.kissing.chaos--

  2. #2

    Default

    Yeah I had the same problem too. Forgot how I fixed it though :/

  3. #3
    Join Date
    Apr 2012
    Location
    ON A BOAT, MOTHERF--
    Posts
    2,700

    Default

    Yeah, none of the healing scripts I know of are working, which is... weird.
    Wyrom: Crux already died for our sins.
    SEND[Kenstrom] Behold Dark Cruxophim, Blood Reaver and Weaver of Shadows, eater of Rooks, corruptor of orphans, flayer of flesh...but won't read a letter from some dying woman's diary, haha.
    Thadston says, "Stand down Baron, and your men. Or I swear to Koar, Liabo, Lornon, Cruxophim, I will release your daughter and watch her die right here."
    Stormyrain evenly asks, "Did you just make Cruxophim a god?"
    --Order of the Shadow--
    --carrion.kissing.chaos--

  4. #4

    Default

    Have you also tried ;sheal? That's the one I used but I modified it a bit.

  5. #5
    Join Date
    Apr 2012
    Location
    ON A BOAT, MOTHERF--
    Posts
    2,700

    Default

    Seems like it may be a bigger issue with Lich sputtering out... not sure why?
    Wyrom: Crux already died for our sins.
    SEND[Kenstrom] Behold Dark Cruxophim, Blood Reaver and Weaver of Shadows, eater of Rooks, corruptor of orphans, flayer of flesh...but won't read a letter from some dying woman's diary, haha.
    Thadston says, "Stand down Baron, and your men. Or I swear to Koar, Liabo, Lornon, Cruxophim, I will release your daughter and watch her die right here."
    Stormyrain evenly asks, "Did you just make Cruxophim a god?"
    --Order of the Shadow--
    --carrion.kissing.chaos--

  6. #6
    Join Date
    Jun 2011
    Location
    PWC, VA
    Posts
    9,132
    Blog Entries
    8

    Default

    Quote Originally Posted by FlayedAngel View Post
    Seems like it may be a bigger issue with Lich sputtering out... not sure why?
    So you are an empath trying to use the script to heal someone else correct?

  7. #7
    Join Date
    Jun 2011
    Location
    PWC, VA
    Posts
    9,132
    Blog Entries
    8

    Default

    This is the version of ;heal I am using and I just tried it on one person and it seemed to work fine.

    What exactly are you trying to have it do?

    Code:
    # REQUIRED: Lich v2.88+ if you use Wizard, or Lich v3.37+ if you use StormFront
    # Script for empaths to heal a target, then themselves. Basically, it clones the infamous JSE script (I think it works exactly the same, anyway... I've never used JSE, have never been an empath, and wrote it by request to suit the guy who asked for it, so who knows).
    
    # This is the level of wound you want the script to stop at... 1 would be a minor wound (rank 1). If you'd like it to go all the way to fully healed, just change the line so that the number is 0 instead of 1.
    #
    # Edited by Tayre. It's faster now.
    #
    if Char.level >= 25
    stop_at = 1
    else
    stop_at = 0
    end
    
    # The command 'quiet_exit' just tells Lich that it shouldn't clutter your game window when the script ends by informing you it exited.
    #quiet_exit
    
    # This checks to make sure the user gave us a name of a target to act on ('script.vars' is an array of the words the user entered after the script name, and calling the 'empty?' method of an array asks if the array is empty or not).
    if script.vars.empty?
    	respond("You didn't supply a target! You need to tell me who to heal.")
    	exit
    end
    pause_script("knewhealbot")
    # This sounds a whole lot more complicated than it really is, but the following defines a 'procedure object' -- what it does is wrap up everything in the block (the 'block' is what's between the opening squiggly '{' and the closing one '}'). Once you've defined a procedure object, you can call the object and execute it at anytime, as many times as you want, by just calling the 'call' method of procedures. So basically, 'healdown = proc' means, 'make a variable called healdown, and put the following procedure object into it'. Once that's done, you can execute the procedure with the command 'healdown.call' (for anyone familiar with JSE, I *believe*, but am not positive, there's a JSE function named 'callsub' -- the name sounds like it's doing the same thing as this, which is more or less executing a subroutine; if it helps, think of this as declaring the label for 'callsub' to execute [I think JSE works that way?]).
    healdown = proc { |area|
    	if area =~ /head|neck/
    		spell = 1104
    		if Wounds.neck > 1 then cost = 9 else cost = 4 end
    	elsif area =~ /hand|arm|leg/
    		spell = 1102
    		if Wounds.limbs > 1 then cost = 7 else cost = 2 end
    	elsif area =~ /eye|ab|chest|back/
    		spell = 1105
    		if Wounds.torso > 1 then cost = 10 else cost = 5 end
    	elsif area =~ /nerve/
    		spell = 1103
    		if Wounds.nerves > 1 then cost = 8 else cost = 3 end
    	end
    	unless mana?(cost)
    		respond("Insufficient mana, will continue when you have enough...")
    		until mana?(cost)
    			sleep 1
    		end
    	end
    #	fput "prep #{spell}"
    	fput "cure #{area}"
    	sleep 3
    	waitrt?
    }
    
    # Another procedure object that will be called later on in the script. I'm a big fan of the 'DRY' principle (Don't Repeat Yourself), so I like to write things just once and then repeat them with a single line instead of having to write them over & over again anytime I want to do the same thing.
    translate_wound = proc { |wound|
    	wound = wound.split.join(' ')
    	if wound =~ /(l|r)(?:eft|ight) (arm|hand|leg|eye)/
    		Wounds.send("#{$1}#{$2}")
    	elsif wound =~ /abdom/
    		Wounds.send("abs")
    	elsif wound =~ /nerve/
    		Wounds.send('nerves')
    	elsif wound =~ /(head|neck)/
    		Wounds.send($1)
    	elsif wound =~ /(chest|back)/
    		Wounds.send($1)
    	end
    }
    
    script.vars.shift
    until script.vars.empty?
    # This puts the name the user entered into a variable named 'target' (script.vars is the array of words the user gave us, and [1] means word 1; 'script.vars[2]' would ask for the second word the user gave the script, and so on).
    target = script.vars.shift
    fput "appraise #{target}"
    
    # Now we wait for the result of the 'appraise (person)' command by using 'waitfor', which takes as many lines to wait for as you want (there's no limit to how many). When it finds a line that contains one of the strings (a string is just text... this comment, for instance, is a 'string') you gave it, it returns the entire matching game line. So 'wound_line = waitfor' waits for a matching line, and then sticks the matching line into the 'wound_line' variable.
    wound_line = waitfor("Appraise what", "You take a quick appraisal of ")
    #echo wound_line
    
    # The 'waitfor' command does it for you automatically, but if you want to test if a string has a certain snippet inside it or not (like 'hi there' contains the snippet 'there', etc.), the easiest way is to use a regular expression match -- there's a hundred useful ways to use regular expressions, but if you don't want to get complicated, you can just ignore them all (see the comments in 'spell-list.txt' in your Lich scripts directory for more info on regular expressions). In Lich, anything inbetween two '/' characters is made a regular expression, and you can match by using the '=~' operator. So that's what this next line is about... it literally means "if the line in the 'wound_line' variable contains 'Appraise what' somewhere in it" -- if you want to, you can also do the same thing by using labels and 'match' lines the way Wizard scripts do it instead of using the method seen here.
    if wound_line =~ /Appraise what/
    	respond("Couldn't find the target! Are you sure '#{target}' is here...?")
    	unpause_script("knewhealbot")
    	exit
    elsif wound_line =~ /no apparent/
    	respond("dum dum dum, not injured, exiting")
    	unpause_script("knewhealbot")
    	exit
    end
    
    # Here we exploit a feature of regular expressions, which is automatically setting certain variables based on a succesful regular expression match -- for instance, enclosing something in parentheses is a quick and easy way of 'slicing' out whatever is between the opening '(' and the closing ')'. Each one gets put into a matching '$1' or '$2' or however many you have (in the following, if we added a second set of characters inside parentheses, whatever was in that part of the sentence would be in '$2' for example). All this does is extract the person's full name and use that as the target, instead of the (probably abbreviated) name the user entered.
    if wound_line =~ /You take a quick appraisal of (\w+)/
    	target = $1.dup
    end
    
    if wound_line.include?(',')
    	wound_array = wound_line.split(/You take a quick appraisal of|,/)
    else
    	wound_array = wound_line.scan(/a (?:blinded|swollen|bruised) (?:left|right) eye|deep lacerations across (?:his|her) \w+|deep gashes and serious bleeding (?:on|from|across) (?:his|her) \w+|minor cuts and bruises on (?:his|her) (?:left|right) (?:hand|arm|leg)|a (?:fractured and bleeding|completely severed) (?:left|right) (?:hand|arm|leg)|moderate bleeding from (?:his|her) neck|snapped bones and serious bleeding from the neck|minor bruises on (?:his|her) neck|minor (?:bruises|lacerations) about the head|minor cuts and bruises on (?:his|her) (?:chest|back|abdominal area)|severe head trauma and bleeding from the ears|strange case of muscle twitching|case of (?:sporadic|uncontrollable) convulsions/)
    end
    
    # This creates a new, empty array and puts it into the 'wounds' variable
    wounds = Array.new
    
    # This takes the line containing all the person's wounds that we've '.split' up into an array, and for '.each' value in the array, executes the entire block (as mentioned above, a 'block' is the code inside the squiggly brackets). We have to know how to refer to each value of the array uniquely, but we want to do the same exact thing for every one -- so when we declare the opening of the block with the squiggly '{' we also declare that inside the block, we want the current value to be in the variable 'wound'. That's what '|wound|' does.
    wound_array.each { |wound|
    	if wound =~ /(a blinded|a swollen|a bruised|deep lacerations across his|deep lacerations across her|cuts and bruises on his|cuts and bruises on her|fractured and bleeding|completely severed|deep gashes and serious bleeding on his|deep gashes and serious bleeding on her|deep gashes and serious bleeding from his|deep gashes and serious bleeding from her) (\w+)( \w+)?/
    		bodypart = "#{$2.dup} #{$3.dup}"
    	elsif wound =~ /moderate bleeding from (his|her) neck|snapped bones and serious bleeding from the neck|minor bruises on (his|her) neck/
    		bodypart = "neck"
    	elsif wound =~ /minor bruises about the head|minor lacerations about the head|severe head trauma and bleeding from the ears/
    		bodypart = "head"
    	elsif wound =~ /strange case of muscle twitching|case of sporadic convulsions|case of uncontrollable convulsions/
    		bodypart = "nerves"
    	else
    # If this particular value in the array doesn't match any of the regular expressions above (again, see 'spell-list.txt' for details on regular expressions), then we don't know what wound it is and have no idea what to do with it -- so to avoid it being part of our finished wound stack (the 'wounds' array), we use the 'next' command, which skips anything else left inside a block and moves on to the next iteration (an 'iteration' is the name for each time the code inside a block is executed -- so skipping the rest of the code and moving to the next 'iteration', in this case, means just keep going and repeat the code block for the next value in the array).
    		next
    	end
    
    # Now that we've identified which wound we're dealing with (that's what the 'if/elsif' stuff above is about), we '.push' the result on to our 'wounds' array
    	wounds.push(bodypart)
    }
    
    
    # Since the previous code block is pretty advanced compared to Wizard scripts, let me try to clarify: at this point in the script (when Lich has gotten to the line that this comment is on), the above code block has been executed for every value in the 'wound_array' variable. The 'wound_array' variable is, as the name suggests, an 'array' of values, and each value happens to be the description of a given wound ('a fractured and bleeding right leg', for instance). So for every one of those lines, the code block was executed, and each time the 'wound' variable was replaced with the current value. So if the wound_array was an array containing the strings, 'cuts and bruises on his left leg', and 'a fractured and bleeding right arm', the 'wound' variable would contain the string 'cuts and bruises on his left leg' the first time the block was executed, then the second time it was executed, the 'wound' variable would contain 'a fractured and bleeding right arm'. I hope that helps clear up what it did.
    
    # If the 'wound_array' variable was an empty array, or if none of the strings it contained could be identified as meaning a person had a certain wound, then our 'wounds' variable will be an empty array (because the 'wounds.push(bodypart)' line from the above code block never got to be executed). This just checks to make sure there's something inside 'wounds' for us to be working on.
    
    # This just creates yet another empty array, and sticks it into another variable (here we use 'to_heal'). If you haven't stumbled on the info yet, in Lich, you can create a variable with any name you want by doing this, and make it equal anything you want (just make sure you don't try to make a variable with the same name as a command, otherwise you're going to get cryptic-sounding errors about 'no method for =' and so forth).
    to_heal = Array.new
    
    # Now we again call '.each', but this time, we want to use the 'wounds' array. We again use the 'wound' variable for each value of the array, but we could make up any variable name we wanted -- 'thingiemajig', 'myvariable', 'you_suck', whatever name you want the variable to have, just as long as it's one word.
    wounds.each { |wound|
    	wound = wound.split.join(' ')
    	if wound =~ /(l|r)(?:eft|ight) (arm|hand|leg|eye)/
    		to_heal.push(wound)
    		if Wounds.send("#{$1}#{$2}") == 3
    			healdown.call(wound)
    		end
    		fput "transfer #{target} #{wound}"
    		
    	elsif wound =~ /abdom/
    		to_heal.push('abdomen')
    		if Wounds.send("abs") == 3
    			healdown.call('abdomen')
    		end
    		fput "transfer #{target} abdomen"
    		sleep 1
    	elsif wound =~ /nerve/
    		to_heal.push('nerves')
    		if Wounds.send('nerves') == 3
    			healdown.call('nerves')
    		end
    		fput "transfer #{target} nerves"
    		sleep 1
    	elsif wound =~ /(head|neck)/
    		to_heal.push($1)
    		if Wounds.send($1) == 3
    			healdown.call($1)
    		end
    		fput "transfer #{target} #{$1}"
    		
    	elsif wound =~ /(chest|back)/
    		to_heal.push($1)
    		if Wounds.send($1) == 3
    			healdown.call($1)
    		end
    		put "transfer #{target} #{$1}"
    		
    	end
    }
    
    # Now we make a new variable called 'bloodline' and put an empty 'string' in it.
    bloodline = String.new
    
    # This is the same kind of concept as 'array.each' -- except 'until' keeps repeating code over & over again, without any limit to how many times, 'until' something is true. In this case, we ask it to repeat the code until the value of 'bloodline' is a string containing 'Nothing happens' or 'all', OR the value of 'health?' is less than or equal to 75 ('health?' is a Lich command which means your current health).
    until bloodline =~ /Nothing happens|all|want/
    	if health? <= 75 or percenthealth < 51
    		if mana?((maxhealth - health?) / 10)
    #			fput "prep 1101"
    			fput "cure"
    			sleep 3
    			waitrt?
    			next
    		else
    			respond("You have insufficient health to safely continue, and insufficient mana to heal yourself... please handle the situation manually.")
    			break
    		end
    	end
    #	if health? <= 75
    #		respond("You have insufficient health to safely continue, and insufficient mana to heal yourself... please handle the situation manually.")
    #		break
    #	end
    	fput "transfer #{target}"
    	bloodline = waitfor "Nothing happens", "You take some", "You take all", "want"
    end
    
    # 'percenthealth' is another Lich command, and it's just the percentage of your current health. So now we say, "until we have 100% health, keep doing this over & over".
    while (health?.to_i != 0) and (health?.to_i < maxhealth.to_i)
    	cost = (maxhealth - health?) / 10
    	unless mana?(cost)
    		respond("Insufficient mana, will continue when you have enough...")
    		until mana?(cost)
    			sleep 1
    		end
    	end
    	fput "cure blood"
    	sleep 3
    	waitrt?
    end
    end
    # And yet another 'array.each' section (as you might guess from how often I use it, it's *incredibly* handy -- it's also very easy for Lich to do, so it's *extremely* fast & *extremely* efficient, as well). Now this is where we really stick to that DRY concept (again, just stands for "Don't Repeat Yourself," which is a silly way of saying 'why write the same thing over & over when you could just write it once and reuse it?'). We keep calling those 'procedure objects' we defined above over & over, and giving them the current value of 'wound'.
    to_heal.each { |wound|
    	until translate_wound.call(wound) == stop_at or translate_wound.call(wound) == 0
    		healdown.call(wound)
    	end
    }
    
    # And now we're done, so just point out to the user "hey, you there -- I'm finished. So, g'bye"
    respond "#{target} is fully healed."
    Last edited by drauz; 03-23-2017 at 12:42 AM.

  8. #8
    Join Date
    Feb 2010
    Location
    Down South
    Posts
    194

    Default

    Quote Originally Posted by drauz View Post
    This is the version of ;heal I am using and I just tried it on one person and it seemed to work fine.

    What exactly are you trying to have it do?

    Code:
    # REQUIRED: Lich v2.88+ if you use Wizard, or Lich v3.37+ if you use StormFront
    # Script for empaths to heal a target, then themselves. Basically, it clones the infamous JSE script (I think it works exactly the same, anyway... I've never used JSE, have never been an empath, and wrote it by request to suit the guy who asked for it, so who knows).
    
    # This is the level of wound you want the script to stop at... 1 would be a minor wound (rank 1). If you'd like it to go all the way to fully healed, just change the line so that the number is 0 instead of 1.
    #
    # Edited by Tayre. It's faster now.
    #
    if Char.level >= 25
    stop_at = 1
    else
    stop_at = 0
    end
    
    # The command 'quiet_exit' just tells Lich that it shouldn't clutter your game window when the script ends by informing you it exited.
    #quiet_exit
    
    # This checks to make sure the user gave us a name of a target to act on ('script.vars' is an array of the words the user entered after the script name, and calling the 'empty?' method of an array asks if the array is empty or not).
    if script.vars.empty?
    	respond("You didn't supply a target! You need to tell me who to heal.")
    	exit
    end
    pause_script("knewhealbot")
    # This sounds a whole lot more complicated than it really is, but the following defines a 'procedure object' -- what it does is wrap up everything in the block (the 'block' is what's between the opening squiggly '{' and the closing one '}'). Once you've defined a procedure object, you can call the object and execute it at anytime, as many times as you want, by just calling the 'call' method of procedures. So basically, 'healdown = proc' means, 'make a variable called healdown, and put the following procedure object into it'. Once that's done, you can execute the procedure with the command 'healdown.call' (for anyone familiar with JSE, I *believe*, but am not positive, there's a JSE function named 'callsub' -- the name sounds like it's doing the same thing as this, which is more or less executing a subroutine; if it helps, think of this as declaring the label for 'callsub' to execute [I think JSE works that way?]).
    healdown = proc { |area|
    	if area =~ /head|neck/
    		spell = 1104
    		if Wounds.neck > 1 then cost = 9 else cost = 4 end
    	elsif area =~ /hand|arm|leg/
    		spell = 1102
    		if Wounds.limbs > 1 then cost = 7 else cost = 2 end
    	elsif area =~ /eye|ab|chest|back/
    		spell = 1105
    		if Wounds.torso > 1 then cost = 10 else cost = 5 end
    	elsif area =~ /nerve/
    		spell = 1103
    		if Wounds.nerves > 1 then cost = 8 else cost = 3 end
    	end
    	unless mana?(cost)
    		respond("Insufficient mana, will continue when you have enough...")
    		until mana?(cost)
    			sleep 1
    		end
    	end
    #	fput "prep #{spell}"
    	fput "cure #{area}"
    	sleep 3
    	waitrt?
    }
    
    # Another procedure object that will be called later on in the script. I'm a big fan of the 'DRY' principle (Don't Repeat Yourself), so I like to write things just once and then repeat them with a single line instead of having to write them over & over again anytime I want to do the same thing.
    translate_wound = proc { |wound|
    	wound = wound.split.join(' ')
    	if wound =~ /(l|r)(?:eft|ight) (arm|hand|leg|eye)/
    		Wounds.send("#{$1}#{$2}")
    	elsif wound =~ /abdom/
    		Wounds.send("abs")
    	elsif wound =~ /nerve/
    		Wounds.send('nerves')
    	elsif wound =~ /(head|neck)/
    		Wounds.send($1)
    	elsif wound =~ /(chest|back)/
    		Wounds.send($1)
    	end
    }
    
    script.vars.shift
    until script.vars.empty?
    # This puts the name the user entered into a variable named 'target' (script.vars is the array of words the user gave us, and [1] means word 1; 'script.vars[2]' would ask for the second word the user gave the script, and so on).
    target = script.vars.shift
    fput "appraise #{target}"
    
    # Now we wait for the result of the 'appraise (person)' command by using 'waitfor', which takes as many lines to wait for as you want (there's no limit to how many). When it finds a line that contains one of the strings (a string is just text... this comment, for instance, is a 'string') you gave it, it returns the entire matching game line. So 'wound_line = waitfor' waits for a matching line, and then sticks the matching line into the 'wound_line' variable.
    wound_line = waitfor("Appraise what", "You take a quick appraisal of ")
    #echo wound_line
    
    # The 'waitfor' command does it for you automatically, but if you want to test if a string has a certain snippet inside it or not (like 'hi there' contains the snippet 'there', etc.), the easiest way is to use a regular expression match -- there's a hundred useful ways to use regular expressions, but if you don't want to get complicated, you can just ignore them all (see the comments in 'spell-list.txt' in your Lich scripts directory for more info on regular expressions). In Lich, anything inbetween two '/' characters is made a regular expression, and you can match by using the '=~' operator. So that's what this next line is about... it literally means "if the line in the 'wound_line' variable contains 'Appraise what' somewhere in it" -- if you want to, you can also do the same thing by using labels and 'match' lines the way Wizard scripts do it instead of using the method seen here.
    if wound_line =~ /Appraise what/
    	respond("Couldn't find the target! Are you sure '#{target}' is here...?")
    	unpause_script("knewhealbot")
    	exit
    elsif wound_line =~ /no apparent/
    	respond("dum dum dum, not injured, exiting")
    	unpause_script("knewhealbot")
    	exit
    end
    
    # Here we exploit a feature of regular expressions, which is automatically setting certain variables based on a succesful regular expression match -- for instance, enclosing something in parentheses is a quick and easy way of 'slicing' out whatever is between the opening '(' and the closing ')'. Each one gets put into a matching '$1' or '$2' or however many you have (in the following, if we added a second set of characters inside parentheses, whatever was in that part of the sentence would be in '$2' for example). All this does is extract the person's full name and use that as the target, instead of the (probably abbreviated) name the user entered.
    if wound_line =~ /You take a quick appraisal of (\w+)/
    	target = $1.dup
    end
    
    if wound_line.include?(',')
    	wound_array = wound_line.split(/You take a quick appraisal of|,/)
    else
    	wound_array = wound_line.scan(/a (?:blinded|swollen|bruised) (?:left|right) eye|deep lacerations across (?:his|her) \w+|deep gashes and serious bleeding (?:on|from|across) (?:his|her) \w+|minor cuts and bruises on (?:his|her) (?:left|right) (?:hand|arm|leg)|a (?:fractured and bleeding|completely severed) (?:left|right) (?:hand|arm|leg)|moderate bleeding from (?:his|her) neck|snapped bones and serious bleeding from the neck|minor bruises on (?:his|her) neck|minor (?:bruises|lacerations) about the head|minor cuts and bruises on (?:his|her) (?:chest|back|abdominal area)|severe head trauma and bleeding from the ears|strange case of muscle twitching|case of (?:sporadic|uncontrollable) convulsions/)
    end
    
    # This creates a new, empty array and puts it into the 'wounds' variable
    wounds = Array.new
    
    # This takes the line containing all the person's wounds that we've '.split' up into an array, and for '.each' value in the array, executes the entire block (as mentioned above, a 'block' is the code inside the squiggly brackets). We have to know how to refer to each value of the array uniquely, but we want to do the same exact thing for every one -- so when we declare the opening of the block with the squiggly '{' we also declare that inside the block, we want the current value to be in the variable 'wound'. That's what '|wound|' does.
    wound_array.each { |wound|
    	if wound =~ /(a blinded|a swollen|a bruised|deep lacerations across his|deep lacerations across her|cuts and bruises on his|cuts and bruises on her|fractured and bleeding|completely severed|deep gashes and serious bleeding on his|deep gashes and serious bleeding on her|deep gashes and serious bleeding from his|deep gashes and serious bleeding from her) (\w+)( \w+)?/
    		bodypart = "#{$2.dup} #{$3.dup}"
    	elsif wound =~ /moderate bleeding from (his|her) neck|snapped bones and serious bleeding from the neck|minor bruises on (his|her) neck/
    		bodypart = "neck"
    	elsif wound =~ /minor bruises about the head|minor lacerations about the head|severe head trauma and bleeding from the ears/
    		bodypart = "head"
    	elsif wound =~ /strange case of muscle twitching|case of sporadic convulsions|case of uncontrollable convulsions/
    		bodypart = "nerves"
    	else
    # If this particular value in the array doesn't match any of the regular expressions above (again, see 'spell-list.txt' for details on regular expressions), then we don't know what wound it is and have no idea what to do with it -- so to avoid it being part of our finished wound stack (the 'wounds' array), we use the 'next' command, which skips anything else left inside a block and moves on to the next iteration (an 'iteration' is the name for each time the code inside a block is executed -- so skipping the rest of the code and moving to the next 'iteration', in this case, means just keep going and repeat the code block for the next value in the array).
    		next
    	end
    
    # Now that we've identified which wound we're dealing with (that's what the 'if/elsif' stuff above is about), we '.push' the result on to our 'wounds' array
    	wounds.push(bodypart)
    }
    
    
    # Since the previous code block is pretty advanced compared to Wizard scripts, let me try to clarify: at this point in the script (when Lich has gotten to the line that this comment is on), the above code block has been executed for every value in the 'wound_array' variable. The 'wound_array' variable is, as the name suggests, an 'array' of values, and each value happens to be the description of a given wound ('a fractured and bleeding right leg', for instance). So for every one of those lines, the code block was executed, and each time the 'wound' variable was replaced with the current value. So if the wound_array was an array containing the strings, 'cuts and bruises on his left leg', and 'a fractured and bleeding right arm', the 'wound' variable would contain the string 'cuts and bruises on his left leg' the first time the block was executed, then the second time it was executed, the 'wound' variable would contain 'a fractured and bleeding right arm'. I hope that helps clear up what it did.
    
    # If the 'wound_array' variable was an empty array, or if none of the strings it contained could be identified as meaning a person had a certain wound, then our 'wounds' variable will be an empty array (because the 'wounds.push(bodypart)' line from the above code block never got to be executed). This just checks to make sure there's something inside 'wounds' for us to be working on.
    
    # This just creates yet another empty array, and sticks it into another variable (here we use 'to_heal'). If you haven't stumbled on the info yet, in Lich, you can create a variable with any name you want by doing this, and make it equal anything you want (just make sure you don't try to make a variable with the same name as a command, otherwise you're going to get cryptic-sounding errors about 'no method for =' and so forth).
    to_heal = Array.new
    
    # Now we again call '.each', but this time, we want to use the 'wounds' array. We again use the 'wound' variable for each value of the array, but we could make up any variable name we wanted -- 'thingiemajig', 'myvariable', 'you_suck', whatever name you want the variable to have, just as long as it's one word.
    wounds.each { |wound|
    	wound = wound.split.join(' ')
    	if wound =~ /(l|r)(?:eft|ight) (arm|hand|leg|eye)/
    		to_heal.push(wound)
    		if Wounds.send("#{$1}#{$2}") == 3
    			healdown.call(wound)
    		end
    		fput "transfer #{target} #{wound}"
    		
    	elsif wound =~ /abdom/
    		to_heal.push('abdomen')
    		if Wounds.send("abs") == 3
    			healdown.call('abdomen')
    		end
    		fput "transfer #{target} abdomen"
    		sleep 1
    	elsif wound =~ /nerve/
    		to_heal.push('nerves')
    		if Wounds.send('nerves') == 3
    			healdown.call('nerves')
    		end
    		fput "transfer #{target} nerves"
    		sleep 1
    	elsif wound =~ /(head|neck)/
    		to_heal.push($1)
    		if Wounds.send($1) == 3
    			healdown.call($1)
    		end
    		fput "transfer #{target} #{$1}"
    		
    	elsif wound =~ /(chest|back)/
    		to_heal.push($1)
    		if Wounds.send($1) == 3
    			healdown.call($1)
    		end
    		put "transfer #{target} #{$1}"
    		
    	end
    }
    
    # Now we make a new variable called 'bloodline' and put an empty 'string' in it.
    bloodline = String.new
    
    # This is the same kind of concept as 'array.each' -- except 'until' keeps repeating code over & over again, without any limit to how many times, 'until' something is true. In this case, we ask it to repeat the code until the value of 'bloodline' is a string containing 'Nothing happens' or 'all', OR the value of 'health?' is less than or equal to 75 ('health?' is a Lich command which means your current health).
    until bloodline =~ /Nothing happens|all|want/
    	if health? <= 75 or percenthealth < 51
    		if mana?((maxhealth - health?) / 10)
    #			fput "prep 1101"
    			fput "cure"
    			sleep 3
    			waitrt?
    			next
    		else
    			respond("You have insufficient health to safely continue, and insufficient mana to heal yourself... please handle the situation manually.")
    			break
    		end
    	end
    #	if health? <= 75
    #		respond("You have insufficient health to safely continue, and insufficient mana to heal yourself... please handle the situation manually.")
    #		break
    #	end
    	fput "transfer #{target}"
    	bloodline = waitfor "Nothing happens", "You take some", "You take all", "want"
    end
    
    # 'percenthealth' is another Lich command, and it's just the percentage of your current health. So now we say, "until we have 100% health, keep doing this over & over".
    while (health?.to_i != 0) and (health?.to_i < maxhealth.to_i)
    	cost = (maxhealth - health?) / 10
    	unless mana?(cost)
    		respond("Insufficient mana, will continue when you have enough...")
    		until mana?(cost)
    			sleep 1
    		end
    	end
    	fput "cure blood"
    	sleep 3
    	waitrt?
    end
    end
    # And yet another 'array.each' section (as you might guess from how often I use it, it's *incredibly* handy -- it's also very easy for Lich to do, so it's *extremely* fast & *extremely* efficient, as well). Now this is where we really stick to that DRY concept (again, just stands for "Don't Repeat Yourself," which is a silly way of saying 'why write the same thing over & over when you could just write it once and reuse it?'). We keep calling those 'procedure objects' we defined above over & over, and giving them the current value of 'wound'.
    to_heal.each { |wound|
    	until translate_wound.call(wound) == stop_at or translate_wound.call(wound) == 0
    		healdown.call(wound)
    	end
    }
    
    # And now we're done, so just point out to the user "hey, you there -- I'm finished. So, g'bye"
    respond "#{target} is fully healed."
    I use this with no problems. Last used this morning.
    Mihorkan quietly exclaims, "I pulled a Jodia AND a Kaylisidee!"
    Mihorkan quietly exclaims, "A Jodisidee!"
    Mihorkan quietly exclaims, "A Kaydia!"

  9. #9
    Join Date
    Apr 2012
    Location
    ON A BOAT, MOTHERF--
    Posts
    2,700

    Default

    It seems it might be a bigger issue than just healing scripts... the game itself seems to be lagging kinda heavily at times for me, and various things seem to want to cut in and out -- including ;go2, which may be related to the lagging, as I'm guessing scripts are getting hung up trying to execute something and then failing?

    I've actually had it not be able to track any rooms before (as if the database is gone, or something), which is weird... when that happens, I usually log out and log back in again and it's corrected.

    Is it some kind of connectivity issue?
    Last edited by FlayedAngel; 03-25-2017 at 02:25 AM.
    Wyrom: Crux already died for our sins.
    SEND[Kenstrom] Behold Dark Cruxophim, Blood Reaver and Weaver of Shadows, eater of Rooks, corruptor of orphans, flayer of flesh...but won't read a letter from some dying woman's diary, haha.
    Thadston says, "Stand down Baron, and your men. Or I swear to Koar, Liabo, Lornon, Cruxophim, I will release your daughter and watch her die right here."
    Stormyrain evenly asks, "Did you just make Cruxophim a god?"
    --Order of the Shadow--
    --carrion.kissing.chaos--

  10. #10

    Default

    Quote Originally Posted by FlayedAngel View Post
    It seems it might be a bigger issue than just healing scripts... the game itself seems to be lagging kinda heavily at times for me, and various things seem to want to cut in and out (including ;go2, which may be related to the lagging).

    I've actually had it not be able to track any rooms before (as if the database is gone, or something), which is weird... when that happens, I usually log out and log back in again and it's corrected.
    Do you happen to run the ;title script?

Similar Threads

  1. bigshot scripts not working?
    By LeftBench in forum The Lich Project
    Replies: 0
    Last Post: 02-04-2017, 08:38 PM
  2. Replies: 24
    Last Post: 02-18-2006, 05:57 PM
  3. Automated healing scripts?
    By kranfer in forum Scripting Discussion
    Replies: 13
    Last Post: 05-13-2005, 07:38 PM
  4. Replies: 1
    Last Post: 12-05-2003, 06:37 PM
  5. Healing Scripts and the like
    By Chyrain in forum Mechanics Complaints
    Replies: 16
    Last Post: 07-30-2003, 08:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •