* After adding friendly-fire avoidance back in, I sometimes get a muzzle flash but no shot coming out. It doesn't happen very often, and there are no friendly ships within the 20ls radius that I'm using to check for friendly ships and stations. I don't think it's trying to fire on friendlies and then deleting the shots while leaving the muzzle flash behind (the original problem that George may have seen on the stream). I need to play through the mod some more to figure out what's going on.

* The mod correctly remembers which ships is being escorted within a game session, but it still forgets this information if I save and re-open a game.

If I can't figure out what's causing the muzzle flash within a week or so, I'll go ahead and release the alpha.

I've gone back and forth a few times over how friendly fire avoidance should work. I believe the purpose of turning it off should be as a defense against "friendly" but angry ships that are shooting at you.

Under this assumption, even if friendly fire avoidance is on, ICX devices should target angry ships' beams and missiles without targeting the ships themselves. If friendly fire avoidance is off, ICX devices should target the angry ships as well without targeting ships that are truly friendly.

It looks like I have the code doing what is described in the paragraph above. I'm going to modify the settings text from "Allow Friendly Fire" to "Shoot at Angry Ships". After that, I have to update the old PDmod's Longreach and ammo-based devices so they use the new friendly-fire avoidance code.

Another change: It's now possible for a modder creating a new ICX device to specify the criteria to be used for friendly fire avoidance. For example, "sTF N:20 S:D" means to avoid hitting friendly ships and stations within 20 ls.

The next step is to test the mod in actual gameplay to make sure nothing else is broken. (I still haven't figured out what's causing the two bugs mentioned in the previous post, either.)

EDIT: The bug where the ICX fires at the playerhip's own shots has reappeared. It also sometimes (rarely) shoots at friendly ships. I need to work on the friendly fire filters.

EDIT #2: After further testing, I believe the ICX devices are firing on friendly freighters because they're associated with an angry Black Market station. This only happens when the "Fire at Angry Friendlies" setting is ON.

Also: I have a filter that keeps ICX devices from firing at the shots from the player's main weapon, but if more than one ICX device is installed, they'll sometimes send shots at the same time toward some point exactly due east of the ship's position. If the devices are disabled until only one is active, this behavior stops. This behavior happens regardless of whether "Fire at Angry Friendlies" is ON. The stream of eastward-bound shots can hit friendly stations, so FF avoidance appears to not be working in the case of this bug.

It turns out that ICX devices are only shooting at friendly freighters when "Fire at Angry Friendlies" is ON *and* the freighters are associated with an angry station, such as an annoyed Black Market station. This isn't a bug so much as it is an annoyance, since the game doesn't give any indication that the freighters are angry, and they don't shoot back.

As for the ICX devices shooting at the player's own shots: I believe they are actually shooting each other's shots. The bug doesn't appear when only one ICX devices is active. I tried to fix the bug by making sure the target is angry and that it's not from the same sovereign as gSource, but the bug didn't go away.

This major problem because friendly-fire avoidance seems to break: the stream of shots from ICX's targeting each other actually hits friendly stations.

Because of that bug, I'm removing the ability for auto-defense to target friendly-but-angry missiles, at least for now.

With the major bugs dealt with, I need to do some more testing and then port the new code over to the original PDmod devices.

Red ships
Missiles and beams fired by red ships
Green, angry ships
(This is a weird one) Green ships that are NOT angry but that are called in as reinforcements by an angry station (freighters called in by annoyed Black Market stations)

It does NOT target:
Green, not-angry ships, with the exception noted above
Missiles and beams fired by green, angry ships

If I get rid of the 'Y', I'm able to target missiles and beams fired by green, angry ships. I then have to manually filter the shots; otherwise, green, friendly ships get targeted:

Targets:
All ships, green or red, angry or not
Missiles and beams from red ships
Missiles and beams from green ships ONLY if the ships are angry

It does NOT target:
Missiles and beams from green-but-friendly ships

The really weird thing is that I get shots fired sideways (that's a zero degree angle in Transcendence, right?), and the friendly-fire avoidance checks aren't functioning in the case of those buggy shots ONLY. The buggy shots are hitting friendly stations.

That suggests to me that the bug is actually not in my new criteria or my new detection code, but in the original PDmod code that uses sysCreateWeaponFire and that somehow that function is being triggered accidentally. The bug is supressed if 'E' or 'Y' are used, so it wasn't noticeable before.

and then setting my targeting criteria to "bsm -H N:20" gets rid of the bug. It might do so by bypassing the code that's causing the seemingly accidental point-defense firing, since friendly-fire avoidance is coded to use (if) statements to avoid calling sysCreateWeaponFire.

EDIT #2: Unfortunately, this fix DOES make point-defense less effective because only one shot at a time can be fired at any target. I'm choosing not to use the fix because it basically cripples point-defense.

EDIT #3: Using "bsm -H -J N:20" seems no different than "bsm -H N:20". Using "bsm -H -J:&svPlayer; N:20" causes ICX shots to fly off at large angles, most of them aiming at seemingly nothing.

EDIT #4: For some reason, Ferians show up as angry friendlies. In order to prevent ICX devices from firing on Ferians, any targets that are mining are kept on the friendly-fire avoidance list.

Since the last post, I've added an RPC suggestion: a level 4 device with rapid fire and some inaccuracy (the RPCX kinetic defense turret).

The Longreach concept works pretty well: take an obsolete damage type that has lots of DPS for its level and shoot down missiles. For the endgame, we need a particle or blast equivalent of the Longreach. The result: a level 9 Hanzoreach autocannon.

I've raised powerUse again for about half of the devices in order to follow a general assumption: powerUse and value should double each level, but damage should normally go up by 60%. (For an obsolete damage type, damage is allowed to rise by more than 60%.)

Code is mostly cleaned up since I started working on the update.

A few devices still use TVR's unmodified code: the level 10 and higher alien devices, the Smartcannon PD turret, and the custom-ammo Interceptor turret and launcher. These devices don't have UI issues and aren't meant to be effective against enemy ships, so I've left them as they are for now. If you want them updated, let me know.

I'm updating documentation now and plan to release the alpha tonight.

EDIT: I decided to take yet another go at making the devices target beams and missiles from green Molotoks. (I happened to get destroyed by a Black Market station during testing.)

"bsm -H Z N:20" doesn't solve the problem, even though 'Z' is supposed to exclude the player.

Still haven't given up: Following RPC's example, I'm printing the angle calculated for each ICX shot to the debug log.

With "bsmY -H N:20", after several dozen shots were fired, none of these angles was zero.

However, with "bsm -H N:20", a LOT of the shots are fired at an angle of zero, perhaps half. It is quite possible that when ICX devices target each other, the way the vectors subtract results in perfect cancellation.

aaand our guess seems to be right. Here's the debug log info for a shot that worked correctly:

So all we should have to do to eliminate the self-targeting problem is to make sure that sysVectorSubtract returns a non-zero vector before creating the shot!

EDIT #2: The bug is finally fixed... it was really a combination of several bugs, including a weird issue with onFireWeapon that I'd feel irresponsibile for not mentioning:

[21:26] <gunship256> Question: Can onFireWeapon still return 'noShot?
[21:27] <gunship256> I commented out sysCreateWeaponFire...
[21:27] <gunship256> and the ICX device still shoots!
[21:37] <gunship256> Ok... I verified that 'noShot still works by typing it directly into the onFireWeapon element
[21:37] <gunship256> So there's a bug in the Lisp code that's keeping 'noShot from being returned
[21:49] <gunship256> OK
[21:50] <gunship256> Turns out that onFireWeapon has to return 'noShot (don't shoot), Nil (shoot the weapon normally), or 'shotFired (we've fired in Lisp already, so don't fire the weapon normally)
[21:50] <gunship256> If we don't return 'shotFired, bad things can happen
[21:50] <gunship256> Like the ICX device targeting the wrong target and then firing on its own
...
[22:07] <gunship256> the only documentation I saw was in digDug's changelog
[22:08] <gunship256> It MENTIONS 'noShot, 'shotFired, and Nil
[22:08] <gunship256> Without saying what they're for
[22:08] <gunship256> Turns out they're instructions to the engine for whether to fire the weapon in question
[22:09] <gunship256> That's on George, not digDug. All digdug did was compile george's comments
[22:09] <gunship256> I was wondering why the ICX devices seemed so powerful
[22:10] <gunship256> I think each shot has been firing *twice* (once by sysCreateWeaponFire and once by the game engine)
[22:10] <gunship256> But since the shots happen at exactly the same time...
[22:10] <gunship256> They overlap perfectly and look like ONE shot

Despite the incompleteness of the Transcendence changelogs, without digdug's compilation of those changelogs, this problem would have been nearly impossible to solve.

Working on porting the fixes over to the other devices now. The changes should be simple: just remove 'Y' from targetCriteria to allow the devices to target beams and missiles from green Molotoks, then test the mod again.

It's getting late, so this bug fix may have delayed the release until Tuesday, when I'll have time to finish everything and upload the file here.

EDIT #3: Everything seems to be working except for one agricultural mission where I had "Fire at Angry Friendlies" turned on and my ICX started shooting the freighters that had been docked to the agricultural station. The ICX kept firing even after I turned "Fire at Angry Friendlies" off. I have not been able to replicate this bug.

Since I have to test stuff anyway, I spent about an hour adding a few new devices.

The Longreach I and II now target beams as well as missiles. The Longreach II swaps its repeat="1" for a faster fire rate.

Added an enhancer device that makes auto-defense devices shoot faster. It works for any devices with the "PointDefence" attribute.

Added a turreted ion disruptor that automatically fires at ships. It's level 7 and fires slowly, but it should be useful until right before Heretic.

The only things left to do, in theory, are some remaining tests and documentation updates.

EDIT: The muzzle-flash-no-shot bug has been fixed. I had imported the code from the Nandao bolt cannon to make the Nando ICX. It turns out that the fire effects in the <Missile> element overrides the fire effects in the <Weapon> element, so setting <FireEffect><Null /></FireEffect> in the weapon element wasn't working.

New bug: The vector-subtraction workaround described in the previous post works for all the ICX devices except the RPCX. Other ICX devices are shooting at the RPCX's shots. This could be because the RPCX shots are have a slower shot speed and fire more frequently (30 shots/sec) than the shots from other devices, but I haven't done the testing to verify this. I've set the frequency of the RPCX to notrandom until I can fix the bug.

The Razorwind has the opposite problem: it works fine when installed by itself, but when other ICX devices are installed, it shoots at their shots. I've set the Razorwind's frequency to notrandom until I can figure this out.

NMS wrote:So, do I understand correctly that you've found a way to prevent it from firing at the player's own shots, but not shots created using sysCreateWeaponFire (other than relying on vector cancelling)?

Can you do something like (objSetData (sysCreateWeaponFire ...) 'playerShot True)?

I should try objSetData. It sounds like I can store gSource onto the shot and then read that information back from the shot to find out which ship fired the shot, right?

EDIT: Escort mode didn't have friendly-fire avoidance code; this is why ICX devices were firing on friendly ships during the agricultural mission I described earlier in this thread. I added the necessary code and updated the download link in this post.

Another bug: Point-defense devices are shooting at shots from the player's main weapon but *only* while in Escort mode.
They also fire at shots from TBR's Woodpecker main weapon, whether in Escort mode or not.

QUESTION FOR PLAYERS: Do you actually want settings to include attack mode, which focuses fire on ships only, and defense mode, which targets beams/missiles only? Or does including these two modes make the settings screen unnecessarily complicated?

Should Default mode focus fire equally on beams, missiles, and ships (which is what we have now), or should it prioritize shooting beams and missiles over ships?

gunship256 wrote:I should try objSetData. It sounds like I can store gSource onto the shot and then read that information back from the shot to find out which ship fired the shot, right?

For objects as data, you need (objSetObjRefData ...) to store an object as data and (objGetObjRefData ...) to extract that data. They are used just like objSetData and objGetData are used for other data.

Download and Play in 1.8 Beta...Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
Download and Play in 1.7...Star Castle Arcade: Relive classic arcade gaming in a new Transcendence adventure!Playership Drones v7 (Beta): (OUTDATED!) Acquire and command almost any ship in Stars of the Pilgrim or Eternity Port.
Work in progress... Playership Drones v8: Work just started! Details to come later...

So I did a little experiment of my own, and realized that PD things should be left to the experts.
My own version of ICX was super strange. It fired at everything that didn't come out of me.
Like the ore I mined.
And the Slam Cannon shots of a friendly freighter.
At one stage, it was even firing at my own kinetic shots.

I haven't played with this yet, but after browsing some code I have some ideas:
- PM's point about using (objSetObjRefData ...) to store references to objects might fix your problem with saved targets not persisting through save and load.
- Does (sysCreateWeaponFire weaponID objSource ...) automatically set the shot to the sovereign of objSource? If not, would setting it manually help identify it as an object not to shoot at?

NMS wrote:
- PM's point about using (objSetObjRefData ...) to store references to objects might fix your problem with saved targets not persisting through save and load.

If you use objSetData for objects instead of ObjSetObjRefData, then saved object will not persist. I made this mistake before.

Download and Play in 1.8 Beta...Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
Download and Play in 1.7...Star Castle Arcade: Relive classic arcade gaming in a new Transcendence adventure!Playership Drones v7 (Beta): (OUTDATED!) Acquire and command almost any ship in Stars of the Pilgrim or Eternity Port.
Work in progress... Playership Drones v8: Work just started! Details to come later...