XenoBot Forums - Powered by vBulletin

User Tag List

Results 1 to 7 of 7

Thread: Help on this sio/mas res script

  1. #1

    Join Date
    Jun 2012
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help on this sio/mas res script

    Hey guys, I'm trying to learn lua and I made this function to heal with mas res/exura sio, but for some reason it only works when there are no monsters on screen, and it sometimes doesn't randomize the hp correctly.
    could someone that knows what they're doing take a look?

    lua code:
    -----Pacman's sio/mas res script


    local playerstoheal = {"Bubble"} --name of the players to heal
    local hppct = 75 --target hp percent to heal him/mas res
    local hpself = 80 --self hp percent to heal others (if below this and the nigga is close it'll mas res)
    local manapcself = 40 --self mp percent to do shit


    ----only touch below this line if you know what the fuck you are doing----
    math.randomseed(os.time())
    local hppctr = hppct + math.random(-5, 5)
    function checkheal ()
    local specs = Self.GetSpectators(false)
    for i = 1, #specs do
    local healtarget = specs[i]
    if healtarget:isPlayer() then
    for z = 1, #playerstoheal do
    if healtarget:Name() == playerstoheal[i] then
    local hppctr = hppct + math.random(-5, 5)
    if healtarget:HealthPercent() <= hppctr then
    print("healed at "..hppctr.."% expected")
    local smppc = math.floor(Self.Mana() / Self.MaxMana()*100)
    if smppc >= manapcself then
    local shppc = math.floor(Self.Health() / Self.MaxHealth()*100)
    if shppc <= hpself then
    local htpos = healtarget:Position()
    local difx = math.abs(Self.Position().x - htpos.x)
    local dify = math.abs(Self.Position().y - htpos.y)
    local mrarea = (dify + difx)
    if mrarea <= 4 and (difx <= 3) and (dify <= 3) then
    if Self.CanCastSpell("exura gran mas res") then
    Self.Cast("exura gran mas res", 300)
    end
    end
    else
    Self.Say("Exura sio \""..healtarget:Name())
    wait(200,400)
    end
    end
    end
    end
    end
    end
    end
    end

    --i dunno how to do modules with delay inside of them yet :(
    while true do
    checkheal()
    wait(400, 800)
    end


  2. #2
    Senior Member pixie_frigo's Avatar
    Join Date
    Dec 2012
    Location
    Ghent, Belgium
    Posts
    458
    Mentioned
    38 Post(s)
    Tagged
    0 Thread(s)
    playerstoheal[i] should be playerstoheal[z]

    I cleaned up your script a little !
    There is a function table.find and self.cast already checks if you can cast it or not
    Also there is a cool lua thing:

    for index,value in ipairs(table) do
    end

    that works the same as

    PHP Code:
    for index 1#list do
        
    value = list[i]
    end 
    PHP Code:

    function checkHeal()
        
    local spcs Self.GetSpectators(false)
        for 
    ihealtarget in ipairs(specs) do
            if 
    healtarget:isPlayer() and table.find(playerstoheal,healtarget:Name()) then
                local hppctr 
    hppct math.random(-55)
                
    local smppc math.floor(Self.Mana() / Self.MaxMana()*100)
                if 
    healtarget:HealthPercent() <= hppctr and smppc >= manapcself then
                    
    print("healed at "..tostring(hppctr).."% expected")
                    
    local shppc math.floor(Self.Health() / Self.MaxHealth()*100)
                    if 
    shppc <= hpself then
                        local htpos 
    healtarget:Position()
                        
    local difx math.abs(Self.Position().htpos.x)
                        
    local dify math.abs(Self.Position().htpos.y)
                        
    local mrarea = (dify difx)
                        if  
    mrarea <= and (difx <= 3) and (dify <= 3then
                            Self
    .Cast("exura gran mas res"300)
                        
    end
                    
    else
                        
    Self.Cast("Exura sio \""..healtarget:Name())
                    
    end
                end
            end
        end
    end 
    Last edited by pixie_frigo; 06-26-2013 at 08:43 PM.

  3. #3
    Administrator
    Join Date
    Dec 2010
    Posts
    2,565
    Mentioned
    228 Post(s)
    Tagged
    1 Thread(s)
    I always feel bad when it's the little things...


  4. #4

    Join Date
    Jun 2012
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help guys! i feel so dumb for missing that the last two days

  5. #5
    Administrator
    Join Date
    Dec 2010
    Posts
    2,565
    Mentioned
    228 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Slayer2k91 View Post
    Thanks for the help guys! i feel so dumb for missing that the last two days
    Wasn't me! Thank pixie!

  6. #6
    Senior Member pixie_frigo's Avatar
    Join Date
    Dec 2012
    Location
    Ghent, Belgium
    Posts
    458
    Mentioned
    38 Post(s)
    Tagged
    0 Thread(s)
    hehe you're welcome
    But on things like this I would use in ipairs then you can't make small annoying mistakes like that ^^ Just tips !
    But looks better then my scripts a few months back haha

  7. #7

    Join Date
    Jun 2012
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pixie_frigo View Post
    hehe you're welcome
    But on things like this I would use in ipairs then you can't make small annoying mistakes like that ^^ Just tips !
    But looks better then my scripts a few months back haha
    thanks for the tips dude, I'm still trying to wrap my head around ipars, but i'll try to use them anyway.

    Offtopic: do you think anyone would be interested in a directional spell script i made? the code is even worse than this one, but it works pretty well. (I also got lazy and didn't implement aoe runes or single target spells, but that should be easy enough), or do you guys mind taking a look at it?



    EDIT: Here it is anyway.

    Code:
    --Pacman's shitty area spell caster thingamajig
    spell = {}
    area = {}
    
    
    
    --CONFIG
    spell[1] = {words = "exevo frigo hur",
    			manacost = 25,
    			area = {{0,0,0,1},
    					{0,1,1,1},
    					{1,1,1,1},
    					{0,1,1,1},
    					{0,0,0,1}},
    			creaturecount = 2}
    			
    spell[2] = {words = "exevo gran frigo hur",
    			manacost = 170,
    			area = {{0,1,1},
    					{1,1,1},
    					{0,1,1}},
    			creaturecount = 1}			
    
    
    
    		
    		
    --initializing shit (i'm too shit at lua to know how to do this for sure inside the script :C)
    e = 0
    n = 0
    s = 0
    w = 0
    largest = 0	  
    
    print("Pacman's shit directional spell caster thingamajig")
    
    function inarea(posc, sn)
    	sarea = spell[sn].area
    	compensatey = math.ceil((#sarea/2))
    	for y =1, #sarea do
    		for x=1, #sarea[1] do
    			if sarea[y][x] > 0 then
    				correctedy = y - compensatey
    				if posc.x == Self.Position().x + x and posc.y == Self.Position().y + correctedy then
    					e = e  + sarea[y][x]
    				end
    				if posc.x == Self.Position().x - x and posc.y == Self.Position().y + correctedy then
    					w = w + sarea[y][x]
    				end
    				if posc.x == Self.Position().x + correctedy and posc.y == Self.Position().y + x then
    					s = s + sarea[y][x]
    				end
    				if posc.x == Self.Position().x + correctedy and posc.y == Self.Position().y - x then
    					n = n + sarea[y][x]
    				end				
    			end
    		end
    	end
    end
    
    	
    		
    function findtargets(sn)
    	local creatures = Self.GetSpectators(false)
    	for i = 1, #creatures do
    		local cre = creatures[i]
    		if cre:isMonster() then
    			local crepos = cre:Position()
    			inarea(cre:Position(), sn)
    		end
    	end
    	largest = e
    	dir = "east"
    	if largest < s then
    		largest = s
    		dir = "south"
    	end
    	if largest < w then
    		largest = w
    		dir = "west"
    	end
    	if largest < n then
    		largest = n
    		dir = "north"
    	end
    	scount = spell[sn].creaturecount
    	swords = spell[sn].words
    	if largest >= scount and Self.CanCastSpell(swords) then
    		castaspell = true
    	end
    	e = 0
    	n = 0
    	s = 0
    	w = 0
    	largest = 0
    end
    					
    
    
    while true do
    	for sn = 1, #spell do
    		findtargets(sn)
    		if castaspell then
    			Walker.Delay(1200)
    			setTargetingEnabled(false)
    			wait(200, 300)
    			Self.Turn(dir)
    			wait(300, 400)
    			Self.Cast(spell[sn].words, spell[sn].manacost)
    			wait(300, 400)
    			setTargetingEnabled(true)
    			wait(1600, 1900)
    			castaspell = false
    		end
    		wait(200, 400)
    	end
    end
    Last edited by Slayer2k91; 06-26-2013 at 09:17 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
  •