Skip to content

Add plugin API to VehicleCrashedParticle#22046

Merged
Gymnasiast merged 2 commits into
OpenRCT2:developfrom
spacek531:api/crashed-vehicle-particle
May 29, 2024
Merged

Add plugin API to VehicleCrashedParticle#22046
Gymnasiast merged 2 commits into
OpenRCT2:developfrom
spacek531:api/crashed-vehicle-particle

Conversation

@spacek531

@spacek531 spacek531 commented May 17, 2024

Copy link
Copy Markdown
Collaborator

Allows plugins to spawn VehicleCrashedParticles the way cpp code can.

I tested both calling SetupValues from plugin and crashing a regular roller coaster. Everything seemed normal.

@github-actions github-actions Bot added the requires dependency Another change should be merged first. label May 17, 2024
@spacek531 spacek531 force-pushed the api/crashed-vehicle-particle branch from f018c0f to ba2bea9 Compare May 17, 2024 15:36
Comment thread distribution/openrct2.d.ts Outdated
Comment thread distribution/openrct2.d.ts
Comment thread distribution/openrct2.d.ts Outdated
Comment thread src/openrct2/scripting/bindings/world/ScMap.cpp Outdated
Comment thread src/openrct2/scripting/bindings/world/ScMap.cpp Outdated
Comment thread distribution/openrct2.d.ts Outdated
@spacek531 spacek531 force-pushed the api/crashed-vehicle-particle branch from 0305f3d to c5d37e9 Compare May 19, 2024 18:02
@spacek531

Copy link
Copy Markdown
Collaborator Author

I have removed the double increment for API version from this PR because #22048 is expanding in scope and not ready for merging, while this PR is ready (after review)

@github-actions github-actions Bot removed the requires dependency Another change should be merged first. label May 19, 2024
Comment thread distribution/openrct2.d.ts Outdated
Comment thread distribution/openrct2.d.ts Outdated
Comment thread distribution/openrct2.d.ts
@spacek531 spacek531 force-pushed the api/crashed-vehicle-particle branch from 51fea0f to a698914 Compare May 25, 2024 22:09

@Basssiiie Basssiiie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Would the string union for the particle type still be possible? 😃

Edit: my test script so far btw.
registerPlugin({
	name: 'Test crash particle',
	version: '1',
	authors: ['Basssiiie'],
	type: 'local',
	licence: 'MIT',
	targetApiVersion: 100,
	main() {
		ui.registerMenuItem("Test crash particle", function()
		{
			ui.activateTool({
				id: "crash-particle",
				cursor: "cross_hair",
				onDown: function(args)
				{
					var coords = args.mapCoords;
					if (!coords) return;
					if (args.tileElementIndex !== undefined)
						coords.z = map.getTile(Math.floor(coords.x/32), Math.floor(coords.y/32)).getElement(args.tileElementIndex).baseZ;

					var particle = map.createEntity("crashed_vehicle_particle", coords);

					function setColour(part, colour)
					{
						var colours = particle.colours;
						console.log(colours);
						colours[part] = colour;
						particle.colours = colours;
					}

					console.log(coords, particle);

					var window = ui.openWindow({
						classification: "test-crash-particle",
						title: "Crash particle",
						width: 210,
						height: 280,
						onUpdate: function()
						{
							if (!particle || particle.type != "crashed_vehicle_particle") return;
							var colour1 = window.findWidget("colour1");
							var colour2 = window.findWidget("colour2");
							var timeToLive = window.findWidget("timeToLive");
							var frame = window.findWidget("frame");
							var velocity = window.findWidget("velocity");
							var acceleration = window.findWidget("acceleration");
							var crashParticleType = window.findWidget("crashParticleType");

							colour1.colour = particle.colours.main; // should be body
							colour2.colour = particle.colours.trim;
							timeToLive.text = String(particle.timeToLive);
							frame.text = String(particle.frame);
							velocity.text = [ particle.velocity.x, particle.velocity.y, particle.velocity.z ].join(', ');
							acceleration.text = [ particle.acceleration.x, particle.acceleration.y, particle.acceleration.z ].join(', ');
							crashParticleType.selectedIndex = particle.crashParticleType;
						},
						widgets: [
							{
								type: "colourpicker",
								name: "colour1",
								x: 5,
								y: 20,
								width: 20,
								height: 20,
								onChange: function(col)
								{
									setColour("main", col) // should be body
								}
							},
							{
								type: "colourpicker",
								name: "colour2",
								x: 25,
								y: 20,
								width: 20,
								height: 20,
								onChange: function(col)
								{
									setColour("trim", col)
								}
							},
							{
								type: "textbox",
								name: "timeToLive",
								x: 5,
								y: 40,
								width: 200,
								height: 15,
								onChange: function(text)
								{
									particle.timeToLive = Number(text);
								}
							},
							{
								type: "textbox",
								name: "frame",
								x: 5,
								y: 60,
								width: 200,
								height: 15,
								onChange: function(text)
								{
									particle.frame = Number(text);
								}
							},
							{
								type: "textbox",
								name: "velocity",
								x: 5,
								y: 80,
								width: 200,
								height: 15,
								onChange: function(text)
								{
									var coords = text.split(',');
									particle.velocity = { x: Number(coords[0]), y: Number(coords[1]), z: Number(coords[2]) };
								}
							},
							{
								type: "textbox",
								name: "acceleration",
								x: 5,
								y: 100,
								width: 200,
								height: 15,
								onChange: function(text)
								{
									var coords = text.split(',');
									particle.acceleration = { x: Number(coords[0]), y: Number(coords[1]), z: Number(coords[2]) };
								}
							},
							{
								type: "dropdown",
								name: "crashParticleType",
								x: 5,
								y: 120,
								width: 200,
								height: 15,
								items: [ "Particle 0", "Particle 1", "Particle 2", "Particle 3", "Particle 4" ],
								onChange: function(index)
								{
									particle.crashParticleType = index;
								}
							},
							{
								type: "button",
								x: 5,
								y: 140,
								width: 200,
								height: 15,
								text: "Launch",
								onClick: function() { particle.launch({ main: 0, trim: 1, tertiary: 2 })} // should be body
							},
						]
					})
				}
			})
		});
	},
});

Comment thread src/openrct2/scripting/bindings/entity/ScParticle.cpp Outdated
@spacek531 spacek531 force-pushed the api/crashed-vehicle-particle branch from 83a5e8c to 12ac882 Compare May 27, 2024 17:51

@Basssiiie Basssiiie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it again and LGTM!

Comment thread src/openrct2/entity/Particle.cpp Outdated
Co-authored-by: Michael Steenbeek <1478678+Gymnasiast@users.noreply.github.com>
@Gymnasiast Gymnasiast merged commit 94750f4 into OpenRCT2:develop May 29, 2024
@tupaschoal tupaschoal added this to the v0.4.12 milestone May 29, 2024
janisozaur added a commit that referenced this pull request Jul 7, 2024
- Feature: [#622] Add option to align the top toolbar buttons horizontally centred (off by default).
- Feature: [#20263] Ability to increase the size of the map in the (0, 0) direction.
- Feature: [#21714] [Plugin] Costume assignment is now tailored to each staff type.
- Feature: [#21853] Enlarged UI mode.
- Feature: [#21893, #22065] On launch, the game now indicates what system is being initialised.
- Feature: [#21913] [Plugin] Allow precise and safe control of peep animations.
- Feature: [#22046] [Plugin] Add interface for crashed vehicle particle.
- Feature: [#22085] [Plugin] The result of actions that create banners now includes the bannerIndex.
- Feature: [#22087] [Plugin] Expose guests’ favourite rides to the plugin API.
- Feature: [#22090] [Plugin] Allow writing of paused state in non-networked settings.
- Feature: [#22140] Add option to automatically close dropdown menus if Enlarged UI is enabled.
- Feature: [#22150] [Plugin] Expose monthly expenditure history to the plugin API.
- Feature: [#22210] [Plugin] Peeps can now be made stationary or completely frozen.
- Feature: [#22210] [Plugin] The direction in which a peep is facing can now be manipulated.
- Improved: [#19870] Allow using new colours in UI themes.
- Improved: [#21774] The Alpine Coaster now supports using the alternative colour schemes.
- Improved: [#21853] Dropdowns now automatically use multiple columns if they are too tall for the screen.
- Improved: [#21981] Rendering performance of the map window has been improved considerably.
- Improved: [#21981] The map window now defaults to showing as much of the map as fits the screen.
- Improved: [#21983] Taking a screenshot now shows a message again, closing when taking another.
- Improved: [#22026] The options window now stays centred when window scaling is changed.
- Improved: [#22060] [Plugin] The scroll wheel can now be used to modify spinner widget values in custom/script windows.
- Improved: [#22065] Joining a network game now indicates progress using coaster trains.
- Improved: [#22075] [Plugin] Plugins can now use G1 Icons.
- Improved: [#22084] The game now temporarily pauses while the load/save window is open.
- Improved: [#22217] See-through items are ignored again in viewport/pointer interaction.
- Improved: [objects#238] Add preview image for invisible queue.
- Improved: [objects#329] Add RCT1AA lay-down coaster trains (for import only).
- Change: [#7248] Small mini-maps are now centred in the map window.
- Change: [#20240] Heavy snow and blizzards now make guests buy and use umbrellas.
- Change: [#21043] The new music styles are no longer added to old parks automatically.
- Change: [#21214] Wacky Worlds and Time Twister’s scenario names now match their park names.
- Change: [#21991] UI themes JSON now use colour names and a translucency bool, instead of a number (old themes still work).
- Change: [#22057] Reorder Time Twister’s scenarios and adjust their difficulty classification.
- Change: [#22173] Patrol path selection is visible over existing patrol paths.
- Change: [#22196] Make track navigation buttons holdable.
- Change: [#22227] [Plugin] Ride prices are now constrained for plugins as well.
- Fix: [#13234] Vehicle weight sometimes wrong after using Remove All Guests cheat.
- Fix: [#13294] Map corners are cut off in some directions (original bug).
- Fix: [#14630] Non-ASCII thousands and decimal separators not processed correctly.
- Fix: [#21496] Some RCT1 scenery is hidden after saving and reloading.
- Fix: [#21533] Support glitches on Hybrid Coaster.
- Fix: [#21974] No reason specified when attempting to place benches, lamps, or bins on path with no unconnected edges (original bug).
- Fix: [#21987] [Plugin] API cannot handle negative removal prices.
- Fix: [#22008] Uninverted Lay-down roller coaster uses the wrong support type.
- Fix: [#22012] [Plugin] Images on ImgButton widgets cannot be updated.
- Fix: [#22121] Some news items in the “Recent Messages” window have the wrong text colour.
- Fix: [#22152] [Plugin] Negative signed integers are truncated.
- Fix: [#22161] Using arrow keys in textboxes crashes the game.
- Fix: [#22174] Cheats are reset when starting a server.
- Fix: [#22185] Intensity and nausea are incorrectly sorted in the rides list after ratings invalidation.
- Fix: [#22226] Red traffic light shows incorrect sprite when pressed.
- Fix: [objects#323] Incorrect wall boundaries on large WW/TT scenery objects.
- Fix: [objects#331] Incorrect hover car capacity string.
- Fix: [objects#334] Incorrect school bus capacity string.
- Fix: [objects#337] Swan Boats use an incorrect third remap colour (original bug).
CorySanin added a commit to CorySanin/OpenRCT2 that referenced this pull request Feb 3, 2025
Release v0.4.12

- Feature: [OpenRCT2#622] Add option to align the top toolbar buttons horizontally centred (off by default).
- Feature: [OpenRCT2#20263] Ability to increase the size of the map in the (0, 0) direction.
- Feature: [OpenRCT2#21714] [Plugin] Costume assignment is now tailored to each staff type.
- Feature: [OpenRCT2#21853] Enlarged UI mode.
- Feature: [OpenRCT2#21893, OpenRCT2#22065] On launch, the game now indicates what system is being initialised.
- Feature: [OpenRCT2#21913] [Plugin] Allow precise and safe control of peep animations.
- Feature: [OpenRCT2#22046] [Plugin] Add interface for crashed vehicle particle.
- Feature: [OpenRCT2#22085] [Plugin] The result of actions that create banners now includes the bannerIndex.
- Feature: [OpenRCT2#22087] [Plugin] Expose guests’ favourite rides to the plugin API.
- Feature: [OpenRCT2#22090] [Plugin] Allow writing of paused state in non-networked settings.
- Feature: [OpenRCT2#22140] Add option to automatically close dropdown menus if Enlarged UI is enabled.
- Feature: [OpenRCT2#22150] [Plugin] Expose monthly expenditure history to the plugin API.
- Feature: [OpenRCT2#22210] [Plugin] Peeps can now be made stationary or completely frozen.
- Feature: [OpenRCT2#22210] [Plugin] The direction in which a peep is facing can now be manipulated.
- Improved: [OpenRCT2#19870] Allow using new colours in UI themes.
- Improved: [OpenRCT2#21774] The Alpine Coaster now supports using the alternative colour schemes.
- Improved: [OpenRCT2#21853] Dropdowns now automatically use multiple columns if they are too tall for the screen.
- Improved: [OpenRCT2#21981] Rendering performance of the map window has been improved considerably.
- Improved: [OpenRCT2#21981] The map window now defaults to showing as much of the map as fits the screen.
- Improved: [OpenRCT2#21983] Taking a screenshot now shows a message again, closing when taking another.
- Improved: [OpenRCT2#22026] The options window now stays centred when window scaling is changed.
- Improved: [OpenRCT2#22060] [Plugin] The scroll wheel can now be used to modify spinner widget values in custom/script windows.
- Improved: [OpenRCT2#22065] Joining a network game now indicates progress using coaster trains.
- Improved: [OpenRCT2#22075] [Plugin] Plugins can now use G1 Icons.
- Improved: [OpenRCT2#22084] The game now temporarily pauses while the load/save window is open.
- Improved: [OpenRCT2#22217] See-through items are ignored again in viewport/pointer interaction.
- Improved: [objects#238] Add preview image for invisible queue.
- Improved: [objects#329] Add RCT1AA lay-down coaster trains (for import only).
- Change: [OpenRCT2#7248] Small mini-maps are now centred in the map window.
- Change: [OpenRCT2#20240] Heavy snow and blizzards now make guests buy and use umbrellas.
- Change: [OpenRCT2#21043] The new music styles are no longer added to old parks automatically.
- Change: [OpenRCT2#21214] Wacky Worlds and Time Twister’s scenario names now match their park names.
- Change: [OpenRCT2#21991] UI themes JSON now use colour names and a translucency bool, instead of a number (old themes still work).
- Change: [OpenRCT2#22057] Reorder Time Twister’s scenarios and adjust their difficulty classification.
- Change: [OpenRCT2#22173] Patrol path selection is visible over existing patrol paths.
- Change: [OpenRCT2#22196] Make track navigation buttons holdable.
- Change: [OpenRCT2#22227] [Plugin] Ride prices are now constrained for plugins as well.
- Fix: [OpenRCT2#13234] Vehicle weight sometimes wrong after using Remove All Guests cheat.
- Fix: [OpenRCT2#13294] Map corners are cut off in some directions (original bug).
- Fix: [OpenRCT2#14630] Non-ASCII thousands and decimal separators not processed correctly.
- Fix: [OpenRCT2#21496] Some RCT1 scenery is hidden after saving and reloading.
- Fix: [OpenRCT2#21533] Support glitches on Hybrid Coaster.
- Fix: [OpenRCT2#21974] No reason specified when attempting to place benches, lamps, or bins on path with no unconnected edges (original bug).
- Fix: [OpenRCT2#21987] [Plugin] API cannot handle negative removal prices.
- Fix: [OpenRCT2#22008] Uninverted Lay-down roller coaster uses the wrong support type.
- Fix: [OpenRCT2#22012] [Plugin] Images on ImgButton widgets cannot be updated.
- Fix: [OpenRCT2#22121] Some news items in the “Recent Messages” window have the wrong text colour.
- Fix: [OpenRCT2#22152] [Plugin] Negative signed integers are truncated.
- Fix: [OpenRCT2#22161] Using arrow keys in textboxes crashes the game.
- Fix: [OpenRCT2#22174] Cheats are reset when starting a server.
- Fix: [OpenRCT2#22185] Intensity and nausea are incorrectly sorted in the rides list after ratings invalidation.
- Fix: [OpenRCT2#22226] Red traffic light shows incorrect sprite when pressed.
- Fix: [objects#323] Incorrect wall boundaries on large WW/TT scenery objects.
- Fix: [objects#331] Incorrect hover car capacity string.
- Fix: [objects#334] Incorrect school bus capacity string.
- Fix: [objects#337] Swan Boats use an incorrect third remap colour (original bug).
@spacek531 spacek531 deleted the api/crashed-vehicle-particle branch September 9, 2025 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants