Page 1 of 1

Problem with damageTile and skeleton_patrol

Posted: Sun Oct 14, 2012 8:10 am
by Lmaoboat
I got a script that periodically looks for any nearby enemies with "skeleton" in their name, and damages them. It works fine with normal skeletons, but with skeleton_patrols, it will damage the entire group for each skeleton in it, causing it to take four times the damage. I tried making a different check with different damage for each type of skeleton, that just made them take the damage for each.

Code: Select all

function skullcheckB()
	for i=-1,1 do 
		for j=-1,1 do
			for h in entitiesAt(party.level,party.x + j,party.y + i) do
				if h.name:sub(1,8) == "skeleton" then
					damageTile(party.level, party.x + j, party.y + i, 0,10111101, "fire", 20)
	
				end
			end
		end
	end
end

Re: Problem with damageTile and skeleton_patrol

Posted: Sun Oct 14, 2012 8:19 am
by King Semos
Maybe renaming the group of skeletons will eliminate any ties that their given name has to each individual one.

Re: Problem with damageTile and skeleton_patrol

Posted: Sun Oct 14, 2012 8:20 am
by Blichew
It because of that a skeleton patrol is essentially skeleton_warrior x4. So it triggers 4 times on the square, one for each.
You could try countering that by adding "break" after damageTile. With that the "for h" loop should be exited, and iterator should go for next j value.

Code: Select all

    function skullcheckB()
       for i=-1,1 do
          for j=-1,1 do
             for h in entitiesAt(party.level,party.x + j,party.y + i) do
                if h.name:sub(1,8) == "skeleton" then
                   damageTile(party.level, party.x + j, party.y + i, 0,10111101, "fire", 20)
                   break
                end
             end
          end
       end
    end
I didn't test it but logic says it should work (unless a break function would instead break the whole function :) )
:edit: damn typo. 'I didn't tested', lol... -_-

Re: Problem with damageTile and skeleton_patrol

Posted: Sun Oct 14, 2012 8:27 am
by Lmaoboat
That seems to work. I really need to learn some of the basic things like how return and break work, there's probably a lot of things I could do easier.