Forum

> > CS2D > Scripts > Tibia script thread (Post tibia requests here)
Forums overviewCS2D overview Scripts overviewLog in to reply

English Tibia script thread (Post tibia requests here)

347 replies
Page
To the start Previous 1 215 16 17 18 Next To the start

old Re: Tibia script thread (Post tibia requests here)

Mami Tomoe
User Off Offline

Quote
More >


Edit: Lets make it easier to understand shall we
I need an add-on to Tibia script that will remove all dropped items and monsters alive every 12 hours.
I also want a HUDTEXT to show to everyone when will this happen so they can be ready.

Please help me I add you credits with happy face and if you join my server I give you pizza

Edit: plz someone help me or at least give me hint idk how
i give cookie in pm
edited 3×, last 24.08.16 08:04:09 am

old Re: Tibia script thread (Post tibia requests here)

Mami Tomoe
User Off Offline

Quote
More >


Solved that problem but now I need to make certain monsters rotate forever ( not to player just rotate 360 like a ball )
Please help
?
edited 1×, last 27.08.16 11:41:19 pm

old Re: Tibia script thread (Post tibia requests here)

Yates
Reviewer Off Offline

Quote
@user Mami Tomoe: That won't prevent lag. You will eventually end up with an infinite loop because monsters spawn randomly.

I suggest you don't do this. There are too many things to consider. You will probably kill off a few monsters that simply ran away as well.

old Re: Tibia script thread (Post tibia requests here)

Mami Tomoe
User Off Offline

Quote
I was planning to set the max monsters to around 25 and let them only show near the players because my map is big and if I will spawn more than 25 monsters then players who connect will freeze (common RPG bug/lag) and if the max monsters are 25 in a big map you will need to walk a bit in order to find a monster...

Anyone has a good idea for that? Or is there a way to optimize the monster codes to remove that bug?

old Re: Tibia script thread (Post tibia requests here)

Yates
Reviewer Off Offline

Quote
It's very easy to solve. I can't believe no one figured it out yet.

Stop moving the images (recreation) when no one is near a monster, set the opacity of the image to 0 to avoid an image being somewhere the monster is not and start moving the image once a player is close to a monster.

Problem solved. 90 monsters without a problem.

old Re: Tibia script thread (Post tibia requests here)

Yates
Reviewer Off Offline

Quote
I wrote this a few years ago, it's ugly but works:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function Monster:pos(x, y)
	if not x and not y then
		return self.x, self.y
    else
        if not occupied(x,y,self.id) then
		    self.x, self.y = x or self.x, y or self.y
        end
		for all = 1, 17 do
			if player(all,"exists") and player(all,"health") > 0 then
				if player(all,"x") >= self.x-800 and player(all,"x") <= self.x+800 and player(all,"y") >= self.y-800 and player(all,"y") <= self.y+800 then
                    imagepos(self.image, self.x, self.y, self.imgang)
                    imagealpha(self.image, 1)
                    break
				end
			end
			if all == 17 then
				imagealpha(self.image, 0)
			end
		end
	end
	return true
end

You can test it by running around seeing that every monster has spawned, then go spectator. You will no longer be able to see any (unless there is another player close by monsters).

The distance is just out of game window, so monsters will be visible just before you can actually see them on your screen.

old Re: Tibia script thread (Post tibia requests here)

Mami Tomoe
User Off Offline

Quote
It works until I get near a monster and that spams on my console:
1
2
3
4
LUA ERROR: sys/lua/cs2dtibia/monsters.lua:1421: attempt to call global 'occupied' (a nil value)
 -> sys/lua/cs2dtibia/monsters.lua:1421: in function 'pos'
 -> sys/lua/cs2dtibia/monsters.lua:1447: in function 'move'
 -> sys/lua/cs2dtibia/monsters.lua:1399: in function <sys/lua/cs2dtibia/monsters.lua:1325>

I think I'm missing the
occupied
function.
To the start Previous 1 215 16 17 18 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview