Forum

> > CS2D > Scripts > RPG - An item that if used will summon a monster
Forums overviewCS2D overview Scripts overviewLog in to reply

English RPG - An item that if used will summon a monster

17 replies
To the start Previous 1 Next To the start

old RPG - An item that if used will summon a monster

Mami Tomoe
User Off Offline

Quote
Hi guys I need help with the RPG Tibia script (the original)
I want an item that if I consume it it will summon a monster (and remove the summoning item from my inventory).
I don't really know what to give you because I don't know what you will need so please help if you need something just ask.

file cs2d CS2DTibia - RPG

old Re: RPG - An item that if used will summon a monster

Yates
Reviewer Off Offline

Quote
Note that the monster will attack you as well. You could probably edit the monster code to not attack a certain ID if provided but that's too much work to do right now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[100] = {
	name = "Spawn Monster", 
	desc = "You may only use it once.", 
	r = 128, g = 0, b = 0, 
	action = {"cast", "hold"}, 
	slot = 9, 
	fimage = "gfx/weiwen/rune.png", 
	func = {function(id, itemslot, itemid, equip)
		local m = deepcopy(CONFIG.MONSTERS[math.random(#CONFIG.MONSTERS)]) -- Set your monster here, currently gets random
		m.x, m.y = math.floor(player(id,"x")*32+16), math.floor(player(id,"y")*32+16) -- Define your spawn x & y, currently uses player pos
		Monster:new(m) -- Execute the new monster spawn
		destroyitem(id, itemslot, equip) -- Destroy the item
	end, equip},
},

Tibia seriously needs to be recoded lol.

old Re: RPG - An item that if used will summon a monster

Yates
Reviewer Off Offline

Quote
Awesome! I'll give it a test, hold on.

• Edit: No idea dude. I have tried to debug it as quick as I could but alas I came up with nothing. I cannot debug it further right now, stuff to do - places to go. I will try again tomorrow if someone has no beaten me to it.
edited 1×, last 16.08.16 10:09:32 pm

old Re: RPG - An item that if used will summon a monster

Mami Tomoe
User Off Offline

Quote
OK but I think the problem is with X and Y because maybe monster try to spawn on SAFE ZONE and then game say aaa and crash?

Edit: Please I really need that for my server
I put you in credits with a smiley
edited 1×, last 17.08.16 05:05:40 pm

old Re: RPG - An item that if used will summon a monster

Yates
Reviewer Off Offline

Quote
I'm @ work from 9 till 5:30 (so I'm not going to download the game and test it here). I'll be home around 6 but I need to do a few things as soon as I'm back. I'll try and get to it around 8/9-ish.

Don't worry, I haven't forgotten. In fact I'm also pretty interested in this.

old Re: RPG - An item that if used will summon a monster

TrialAndError
User Off Offline

Quote
user Yates has written
Note that the monster will attack you as well. You could probably edit the monster code to not attack a certain ID if provided but that's too much work to do right now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[100] = {
	name = "Spawn Monster", 
	desc = "You may only use it once.", 
	r = 128, g = 0, b = 0, 
	action = {"cast", "hold"}, 
	slot = 9, 
	fimage = "gfx/weiwen/rune.png", 
	func = {function(id, itemslot, itemid, equip)
		local m = deepcopy(CONFIG.MONSTERS[math.random(#CONFIG.MONSTERS)]) -- Set your monster here, currently gets random
		m.x, m.y = math.floor(player(id,"x")*32+16), math.floor(player(id,"y")*32+16) -- Define your spawn x & y, currently uses player pos
		Monster:new(m) -- Execute the new monster spawn
		destroyitem(id, itemslot, equip) -- Destroy the item
	end, equip},
},

Tibia seriously needs to be recoded lol.


Lol, I think you were a bit tired..

1
m.x, m.y = math.floor(player(id,"x")*32+16), math.floor(player(id,"y")*32+16)

Of course it will crash when the spawn is (*32+16) by the players "x" and "y" coordinates

1
m.x, m.y = math.floor(player(id,"x")), math.floor(player(id,"y"))

Also check if the player is in a monster disabled zone or as long as I remember, water also caused crash when monsters were spawned in it.

old Re: RPG - An item that if used will summon a monster

TrialAndError
User Off Offline

Quote
@user Mami Tomoe: Lol.

The
[...]
needs to be a number as there isn't such thing as
["Monster scary"] = {name, health, ...}
in CONFIG.MONSTER.

The monster system of tibia is:
{{},{},{}}


If the "Monster scary" is in 10th place in the table, then it should be :

1
local m = deepcopy(CONFIG.MONSTERS[10])

old Re: RPG - An item that if used will summon a monster

Yates
Reviewer Off Offline

Quote
Check for the following:
1
if not gettile(player(id, "x"), player(id, "y")).SAFE and not gettile(player(id, "x"), player(id, "y")).NOMONSTERS then

player(id, "x")
and
player(id, "y")
may need to be changed to
tilex
and
tiley
- Not sure. Been a long time since I worked with Tibia zones.

You will also need to check if the current tile a player is standing on is one of the configured water tiles and that the tile is walkable.

old Re: RPG - An item that if used will summon a monster

Mami Tomoe
User Off Offline

Quote
I changed it to this:
1
if player(id,"health") > 0 and not gettile(player(id, 'tilex'), player(id, 'tiley')).SAFE and not gettile(player(id, "tilex"), player(id, "tiley")).NOMONSTERS then

And it wont spawn on SAFE ZONE or when I'm dead but how to check if I'm on water or inside a wall?

I made this function so please edit it:
1
2
3
4
5
6
7
function can_it_spawn(id)
	if player(id,"health") > 0 and not gettile(player(id, 'tilex'), player(id, 'tiley')).SAFE and not gettile(player(id, "tilex"), player(id, "tiley")).NOMONSTERS then
		return true
	else
		return false
	end
end
edited 1×, last 17.08.16 06:55:55 pm

old Re: RPG - An item that if used will summon a monster

TrialAndError
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[900] = {
     name = "Spawn Monster", 
     desc = "You may only use it once.", 
     r = 128, g = 0, b = 0, 
     action = {"cast", "hold"}, 
     slot = 9, 
     fimage = "gfx/weiwen/rune.png", 
     func = {function(id, itemslot, itemid, equip)
	if (gettile(PLAYERS[id].x, PLAYERS[id].y).SAFE or gettile(PLAYERS[id].x, PLAYERS[id].y).NOMONSTERS) then msg2(id,"\169255000000You can't spawn a monster in a monster-disabled zone!") return false end
	if inarray(CONFIG.WATERTILES, tile(player(id,"tilex"), player(id,"tiley"), 'frame')) then msg2(id,"\169255000000You can't spawn a monster in the water!") return false end
	if tile(player(id,"tilex"),player(id,"tiley"),"wall") then msg2(id,"\169255000000You can't spawn a monster in a wall!") return false end
	if player(id,"health") > 0 then 
	local m = deepcopy(CONFIG.MONSTERS[math.random(#CONFIG.MONSTERS)])
		m.x, m.y = math.floor(player(id,"x")), math.floor(player(id,"y"))
		Monster:new(m)
		destroyitem(id, itemslot, equip)
		return true
	end
     end, equip},
	},

I love the inarray function, one of my favourite things I learnt from the tibia code.

old Re: RPG - An item that if used will summon a monster

Mami Tomoe
User Off Offline

Quote
Thank you it work perfect now
I add you credits even though I'm the only one playing
Yates too

Edit:
How to make something into tilex or tiley?
I want monster scary spawn friends near it but Lua wont accept anything but tilex and tiley so I need self.x and self.y to tilex and tiley
plz
edited 2×, last 17.08.16 07:12:37 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview