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

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

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 Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 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: 2570
Joined: Wed Sep 01, 2010 12:54 am

Maybe use events like <OnDamage> and others to control what happens when a shot hits.
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.
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

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!)

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: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

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

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

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

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: 1190
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

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

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

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

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