Targetting subents
Moderators: winston, another_commander
- CommonSenseOTB
- ---- E L I T E ----
- Posts: 1397
- Joined: Wed May 04, 2011 10:42 am
- Location: Saskatchewan, Canada
Targetting subents
Is there a way through script or AI to have NPC's target a subent of the player ship or of other NPC's instead of the main entity so they would effectively ignore the main entity to attack the subent(s) only?
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.
CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
Re: Targetting subents
Not to my knowledge, no.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
Re: Targetting subents
Sorry, I hadn't noticed this one at the time!
I take it you've already tried this snippet inside your NPC js script:
I haven't actually looked into this at all, but I'd have thought there's nothing in trunk (and in 1.75.3) to stop it from working...
I take it you've already tried this snippet inside your NPC js script:
Code: Select all
this.shipTargetAcquired = function(targetShip){
if(targetShip.subEntities.length > 0) this.ship.target = targetShip.subEntities[0];
}
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Targetting subents
I remember looking in the code and noticed that the code always makes sure it is not targeting subEnts. It selects the mother when tried.Kaks wrote:I haven't actually looked into this at all, but I'd have thought there's nothing in trunk (and in 1.75.3) to stop it from working...
UPS-Courier & DeepSpacePirates & others at the box and some older versions
Re: Targetting subents
Ok, then all you can do is to specifically override the targetted ship's takingDamage, to transfer all the damage to one of its subentities. Technically it's not the same, but hey, as long as you don't tell anybody...
Something along these lines:
Shouldn't be too far from working ok: as long as it's got at least a subent, any hit from 'thatSpecificShip' is going to damage the first subent. Once all subents are gone it'll behave exactly as before!
The extra stuff in the script is to take into account NPC shields & the like. If you don't care about that, then things should get simpler.
NB: the keyword this should refer to different things depending on the context, that's why I used player to transfer the original this.ship value inside the function. To be 'proper' I should have used closures instead, but that could have meant a bit of a longer explanation...
Anyway, hope this goes some way towards helping you make your ideas reality!
Something along these lines:
Code: Select all
this.ship.target.script.oldDamageEvent = this.ship.target.script.shipTakingDamage
player.thatSpecificShip = this.ship;
this.ship.target.script.shipTakingDamage = function(amount, whom, type)
{
if(whom.isValid && whom == player.thatSpecificShip && this.ship.subEntities.length > 0){
// they're targetting subents!!!
this.ship.energy += amount;
this.ship.subEntities[0].energy -= amount;
}
else if (this.oldDamageEvent) this.oldDamageEvent();
}
The extra stuff in the script is to take into account NPC shields & the like. If you don't care about that, then things should get simpler.
NB: the keyword this should refer to different things depending on the context, that's why I used player to transfer the original this.ship value inside the function. To be 'proper' I should have used closures instead, but that could have meant a bit of a longer explanation...
Anyway, hope this goes some way towards helping you make your ideas reality!
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- CommonSenseOTB
- ---- E L I T E ----
- Posts: 1397
- Joined: Wed May 04, 2011 10:42 am
- Location: Saskatchewan, Canada
Re: Targetting subents
Thanx Kaks. That should help tremendously down the road.
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.
CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs