Need help making an auto-basher

Post Reply
Vankara
Posts: 4
Joined: Wed Mar 21, 2012 12:37 am

Need help making an auto-basher

Post by Vankara » Wed Mar 21, 2012 12:45 am

This is for Lusternia. I'm trying to make an auto-basher, or really a semi-auto-basher. I've made one in cMud before but don't really know how to go about making one here. As I play a monk I have to track various variables for the loss of balance on each arm and leg, as well as regaining that balance, and retaining the balance if there was no target. I also want it to track if the mob is shielded, and switch to a raze form if it does. I have the following set to fire off my prompt, though it returns an error saying that 'then' is exepected near '='. As you can probably tell from looking at this, I have no real idea what I'm doing.
Code: [show] | [select all] lua
if system.RAB = true and system.LAB = true and system.LLB = true and system.RLB = true and system.unshielded = true and system.autobash = true
	then send("kata perform " .. target .. " pvm1")
end

if system.RAB = true and system.LAB = true and system.LLB = true and system.RLB = true and system.unshielded = false and system.autobash = true
	then send("kata perform " .. target .. " razehunt")
end
each of those system.(whatever) are set by triggers. Or I assume they are, since I simply have a trigger firing off of each line with system.(whatever) = true or false depending on the trigger.

Like I said, no real idea what I'm doing. Just trying to learn how to do all this, and any help in doing so would be appreciated.

This is my first attempt at creating something moderately complex in Mudlet, as all the other things I have created have been basic targeting triggers and echos for shields and the like, and it's mostly a learning experience. Problem is I think I'm just bungling everything without really learning anything.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Need help making an auto-basher

Post by tsuujin » Wed Mar 21, 2012 2:02 am

Given that the game rules expressly forbid auto-bashing, you're probably not going to have a lot of people jump out to help you with this. The last thing someone wants is to get shrubbed because the admins metagamed the knowledge that you're an autobasher.

Vankara
Posts: 4
Joined: Wed Mar 21, 2012 12:37 am

Re: Need help making an auto-basher

Post by Vankara » Wed Mar 21, 2012 2:10 am

Except it isn't really fully auto I'm looking for. I don't want it to grab lists of mobs and kill everything in the room before moving on it's own. Just something that I can hit one key to have it attack one target. Once it is done with that target, it turns itself off until I start it again. And I have to specify the specific target. It is, in fact, less automated than some of the things I have seen out there, such as some of the influencing scripts.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Need help making an auto-basher

Post by Oneymus » Wed Mar 21, 2012 3:06 am

Well, since I don't play any of the MuDs, and the one I worked on went under, I don't mind helping you out in the least.

First of all, to check a value for equality in Lua, you use '=='. A single '=' is for assignation. I might also suggest a change in your structure, like so:
Code: [show] | [select all] lua
-- Define this in your start-up script, or somewhere outside of the attack function itself.
system.balances = {
  right_arm = true,
  left_arm = true,
  right_leg = true,
  left_leg = true
}

-- Same with this one.
system.enemy = {
  name = "",
  unshielded = true
}

-- We call this function from our alias or (in your case) the prompt trigger.
-- Generally speaking, breaking up scripts into discrete, focused-purpose functions,
-- it becomes easier to navigate and refactor.
function doAttack ()
  -- Test for autobash here. This allows us to escape early and avoid further processing
  -- if we don't want to autobash.
  if system.autobash == true then
    -- We use _ because we don't actually need the name of the balance. We only need the value,
    -- which we store in bool.
    -- have_bal is a variable we'll use to check whether or not we have all balances.
    local have_bal = true
    for _, bool in pairs( system.balances ) do
      if bool == false then
        -- We're missing a balance. Break ends the loop early. Setting have_bal
        -- to false lets us know we're missing a balance.
        have_bal = false
        break
      end
    end

    -- In Lua, you don't need to explicitly check for true, false, or nil.
    -- It's a little more complicated than that, but consider it an exercise.
    -- We have all balances, so we want to attack.
    if have_bal then
      -- Let's figure out which attack we want.
      if system.enemy.unshielded then
        send( "kata perform " .. system.enemy.name .. " pvm1" )
      else
        send( "kata perform " .. system.enemy.name .. " razehunt" )
      end
    end
  end
end
This was written completely in the post box, so no guarantees of syntax or performance. But it should do what you're after, and it's MUCH cleaner. Long strings of AND make for horrible debugging.

Vankara
Posts: 4
Joined: Wed Mar 21, 2012 12:37 am

Re: Need help making an auto-basher

Post by Vankara » Wed Mar 21, 2012 3:10 am

Thank you for the reply! In the very least, if it doesn't work, I can pick at it to see how you set things up to figure out how to make one that does myself.

Sheia
Posts: 33
Joined: Tue Dec 01, 2009 4:40 am

Re: Need help making an auto-basher

Post by Sheia » Wed Mar 21, 2012 2:22 pm

As a note Lusternia doesn't forbid anything you've posted here Vankara. An auto-basher that moves you from room to room would be a problem, not one that simply attacks continuously at your command. I can help you more with this if you need it, just send me a message.

User avatar
Vadi
Posts: 4733
Joined: Sat Mar 14, 2009 3:13 pm

Re: Need help making an auto-basher

Post by Vadi » Thu Mar 22, 2012 7:53 pm

(though their administration on this is lacking, and people do have complete autobashers that are leave-and-forget type)

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Need help making an auto-basher

Post by tsuujin » Thu Mar 22, 2012 8:05 pm

I'm not really complaining about people having full-auto bashers, I can't tell you how many people I've killed who were stupid enough to walk into PK areas and turn on an autobasher.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests