View unanswered posts | View active topics It is currently Thu Dec 26, 2024 7:54 pm



Reply to topic  [ 10 posts ] 
 Gun Ship MK1 | Documented so you can learn how to do it! 
Author Message
User avatar

Joined: Fri May 15, 2009 5:15 am
Posts: 19
Reply with quote
Post Gun Ship MK1 | Documented so you can learn how to do it!
Well I was searching the other day on the good ol' fan forums for a dropship with a turret on it...But I couldn't find like, any!...So I decided to make one + give a documentary on how it works! This way I am hoping to help get more good mods out there.

So yea, this is just a basic Drop Ship MK1 that shoots rockets out of a point below the ship, this uses no custom sprites because this is simply to teach other how to make gunships.


btw, feel free to give advice cause this is my first time giving a documentary of tutorial of some kind :-(

Edit : OOPS! forgot to say how to fire the rockets :oops: Anyways, press F to fire them.


Attachments:
File comment: Now you too can be a proud owner of a gunship!
GunShip.rte.rar [30.58 KiB]
Downloaded 825 times
Thu Jun 11, 2009 10:20 pm
Profile
Banned
User avatar

Joined: Thu May 14, 2009 9:22 pm
Posts: 826
Location: Lookin' forward to mocking people on Jan 1st 2013.
Reply with quote
Post Re: Gun Ship MK1 | Documented so you can learn how to do it!
BWAHAHAHAHA!
Now, we shall have proper doom-raining machines of death!
All that's left is for someone to make a flippable dropship and we're all set.


Thu Jun 11, 2009 10:34 pm
Profile YIM
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Gun Ship MK1 | Documented so you can learn how to do it!
@above:
See grif's plane
@OP:
That is a lot of documentation.
Should be enough so that people with absolutely no programming background can change it.


Thu Jun 11, 2009 11:08 pm
Profile
User avatar

Joined: Mon Apr 06, 2009 9:41 am
Posts: 712
Location: New York
Reply with quote
Post Re: Gun Ship MK1 | Documented so you can learn how to do it!
Can this go in the template post?


Fri Jun 12, 2009 3:43 am
Profile YIM
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Gun Ship MK1 | Documented so you can learn how to do it!
This is not exactly a module.


Fri Jun 12, 2009 4:36 am
Profile
User avatar

Joined: Wed Feb 27, 2008 4:04 am
Posts: 30
Reply with quote
Post Re: Gun Ship MK1 | Documented so you can learn how to do it!
This is an excellent post. A good idea and a good example of how to do it, along with details on how to do it.

So, since you asked for advice, I will give it.

Your code seems a little inefficient. Your update code is running every frame, which is unnecessary. Only check actors, create rockets, etc when the F key is pressed AND when the timer has reset. It's unnecessary to scan for a new target when you still have a valid target, as well. Just check to see if your current target is valid each frame. You are also running a for loop over every actor twice each frame, which you really do not need. You can get away with running that code once.

I've attached suggested optimizations to the code with new comments on the optimizations for anyone to look at.
Whoever wants to look at this should understand the first piece of code first.

I'm sure there are even further optimizations that could be performed on the code, but that's the nature of programming. :D


Attachments:
GunShipUpdated.rar [1.07 KiB]
Downloaded 223 times
Fri Jun 12, 2009 4:50 pm
Profile
User avatar

Joined: Fri May 15, 2009 5:15 am
Posts: 19
Reply with quote
Post Re: Gun Ship MK1 | Documented so you can learn how to do it!
Hey thanks, I guess I need to learn more coding myself then :P


Fri Jun 12, 2009 5:05 pm
Profile
User avatar

Joined: Wed Feb 27, 2008 4:04 am
Posts: 30
Reply with quote
Post Re: Gun Ship MK1 | Documented so you can learn how to do it!
You still got it to work though, and taught some people more about coding. That deserves at least one Kudos.

That's the real advantage of communities like this, everyone gets to learn from everyone!


Fri Jun 12, 2009 5:48 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Gun Ship MK1 | Documented so you can learn how to do it!
This forum will probably never have a rep system, btw.

Anyway, I've optimized the optimized code even more.

Primarily the conditionals.

Remember, lua has short circuited logic, so put the things that will most likely end the statement's processing first.


Attachments:
File comment: .txt because WJ still has not allowed lua files.
GunShipUpdated.txt [1.95 KiB]
Downloaded 238 times
Fri Jun 12, 2009 7:18 pm
Profile
User avatar

Joined: Wed Feb 27, 2008 4:04 am
Posts: 30
Reply with quote
Post Re: Gun Ship MK1 | Documented so you can learn how to do it!
mail2345 wrote:
Remember, lua has short circuited logic, so put the things that will most likely end the statement's processing first.


True, and good catch.


Sat Jun 13, 2009 6:36 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.087s | 15 Queries | GZIP : Off ]