[Script] Hive Shield v1.20 (10/10/2011)

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
BinaryBoy
Posts: 78
Joined: Tue, 14. Oct 08, 19:43
x3tc

[Script] Hive Shield v1.20 (10/10/2011)

Post by BinaryBoy » Fri, 19. Nov 10, 05:21

Hive Shield

Hive Shield v1.20 Image

Introduction
---
In version 1.20, I moved away from the inital idea of all ships supporting each other, and more towards the Shield Ship Idea, greatly increasing the scripts performace and away from working passively, using the command console instead.

Mechanics
---
you will need an M1, M2 or M7 with special command software MK1 installed in order to use Hive Shield.

Hive shield only works on ships that are within 5Km of Ships designated as Hive Shield Ships, for any ship that's within range of the Shield Ship, those ships get 5% of the value of the ships shields energy (shield energy that is available, not max shield capacity). However, the Shield ship has to hold position in order to activate the Shield ship effect.

overcharge modes will improve the Hive Shield Ship effect but will constantly leech shield energy, overcharge modes can either provided an extended range of 15Km, an doubled regen rate or an increased regen amount of 8%.

V1.20
No longer an AL Plugin, instead it's activated via Command console
reduced effected ships to selected 'Shield Ships'
Hive shield ships will provide a bigger boost in regen to other ships than before
Overcharge modes added

v1.10
Reduced effected ships to player owned ships only
excluded docked ships from being effected
range increased to 5Km
a few other minor improvements.

if you prefered the previous version of Hive shield instead (1.10v), it's still downloadable here

Command slot used <t id="546">COMMAND_TYPE_SPECIAL_46</t>
Last edited by BinaryBoy on Mon, 10. Oct 11, 18:29, edited 5 times in total.

User avatar
Ikaruga
Posts: 372
Joined: Fri, 30. Jan 04, 15:26
x3tc

Post by Ikaruga » Fri, 19. Nov 10, 09:45

Good idea ! Reminds me a ship from the XTM mod for Reunion called the Custodian : she had the ability to take shield damages instead of the ships around her.

However, you might want to increase the distance because 1km is a bit short and collision avoidance script/ships crashes will happen before a friendly ship reaches this distance. Even longer before with capital ships.

I suggest you change it to be 5 km.
If brute force doesn't solve your problems, then you aren't using enough

User avatar
BinaryBoy
Posts: 78
Joined: Tue, 14. Oct 08, 19:43
x3tc

Post by BinaryBoy » Fri, 19. Nov 10, 16:45

I'll make the distance changes from 1Km to 5Km in the next version, for the time being, I've provided a small patch if you want it to be 5Km now.

just replace the events script file with the one from the provided zip according to which one you installed.

Sector Version 5Km Patch
Last edited by BinaryBoy on Sat, 27. Nov 10, 21:08, edited 1 time in total.

Triaxx2
Posts: 7217
Joined: Tue, 29. Dec 09, 03:15
x4

Post by Triaxx2 » Fri, 19. Nov 10, 17:00

This is awesome. I was expecting something like clusters set to use shields equal to all the ships in it, but this is just awesome.

I think 5km is a better number. Unless you can make it scale with ship size. Since fighters inside of 1k are fine, but carriers and destroyers that close aren't really a good idea.

Bobucles
Posts: 2252
Joined: Fri, 25. Dec 09, 04:56
x3tc

Post by Bobucles » Fri, 19. Nov 10, 17:10

2% of those ships shields energy (shield energy that is available, not max shield capacity) is added to that ship
What does this mean??? :?

User avatar
Ikaruga
Posts: 372
Joined: Fri, 30. Jan 04, 15:26
x3tc

Post by Ikaruga » Fri, 19. Nov 10, 17:57

If I guessed correctly, when a ship equipped with this device gets hit, it takes shield battery from the friendly ships 1 km around instead of its own, but not more than 2 % of the other ship ...

Example : a fighter has 25 MJ and lost 5 MJ in a fight, it gets close to a corvette which has 100 MJ, the fighter will insta reload 100 * 0.02 = 2 MJ from the corvette.

Can BinaryBoy confirm this please ?

And thanks for the new version, by the way ! Glad I could help 8)
If brute force doesn't solve your problems, then you aren't using enough

User avatar
BinaryBoy
Posts: 78
Joined: Tue, 14. Oct 08, 19:43
x3tc

Post by BinaryBoy » Fri, 19. Nov 10, 18:39

It adds a boost to shield regeneration, but doesn't subtract shield energy from other ships

the script gets a list of all ships that are close to each ship in the sector, it then gets the value of available shield energy and calculates what 2% of that value is. the script then uses that number and adds that number to the current ships shield value.

it does this every 10 seconds

the example you gave sounds about right.

User avatar
BinaryBoy
Posts: 78
Joined: Tue, 14. Oct 08, 19:43
x3tc

Post by BinaryBoy » Fri, 19. Nov 10, 18:41

to explain what happens with the script better, I've prepared a scenario and diagram for reference

Image

say there are several ships, which are numbered 1 to 5 from left to right, range is shown in kilometres at the top, and shields are shown in megajoules at the bottom

Ship 1 is an M2, with 8000MJ of shield energy available and is already at full shields, so no regeneration for ship 1 is needed.

Ship 2 is an M3, and has 60 out of 75 shield energy available, and since it's within range of ship 1, which has better shields so ship 2 will get a significant regeneration effect. Ship 2 is also within range of ships 3 and 4.

Ship 2 cap is 20% of 75 = 15
get 2% shield value from other ships
S1 (160) + S3 (1.2) + S4 (0.2) = 161.4

Ship 3 is within range of ships 2 4 and 5

S2 (1.1) + S4 (0.2) + S5 (1.5) = 2.8

Ship 4 is within range of ships 2 3 and 5, which is the same number of ships and same type of ships as the last ship we calculated, but actually gets a better regeneration effect since there's a larger amount of shield energy available.

S2 (1.1) + S3 (1.2) + S5 (1.5) = 3.8

Ship 5 has full shields already, so it is ignored and receives no regeneration effect

lamoyja
Posts: 121
Joined: Wed, 9. Dec 09, 05:53
x3tc

Post by lamoyja » Thu, 25. Nov 10, 03:49

Love the idea.

Think there's alot of room for ideas from this one. Shield ships,etc...

User avatar
Alex Corvis
Posts: 1296
Joined: Fri, 29. Dec 06, 22:30
x4

Post by Alex Corvis » Fri, 26. Nov 10, 10:50

What about docked ships? Will there be a boost to a M7's shields if there are many ships docked? or does it only work with ships in ships?

A. Corvis

User avatar
BinaryBoy
Posts: 78
Joined: Tue, 14. Oct 08, 19:43
x3tc

Post by BinaryBoy » Fri, 26. Nov 10, 21:24

Hive shield currently doesn't distinguish between docked and flying ships, although that may change in a later version to flying only.

User avatar
Litcube
Posts: 4245
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Sat, 27. Nov 10, 03:44

Mother of God. This is a neverending 15 ms loop. You're going to get AL pileups, which are null run scripts of the main event. Some games have 3,000 - 5,000 ships in the Universe on average. 15 ms isn't actually a 15 ms wait. Depending on the number of scripts being run, this could be about 100 - 200 ms. Your script will not complete in time to run its second instance of the AL event within 10 seconds.

Rough math, it'll take 10 - 15 mins to complete one full loop on a Universe scale. Check your global scripts. See if there's a few running on the null stack.

Also, 10 seconds will have no effect 1/3 of the time on a Universal scope. The ships themselves are only updated once every 30 seconds. I'd stick with the sector only version. Even then, looping through every ship every 10 seconds is a costly thing.

User avatar
BinaryBoy
Posts: 78
Joined: Tue, 14. Oct 08, 19:43
x3tc

Post by BinaryBoy » Sat, 27. Nov 10, 21:05

thanks for the info, I'll stick to a sector wide version from now on. The sector wide script should be ok to run without a wait command added.
Last edited by BinaryBoy on Sat, 27. Nov 10, 23:57, edited 1 time in total.

User avatar
Litcube
Posts: 4245
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Sat, 27. Nov 10, 21:10

Your loop is what is refered to as n². If the current sector has 80 ships, your new script is going to run through that 6,400 times before any other script can take hold of the engine. And it'll do this every 10 seconds. :D

User avatar
BinaryBoy
Posts: 78
Joined: Tue, 14. Oct 08, 19:43
x3tc

Post by BinaryBoy » Sat, 27. Nov 10, 21:19

So should I keep some wait to avoid tying up the engine when it's run?

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”