Forum

> > CS2D > Scripts > RPG - Rotate and change image of monsters
Forums overviewCS2D overview Scripts overviewLog in to reply

English RPG - Rotate and change image of monsters

16 replies
To the start Previous 1 Next To the start

old RPG - Rotate and change image of monsters

Mami Tomoe
User Off Offline

Quote
Hi
Can I make monster look at player?
So image rotate to the closest player is that possible?
And also change image if monster is low on health
plz help idk what to do
Oh and I hope I'm not asking for too much but I never edited tibia that much and I'm starting from nothing but if my script will be good I will host it

I did search but all I got is yates saying he is not willing to share the secret (O_o?)

old Re: RPG - Rotate and change image of monsters

TrialAndError
User Off Offline

Quote
http://www.unrealsoftware.de/forum_posts.php?post=294172&start=220#post350928

You searched alot, lol

1
2
3
4
if self.health <= 20 then
	freeimage(self.image)
	self.image = image("path/to/image",self.x,self.y,0)
end

You can put this in Monster:damage, it may be an easier way to do it, but this is what I had in mind.

If you want to specify which monster to change image you could use:

1
2
3
if self.name == "Insert monster name here" then
	--the code...
end

You could even ask this in the old thread, instead of creating a new one.
edited 1×, last 17.08.16 07:57:38 pm

old Re: RPG - Rotate and change image of monsters

TrialAndError
User Off Offline

Quote
Find

1
2
addhook("ms100", "MONSTERms100")
function MONSTERms100()
in Monsters.lua

and scroll down a bit until you see
1
2
3
if target ... then 
if dist < 400 then 
m.ang ...

replace the code with this one

1
2
3
4
5
6
7
8
9
10
11
12
if m.target and player(m.target, 'exists') and player(m.target, 'health') > 0 and 
	not gettile(PLAYERS[m.target].x, PLAYERS[m.target].y).SAFE and 
	not gettile(PLAYERS[m.target].x, PLAYERS[m.target].y).NOMONSTERS then
	xdist, ydist = player(m.target, 'x') - m.x, player(m.target, 'y') - m.y
	local dist = math.sqrt(xdist^2 + ydist^2)
	if dist < 400 then
		m.ang = math.atan2(ydist, xdist)-math.pi/2+math.random(-1, 1)/2
		m.imgang = math.deg(math.atan2(ydist, xdist))+90
	else
		m.target = nil
	end
end

old Re: RPG - Rotate and change image of monsters

Mami Tomoe
User Off Offline

Quote
I found this but I'm afraid to mess stuff up so can you please place it in there properly?

Spoiler >


Thanks
Oh and I only want certain monsters to look at you not all

old Re: RPG - Rotate and change image of monsters

TrialAndError
User Off Offline

Quote
Spoiler >


To make it certain monsters, just add
if m.name == "Insert monster name here" then
before the
m.imgang = math.deg(math.atan2(ydist, xdist))+90

old Re: RPG - Rotate and change image of monsters

Mami Tomoe
User Off Offline

Quote
The rotation code works but everyone look at me
Spoiler >

old Re: RPG - Rotate and change image of monsters

Mami Tomoe
User Off Offline

Quote
Thanks it works I just typed this:
if m.name == "something" or "something else" then

Instead of
1
if m.name == "something" or m.name == "something else" then

One last thing (I hope) can I change a monster's speed somehow?
For example and his health is below half he will be faster and his attack speed will also be faster (like rage)

Basically I need something like:
self.speed
self.atkspeed
That I can change at any time of the battle

Edit:
Found fix
self.atkspd=?
self.spd = ?
edited 1×, last 17.08.16 11:33:26 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview