Bullets and missiles. Their variables, function, events.

Freeform discussion about anything related to modding Transcendence.
EditorRUS
Militia Lieutenant
Militia Lieutenant
Posts: 148
Joined: Tue Oct 30, 2012 6:30 pm

Hello. I want to write one complex weapon. It will work in next way:
1. Player select the weapon in the inventory (U). There's 2 options: add matter, add energy.
2. First option let you add any item in weapon's store. No matter what it is, but mass. Than more mass you add, than more energy it can contain inside (in fact you can add any amount of energy in the matter, but it will add containing cost significially) and than more kinetic energy you'll get.
3. Second option let you select how many watts of energy you want to put inside. Than more energy you add than more powerful shockwave you'll get. The energy can be gathered from a reactor. So, if you add, for instance, 1 GW of energy, your reactor that have 15 MW and you're using 5MW of energy, then it will take 100 seconds to charge the matter and reactor will have to work for 100 seconds at full power. As the matter is charged up the ship will have power to be able to contain the charged matter otherwise the matter will fall at ship's floor and explode, likely to destroy the ship. Now, virtual weapon "Fire the EtM-cannon" should be installed in launcher slot no matter how many slots are busy.
4. When you fired from the virtual weapon a custom bullet appear. Or not bullet, but missile, whatever. The missile must have some custom parametrs such as damage, impulse, type and radius of explosion upon collision.

Also, all of the missile fly with 10 000 000 ms a sec (one thirteenth of ls a sec)
For example let's take a chunk of 50 tons charged with 1 GW of energy.
Impulse: 50 000 * 10^6 = 5*10^10
So, if the chunk hit a ship, covered with 4 segments of 12-ton armor and with 2 tank of water he will get a half of the impulse, so, 5*10^6 ms a sec.
Damage: kinetic:mass in tons / 2 (25)
But that's only damage made by direct collision. Let's see at explosion...

1 GW
First, type of explosion.
It depends from energy and mass. Or, to be accurate, from energy-density. Let's take density for all matter in the game: 10 000 kg per m^3, except for neutronium which have (my palm of hand is approximate 0.1*0.1*0.03 = 0,0003 m^3, and ton of the ore can be held in this volume, so...) 1 000 / 0.0003 = 3 333 333 kg per m^3.
So, next formula is energy density: energy / mass * 10 000.
So, in our instance: 10^9 / 50 000 * 10 000 = 200 000 000 watts per kg

0<X<10 000 000
Kinetic explosion

10 000 000 < X < 50 000 000
Laser explosion

50 000 00 < X < 200 000 000
Blast

200 000 000 < X < 500 000 000
Thermo

500 000 000 < X < 1 000 000 000
Plasma

1 000 000 000 < X < 10 000 000 000
Graviton (Energy - gravity ? )

10 000 000 000 < X < INFINITY
Singularity (Energy - singularity ? )

Now, radius. There's nothing hard to compute: volume / 1 000 000 (one ton - one thirteen of ls)


So, can someone give me a list of functions and variables i need to make that?

(( to be honest that's practice of coding. Code something hard before you start to make something other ))
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

Here's a list of resources that I find to be useful:
list of functions:
http://forums.kronosaur.com/viewtopic.php?f=8&t=6136
making weapons:
http://transcendence.kronosaur.com/wiki ... on_devices
list of events (but they might not work on all types):
http://transcendence.kronosaur.com/wiki ... s[]=events

If you have any more questions, just ask ;)
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Image
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
EditorRUS
Militia Lieutenant
Militia Lieutenant
Posts: 148
Joined: Tue Oct 30, 2012 6:30 pm

Nothing of those links have information about interaction with bullets and missile.

In fact there's only three such events that could be useful - <OnDamage%something%>.
Although it can be useful it still doesn't give any opportunity to change bullets.
There's no way to make WIDE BEAM except firing many of them at once from different positions.
There's also no way to make projectile do something when it intersects with another projectile.

Of course i can make all of the idea without that, but that's not hardcore way to go(tm)
User avatar
sun1404
Militia Captain
Militia Captain
Posts: 527
Joined: Thu Nov 03, 2011 10:32 am
Location: Heretic. (Finally!)

Well, the best way is possibly to look at present weapon codes. The interaction/Boom-on-hit part you spoke of can be found in most missiles' codes, there are preset shockwave/radius attacks that can be customized, and you may even find more ideas for your weapon.

I'm not sure about changing the bullet, but I think I've once saw a mod with a weapon that you can choose how much energy it will consume, and the shot's power will scale with the energy you select. Also I've seen mods that contain weapons that randomly fire many kinds of shots.
Yes, look at my avatar, I have a wyvera type ship.
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

Although it can be useful it still doesn't give any opportunity to change bullets.<-- use systemCreateWeaponFire?
There's no way to make WIDE BEAM except firing many of them at once from different positions. <--- If worst comes to worst you can always make an image of a wide beam and have the weapon fire that.
There's also no way to make projectile do something when it intersects with another projectile. <--- You're right, it's currently not possible.
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Image
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
EditorRUS
Militia Lieutenant
Militia Lieutenant
Posts: 148
Joined: Tue Oct 30, 2012 6:30 pm

Although it can be useful it still doesn't give any opportunity to change bullets.<-- use systemCreateWeaponFire?
Oh, it seems like what i want. Anyway, i meant that there's no way to change bullets when they're flying. For instance let's take next situation: there's a weapon whose bullets, when they are near enough to an enemy ship teleport right before the ship and change their direction in opposite side of direction the ship flying. Try to make that.
PM
Fleet Admiral
Fleet Admiral
Posts: 2570
Joined: Wed Sep 01, 2010 12:54 am

With events, it is possible to make missiles do some things in mid-flight.
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.
TVR
Militia Commander
Militia Commander
Posts: 334
Joined: Sat Sep 08, 2012 3:26 am

It's possible to create a fully scripted weapon (damage, radius, impulse) including collision detection, as done so for the Interceptor anti-missile launcher in the PDmod by using a lifetime="1", failsafe="0" weapon with a self-cloning <OnFragment> event. The only limitations are projectile HP and that collision detection is low resolution.

I shall prepare a framework for you by next week. Also, it's good to see you again, EditorRUS!
Fiction is reality, simplified for mass consumption.
PGP: 0x940707ED, 5DB8 4CB4 1EF5 E987 18A0 CD99 3554 3C13 9407 07ED
Bitcoin: 1LLDr7pnZDjXVT5mMDrkqRKkAPByPCQiXQ
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

TVR wrote:It's possible to create a fully scripted weapon (damage, radius, impulse) including collision detection, as done so for the Interceptor anti-missile launcher in the PDmod by using a lifetime="1", failsafe="0" weapon with a self-cloning <OnFragment> event. The only limitations are projectile HP and that collision detection is low resolution.

I shall prepare a framework for you by next week. Also, it's good to see you again, EditorRUS!
Beware that doing this on anything of which multiple instances might be in use in a system risks causing lag. The TVR's low resolution collision detection is cheaper than the engine's collision detection, but the event overhead can add up quickly when running an event per tick per projectile and object filtering involves iteration in the engine even if none is done at the script level.
Literally is the new Figuratively
TVR
Militia Commander
Militia Commander
Posts: 334
Joined: Sat Sep 08, 2012 3:26 am

Still interested in this weapon, EditorRUS?
Fiction is reality, simplified for mass consumption.
PGP: 0x940707ED, 5DB8 4CB4 1EF5 E987 18A0 CD99 3554 3C13 9407 07ED
Bitcoin: 1LLDr7pnZDjXVT5mMDrkqRKkAPByPCQiXQ
EditorRUS
Militia Lieutenant
Militia Lieutenant
Posts: 148
Joined: Tue Oct 30, 2012 6:30 pm

Yeah, i've been learning the language for few days.

Now, i have written the MIDAS.
But it's laggy. Well, there's nothing strange - that bomb emits 200 rays per second, which are alive for 10 seconds, so, 2K rays.

I tried to repeat the bomb in the video: http://www.youtube.com/watch?v=6_KLAiyMynI .

Now, i've learnt the language for 50%. The syntax is really confusing, though.

[spoiler=]

Code: Select all

				<Missile ammoID="&itMidas;"
						type=			"missile"

						damage=			"generic:0"
						missileSpeed=	"10"
						hitPoints=		"200"
						lifetime=		"200"

						maneuverability="2"

						sound=			"&snMissileLauncher;"
						vaporTrailLength="100"
						vaporTrailWidth="150"
						vaporTrailWidthInc="10"
						vaporTrailColor="0xa0, 0xc0, 0xc0"
						>

					<Effect>
						<Image imageID="&rsStdMissile1;" imageX="0" imageY="0" imageWidth="32" imageHeight="32" rotationCount="40"/>
					</Effect>						

					<HitEffect
							sound="&snArmorHit1;"
							>
						<Image imageID="&rsExplosionsAG128;"
								imageX="0"
								imageY="0"
								imageWidth="128"
								imageHeight="128"
								imageFrameCount="16"
								imageTicksPerFrame="2"/>
					</HitEffect>

					<Fragment 
							count=			"1"
							type=			"radius"

							damage=			"thermo:0d0; momentum7; WMD7"
							minRadius=		"1"
							maxRadius=		"40"
							missileSpeed=	"0"
							>

						<Effect>
							<Flare
									style=			"fadingBlast"
									radius=			"0"
									primaryColor=	"0xff, 0xff, 0xf0"
									lifetime=		"20"
									/>
						</Effect>
					</Fragment>
					<Events>								
						<OnFragment>
							(block (x)
								(setq x (sysCreateStation &stMidasEmitter; aHitPos))
								(objFireEvent x "Start")
							)
						</OnFragment>
					</Events>
				</Missile>
			</Missiles>

		</Weapon>

	</ItemType>

	<ItemType UNID="&itMidas;"
			name=				"M.I.D.A.S. bomb"
			level=				"10"
			value=				"250000"
			mass=				"500"
			frequency=			"veryrare"
			numberAppearing=	"1"
			attributes=			"Consumable; Missile; NAMILauncher; Commonwealth;"
			showReference=		"true"

			description=		"This is the most powerful gamma-bomb ever created. It emits antimatter ray, that passes through any object and destroy it very quickly."

			sortName=			"MIDAS"
			>

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

	<ItemType UNID="&itMidasRay;"
			name=				"(midas ray)"
			virtual=			"1"
			level=				"25"
>
			<Weapon
				type=				"beam"
				damage=				"generic:5; WMD7; mining7; shatter7; momentum2"
				lifetime=			"25"
				passthrough=		"100"
				>
				<Effect>
					<Beam
                                beamType=			"laser"
								primaryColor=		"0xff, 0xff, 0xff"
								secondaryColor=		"0xff, 0x00, 0xff"
							/>
				</Effect>
			</Weapon>
	</ItemType>
	
	<StationType UNID="&stMidasEmitter;"
		name=					"(midas emitter)"
		virtual=				"1"
		>
		<Events>
			<Emit>
					(block (tick angles)
						(setq tick (objGetData gSource "tick"))
						(setq angles (objGetData gSource "angles"))
						(objIncData gSource "tick")
						(enum angles ang
							(block Nil
								(sysCreateWeaponFire &itMidasRay; gSource (objGetPos gSource) ang (divide tick 250) Nil)
							)
						)
						(if (leq tick 10000)
							(if (eq (modulo tick 1000) 0)
								(sysAddObjTimerEvent 5 gSource "Emit") (objFireEvent gSource "Emit"))
							nil
						)
						(if (eq (modulo tick (divide 10000 4)) 0) (objFireEvent gSource "Split"))
						tick
					)
			</Emit>
			<Split>
				(block (toOperate got len)
					(setq toOperate (objGetData gSource "angles"))	
					(setq len (count toOperate))
					(for indx 0 (subtract len 2)
						(block (current next)
							(setq current (item toOperate indx))
							(setq next (item toOperate (add indx 1)))
							(setq got (append got (divide (add current next) 2)))
						)
					)
					(objSetData gSource "angles" (sort (append toOperate got) ))
				)
			</Split>
			<Start>
				(block Nil
					(objSetData gSource "angles" (list 0 90 180 270 360))
					(objSetData gSource "tick" 1)
					(objFireEvent gSource "Emit")
				)
			</Start>
		</Events>
	</StationType>
[/spoiler]
That's old code.
Now, i can try to code my weapon.
EditorRUS
Militia Lieutenant
Militia Lieutenant
Posts: 148
Joined: Tue Oct 30, 2012 6:30 pm

I found the way to make custom weapon, thanks to WeaponLabs mod - by using [CDATA] block and TemplateType.
EditorRUS
Militia Lieutenant
Militia Lieutenant
Posts: 148
Joined: Tue Oct 30, 2012 6:30 pm

Oookk... i have written dat weapon for 4/5.

And well, there's some errors.

http://pastebin.com/rjqhqWjz

First of all: commented part. For some reason (i can't understand why) it always disables 1st to 3rd actions and enables 5th actions as if the weapon has ready=1 and gathers=0.

Another one error: (Identifier expected [Nil]

Code: Select all

                                <Action name="Start to collect power" key="s"> ;2
                                        (block (vLoad)
                                                (typCreate &loaderEMC; (subst (objGetStaticData gSource "EnergyLoad")
                                                {
                                                puse: (divide (objGetMaxPower gPlayerShip) 2)
                                                }
                                                ))
                                                (setq vLoad (itmCreate &loaderEMC; 1))
                                                (objAddItem gPlayerShip vLoad)
                                                (shpInstallDevice gPlayerShip vLoad)
                                                (objSetData vLoad "parent" gSource)
                                                (objSetData gSource "gathers" 1)
                                                (scrShowPane gScreen "Default")
                                        )
                                </Action>
Somewhere here.
EditorRUS
Militia Lieutenant
Militia Lieutenant
Posts: 148
Joined: Tue Oct 30, 2012 6:30 pm

Also i tried to make "get information" dockscreen that refreshes itself every tick, but i haven't found a way to run OnPaneInit on the pane.

gSource doesn't work. It returns main object.
[OnGlobalPaneInit] doesn't work too otherwise aPane could be useful.
TVR
Militia Commander
Militia Commander
Posts: 334
Joined: Sat Sep 08, 2012 3:26 am

I'll keep you updated with errors and fixes.

Problem:

Code: Select all

(objSetData vLoad "parent" gSource)
vLoad is not a spaceObject; vLoad is an itemStruct. (objSetData) only stores data on spaceObjects.

Solution: As far as I know, it is impossible to store data on an itemStruct. Instead, try storing the data about the item on the ship with

Code: Select all

(objSetData gSource (cat (item gItem 0) (item gItem 1) "identifier") data)
and retrieving it with

Code: Select all

(objGetData gSource (cat (item gItem 0) (item gItem 1) "identifier") data)
Fiction is reality, simplified for mass consumption.
PGP: 0x940707ED, 5DB8 4CB4 1EF5 E987 18A0 CD99 3554 3C13 9407 07ED
Bitcoin: 1LLDr7pnZDjXVT5mMDrkqRKkAPByPCQiXQ
Post Reply