I think I broke something.

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
Song
Fleet Admiral
Fleet Admiral
Posts: 2801
Joined: Mon Aug 17, 2009 4:27 am

And I'm not sure how. I decided to try learning some Translisp so I can start thinking about modding properly again. So I took some translisp from a mod I released in 2010 (Mining Charges), a test effect from SM&M++, and made a test gun that would, on damaging armor, create an explosion effect. THe idea was to create a starting point for a weapon I'm hoping to make next year.


And then strange things happened.

The gun works fine, and does what it should do. But the damage pattern is bizarre. Small ships die instantly, as expected. Antares freighters take far more hits than I would expect, but do (usually) die.

On attacking a scarab, the first hit resets the damage indicator on the targeting system to 0. The second takes it to roughly 60,000% damage. The third takes it back to "no damage", and sends the hitpoint bar flying off to ther side of the screen. The fourth shot kills the ship.

On attacking a CSC, the first hit instakills the carrier (?!!).

And on attacking the Sister's of Domina, I end up with it alternating between "insanely high" and "massively negative" HP values, and it's now unkillable. Here's the result of several shots, plus switching to a massively sped-up APA to try to "fix" the problem:
Derp Gun.png
Derp Gun.png (179.93 KiB) Viewed 2651 times
That's the negative hitpoint mode. I don't have a screenshot of the overflow mode.


Here's the code. Can anyone see anything immediately that might cause this, or is it a bug in the game? Wolfy think's it's a bug, and I'm inclined to agree....but neither of us is exactly sure what is breaking.

Code: Select all

<ItemType UNID="&itTestGun;"
			name=				"Test Weapon"
			level=				"4"
			value=				"3500"
			mass=				"3000"
			frequency=			"notRandom"
			attributes=			"MajorItem; Rasiermesser"

			description=		"Used for testing basic scripted weapon effects"
			>

		<Image imageID="&rsItemsRasiermesser3;" imageX="288" imageY="0" imageWidth="96" imageHeight="96"/>

		<Weapon
				type=				"missile"

				damage=				"kinetic:4d8; momentum2; WMD2"
				fireRate=			"120"
				missileSpeed=		"90"
				lifetime=			"50"
				interaction=		"20"
				powerUse=			"130"

				effect=				"&efKineticBoltDefault;"
				sound=				"&snRecoillessCannon;"
				>
				<Events>
				<OnDamageArmor>
				(sysCreateWeaponFire 
						&vtTestGunBlast;
						gSource
					(objGetPos gSource)
					(sysVectorAngle objVel)
					(sysVectorSpeed objVel)
					Nil)
					</OnDamageArmor>
					</Events>
		</Weapon>
	</ItemType>
	
	<ItemType UNID="&vtTestGunBlast;"
			name=				"Test Gun Effect"
			virtual=			"true"
			>

		<Weapon
				

							type=			"radius"
							canhitsource=	"true"
							passthrough=	"100"
							damage=			"blast:1d24; momentum5; WMD7"

							minRadius=		"0"

							maxRadius=		"15"


							>

<Hiteffect>
<Null/>
</Hiteffect>

						<Effect>

							<Flare

									style=			"fadingBlast"

									radius=			"500"

									primaryColor=	"#dd6200"

									lifetime=		"14"

									/>
									
									<Shockwave
						style=			"glowRing"
						lifetime=		"3"
						speed=			"70"
				
						width=			"1"
						glowSize=		"8"
						fadeStart=		"0"
						primaryColor=	"#dd6200"
						secondaryColor=	"0xc0, 0xc2, 0x85"
						/>

						<ParticleJet
					
					emitDuration=	"3"
					emitRate=		"500-1000"
					emitSpeed=			"54-72"
					particleLifetime=	"7-20"
					spreadAngle=		"360"
					>
				<ParticleEffect>
					<Particle
											style=			"flame"
											minwidth=		"1"
											maxWidth=		"2-5"
											/>
				</ParticleEffect>
			</ParticleJet>
						</Effect>


					<Fragment

							count=			"8d20"
							
							type=			"missile"



							lifetime=		"1d6"
							passthrough=	"100"
							canhitsource=	"true"
							damage=			"blast:2d6; armor7; WMD1"

							missileSpeed=	"25-55"

							>



						<Effect>

							<ImageAndTail 

									imageID=			"&rsMissiles4;" 

									imageX=				"0" 

									imageY=				"0" 

									imageWidth=			"16" 

									imageHeight=		"16"

									imageFrameCount=	"4"

									imageTicksPerFrame=	"1"



									length=				"32"

									width=				"1"

									primaryColor=		"0xff, 0xff, 0xff"

									secondaryColor=		"0xc0, 0xc2, 0x85"

									/>

						</Effect>
<Hiteffect>
<Null/>
				</Hiteffect>
					</Fragment>
		</Weapon>
	</ItemType>
EDIT: it occurs to me that whatever is causing this massive over-damage effect may be linked to why some of my older SM&M cluster-missiles massively overperformed against larger ships. I believe there may be a serious bug with the hit detection system somewhere...but I do not know where. This thread may need moving to the bug forum.
Mischievous local moderator. She/Her pronouns.
User avatar
pixelfck
Militia Captain
Militia Captain
Posts: 571
Joined: Tue Aug 11, 2009 8:47 pm
Location: Travelling around in Europe

I didn't read through your code, but from your description I gather that you run into an (unsigned) integer overflow: if a number gets big enough, it 'wraps around' and becomes a large negative number.
It is not a bug per-se, (although you could argue the engine should do a boundary check) it is more that your damage value is operating outside what the engine designer (George) thought would ever be needed.

~Pixelfck
Image
Download the Black Market Expansion from Xelerus.de today!
My other mods at xelerus.de
User avatar
Song
Fleet Admiral
Fleet Admiral
Posts: 2801
Joined: Mon Aug 17, 2009 4:27 am

The damage code (the entire explosion, in fact) is taken from another weapon, which works fine: it shouldn't be overflowing an integer.
Mischievous local moderator. She/Her pronouns.
TVR
Militia Commander
Militia Commander
Posts: 334
Joined: Sat Sep 08, 2012 3:26 am

Code: Select all

<Events>
	<OnDamageArmor>
		(sysCreateWeaponFire
			&vtTestGunBlast;
			gSource
			(objGetPos gSource)
			(sysVectorAngle objVel)
			(sysVectorSpeed objVel)
			Nil
		)
	</OnDamageArmor>
</Events>
(sysCreateWeaponFire) returns a shotObject, which is a number in the 1000000's magnitude.

<OnDamageArmor> interprets that number as the amount of damage to do.

To fix this, use the following code instead:

Code: Select all

<Events>
	<OnDamageArmor>
		(block Nil
			(sysCreateWeaponFire
				&vtTestGunBlast;
				gSource
				(objGetPos gSource)
				(sysVectorAngle objVel)
				(sysVectorSpeed objVel)
				Nil
			)
			
			;; Return Nil
			Nil
		)
	</OnDamageArmor>
</Events>
One final note: objVel is not a default populated variable in the <OnDamageArmor> event. Perhaps there should be an (objGetVel gSource), or (objGetVel aCause) instead?
Fiction is reality, simplified for mass consumption.
PGP: 0x940707ED, 5DB8 4CB4 1EF5 E987 18A0 CD99 3554 3C13 9407 07ED
Bitcoin: 1LLDr7pnZDjXVT5mMDrkqRKkAPByPCQiXQ
User avatar
Song
Fleet Admiral
Fleet Admiral
Posts: 2801
Joined: Mon Aug 17, 2009 4:27 am

Cheers TVR. :)
Mischievous local moderator. She/Her pronouns.
Post Reply