Example mod: One-Hit Per Target Passthrough

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
Post Reply
Fleet Admiral
Fleet Admiral
Posts: 2316
Joined: Wed Sep 01, 2010 12:54 am

Sat Oct 10, 2015 11:38 pm

This example mod adds a particle weapon that fires beams with 100% passthrough, but only hits each target once instead of multiple times. The weapon is installed on the playership at the start of a new game. The mod is fully functional and should work after a simple copy-and-paste to a blank xml file.

Code: Select all

<?xml version="1.0" ?>
<!DOCTYPE TranscendenceExtension
	<!ENTITY unid912Passthrough	"0xd912fffc">
	<!ENTITY it912Passthrough	"0xd912fffd">

; Made for Transcendence v1.6.2 or later.
<TranscendenceExtension UNID="&unid912Passthrough;"
	name="One-Hit Per Target Passthrough Tutorial"

; Since we are using resources from the standard game, we need to include this library!
; Including libraries is the first thing we need to do before anything else in this file.
	<Library unid="&unidHumanSpaceLibrary;"/>

; Here are global function(s) we will use.
		(block Nil
			; Helps prevent passthrough missiles from re-hitting target and doing too much damage.
			; This function is called within three separate events.
			(setq pass912OnDamage (lambda Nil
				(if (eq (objGetObjRefData aCause "d912_LastTargetHit") gSource)
					; YES:  Hit the previous target already, so return zero damage.
					;  Unfortunately, a hit that does no damage still aggravates whoever was hit.

					; NO:  New target.  Standard damage procedure.
					(block Nil
						; Remember who we hit.
						(objSetObjRefData aCause "d912_LastTargetHit" gSource)

						; Return Nil to proceed with usual damage.

; This weapon was a copy of the particle beam weapon.
; Now heavily modified for our purposes.

; The weapon will be given for free at the start of a game.
; Value will be zero so that the player cannot sell for quick cash.
; We do not want this weapon to appear anywhere else.
; Frequency is notrandom, and attribute includes CannotOrder.

	<ItemType UNID="&it912Passthrough;"
			name=				"particle beam penetrator"
			attributes=			"cannotOrder, energyWeapon, majorItem"
			level=				"3"
			frequency=			"notrandom"
			value=				"0"
			mass=				"1500"

			description=		"Beams fired by this particle weapon can passthrough and hit multiple targets.  Each target takes damage only once, usually."

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

				type=				"beam"

				damage=				"particle:1d8+1"
				fireRate=			"16"
				lifetime=			"40"
				powerUse=			"50"
				passthrough=			"100"

				effect=				"&efParticleBeamDefault;"
				sound=				"&snLaserCannon;"

		; Called when beam hits a planet, wreck, or other similar object.

		; Called when beam hits armor.

		; Called when beam hits shields.

		; Called when we start a new game, after ship select.
				(block (newItem)
				; Create our gift.
					(setq newItem (itmCreate &it912Passthrough; 1))
				; Add the new weapon to ship's cargo hold.
					(objAddItem gPlayerShip newItem)
				; Install the weapon.
					(shpInstallDevice gPlayerShip newItem)

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...

Post Reply