Derakon plays around with ideas

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

Sat Mar 17, 2018 11:54 pm

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 Commander
Militia Commander
Posts: 355
Joined: Thu Jul 30, 2015 3:10 pm
Location: Deep dark space/Indonesia

Sun Mar 18, 2018 2:27 pm

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!
Semesta I.G.C v1.36
Great corporate that feature a new items and challenges!
YourCORP v1.15
Build your very own corporation!
Trade Item Extension v1.14
New misc items, foods and resources!
StrongBox v1.4
Open it up to get a random equipments!
Flare Weapons v1.6
New weapons that have very unique abilities!
Click this link!

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

Sun Mar 18, 2018 6:09 pm

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: 2313
Joined: Wed Sep 01, 2010 12:54 am

Sun Mar 18, 2018 6:40 pm

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

User avatar
AssumedPseudonym
Militia Captain
Militia Captain
Posts: 993
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

Sun Mar 18, 2018 8:00 pm

 …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

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: 136
Joined: Sat Jan 21, 2017 2:53 am

Mon Mar 19, 2018 12:03 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: 136
Joined: Sat Jan 21, 2017 2:53 am

Mon Mar 19, 2018 2:08 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: 136
Joined: Sat Jan 21, 2017 2:53 am

Tue Mar 20, 2018 2:32 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 Commander
Militia Commander
Posts: 434
Joined: Tue Mar 05, 2013 8:26 am

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.

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

Tue Mar 20, 2018 1:21 pm

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: 136
Joined: Sat Jan 21, 2017 2:53 am

Wed Mar 21, 2018 3:22 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 Commander
Militia Commander
Posts: 434
Joined: Tue Mar 05, 2013 8:26 am

Wed Mar 21, 2018 7:45 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: 136
Joined: Sat Jan 21, 2017 2:53 am

Wed Mar 21, 2018 1:14 pm

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 Commander
Militia Commander
Posts: 434
Joined: Tue Mar 05, 2013 8:26 am

Thu Mar 22, 2018 4:38 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: 136
Joined: Sat Jan 21, 2017 2:53 am

Thu Mar 22, 2018 1:26 pm

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

Post Reply