Multi-part death trigger tutorial

Scripting help, tricks, and tips. How to use the editor.
Post Reply
KittyBeast
Posts: 22
Joined: Sat Jun 09, 2012 2:42 am
Location: Norway

Multi-part death trigger tutorial

Post by KittyBeast »

Introduction:

This is a fairly uncommon way to create death triggers but basically it's possible to stack death triggers on top of each other to execute some other command. I've made an example of this which can be found here: http://zetaflow.skylogic.ca/game/profile/14620

TL;DR:

The yellow text explains the following code.

Uses for this:

1: Assume you have 2 parts and the core. The core has been made invincible, and the intended way to make it vulnerable would be to destroy the two parts in the level. Without multi-part death triggers, this would have to be solved by placing a part to cover the core to act as the first shield, which would be destroyed by the first death trigger, and then the second part to make the core vulnerable. This would ruin the look of your level.

2: Take the previous example and instead of wanting to make the core vulnerable, assume you wanted to enable a gun, or change the color of a part. In order to do this you would have to use multi-part triggers to get the desired result. There is no other way to do this with the condition that only the two intended parts get destroyed.

Explanation and how to use multi-part death triggers:

Death triggers work in that when you destroy the part that the death trigger is attached to, you can execute a new command. A few examples of this would be:

Death trigger usage

Code: Select all

makeTrigger, death, SOURCE_PART#, ANY_COMMAND
makeTrigger, death, 1, destroy, 0
makeTrigger, death, 1, col, FFFFFF, 0
makeTrigger, death, 1, makeTrigger, time, 100, makeVulnerable, 0 
The death trigger is limited in that you can only use it with one part at a time. The following command would not work because part 2 would overwrite the command- rendering it useless.

Incorrect usage

Code: Select all

makeTrigger, death, 1, 2, destroy, 0
Here's how to use multi-part death triggers. The following code would destroy the core after you have destroyed part 1 and part 2:

Two part death trigger

Image

Code: Select all

makeTrigger, death, 1, makeTrigger, death, 2, destroy, 0
makeTrigger, death, 2, makeTrigger, death, 1, destroy, 0
Both commands have to be included. Here's why: the first line of code is based around part 1 being destroyed first. After part 1 has died, the command waits for part 2 to die, which leads to the core being destroyed. If you only had this command, then if you destroyed part 2 first, and then part 1, it would wait for part 2 to be destroyed, which has already been destroyed- rendering this command impossible.

That's why you need to add a second command with part 2 first followed by part 1. No matter what, both commands will never trigger, only one of them.

This is the most efficient way of creating multi-part death triggers. If you want to use more parts in the multi-part death trigger, then there are ways to be more efficient. Let me show you an example of code for a 3-part multi-part death trigger:

Inefficient three part death trigger

Image

Code: Select all

makeTrigger, death, 1, makeTrigger, death, 2, makeTrigger, death, 3, destroy, 0
makeTrigger, death, 1, makeTrigger, death, 3, makeTrigger, death, 2, destroy, 0
makeTrigger, death, 2, makeTrigger, death, 1, makeTrigger, death, 3, destroy, 0
makeTrigger, death, 2, makeTrigger, death, 3, makeTrigger, death, 1, destroy, 0
makeTrigger, death, 3, makeTrigger, death, 1, makeTrigger, death, 2, destroy, 0
makeTrigger, death, 3, makeTrigger, death, 2, makeTrigger, death, 1, destroy, 0
As you can see, just adding one more part to the death trigger makes it highly inefficient. The reason for this, by the way, is that the amount of lines you will need is equal to the factorial of the amount of parts you have in the multi-part death trigger. 2!=2 lines of code, 3!=6 lines of code, 4!=24 lines of code and so on. Here's one way to get around this ever increasing amount of lines:

Assume you want to make a 3 part death trigger. Place the three parts and one more part which will be invicible (using setWidth and setHeight), invincible and preferably connected to the core. This fourth part will be an aid for the multi-part death trigger, and will shorten the code, especially as you get more parts for a death trigger.

Using the following code you will get a 3 part death trigger (using the set-up listed in the above paragraph:

Efficient three part death trigger using four parts

Image

Code: Select all

makeTrigger, death, 1, makeTrigger, death, 2, destroy, 4
makeTrigger, death, 2, makeTrigger, death, 1, destroy, 4
makeTrigger, death, 3, makeTrigger, death, 4, makeVulnerable, 0
makeTrigger, death, 4, makeTrigger, death, 3, makeVulnerable, 0
Image

This will act as two times two part death triggers connected to each other to act as a 3 part death trigger. The code is 2 lines shorter than a 3 part death trigger and uses 1 more part, but serves the same function.

The same can be used for a four part death trigger, and instead of using 24 lines of code, you can rather use 6 lines of code and 6 parts. Assume part 1,2,3 and 4 are visible and part 5 and 6 are invisible and invincible. Here's how that would look:

Efficient four part death trigger using six parts

Image

Code: Select all

makeTrigger, death, 1, makeTrigger, death, 2, destroy, 5
makeTrigger, death, 2, makeTrigger, death, 1, destroy, 5
makeTrigger, death, 3, makeTrigger, death, 4, destroy, 6
makeTrigger, death, 4, makeTrigger, death, 3, destroy, 6
makeTrigger, death, 5, makeTrigger, death, 6, makeVulnerable, 0
makeTrigger, death, 6, makeTrigger, death, 5, makeVulnerable, 0
Image

And that's most of it. Have a look at these levels which make use of some variant of this and the various ways you can use multi-part death triggers:

asdasdg's order doesn't matter http://zetaflow.skylogic.ca/game/profile/13120
Piconoe's [Xenon Saga] Armored Space Destroyer http://zetaflow.skylogic.ca/game/profile/14430
KittyBeast's Challenge mode: Level 8 http://zetaflow.skylogic.ca/game/profile/14691
KittyBeast's Guardian http://zetaflow.skylogic.ca/game/profile/14626

I hope this has inspired some of to try using some multi-part death triggers! Perhaps my in depth explanations can spark some new never-before-seen concepts. I guess I'll have to see :-)

UPDATE: Added illustrations to clear up confusion. Green circles are visible and interactive parts, red circles are invisible and invincible. The logic illustrations shows what parts interact with each other.

Thanks for reading
Kind regards,
KittyBeast
Last edited by KittyBeast on Sat Jan 19, 2019 2:08 am, edited 5 times in total.
MD
Site Admin
Posts: 195
Joined: Sun Aug 12, 2007 2:06 pm

Re: Multi-part death trigger tutorial

Post by MD »

Thanks for the tutorial KittyBeast! I think it should help some people out.
KittyBeast
Posts: 22
Joined: Sat Jun 09, 2012 2:42 am
Location: Norway

Re: Multi-part death trigger tutorial

Post by KittyBeast »

No problem MD! I'll probably make more tutorials to spread my knowledge about the game in a comprehensive yet newbie-friendly way :-)
Next, I'll make sure everyone uses the legacy commands that are in the campaign hahaha!
Post Reply