Right now, shield devices come with the following three events:
<GetMaxHP>
<OnShieldDamage>
<OnShieldDown>
It would be very helpfull to have a <GetRegenHP> event (fired every 30 ticks or so), as to allow for the creation of shields with a dynamic regen rate.
The other method would be to add a 'regenBonusPerCharge=' attribute for shield generators using charges, but I think the event would be more flexible
Just imagining a large HP shield with increasing regeneration proportionate to how much damage it has sustained "(the missing percentage of it's maximum HP) Per X seconds"
So a kaidun shield with 400HP would regenerate 400 HP/X sec.
but one with 600 HP would regenerate 200 HP/X sec.
And a shield with 50 HP would regenerate 750 HP/X sec.
That would make enhancement of such shields insanely powerful
(func(Admin Response)= true){
if(admin func(amiable) = true)
Create func(Helpful Posts)
else func(Keep Calm and Post derisive topics)}
I was not aware of the mod you link to. I did something like that myself and it resulted in this request.
Betelgeuse's proof of concept has two issues that both show that dynamic shield regeneration rates are not really supported:
The regeneration is not smooth, but rather bursts of regen every 30 seconds (due to the use of the <onUpdate> event).
The shield generators description will indicate that the shield does not regenerate; hardly a quality that would make me buy one.
1. Doesn't onUpdate activates every 30 ticks? (That's like, just about a second if I'm not mistaken)
2. You can say it in the description, that the shield regenerates with special technique or something.
Yes, look at my avatar, I have a wyvera type ship.
my mistake, I meant to say '30 ticks'. And yes, I could write about the special properties it in the description.
However, it would make things way more polished. and accessible to the casual modder, if the requested event was to be supported.
It would also make things more polished if it was possible to do a custom stat line. For this you'd just want to say "regen variable" or something similar. For weapons using scripted projectiles you'd want multiple damage entries or a damage entry with multiple type icons or somesuch. For the Rasiermesser powered armors and duralloy and similar you'd want a regen entry even though armor doesn't normally have one. For stuff like patcher arms and patch spiders you might want to put a regen entry as well.
@ pixelfck
Is it possible for you to run a scripted event every, say, 3 ticks and gather your variable regeneration through increased fine granularity regenerations? (Or would that just create massive lag?)
(func(Admin Response)= true){
if(admin func(amiable) = true)
Create func(Helpful Posts)
else func(Keep Calm and Post derisive topics)}
@FourFire: I tried it (with recurring- and single event timers) but it turns out that the gSource and/or gItem variables are not set for events triggered by a timer. So that pretty much ruled out that solution.
But even if it did work, it would be more complicated that it may first seem. The engine works with whole number only, the regenerated HP per tick vary, even for a static regeneration rate.
Also, running complex code every tick would put quite a strain on the engine; even more more than one ship (enemies for example) could have the ship equipped.
Happily there is only one shield per ship so you can use objsetdata/objgetdata to store and retrieve the ship's objectID on whatever object your timer is running on. You can also store a counter to count off each timer iteration to handle fractions. Eg. a shield with a 6 2/3 regen per tick would regen 6 on the first iteration, 7 on the second and third, and reset the timer to the start on the fourth.
<ItemType UNID="&Timer;"
name= "Timer1"
level= "5"
value= "2500"
mass= "3000"
frequency= "uncommon"
modifiers= "MajorItem; NAMI"
description= "This device will execute the <OnFireWeapon> event in itTimerEvent once every tick."
>
<Image imageID="&rsItems1;" imageX="0" imageY="192" imageWidth="96" imageHeight="96"/>
<AutoDefenseDevice
targetCriteria= "G N:10000"
weapon= "&itTimerEvent;"
fireRate= "1"
/> <!-- fireRate controls how often the recurring event should fire, 1 or 2 = 30 times per second, 3 = 15/s, 5 = 10/s, 15 = 6/s, etc. Default target criteria is when a gate is within 10k ls, which means it will almost always trigger, and weaponDevice is a special dummy weaponDevice that only includes the code to be executed and some additional parameters -->
<Events>
<OnInstall>
Nil
</OnInstall>
</Events>
</ItemType>
<ItemType UNID="&itTimerEvent;"
name= "Timer Event"
level= "5"
value= "2500"
mass= "3000"
frequency= "notrandom"
modifiers= "MajorItem; NAMI"
description= "When fired and only when fired from an AutoDefenceDevice or the weapon fire button, this weapon device executes the code placed under its <OnFireWeapon> event."
>
<Image imageID="&rsItems1;" imageX="96" imageY="0" imageWidth="96" imageHeight="96"/>
<Weapon
type= "missile"
damage= "generic:0"
fireRate= "15"
powerUse= "100"
sound= "&snRecoillessCannon;"
> <!-- powerUse controls the amount of power consumed by the timer device, fireRate is only used if this device is installed separately from the timer, and sound will play every cycle, other keys have no function -->
</Weapon>
<Events>
<OnFireWeapon>
<!-- repeating code here -->
</OnFireWeapon>
</Events>
</ItemType>
This does not require a new station per system, instead, the timing control device stays on the spaceObject once installed. <checkTarg> can be transferred to <OnFireWeapon> with no or minimum modification.
This provides gSource, and is the recommended timer method since it localized to a single spaceObject. This can serve as the regen'er for the shield with fairly easily.
Fiction is reality, simplified for mass consumption.
PGP: 0x940707ED, 5DB8 4CB4 1EF5 E987 18A0 CD99 3554 3C13 9407 07ED
Bitcoin: 1LLDr7pnZDjXVT5mMDrkqRKkAPByPCQiXQ
@Atarlost: Timer Events cannot be put on items, only on objects or types. So the easy solution is out.
@TVR: I'm looking for engine support, making dynamic shield regeneration rates something to play with of everybody.
I'm sure I can come up with code that eventually does what I would like it to do, but in my opinion, it is a horrible solution not very elegant to have a virtual weapon trigger the <OnFireWeapon>-event once every tick, in order to run code that hooks into the shield generator and checks if we need to do some recharging.
All in all, I'm surprised that this feature request has triggered a people into providing all sorts of arguments why it would not be required.
pixelfck wrote:@Atarlost: Timer Events cannot be put on items, only on objects or types. So the easy solution is out.
Common practice is to use a virtual station to hold timer events. I think you can actually get away with only one type per mod no matter how many timers you need, though you'll need one instance per timer instance.