Need to find out which ship fired a shot

Freeform discussion about anything related to modding Transcendence.
Post Reply
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

I have a list of space objects that I got from sysFindObject. I'm working on the PDmod update and am trying to deal with a bug where ICX devices shoot at the shots created by the player's own main weapon.

How can tell whether a shot was fired by the player or by a different ship?

Here's the current version of the code if having some context helps:
(avoidCriteria is "sTF N:20 S:D" in the case below)

Code: Select all

					; notTargets: (spaceObject list) List of targets to avoid shooting at all costs
					; Nil means do not hold fire even if there is a chance of hitting a friendly target
					; Set notTargets based on the list of criteria given by the function's avoidCriteria argument
					(setq notTargets (sysFindObject gSource avoidCriteria))
					
					; If allow friendly fire is true, then we REMOVE all angry (but friendly "green" on the LRS) targets from
					; the list of ships to avoid shooting
					; ELSE: Do nothing
					(if (eq (objGetData gSource "pds_allowFriendlyFire") true)
						(block Nil
							; We need to a new list to store the new list of targets as enum iterates through the original list
							(setq newNotTargets Nil)
							
							; Iterate through all the targets we supposedly shouldn't shoot at
							(enum notTargets theTarget
								
								; If the object isn't angry at gSource, add it to the new list
								(if (not (objIsAngryAt theTarget gSource))
									(lnkAppend newNotTargets theTarget)
									)
								)
							
							; Now we have a new list of targets to avoid shooting, and none of the ships in the list is angry at gSource
							; Make the original list equal to the new one, since we're finished with enum
							(setq notTargets newNotTargets)
							)
						)
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

In the game, the Long Reach Cannon does not react to the Player's shots: so whatever you are doing is going against the ICX instead of with it.
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

This is for the PDmod update, not for the vanilla devices.

I'm not sure what you mean by going against a device as opposed to with it. Could you please provide more details?
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

gunship256 wrote:This is for the PDmod update, not for the vanilla devices.

I'm not sure what you mean by going against a device as opposed to with it. Could you please provide more details?
As I believed I understood the post, you had something like an auto cannon : but it was reacting to the player's shots.

I am sorry if I misunderstood. I know nothing of this Mod you speak of, I thought I read that a device was not functioning properly and tested the standard device in 1.7.1a to be sure the standard device was not buggy.

It is very easy to get caught up in something and give it too much fuel.

objIsAngryat is for Stations.....ships simply follow orders, they don't get angry.

IF a ship was able to get angry, then got lost in the mix of traffic, you would have a hostile in your midst and that would not be good at all for the player.

however, if the device has the target ( say " missile" ) , it can react to aOrdergiver : I would think that aAttacker would only play if the victim actually takes a hit.
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

shanejfilomena wrote:As I believed I understood the post, you had something like an auto cannon : but it was reacting to the player's shots.

I am sorry if I misunderstood. I know nothing of this Mod you speak of, I thought I read that a device was not functioning properly and tested the standard device in 1.7.1a to be sure the standard device was not buggy.

It is very easy to get caught up in something and give it too much fuel.

objIsAngryat is for Stations.....ships simply follow orders, they don't get angry.

IF a ship was able to get angry, then got lost in the mix of traffic, you would have a hostile in your midst and that would not be good at all for the player.

however, if the device has the target ( say " missile" ) , it can react to aOrdergiver : I would think that aAttacker would only play if the victim actually takes a hit.
Thanks for writing! The code I provided in the original post was for the PD mod update, which I'm currently trying to debug.

Black Market Molotoks actually do get angry - I've seen this when I call objIsAngryAt on them. I think stations also get angry, as you suggested.

Does aOrdergiver work outside of <Events>? Point-defense devices don't use <Events> for detection; they use either targetCriteria or sysFindObject. How would one access the variable outside of event code?
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

Devices Can use Events just as Armor, weapons , stations and Items will use them .

In Midst of Dragons the Mark I, II , III and V have events so they reload Ammo onto NPC ships but not the Player ( which you might notice some ships with a Howitzer may carry several hundred to thousands of rounds .....it gets buggy in full systems with lots of AI calls )

But, you can add Events to your device.

AS I understand what you say of this device it is "Particular" , however, it is a device, it MUST obey the rules of the game and the rules say "Let there be Events!"
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Shane, this is a point-defense device. It searches for objects within a certain radius and then decides which ones to target.

I don't think there are any events that perform the same function, unless I create a special event that gets called every tick, which I'd prefer not to do in order not to slow the game down.

I could also throw an event every time a shot is detected and catch it later, which would probably be computationally even more burdensome for the game.

Am I missing something? It'd be great to have a new way to code point-defense.
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

ok, if you didn't figure it out - I don't know what this " Point defense" thingy is.

if you want a device to lead as a scout .. that is pretty much an auton coded order ..
( break&Amp )

but for a ship device I thought it was just an ICX ( auto cannon ) ....

so, nopes .. I got nothing.
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

An ICX is an example of a point-defense device. If you're curious, you can download the current alpha of the mod and take a look at it:

https://forums.kronosaur.com/viewtopic.php?f=25&t=7682

I'm not sure how one would code an ICX-type device using event code. Could you please elaborate?
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

There's a potential workaround in this thread: Put a virtual station in every system with an <OnSystemWeaponFire> event that stores the attacker as data on every shot that's fired.

But there really ought to be an easier way (and I'm not sure it would work for multi-shot and particle cloud weapons), so I opened a ticket: Request - TLisp functions for accessing projectile data
Feel free to add anything else you might want.
PM
Fleet Admiral
Fleet Admiral
Posts: 2570
Joined: Wed Sep 01, 2010 12:54 am

I'm not sure how one would code an ICX-type device using event code. Could you please elaborate?
Probably something like my ZapSats in DrakeTech. The satellites are missile objects with a recurring event that causes those missiles (the satellites) to find a target and shoot at it. It is a complicated mess.

I could make variations to recreate attacks from other games. Basically, a parent missile that shoots at enemies within a given radius as it flies by.
Download and Play in 1.9 beta 1...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!
Star Castle Arcade: Play a classic arcade game adventure, with or without more features (like powerups)!
Playership Drones: Buy or restore exotic ships to command!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
Post Reply