Turrets -- v1.4 RELEASED [Both Directions!]

Mods, guides how to use and install mods go right in here.
User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 08 Apr 2012, 04:31

IMPORTANT UPDATE! VERY! So, please excuse this.

Image

Win. Got it working!

User avatar
Pyrosaur
Posts: 769
Joined: 03 Feb 2012, 00:15
Contact:

Post » 08 Apr 2012, 04:46

Are you going to replace the laser, or are you using that one? Because they're a lot skinnier than that.

User avatar
idiot9.0
Posts: 1707
Joined: 09 Mar 2012, 10:28
Contact:

Post » 08 Apr 2012, 04:53

Pyr0saur wrote:Are you going to replace the laser, or are you using that one? Because they're a lot skinnier than that.
Exactly what he said. It's great you got it working, but the laser doesn't fit that turret sprite (or any of the other ones that were posted on the previous page for that matter).

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 08 Apr 2012, 04:59

idiot9.0 wrote:
Pyr0saur wrote:Are you going to replace the laser, or are you using that one? Because they're a lot skinnier than that.
Exactly what he said. It's great you got it working, but the laser doesn't fit that turret sprite (or any of the other ones that were posted on the previous page for that matter).
I'll see what I can do. It's the scale that donnit. I'll first let the x value of the laser increase when the turret "sees" you. I wonder how..

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 09 Apr 2012, 17:38

Hey guys, guess what just happened?

Image

Awesomeness. Epic Win.

EDIT: Right now, they aren't dying.. or being picked up. I shall fix this.

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 09 Apr 2012, 21:45

You copied the laser code for the turrets?
This is not going to work.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 09 Apr 2012, 21:53

Maurice wrote:You copied the laser code for the turrets?
This is not going to work.
Not entirely. They slide .. Dunno why. But once I can place them using the edited entities.png then I can fix it.

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 09 Apr 2012, 22:09

They slide because you copied the box code.
No the problem is that the lasers work on a block basis. You'll probably need to use traceline (a function I wrote for you! Hooray) for the turrets.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 09 Apr 2012, 23:24

Maurice wrote:They slide because you copied the box code.
No the problem is that the lasers work on a block basis. You'll probably need to use traceline (a function I wrote for you! Hooray) for the turrets.
........will do. Look I'm just trying my best. So, no offense, you don't have to be a jerk like that.

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 09 Apr 2012, 23:28

He's not being a jerk, he's pointing out what you did wrong and giving you advice on how to fix it. If anything, you're being a jerk here. What else could you ask for?

User avatar
fakeuser
Posts: 135
Joined: 04 Mar 2012, 01:20

Post » 10 Apr 2012, 01:25

Turtle95 wrote:So, no offense, you don't have to be a jerk like that.
He even wrote some code for you... How is that jerkish? And you should not really copy all the lasers code. All you need was the updaterange part. And if I'm correct now you will need only the traceline function

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 10 Apr 2012, 04:14

Camewel wrote:He's not being a jerk, he's pointing out what you did wrong and giving you advice on how to fix it. If anything, you're being a jerk here. What else could you ask for?
I meant that because he was like "hooray" in a rude way.

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 10 Apr 2012, 04:20

Turtle95 wrote:I meant that because he was like "hooray" in a rude way.
Being slightly sarcastic whilst helping someone still makes you helpful. Just because Maurice doesn't have a shining record of helpful behaviour doesn't mean you can instantly assume he's being a dick. That's simply wrong and unfair.

User avatar
jmv3597
Posts: 198
Joined: 03 Feb 2012, 00:43

Post » 10 Apr 2012, 04:34

just calm down guys its not really that important whos calling who names. no one should really ever care about anyone else's opinion about themselves anyway

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 10 Apr 2012, 05:21

jmv3597 wrote:no one should really ever care about anyone else's opinion about themselves anyway
You are the worst judge of yourself possible, you are utterly biased. Therefore, you formulate your opinion on who you are based on what other people have said about you. It's unavoidable human nature.

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 10 Apr 2012, 09:05

I'm sorry I lost all respect from you when you said "firin mah lazor". And then again. And again.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 10 Apr 2012, 17:38

Maurice wrote:I'm sorry I lost all respect from you when you said "firin mah lazor". And then again. And again.
It was twice only. Not doing it anymore. Maurice, you are an awesome person, honestly. I don't want to have you or Saso hate me for any reason. As I said, I'm just trying my best.

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 10 Apr 2012, 22:59

Turtle95 wrote:
Maurice wrote:I'm sorry I lost all respect from you when you said "firin mah lazor". And then again. And again.
It was twice only.
Image

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 10 Apr 2012, 23:04

..Right.

Anywho, I have decided to open doors to anybody who would like to help. Seriously.

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 11 Apr 2012, 02:54

I do like how they work right now. It's a good design choice to make it fit more with Mario's one hit kill thing.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 11 Apr 2012, 03:05

Camewel wrote:I do like how they work right now. It's a good design choice to make it fit more with Mario's one hit kill thing.
It's not one hit kill. But, I am hammering out a few things. Such things are laser deaths and the grabbing.

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 11 Apr 2012, 03:09

You know what I mean, the fact that in Mario, any contact with bad things instantly hurts you, you have no resistance to attacks like in Portal.

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 11 Apr 2012, 03:13

Hey wait no I know what you've done here. You just reskinned a bullet bill as a laser. As much is evident by the fact that bullet bill launchers now fire lasers and that you can jump on lasers.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 11 Apr 2012, 03:18

Camewel wrote:Hey wait no I know what you've done here. You just reskinned a bullet bill as a laser. As much is evident by the fact that bullet bill launchers now fire lasers and that you can jump on lasers.
I have yet to fix it :D

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 11 Apr 2012, 03:24

By the way, the turret's height isn't calibrated properly, so you can jump and land inside the turret and it looks weird.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 11 Apr 2012, 03:25

Camewel wrote:By the way, the turret's height isn't calibrated properly, so you can jump and land inside the turret and it looks weird.
Yep, another thing.

User avatar
fakeuser
Posts: 135
Joined: 04 Mar 2012, 01:20

Post » 11 Apr 2012, 19:32

Turret does not get disabled when tilted and still shoots at Mario. Turret corpse is hostile. There's a bug in your love file - some of the entities are shown as EMPTY in level editor and hitting bricks with head is deadly if there is laser nearby (but not colliding Mario). I like the outcome though

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 11 Apr 2012, 20:09

fakeuser wrote:Turret does not get disabled when tilted and still shoots at Mario. Turret corpse is hostile. There's a bug in your love file - some of the entities are shown as EMPTY in level editor and hitting bricks with head is deadly if there is laser nearby (but not colliding Mario). I like the outcome though
Thx. Idk whats with the blocks doing that. EMPTY was on purpose.

User avatar
fakeuser
Posts: 135
Joined: 04 Mar 2012, 01:20

Post » 11 Apr 2012, 20:22

well I was using the gel overlay enitity... And now it gets displayed as empty in editor (normal in game though)

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 11 Apr 2012, 20:39

fakeuser wrote:well I was using the gel overlay enitity... And now it gets displayed as empty in editor (normal in game though)
Oh.. this entity list must be from some other version of Mari0. Does it still work though? Also, I'm trying to have gel collide with turrets. Any thoughts on that?

User avatar
fakeuser
Posts: 135
Joined: 04 Mar 2012, 01:20

Post » 11 Apr 2012, 21:24

Yes, gel overlay tiles still work as expected and are drawn properly. Even the description in level editor is as it should be. They are only displayed as EMPTY in level editor mode.
For the gel part - well... you could set their y speed to something and shut them down... or something like it.
Just noticed - you have to be kidding... turret.lua and turretL.lua? Haven't you thought about the possibility to just mirror the image? Try

Code: Select all

self.dir, self.animationdirection = "left", "left"
to mirror the image

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 11 Apr 2012, 22:05

fakeuser wrote:Yes, gel overlay tiles still work as expected and are drawn properly. Even the description in level editor is as it should be. They are only displayed as EMPTY in level editor mode.
For the gel part - well... you could set their y speed to something and shut them down... or something like it.
Just noticed - you have to be kidding... turret.lua and turretL.lua? Haven't you thought about the possibility to just mirror the image? Try

Code: Select all

self.dir, self.animationdirection = "left", "left"
to mirror the image
That would help.. alot. Also, I can't pick turrets up unless they have been in the air or rotated.

function mario:pickupturret(turret)
self.pickup = turret
end

Code: Select all

function mario:dropturret()
	self.pickup:dropped()
	
	local set = false
	
	local turretx = self.x+math.sin(-self.pointingangle)*0.3
	local turrety = self.y-math.cos(-self.pointingangle)*0.3
	
	if self.pointingangle < 0 then
		if #checkrect(self.x+self.width, self.y+self.height-14/16, 14/16, 14/16, {"exclude", self.pickup}, true) == 0 then
			self.pickup.x = self.x+self.width
			self.pickup.y = self.y+self.height-14/16
			set = true
		end
	else
		if #checkrect(self.x-12/16, self.y+self.height-14/16, 14/16, 14/16, {"exclude", self.pickup}, true) == 0 then
			self.pickup.x = self.x-12/16
			self.pickup.y = self.y+self.height-14/16
			set = true
		end
	end
	
	if set == false then
		if #checkrect(self.x+self.width, self.y+self.height-14/16, 14/14, 14/16, {"exclude", self.pickup}, true) == 0 then
			self.pickup.x = self.x+self.width
			self.pickup.y = self.y+self.height-14/16
		elseif #checkrect(self.x-12/16, self.y+self.height-14/16, 14/16, 14/16, {"exclude", self.pickup}, true) == 0 then
			self.pickup.x = self.x-12/16
			self.pickup.y = self.y+self.height-14/16
		elseif #checkrect(self.x, self.y+self.height, 14/16, 14/16, {"exclude", self.pickup}, true) == 0 then
			self.pickup.x = self.x
			self.pickup.y = self.y+self.height
		elseif #checkrect(self.x, self.y-14/16, 14/16, 14/16, {"exclude", self.pickup}, true) == 0 then
			self.pickup.x = self.x
			self.pickup.y = self.y-14/16
		else
			self.pickup.x = self.x
			self.pickup.y = self.y + 14/16
		end
	end
	
	for h, u in pairs(emancipationgrills) do
		if u.dir == "hor" then
			if inrange(self.pickup.x+6/16, u.startx-1, u.endx, true) and inrange(u.y-14/16, boxy, self.pickup.y, true) then
				self.pickup:emancipate(h)
			end
		else
			if inrange(self.pickup.y+6/16, u.starty-1, u.endy, true) and inrange(u.x-14/16, boxx, self.pickup.x, true) then
				self.pickup:emancipate(h)
			end
		end
	end
	self.pickup = nil
end

Code: Select all

function mario:use()
	if self.pickup then
		if self.pickup.destroying then
			self.pickup = false
		else
			self:dropbox()
			return
		end
	end
	
	if self.pickup then
		if self.pickup.destroying then
			self.pickup = false
		else
			self:dropturret()
			return
		end
	end
	
	local xcenter = self.x + 6/16 - math.sin(self.pointingangle)*userange
	local ycenter = self.y + 6/16 - math.cos(self.pointingangle)*userange
	
	local col = userect(xcenter-usesquaresize/2, ycenter-usesquaresize/2, usesquaresize, usesquaresize)
	if #col > 0 then
		col[1]:used(self.playernumber)
	end
end

User avatar
fakeuser
Posts: 135
Joined: 04 Mar 2012, 01:20

Post » 11 Apr 2012, 22:18

To pickup a turret only a simple AABB collision logic is used... So my guess is you have not adjusted x, y, width, height of the turret properly. That is most likely correct as Camewell already told you about falling INTO the turret

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 11 Apr 2012, 22:20

fakeuser wrote:To pickup a turret only a simple AABB collision logic is used... So my guess is you have not adjusted x, y, width, height of the turret properly. That is most likely correct as Camewell already told you about falling INTO the turret
It has Turretquad (fixed) and the same update for the parent value.

Code: Select all

function turret:update(dt)

		if time <= 0 then
			playsound(Explode)
			time = 16
		end
		
		
		
		
	self.timer = self.timer + dt
	if self.timer > self.time and self.x > splitxscroll[1] and self.x < splitxscroll[1]+width+2 then
		if self:fire() then
			self.timer = 0
			self:randomtime()
		end
	end
	
	if time <= 0 then
			playsound(Explode)
			time = 16
		end
	
	local friction = boxfrictionair
	if self.falling == false then
		friction = boxfriction
	end
	
	if not self.pushed then
		if self.speedx > 0 then
			self.speedx = self.speedx - friction*dt
			if self.speedx < 0 then
				self.speedx = 0
			end
		else
			self.speedx = self.speedx + friction*dt
			if self.speedx > 0 then
				self.speedx = 0
			end
		end
	else
		self.pushed = false
	end
	
	
	if self.parent then
		local oldx = self.x
		local oldy = self.y
		
		self.x = self.parent.x+math.sin(-self.parent.pointingangle)*0.3
		self.y = self.parent.y-math.cos(-self.parent.pointingangle)*0.3
		
		if self.portaledframe == false then
			for h, u in pairs(emancipationgrills) do
				if u.dir == "hor" then
					if inrange(self.x+6/16, u.startx-1, u.endx, true) and inrange(u.y-14/16, oldy, self.y, true) then
						self:emancipate(h)
					end
				else
					if inrange(self.y+6/16, u.starty-1, u.endy, true) and inrange(u.x-14/16, oldx, self.x, true) then
						self:emancipate(h)
					end
				end
			end
		end
	end
	
	self.userect.x = self.x
	self.userect.y = self.y

	--check if offscreen
	if self.y > 17 then
		self:destroy()
	end
	
	self.portaledframe = false
	
	if self.destroying then
		return true
	else
		return false
	end
	
end

User avatar
Mari0Lu1g1
Posts: 347
Joined: 10 Mar 2012, 12:08

Post » 11 Apr 2012, 23:48

Just asking, can't you make it rapid fire bullets, I can sprite them for you, and the collision against blocks.
It'd be great for Bullet Time!

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 11 Apr 2012, 23:55

Mari0Lu1g1 wrote:Just asking, can't you make it rapid fire bullets, I can sprite them for you, and the collision against blocks.
It'd be great for Bullet Time!
I'm gonna. I just need to fix a few other things :D

User avatar
Mari0Lu1g1
Posts: 347
Joined: 10 Mar 2012, 12:08

Post » 11 Apr 2012, 23:58

Turtle95 wrote:
Mari0Lu1g1 wrote:Just asking, can't you make it rapid fire bullets, I can sprite them for you, and the collision against blocks.
It'd be great for Bullet Time!
I'm gonna. I just need to fix a few other things :D
Great! If you need any help just ask

Also another suggestion:
Some Turrets have the laser except they try to follow you, I know that would require directional sprites. I'd be more then happy to provide them

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 12 Apr 2012, 00:07

Mari0Lu1g1 wrote:
Turtle95 wrote:
Mari0Lu1g1 wrote:Just asking, can't you make it rapid fire bullets, I can sprite them for you, and the collision against blocks.
It'd be great for Bullet Time!
I'm gonna. I just need to fix a few other things :D
Great! If you need any help just ask

Also another suggestion:
Some Turrets have the laser except they try to follow you, I know that would require directional sprites. I'd be more then happy to provide them
Please explain a bit more. Also just made em more rapid, but there's a two second delay after five shots. Is that ok?

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 12 Apr 2012, 00:11

You can make there be no delay. Just open up variables.lua and change maxbulletbills to 100

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 12 Apr 2012, 00:14

Camewel wrote:You can make there be no delay. Just open up variables.lua and change maxbulletbills to 100
HELL YEA!

No. That'd affect bulletbill.lua. I'll just make laserlimit = 100. Then muahaha.. and all..

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 12 Apr 2012, 00:22

Mari0Lu1g1 wrote:
Turtle95 wrote:
Mari0Lu1g1 wrote:Just asking, can't you make it rapid fire bullets, I can sprite them for you, and the collision against blocks.
It'd be great for Bullet Time!
I'm gonna. I just need to fix a few other things :D
Great! If you need any help just ask

Also another suggestion:
Some Turrets have the laser except they try to follow you, I know that would require directional sprites. I'd be more then happy to provide them

How's this?

Image

Leg's aren't good in black BG.. Ah well

EDIT: I'm trying to fix the turrets up a bit. Now, the offset had to be changed (to make Mario stand on them properly) and I changed the #/16 in mario:turretdropped()
to 28/16.

The turret still falls in the floor..

User avatar
fakeuser
Posts: 135
Joined: 04 Mar 2012, 01:20

Post » 12 Apr 2012, 00:55

Your screenshot shows a possible glitch - the topmost turret's laserbeam passes through solid brick.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 12 Apr 2012, 01:21

fakeuser wrote:Your screenshot shows a possible glitch - the topmost turret's laserbeam passes through solid brick.
I'm gonna fix that. I was thinking about that a while ago..

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 12 Apr 2012, 02:22

This has nothing to do with turrets anymore.
It's movable bulletbills.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 12 Apr 2012, 02:24

Maurice wrote:This has nothing to do with turrets anymore.
It's movable bulletbills.
Hey, at least they are turrets. Cut me a bit of slack. I'm at least trying. Better than NOT doing it. No offense, Maurice. It's your game and you don't want turrets anyway.

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 12 Apr 2012, 02:40

Here's some ideas to make this not terrible:
- Loop through every player sorted by distance, call a traceline in the direction of the player (math.atan2 to get the angle). Calculate the distance to the resulting point and the distance to the player (pythagoras), if the player is closer we can assume he is in line of sight. Only do this every X milliseconds though because traceline is heavy on the math. That way we already have the angle and distance (for laser drawing) too.
- Use a seperate graphic for the "arms" so they can rotate
- When having a target, increase timer up until X, when not, decrease it to 0. When the timer is at X, the turret will have adjusted its aim 100% and starts shooting
- Shots should be a new class that are not physics bound. They should carry a payload with their already calculated hitpoint (wall, player, other) and call a function after they reach their target (see portal projectiles)
- Just assume that if abs(speedx) is > Somevalue and the turret is on the ground, it should fall over. There's a handy self.rotation value for that.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 12 Apr 2012, 02:42

Maurice wrote:Here's some ideas:
- Loop through every player sorted by distance, call a traceline in the direction of the player (math.atan2 to get the angle). Calculate the distance to the resulting point and the distance to the player (pythagoras), if the player is closer we can assume he is in line of sight. Only do this every X milliseconds though because traceline is heavy on the math. That way we already have the angle and distance (for laser drawing) too.
- Use a seperate graphic for the "arms" so they can rotate
- When having a target, increase timer up until X, when not, decrease it to 0. When the timer is at X, the turret will have adjusted its aim 100% and starts shooting
- Just assume that if abs(speedx) is > Somevalue and the turret is on the ground, it should fall over. There's a handy self.rotation value for that.
Sure, I'll do that. But I'm kinda in the middle of fixing picking up these turrets. They only pick up after being portaled..

Also, how shall I go about finding the player's X and Y.

I could make a getX() and getY() in mario.lua .. no wait.. thinking java..

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 12 Apr 2012, 02:46

What on earth do you mean "how do I go about finding the player's X and Y" they're stored in variables that you can easily access.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 12 Apr 2012, 02:47

Camewel wrote:What on earth do you mean "how do I go about finding the player's X and Y" they're stored in variables that you can easily access.
Isn't that if it's in mario.lua? Uh.. Lemme think here..

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 12 Apr 2012, 03:06

Turtle95 wrote:I could make a getX() and getY() in mario.lua .. no wait.. thinking java..
Thinking encapsulation.

Locked