Derakon plays around with ideas

A place to discuss mods in development and concepts for new mods.
Derakon
Militia Lieutenant
Militia Lieutenant
Posts: 175
Joined: Sat Jan 21, 2017 2:53 am

I figure this will be better than spamming the screenshots thread. I'm playing around with implementing one-off ideas I've had. First is the gatling howitzer:

Image

Next is a set of fireworks, coming in a handy disposable launcher. I figure I'll make a variant Anarchist Hornet and give this to them. Should give the player a minor heart attack before they realize that the fireworks don't do any damage. :D

Image
User avatar
DigaRW
Militia Captain
Militia Captain
Posts: 517
Joined: Thu Jul 30, 2015 3:10 pm
Location: The place where I belong
Contact:

Next is a set of fireworks, coming in a handy disposable launcher. I figure I'll make a variant Anarchist Hornet and give this to them. Should give the player a minor heart attack before they realize that the fireworks don't do any damage.
I ever made this thing, but it's virtual weapon and not tracking. And used for celebration for YourCORP building, but got cut because I think it's too embrassing.
Download Transcendence mods from Reinvented Workbench Project!
Click this link!
Derakon
Militia Lieutenant
Militia Lieutenant
Posts: 175
Joined: Sat Jan 21, 2017 2:53 am

I'm trying to make a weapon that fires projectiles in a spray depending on the current time, kind of like a sprinkler system. This is what I have right now:

Code: Select all

		<Events>
			<OnFireWeapon>
				(if (eq (itmGetData gItem 'fire) 0)
					(block	(
						(angle (+ aFireAngle (% 10 (unvGetTick))))
						)
						(objSetData gItem "turnDirection" 'angle)
						)
				)
			</OnFireWeapon>
		</Events>
This gives me a numeral expected error. What am I doing wrong?

Also, how do I output text? The dbgOutput function I saw on the wiki doesn't seem to do anything -- I tried invoking it in the above block (before the objSetData call) and the console was empty in-game.

Second question: is there a way to control projectile size besides changing how much damage the weapon does?
PM
Fleet Admiral
Fleet Admiral
Posts: 2570
Joined: Wed Sep 01, 2010 12:54 am

gItem is not an object for objSetData.
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.
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.

 …And (printTo 'console something) will output to the console. I have a feeling the function you’re looking for is objSetItemData, not objSetData.

 Also, Digdug and I try to keep an up-to-date function list over in the Modding Reference forum.
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!)
Derakon
Militia Lieutenant
Militia Lieutenant
Posts: 175
Joined: Sat Jan 21, 2017 2:53 am

Is there a reference for what variables are available? I don't actually know what gItem et al are; I'm inferring based on snippets of code I find lying around. I suspect in retrospect that gItem is the item that's contextually relevant in the event, which in this case would be the weapon, while what I want to get is the shot that was fired.

Also, when are mods loaded? Do I need to restart Transcendence each time I want to tweak my XML? For that matter, do I need to create a new pilot when editing a weapon, or will old pilots that already have an item with the weapon's UNID pick up changes when I make them?
Derakon
Militia Lieutenant
Militia Lieutenant
Posts: 175
Joined: Sat Jan 21, 2017 2:53 am

Some updates:

I made a laser sprinkler:

Image

And I tried to make a kinetic weapon where the initial bullet sprays out more bullets as it flies along:

Image

Unfortunately, it crashes when the main bullet's lifetime expires:

Image

Here's the code for that weapon:

Code: Select all

	<ItemType UNID="&moreBullet;"
			name=				"more bullet"
			attributes=			"commonwealth, majorItem"
			  
			level=				"1"
			frequency=			"common"

			value=				"190000"
			mass=				"10000"
			  
			description=		"Shoots bullets that shoot bullets."
			>

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

		<Weapon
				type=				"missile"

				damage=				"kinetic:1d5"
				fireRate=			"15"
				missileSpeed=			"20"
				lifetime=			"50"
				interaction=			"0"
				powerUse=			"80"
				effect=				"&efKineticBoltDefault;"
				sound=				"&snRecoillessCannon;"
				>
		</Weapon>
		<Events>
			<OnFireWeapon>
				(block	(
					(shot (sysCreateWeaponFire &moreBullet; gSource aFirePos aFireAngle 20 aTargetObj '('fireEffect 'soundEffect) aWeaponBonus))
					)
					(objSetEventHandler shot &moreBullet;)
					(sysAddObjRecurringTimerEvent 10 shot "OnTime")
					)
			</OnFireWeapon>
			<OnTime>
				(if (gr (objGetProperty gSource 'lifeLeft) 0)
					(block	(
							(vel (objGetVel gSource))
							(speed (sysVectorSpeed vel))
							(velAngle (sysVectorAngle vel))
							(theta (+ velAngle 90))
							(phi (- velAngle 90))
						)
							(objIncVel (sysCreateWeaponFire &moreBullet; gSource (objGetPos gSource) theta speed aTargetObj '('fireEffect 'soundEffect) aWeaponBonus) (objGetVel gSource))
							(objIncVel (sysCreateWeaponFire &moreBullet; gSource (objGetPos gSource) phi speed aTargetObj '('fireEffect 'soundEffect) aWeaponBonus) (objGetVel gSource)
						)
					)
					(printTo 'console (objGetProperty gSource 'lifeLeft))
				)
			</OnTime>
		</Events>
	</ItemType>
I added that if statement in the OnTime handler on the theory that it might be trying to read from a deallocated object, but it didn't help. Any ideas? Note that after the crash, the savefile cannot be loaded due to bad references. Maybe the subsidiary bullets maintain references to their parent and don't cope well with it going away? Should I set their parent to be the firing ship? If so, how?

EDIT: I'm pretty sure that my theory is correct -- subsidiary bullets can't cope with the parent bullet being destroyed. I say this for two reasons. First, the error message when trying to load the save file. Second, if I give the first bullet artificially long lifetime with (objSetProperty shot 'lifeLeft 150) and make it only generate bullets for the first 50 ticks, then the program doesn't crash...unless the parent bullet gets despawned due to hitting something.

I tried setting the source with

Code: Select all

(objSetProperty shot1 'sourceObj (objGetProperty gSource 'sourceObj))
(where shot1 is the first sysCreateWeaponFire result), but I get the error
OnTime [kinetic damage]: Invalid property [sourceObj] ### (objSetProperty "shot1" "sourceObj" (objGetProperty gSource "sourceObj")) ###
Which is odd, as "sourceObj" is listed as a valid property of missiles.

On the other hand, just setting the source object at time of creation (in the sysCreateWeaponFire call) works just fine, and doesn't crash! So check it out, the More Bullet weapon:

Image
Derakon
Militia Lieutenant
Militia Lieutenant
Posts: 175
Joined: Sat Jan 21, 2017 2:53 am

I got for loops figured out, and AP pointed out the objSetData function so I can store state across events now, which let me make this:

Image

And then I spent a lot of time banging my head against targeting and figuring out how sysCalcFireSolution works, to make these deployable particle turrets:

Image
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

These are really neat! So you got the "sprinkler" working the way you wanted? Because there are several issues with the code you posted for that which I could get into.

The wiki is not kept perfectly up to date, but it does have a lot of useful information. For instance, the weapon page has info about weapon events.
Derakon
Militia Lieutenant
Militia Lieutenant
Posts: 175
Joined: Sat Jan 21, 2017 2:53 am

NMS wrote:
Tue Mar 20, 2018 9:47 am
These are really neat! So you got the "sprinkler" working the way you wanted? Because there are several issues with the code you posted for that which I could get into.

The wiki is not kept perfectly up to date, but it does have a lot of useful information. For instance, the weapon page has info about weapon events.
Thank you! That's really helpful; it's not always easy to find relevant resources, especially when you don't expect them to exist. :)

As for the sprinkler, yeah, I'm reasonably happy with it. Here's the current state of its code:

Code: Select all

	<ItemType UNID="&rotaryLaser;"
			name=				"rotary laser"
			attributes=			"commonwealth, majorItem"
			  
			level=				"1"
			frequency=			"common"

			value=				"190000"
			mass=				"10000"
			  
			description=		"Like a sprinkler system, made of fire."
			>

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

		<Weapon
				type=				"missile"

				damage=				"laser:2d5"
				fireRate=			"2"
				lifetime=			"50"
				powerUse=			"80"
				effect=				"&efLaserBeamDefault;"
				sound=				"&snLaserCannon;"
				>
		</Weapon>
		<Events>
			<OnFireWeapon>
				(block	(
					(tOff (* 10 (sin (/ (unvGetTick) 5))))
					(angle (+ aFireAngle tOff))
					(shot (sysCreateWeaponFire &rotaryLaser; gSource aFirePos angle 100 aTargetObj '('fireEffect 'soundEffect) aWeaponBonus))
					)
					(objSetItemData gSource gItem 'fire 1)
					)
			</OnFireWeapon>
		</Events>
	</ItemType>
If you have any suggestions, lay 'em on me!
Derakon
Militia Lieutenant
Militia Lieutenant
Posts: 175
Joined: Sat Jan 21, 2017 2:53 am

Just one this time, but I'm pretty fond of it.

Image

The appearance is nothing special, but I like the description of this Atomic Gun: "Promotes dated atomic models." :D

Too bad it's positrons instead of protons in the "nucleus". Come to think, how do these weapons work anyway? They're firing cohesive blobs of similarly-charged particles; they ought to fly apart due to electromagnetic repulsion.
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

I see, the sprinkler is oscillating in a narrow arc, not rotating all the way around (that would be pretty hard to use, I guess). Nice. But does the call to objSetItemData actually do anything? Do you check the data somewhere else? If not, you could just replace it with 'shotFired (or really anything that doesn't evaluate to Nil, 'noShot, or 'default).
Derakon
Militia Lieutenant
Militia Lieutenant
Posts: 175
Joined: Sat Jan 21, 2017 2:53 am

I admit I'm not entirely clear on what that line is doing, but if I remove it, then the weapon fires a straight line of lasers in addition to the oscillating laser, so I assume that "fire" is a special property used to say "this OnFireWeapon event actually produced a projectile, so no need to produce one the normal way."
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

If there's no code in the block after the local variable list, it evaluates to Nil, which in this event tells the game to fire the normal shot.
Derakon
Militia Lieutenant
Militia Lieutenant
Posts: 175
Joined: Sat Jan 21, 2017 2:53 am

Aha! That explains the bare "True" statements I've seen in some other weapons people have shared. Thanks.
Post Reply