Forum

> > CS2D > Scripts > Tibia script thread (Post tibia requests here)
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Tibia script thread (Post tibia requests here)

347 Antworten
Seite
Zum Anfang Vorherige 1 215 16 17 18 Nächste Zum Anfang

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

Mami Tomoe
User Off Offline

Zitieren
Mehr >


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
3× editiert, zuletzt 24.08.16 08:04:09

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

Mami Tomoe
User Off Offline

Zitieren
Mehr >


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

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

Yates
Reviewer Off Offline

Zitieren
@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.

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

Mami Tomoe
User Off Offline

Zitieren
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?

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

Yates
Reviewer Off Offline

Zitieren
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.

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

Yates
Reviewer Off Offline

Zitieren
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.

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

Mami Tomoe
User Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 215 16 17 18 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht