Ship rotation mod idea.

A place to discuss mods in development and concepts for new mods.
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Someone somewhere on the forum requested a mod which would allow you to get the playership to point due N,S, E and W. (h/t to that poster). I think the idea was to make it MUCH easier to take long range shots with fixed weapons. Trying to set up one of the more manoeuvrable ships pointing in one exact direction can be a bit of a nightmare with the 120 facings now used.

I like the idea and am willing to have a go at the mod but have no idea which commands or functions control ship rotation. Can anyone point me in the right direction here?. I'm assuming this mod is actually possible.

I'm thinking of a scrAddAction to the Ship's Interior dockscreen where you select 'P'oint and you can then select N, S, E or W. Or where 'P'oint rotates the ship to the nearest cardinal point. Something like that. TIA.

Edit: I will never, ever, ever, even if I live to be 500 years old, be able to spell manoeuruve
Last edited by relanat on Tue Feb 23, 2016 2:36 am, edited 2 times in total.
Stupid code. Do what I want, not what I typed in!
User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

relanat wrote:I like the idea and am willing to have a go at the mod but have no idea which commands or functions control ship rotation. Can anyone point me in the right direction here?. I'm assuming this mod is actually possible.
 Try something like this:

Code: Select all

(objSetProperty theObj 'rotation theDirection)
 …Where “theObj” is probably going to be gSource or gPlayerShip, and “theDirection” will be either 0,90,180,or 270.
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Thank you. Much appreciated. It's so easy when you know how! :)
Stupid code. Do what I want, not what I typed in!
marsrocks
Commonwealth Pilot
Commonwealth Pilot
Posts: 55
Joined: Fri Nov 05, 2010 6:29 pm

This sounds like a neat idea.

Instead of a dockscreen solution though, why not have a special missile weapon that does this for you?

With the anglefinder missile launcher installed - you simply target the object [T]- fire the weapon [shift key] -
and the missile launcher brings your ship about to face the target exactly and stops the ship on that point.

Then you simply fire the selected weapon [ctrl], once you have fully come about and are stopped, directly facing the selected target.
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

marsrocks wrote:Instead of a dockscreen solution though, why not have a special missile weapon that does this for you?

With the anglefinder missile launcher installed - you simply target the object [T]- fire the weapon [shift key] -
and the missile launcher brings your ship about to face the target exactly and stops the ship on that point.

Then you simply fire the selected weapon [ctrl], once you have fully come about and are stopped, directly facing the selected target.
That sounds useful, though it would require a lot of overwriting to make all the launchers in the game do this.

What about a slotless device that would make your ship turn to face whatever target is selected? It could have an invoke key to prevent having to go through a dockscreen.
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Here's a basic version for 1.7a1a. The turning of the ship is instantaneous which I don't like. Eventually, when I work it out, the ship will turn as you watch it.

The dockscreen gives 2 versions of direction. North,South,East,West and top, bottom, left, right. I want to cut that down to one or the other and would appreciate any feedback about which one seems better.

I'm also working on a version where you press 'P' in the Ship's Interior dockscreen and the ship turns to the nearest cardinal point. So put the ship pointing between NW and NE and it will rotate to N, between NW and SW and it will rotate to W, etc. Once I work out the leq and geq stuff that should be a better way, I think.

Thanks again, AP. Also TransGeek and Betelgeuse for their much referred to posts. And PM, Arkheias, JBW plus heaps of others whose code I crawled through.

================
Great ideas, marsrocks and gunship. Go for it. I'm only doing it this way because I can manage the code (with AP's help). Plus I'm a howitzer lover, so this works for me. The more mods the better.
Attachments
EasyShipPointingWithDockscreen.xml
(5.43 KiB) Downloaded 201 times
Stupid code. Do what I want, not what I typed in!
User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

 I might could give a bit of direction (Ker-pun!) for turning the ship gradually. I’m not nearly coherent figure out the full code right now, but something involving sysAddTypeRecurringTimerEvent to turn the ship by increments on each tick would probably do the trick, canceling the event once you get to the desired direction (or, probably, if the next turn would take you past the desired direction). Getting the number of degrees to turn on each tick is the fun part, especially since some of the older playerships don’t have 120 facings, but it’s doable (and somewhat frighteningly, I am coherent enough to figure this part out on the fly):

Code: Select all

(block (shipFacingHeight shipGraphicHeight shipFacings shipDegreesPerFacing)
  (setq shipFacingHeight (@ (shpGetImageDesc gPlayerShip 91) 4))                      ; This will get the height of each facing.
  (setq shipFacingsMax (add (@ (shpGetImageDesc gPlayerShip 91) 2) shipFacingHeight)) ; At 91°, your ship is on its bottom facing.  Add one facing height to get the total graphic height.
  (setq shipFacings (divide shipFacingsMax shipFacingHeight))                         ; Total height / facing height = facing count
  (setq shipDegreesPerFacing (divide 360 shipFacings))                                ; 360 / facing count = degrees per facing
)
 You’d also need to figure out if it would be quicker to turn clockwise or counterclockwise, keeping in mind that you may have to deal with going over 360 or under 0. If you have trouble working it out, let me know and I’ll try to kludge something together that you can tack onto the mod.
 …Also, I personally prefer North, South, East, and West, just to cast my vote.
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)
marsrocks
Commonwealth Pilot
Commonwealth Pilot
Posts: 55
Joined: Fri Nov 05, 2010 6:29 pm

Good job, relanat!

I was thinking my idea would be easier, using a disposable self-installable device in the missile launcher slot, but now I'm not so sure.

For one thing, I thought I could just use (objgettarget gplayership) to help get the angle/direction I need, but I now realize I know nothing about finding vectors.

What would the code be for "theDirection" to turn the player ship to face the target object?

(objSetProperty gPlayership 'rotation theDirection)
marsrocks
Commonwealth Pilot
Commonwealth Pilot
Posts: 55
Joined: Fri Nov 05, 2010 6:29 pm

Here we go. I found the solution already worked out in Cygnus' excalibur targeting rom.

This is the critical code:

(setq angle
(sysCalcFireSolution (sysVectorSubtract (objGetPos (objGetTarget gPlayerShip)) (objGetPos gPlayerShip)) (sysVectorSubtract (objGetVel (objGetTarget gPlayerShip)) (objGetVel gPlayerShip)) (typGetDataField (itmGetType (objGetProperty gPlayerShip 'selectedWeapon)) "speed")))


(objSetProperty gplayership 'rotation angle)


http://forums.kronosaur.com/viewtopic.p ... it=vectors

http://xelerus.de/index.php?s=mod&id=1230&d=1
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Excellent, excellent, excellent. Thanks, AP. I was thinking I would need some sort of looping function to move the ship in tiny increments and you have explained it beautifully (although I was hoping for a shpTurnTheShipToTheDirectionIWantWhileIWatch function :lol: ). And you comments after the code are great. This is what I like. Getting the info I need but not getting the code given to me. I'm off to give the xelerus functionlist a workout!
======================

I really like your idea, marsrocks. Thinking about it I figured something like a ROM that would enhance a launcher to do that. If you target the enemy and press 'Shift' then the enhanced launcher would turn the ship until it points at the enemy and fire. Great.
Maybe only have this happen when the ship is stationary beacuse otherwise you may not be able to fly your ship when the launcher is doing its stuff. Yeah, otherwise when you are dogfighting you may need to manually fire the missiles by dead reckoning. And if you can use it while moving it becomes more or less an omni launcher. And an override would be a good idea too (picture an angry Phobos bearing down on you and you can't do anything because the launcher is still turning your ship... Yikes!)
Advantages are you don't need a device slot (good thinking, gunship), you need to enhance every launcher you want to use rather than having a total enhancement of every launcher and if you haven't got the enhancement then no probs because the launcher still works.

And thanks for the links to Cygnus' stuff. I was just about to rush off to xelerus when I read the first line of your post when I saw the links at the bottom. Much easier.
Stupid code. Do what I want, not what I typed in!
marsrocks
Commonwealth Pilot
Commonwealth Pilot
Posts: 55
Joined: Fri Nov 05, 2010 6:29 pm

relanat, I have now tested out my idea - and it turns out to be a Godmod-like thing. Just press [T] target - shift - control - and it makes any weapon on your ship kind of like an omni weapon.

It is a disposable launcher which does not shoot missiles - it just turns your ship, so that you can fire another weapon.

A simple mining laser with this installed is deadly, as you never miss. And it turns out you can just hold down shift and control at the same time (you just have to change targets).

And it actually works well if you are moving and shooting at moving targets.

I'm going to have to find a way to slow it down or release it as a godmod device.

I'm thinking of adding a delay to it - before it turns the ship. This is way too powerful.

I may wait and see what you do with AP's slow turning idea.
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

:lol: :lol: :lol:
Here's a post I wrote offline last night. The main thing is to remember that I get there in the end (and it might help if you type slower so I can understand things better :lol: ).

=================
OK, OK, wait, I get it, marsrocks. You weren't talking about a launcher, just using the launcher slot and controls :oops: (hey, I got there in the end, it just took a while....a long while! :lol:).
So something like a Targeting and Ship Rotation device that you could use again and again once you had manually installed it like a DM600 missile pod. And it wouldn't need to be at 90 degrees to the target either. Yes, great idea.

Or some sort of slotless device that you could 'U'se. Or a ROM you could use multiple times. Nice.

=================
Back to the present; I was thinking, after I worked out what you meant, that you would need to tone it down. Otherwise it would be pretty much an omni weapon equivalent. Possibly you could only use the device when your ship was stationary, or only when the target and your ship are stationary. That would limit it to stations only though unless an enemy ship was docked. Or limit it so that it could only hit ships travelling in a straight line.


And, er, I wouldn't wait around for me to get code working :shock: . I can't write it very well yet. I've been working on some mods for over a year! All my stuff has been other people's code either copied or slightly modified and I've been greatly assisted by tutorial posts and mods. Working this out will take me hours of trying to work out what the xelerus functionlist entries mean along with dissecting examples in other people's code and making slight changes to see what happens. It's very time consuming but you also learn a lot. And please put up your idea so we can download it. I like a Godmod as much as the next person (die, alien scum, die.....insert evil laugh) and I like looking at other people's code.
Stupid code. Do what I want, not what I typed in!
User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

It should be noted that the function list on Xelerus is outdated (and, unfortunately, unable to be updated). While it's great if you only need functions that have ben around since 1.1 or so, a fair number of the funcions there are actually deprecated now. You may want to stop by the Modding Reference forum and look at the function list posted by digdug. I would give you a link, myself, but I'm currently at a convention on a crummy little tablet that doesn't support copypasta.
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Here it is!

https://forums.kronosaur.com/viewtopic.php?f=8&t=7567

Unfortunately, the useful descriptions on Xelerus are not there for the newer functions. I've been using Notepad++ to do multi-file searches to see how other people have used those functions so I can learn based on context.
marsrocks
Commonwealth Pilot
Commonwealth Pilot
Posts: 55
Joined: Fri Nov 05, 2010 6:29 pm

Hey guys,

Here is my first version:
"X-ray scope"

http://www.xelerus.de/index.php?s=mod&id=1510

I went ahead and toned it down to make it a more balanced item rather than a godmod.

It now only has 200 charges (so you can only use it 200 times).

Also, I delayed the rotation - so that it doesn't rotate to face the target until 30 ticks have passed, making it only useful for stationary targets.

To test it, I just add it to extensions, and then go grab one out of a Santa Box - under Q for launchers:

http://www.xelerus.de/index.php?s=mod&id=1358

To make it back into a godmod - you can just change the number of charges to 2000, and in the oncreate - change the targetnow timer to occur in 1 tick instead of 30.
Post Reply