Weapon hit detection

Freeform discussion about anything related to modding Transcendence.
Post Reply
Homsclass
Anarchist
Anarchist
Posts: 1
Joined: Fri Feb 19, 2016 8:43 pm

Thu Feb 25, 2016 8:55 pm

I was wondering if anyone could tell me about code that had weapon hit detection. What I mean is like if you hit something that is initially friendly its different damage then if you hit a target that is initially hostile.

gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Fri Feb 26, 2016 12:15 am

I'd also be interested in this. It'd be cool, for example, to have a missile that heals friendly targets but does nothing to hostile targets. (EDIT: A barrel launcher that uses armor repair paste, repair kits, etc. to heal its target?)
Last edited by gunship256 on Mon Feb 29, 2016 5:23 pm, edited 1 time in total.

NMS
Militia Commander
Militia Commander
Posts: 437
Joined: Tue Mar 05, 2013 8:26 am

Fri Feb 26, 2016 10:40 am

I summarized how hit detection works here, but I'm not sure that helps for this.

It might be tricky, but I think what you want should be possible using the <OnFragment> event. This replaces the weapon's normal fragments with a script, which could search for objects within a certain distance and repair their armor, increase their internal HP, etc., if they are friendly to the firing ship.

PM
Fleet Admiral
Fleet Admiral
Posts: 2316
Joined: Wed Sep 01, 2010 12:54 am

Fri Feb 26, 2016 6:48 pm

Maybe use events like <OnDamage> and others to control what happens when a shot hits.
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...

NMS
Militia Commander
Militia Commander
Posts: 437
Joined: Tue Mar 05, 2013 8:26 am

Fri Feb 26, 2016 10:52 pm

I was under the impression <OnDamage> occurred when an object was hit by damage, rather than when a shot dealt damage.

User avatar
sun1404
Militia Captain
Militia Captain
Posts: 527
Joined: Thu Nov 03, 2011 10:32 am
Location: Heretic. (Finally!)

Sat Feb 27, 2016 1:33 am

I believe a weapon's onDamage triggers when it damages another thing, but an armor's or a shield's onDamage triggers when it is damaged.
Yes, look at my avatar, I have a wyvera type ship.

User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1000
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

Sat Feb 27, 2016 1:48 am

It sounds like what you want might be the <OnShotDestroyed> event implemented in API 27.
Image

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)

gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Sat Feb 27, 2016 5:52 am

AssumedPseudonym wrote:It sounds like what you want might be the <OnShotDestroyed> event implemented in API 27.
Added <OnCreateShot> and <OnDestroyShot> for weapons. These are called when a shot is created and destroyed. They are called after OnFireWeapon and for each shot created. gSource is the shot object.
Thanks! I assume that gItem is the shot that was destroyed, right? Can I still get information on gItem even if the shot doesn't exist any more?

User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1000
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

Sat Feb 27, 2016 12:42 pm

Actually, gSource is the projectile, in this case. I'll be better able to give a rundown on what all of the populated variables are tomorrow night whe I get back hom, if you need.
Image

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)

gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Sat Feb 27, 2016 6:14 pm

AssumedPseudonym wrote:Actually, gSource is the projectile, in this case. I'll be better able to give a rundown on what all of the populated variables are tomorrow night whe I get back hom, if you need.
That would be helpful - thanks! If gSource is the projectile, is there a way to access the object the projectile hit? Would I need to use distance detection code to find the object?

EDIT: I'm thinking about creating a missile that acts like the Lumnious tame cube (using quantum cubes as ammo?) in that it would be able to enslave another ship. <OnDestroyShot> wouldn't tell me anything about what kind of damage the shot did, right? For example, if I wanted the missile's probability of enslaving the ship to be proportional to the amount of armor or internal HP damage it did, would there by any way to know that?

EDIT #2: Is there a way to make the shots themselves carry information? For example, could I load the shot with playership data like shield and armor status and then access the data later? It would be interesting to make the probability of capturing the ship based on the relative conditions of the attacking and target ships' armor status. If a special launcher were made to do this that would take barrels of armor repair paste, repair kits, repairing nanos, regen nanos, and patcher arms as ammo, the shot could be given data based on what ammo was used to fire it, and a healing device could be installed on the target to repair its armor if ship capture is successful.

Post Reply