armor damage

A place to discuss mods in development and concepts for new mods.
Post Reply
Artemisfowl333
Anarchist
Anarchist
Posts: 4
Joined: Fri Feb 19, 2016 8:47 pm

Thu Apr 14, 2016 8:01 pm

the following code is a weapon that is meant to make any station or ship disappear on contact, but do lots of damage to the shooters armor. the weapon does make things disappear on contact, but the armor doesn't take any damage. does anybody know how to make my armor take damage, or if i'm using the wrong functions in general

Code: Select all

<ItemType UNID="&itmyweapon;"
			name=				"weeepon"
			attributes=			"commonwealth, EI, energyWeapon, majorItem"
			  
			level=				"2"
			frequency=			"rare"

			value=				"1200"
			mass=				"1000"
			  
			description=		"A single laser cannon with an automated targeting system."
			>

		<Image imageID="&rsItemsEI1;" imageX="0" imageY="192" imageWidth="96" imageHeight="96"/>

		<Weapon
				type=				"beam"

				omnidirectional=	"true"
				damage=				"laser:1d4"
				fireRate=			"10"
				lifetime=			"30"
				powerUse=			"30"

				effect=				"&efLaserBeamDefault;"
				sound=				"&snLaserCannon;"
				>
		</Weapon>
		<Events>
			<OnDamageArmor>
				(block Nil
				(shpDamageArmor aAttacker 0 0 1)
				(objDestroy gSource)
					)
			</OnDamageArmor>
		</Events>
	</Itemtype>

shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1404
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska

Fri Apr 15, 2016 2:11 am

nvm
Last edited by shanejfilomena on Sat Apr 16, 2016 3:41 am, edited 1 time in total.
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..

Artemisfowl333
Anarchist
Anarchist
Posts: 4
Joined: Fri Feb 19, 2016 8:47 pm

Fri Apr 15, 2016 7:58 pm

Unfortunately the suggestion above me didn't help much, and I have tried to do a variety of things. I now believe that the problem is not in the line that is supposed to damage armor, but somewhere else. I have entered the line that I used to damage armor in the debug console, and it worked. If anyone has any knowledge of this let me know, and anything helps. p

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE TranscendenceExtension
   [
   
   <!ENTITY itmyweapon "0xEdaf00a2">
   ]>
   <TranscendenceExtension UNID= "0xEDCB0000" apiVersion= "28" name= "mine-do-not-touch" >
   <Library UNID="&unidHumanSpaceLibrary;"/>
   <ItemType UNID="&itmyweapon;"
			name=				"weeepon"
			attributes=			"commonwealth, EI, energyWeapon, majorItem"
			  
			level=				"2"
			frequency=			"rare"

			value=				"1200"
			mass=				"1000"
			  
			description=		"A single laser cannon with an automated targeting system."
			>

		<Image imageID="&rsItemsEI1;" imageX="0" imageY="192" imageWidth="96" imageHeight="96"/>

		<Weapon
				type=				"beam"

				omnidirectional=	"true"
				damage=				"laser:1d4"
				fireRate=			"10"
				lifetime=			"30"
				powerUse=			"30"

				effect=				"&efLaserBeamDefault;"
				sound=				"&snLaserCannon;"
				>
		</Weapon>
		<Events>
			<OnDamageArmor>
				(block Nil
				
				(objDestroy gSource)
				
				)
			</OnDamageArmor>
			<onFireWeapon>
			(block Nil
			
				(shpDamageArmor gPlayerShip i 12 10)
			
			)
			</onFireWeapon>
		</Events>
	</ItemType>
	</TranscendenceExtension>

marsrocks
Miner
Miner
Posts: 47
Joined: Fri Nov 05, 2010 6:29 pm

Sat Apr 16, 2016 12:44 am

I'm not sure you can call that event from an item.

There is a long discussion about calling events in the ship rotation thread:

http://forums.kronosaur.com/viewtopic.php?f=25&t=7564

You can create a virtual ship or station to use to call events as one way to accomplish it.

Here is the gem of sacrifice code from usefulitems.xml that shane suggested trying:




<!-- Gem of Sacrificce -->

<ItemType UNID="&itGemOfSacrifice;"
name= "gem(s) of sacrifice"
level= "12"
value= "10000"
mass= "1"
frequency= "veryrare"
unknownType= "&itUnknownHaloGem;"
attributes= "HaloGem; MinorItem; CannotOrder"

description= "These gems are used by the Halo Races, though their exact purpose is unknown. The dark-energies embedded in the gem have an influence over spacetime that is not yet fully understood."
>

<Image imageID="&rsItems1;" imageX="0" imageY="576" imageWidth="96" imageHeight="96"/>

<Invoke key="F">
(block (sacrificeEffect)
; Function to lower shields and armor
(setq sacrificeEffect (lambda (theObj)
(block Nil
(objDepleteShields theObj)

(for i 0 (subtract (shpGetArmorCount theObj) 1)
(if (leq (itmGetLevel (shpGetArmor theObj i)) 12)
(block (theDamage)
(setq theDamage (divide (multiply (shpGetArmorMaxHitPoints theObj i) (random 96 99)) 100))
(shpDamageArmor theObj i 12 theDamage)
)
)
)

(objSetProperty theObj 'interiorHP (random 1 10))

(sysCreateEffect &efGemOfSacrifice; theObj (objGetPos theObj))
)
))

; All ships in range have their shields lowered
(objSendMessage gSource Nil "\"May your sacrifice prove true...\"")
(enum (sysFindObject gSource "sN:30;") theObj
(sacrificeEffect theObj)
)

; Invoker also gets effect
(sacrificeEffect gSource)

; Remove the item from the player's list
(objRemoveItem gSource gItem 1)

; Identify the item
(itmSetKnown gItem)
)
</Invoke>

</ItemType>

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

Sat Apr 16, 2016 1:05 pm

artemisfowl's weapon is making things disappear on contact, which suggests that the device is picking up the <OnDamageArmor> event, but if I'm understanding correctly, the armor damage code which works in the debug console doesn't work when it's inserted in either <OnDamageArmor> or <OnFireWeapon>.

The only thing I can think of for the <OnDamageArmor> code is that maybe the aAttacker variable isn't defined for that event. The wiki suggests that it *should* be defined, though.

https://wiki.kronosaur.com/modding/xml/ ... amagearmor

I have no idea what's wrong with the <OnFireWeapon> code. gPlayerShip should work, but apparently it doesn't.

shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1404
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska

Sat Apr 16, 2016 5:21 pm

(if ) the aAttacker is the target it should be obtained as a Target obj
( get target gSource) or (set target gSource)
(** don't use the "codes" it was just stating examples )

if there is alot of weapons going off the engine will need to know whom is the one that it should target based on whom got shot.

Like an Auton.

Which is probably where you want to look for your targeting code if the weapon is to have a mind of it's own.
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

Sat Apr 16, 2016 8:28 pm

The wiki suggests that aAttacker is the ship firing the weapon. I think artemisfowl is trying to damage the armor of the ship that fired the shot.
aAttacker is the object that fired the projectile.

Artemisfowl333
Anarchist
Anarchist
Posts: 4
Joined: Fri Feb 19, 2016 8:47 pm

Mon Apr 18, 2016 7:57 pm

So I was messing around with my code and think I might of found a glitch in the game itself. The following code does the same thing as my previous code. I did change some things so that this mod didn't conflict with the back-ups version I had of this mod, but that's all. The main point I want you to notice in this code through, is that gSource is a variable that represents which object was hit with my weapon.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE TranscendenceExtension
   [
   
   <!ENTITY itmyweapon8 "0xEdaf00a3">
   ]>
   <TranscendenceExtension UNID= "0xEdaf00a4" apiVersion= "28" name= "mine-do-not-touch2" >
   <Library UNID="&unidHumanSpaceLibrary;"/>
   <ItemType UNID="&itmyweapon8;"
			name=				"weeepon two"
			attributes=			"commonwealth, EI, energyWeapon, majorItem"
			  
			level=				"2"
			frequency=			"rare"

			value=				"1200"
			mass=				"1000"
			  
			description=		"A single laser cannon with an automated targeting system."
			>

		<Image imageID="&rsItemsEI1;" imageX="0" imageY="192" imageWidth="96" imageHeight="96"/>

		<Weapon
				type=				"beam"

				omnidirectional=	"true"
				damage=				"laser:1d4"
				fireRate=			"10"
				lifetime=			"30"
				powerUse=			"30"

				effect=				"&efLaserBeamDefault;"
				sound=				"&snLaserCannon;"
				>
		</Weapon>
		<Events>
			<OnDamageArmor>
				(block Nil
				
				
				
				 
				 (objDestroy gSource)
				
				)
			</OnDamageArmor>
			<onFireWeapon>
			(block Nil
			
				(shpDamageArmor gPlayerShip 1 12 10)
			
			)
			</onFireWeapon>
		</Events>
	</ItemType>
	</TranscendenceExtension>
Now this is the new code. This code doesn't destroy things on contact, but it does damage my armor(like I wanted it too.) What makes me think I found a glitch in the code, is that here gSource is the playership(and yes I have tried to uncomment out the <onfireWeapon> but it did nothing.)

Code: Select all

<!DOCTYPE TranscendenceExtension
   [
   
   <!ENTITY [email protected] "0xEdaf00a6">
   ]>
   <TranscendenceExtension UNID= "0xEdaf00a8" apiVersion= "28" name= "mine-do-not-touch3" >
   <Library UNID="&unidHumanSpaceLibrary;"/>
   <ItemType UNID="&[email protected];"
			name=				"weeepon four"
			attributes=			"commonwealth, EI, energyWeapon, majorItem"
			  
			level=				"2"
			frequency=			"rare"

			value=				"1200"
			mass=				"1000"
			  
			description=		"A single laser cannon with an automated targeting system."
			>

		<Image imageID="&rsItemsEI1;" imageX="0" imageY="192" imageWidth="96" imageHeight="96"/>

		<Weapon
				type=				"beam"

				omnidirectional=	"true"
				damage=				"laser:1d4"
				fireRate=			"10"
				lifetime=			"30"
				powerUse=			"30"

				effect=				"&efLaserBeamDefault;"
				sound=				"&snLaserCannon;"
				>
		</Weapon>
		<Events>
			<OnDamageArmor>
				(block Nil
				
				(shpDamageArmor gSource 1 12 10)
				
				 
				 (objDestroy gSource)
				
				)
			</OnDamageArmor>
			<!--<onFireWeapon>
			(block Nil
			
				(shpDamageArmor gPlayerShip 1 12 10)
			
			)
			</onFireWeapon> -->
		</Events> 
	</ItemType>
	</TranscendenceExtension>

relanat
Militia Commander
Militia Commander
Posts: 436
Joined: Tue Nov 05, 2013 9:56 am

Tue Apr 19, 2016 3:52 am

Dated post: I wrote this for when there was only the OP here. It's based on the code in the OP. I'll check out the newer code as well.
---------------------

It's working. And it's good fun. All that was left of Eridani was nav beacons and the stargate :twisted: . I only had to repair my front armor once. Try starting in debug mode and using the debug screen. On it you can type in commands like (shpDamageArmor gPlayerShip 0 0 5) then 'Enter' and on a standard Wolfen you will see the front armor drop by 3 hp. I'm assuming it drops by less than 5 because the light plasteel armor has some resistance to laser damage (type 0).

Damage types: (from the wiki page moddingfunctionlegend)
-1 - Generic
0 (0x0) - Laser
1 (0x1) - Kinetic
2 (0x2) - Particle
3 (0x3) - Blast
4 (0x4) - Ion
5 (0x5) - Thermo
6 (0x6) - Positron
7 (0x7) - Plasma
8 (0x8) - Antimatter
9 (0x9) - Nano
10 (0xA) - Graviton
11 (0xB) - Singularity
12 (0xC) - DarkAcid
13 (0xD) - DarkSteel
14 (0xE) - DarkLightning
15 (0xF) - DarkFire

Additional stuff.
====================================
From the xelerus functionlist:

Name:
shpDamageArmor

Syntax:
(shpDamageArmor ship number number number)

Argument List:
ship: The ship that you want to damage an armor segment on.
number: Where on the ship the armor segment is.
number: The damage type.
number: The amount of damage.

Returns:
condition: True is successful. EDIT: it returns the amount of damage in hp.

Category:
ship, repair/damage, armor

Description:
Damages the armor with the given damage and damage type.

Example:

Code: Select all

(shpDamageArmor gplayership 0 0 1)
Does one point of kinetic damage to the players forward armor.

Comment:
Very nice function for damaging armor in code. Would be nice if you could do this with shields too.
Use 'nosrsflash to stop the Red Screen of Death from showing, as requested in this thread: http://wiki.neurohack.com/transcendence/trac/ticket/648

=======================
From the AE-Function Help in Avian Enterprises-Utility Pack mod.

(shpDamageArmor ship armorSegment damageType damage ['noSRSFlash]) -> damage done

=======================
And the Gem of Sacrifice which sjf mentions, which is in UsefulItems.xml.

Code: Select all

(for i 0 (subtract (shpGetArmorCount theObj) 1)
	(if (leq (itmGetLevel (shpGetArmor theObj i)) 12)
		(block (theDamage)
			(setq theDamage (divide (multiply (shpGetArmorMaxHitPoints theObj i) (random 96 99)) 100))
			(shpDamageArmor theObj i 12 theDamage)
		)
	)
)

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

Tue Apr 19, 2016 4:11 am

It's weird that gSource could point to two *different* ships (the ship that was hit and the playership, respectively) inside of the *same* event (onDamageArmor).

On the face of it, that seems like an error in the functions the game supplies us rather than something artemisfowl did wrong. I may be missing something obvious, though.

relanat
Militia Commander
Militia Commander
Posts: 436
Joined: Tue Nov 05, 2013 9:56 am

Thu Apr 21, 2016 3:17 am

Yep. The wording is definitely weird. I haven't modded weapons so I'm as confused as everyone else.

Remember that this is the code for a weapon. So anything in its code will relate to what the weapon does.
It looks like, as af333 say, that any code inside <OnDamageArmor> refers to the object being attacked. This makes sense because it's not very likely that you will be shooting yourself!
So code inside it will have gSource as the object whose armor is being damaged (ie the ship being shot at)
aAttacker will be the ship which is doing the shooting whether its the playership or something else (wingman, auton, NPC ship).
gPlayerShip will be (duh :? ) the playership.


In the later versions of the code, for whatever reason, you don't get the beam effect from firing the weapon, only the muzzle flash, and you don't get to hit any ships. This looks like its a result of using:

Code: Select all

	<onFireWeapon>
		(block Nil
			(shpDamageArmor gPlayerShip 1 12 10)
		)
	</onFireWeapon>
so I'd suggest avoiding this and using the original version of your code. (Maybe the ship is shooting itself here? I don't know how to test this.)

Here's a higher damage version of the original code that's working for me.
Attachments
artemis vanishing ship weapon.xml
(1.24 KiB) Downloaded 25 times

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

Thu Apr 21, 2016 5:23 am

Interesting! So you're using the code below, and it both makes the ships that were hit disappear and damages the attacker's armor at the same time?

Code: Select all

			<OnDamageArmor>
				(block Nil
					(shpDamageArmor aAttacker 0 0 1)
					(objDestroy gSource)
				)
			</OnDamageArmor>
relanat wrote:In the later versions of the code, for whatever reason, you don't get the beam effect from firing the weapon, only the muzzle flash, and you don't get to hit any ships. This looks like its a result of using:

Code: Select all

	<onFireWeapon>
		(block Nil
			(shpDamageArmor gPlayerShip 1 12 10)
		)
	</onFireWeapon>
I think <onFireWeapon> needs to return Nil in order for the weapon to actually fire a shot. In other words, inserting Nil in the manner below should get the weapon to fire:

Code: Select all

	<onFireWeapon>
		(block Nil
			(shpDamageArmor gPlayerShip 1 12 10)
                        Nil
		)
	</onFireWeapon>
From the Transcendence changelog:
https://forums.kronosaur.com/viewtopic.php?f=8&t=7316
<OnFireWeapon> can return 'noShot and 'shotFired
If OnFireWeapon returns Nil, then normal projectile is fired.
Destroying gSource inside of OnFireWeapon causes a crash

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

Sun Apr 24, 2016 9:18 pm

relanat wrote:In the later versions of the code, for whatever reason, you don't get the beam effect from firing the weapon, only the muzzle flash, and you don't get to hit any ships.
Have you found out how to get rid of that muzzle flash, BTW? It was showing up in PDmod and confused people during the Twitch stream.

EDIT: It looks like the muzzle flash is generated using fireEffect, and there may be a way to change this using onFireWeapon:

1.7 Alpha 1 Ready!
https://forums.kronosaur.com/viewtopic. ... ash#p67853

Weapons Overview (basic++)
https://forums.kronosaur.com/viewtopic. ... ash#p15435

Post Reply