Problem with damageTile and skeleton_patrol

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Problem with damageTile and skeleton_patrol

Post 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
User avatar
King Semos
Posts: 123
Joined: Sun Apr 15, 2012 6:05 pm

Re: Problem with damageTile and skeleton_patrol

Post by King Semos »

Maybe renaming the group of skeletons will eliminate any ties that their given name has to each individual one.
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: Problem with damageTile and skeleton_patrol

Post 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... -_-
Last edited by Blichew on Sun Oct 14, 2012 10:47 am, edited 1 time in total.
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: Problem with damageTile and skeleton_patrol

Post 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.
Post Reply