Decorate. Creating runes.

This lesson was made by requisites by Stepan Kolesnichenko. You can leave your requistas in the VK group or in the comments to the record.

Disassembling actors

Before you begin, download wad from MEGA.

Then, open the DECORATEfile in it. There are 3 actors:

  • rune_part is a rune that spawns rune_part_generator every 10 ticks (1 tick = 1/35 of a second)
  • rune_part_generator is an invisible actor that spawns several particles around it, giving them speed.
  • my_rune is the actor of the particle, disappearsover time.

Here's the code of our actors.

actor my_rune : Inventory 10000 {
	ActiveSound SFIRE
	height 32
	radius 32
	+float
	+floatbob
	states {
		spawn:
			TNT1 A 0 A_LoopActiveSound
			RUNE A 0 A_SpawnItemEx("rune_part_generator",0,0,0,0,0,0,0,0,0,0)
			RUNE A 10 Bright

loop
		pickup:
			RUNE A 1 A_StopSound
			stop
	}
}
actor rune_part_generator {
	+NOGRAVITY
	+noclip
	states {
		spawn:
			TNT1 AAAAAAAAA 1 A_SpawnItemEx("rune_part",random(20,-20),random(20,-20),random(-10,20),0,0,random(2,6),0,128,0)
			stop
	}
}
actor rune_part {
	+noclip 
	+NOGRAVITY
	scale 0.3
	states {
		spawn:
			PART AAAAAAAAAA 2 Bright A_FadeOut
			stop
	}
}

Let's analyze these actors.

+float
+floatbob

These flags cause the actor's sprite to move up/down.

ActiveSound SFIRE

As an activation sound, set the sound of fire. SFIREsound, like all others, is set in SNDINFO.

spawn:
  TNT1 A 0 A_LoopActiveSound
  RUNE A 0 A_SpawnItemEx("rune_part_generator",0,0,0,0,0,0,0,0,0,0)

In the spawnstate, we turn on the repetition of the activation sound (fire) using the command A_LoopActiveSound

And spawnrune_part_generator.

actor rune_part_generator {
	+NOGRAVITY
	+noclip
	states {
		spawn:
			TNT1 AAAAAAAAA 1 A_SpawnItemEx("rune_part",random(20,-20),random(20,-20),random(-10,20),0,0,random(2,6),0,128,0)
			stop
	}

He, in turn, will spawn several particles, located at a random distance around the rune. Similarly, the velocity of the particle is random random(2,6), and is directed upwards along the z-axis.

The particle generator has neither gravity (+NOGRAVITY) nor collision (+noclip), because it does not need them.

actor rune_part {
	+noclip 
	+NOGRAVITY
	scale 0.3
	states {
		spawn:
			PART AAAAAAAAAA 2 Bright A_FadeOut
			stop
	}
}

The particle itself gradually becomes transparent (A_FadeOut), and then disappears.

Also, when picking up the rune, the sound of fire is turned off.

pickup:
  RUNE A 1 A_StopSound
  stop

The rune was dealt with. Let's move on to the ACS code.

Disassemble the ACS code.

Functions drawImage, drawString, drawInt, I will not disassemble because disassembled here

We are currently interested in two scripts:

  • player_loop – the presence of the desired rune is checked
  • simple_rune – a script that is called if selected.

That is, in this script

script "player_loop" ENTER {
	SetHudSize(640, 480,0);
	if (CheckInventory("my_rune") > 0)
	{
		ACS_NamedExecute("simple_rune",0);
	}
	Delay(1);
	restart;
}

The script is called simple_rune. The best part is that the ACS_NamedExecutewill not allow you to call the script simple_runeuntil it finishes its work, so there will be no problems with synchronization.

ACS_NamedExecute("simple_rune",0);

If the number of items my_rune more than 0 (if available).

if (CheckInventory("my_rune") > 0)

Next, we go to the script simple_rune.

script "simple_rune" (void) {
	int my_timer = 1000;

while(CheckInventory("my_rune") > 0) {
		drawInt(my_timer, 1, 1000,1000);
		drawImage("RUNEA0",5,2000,12000);
		if (my_timer <= 0) break;
		if ((my_timer % 35) == 0) {
			HealThing(10);
		}
		SpawnForced("rune_part_generator",GetActorX(0),GetActorY(0),GetActorZ(0),0,0);
		my_timer--;
		Delay(1);
	}
	TakeInventory("my_rune", 1);
	Delay(1);
}

It stores the variable my_timer,which indicates the duration of the rune in ticks.

If the rune is in the inventory (selected)

while(CheckInventory("my_rune") > 0) {

Then, draw the value of the timer,and the picture of the rune, on the screen.

drawInt(my_timer, 1, 1000,1000);
drawImage("RUNEA0",5,2000,12000);

If the timer <= 0, то выходим из цикла.

if (my_timer <= 0) break;

Every 35 clicks (1 second) we give the player 10 hp.

if ((my_timer % 35) == 0) {
  HealThing(10);
}

Spawn in place of the player, particles of the rune.

SpawnForced("rune_part_generator",GetActorX(0),GetActorY(0),GetActorZ(0),0,0);

Reduce the timer by units so that the cycle is not infinite. And we do a back support of 1 tick.

my_timer--;
Delay(1);

After the rune has worked its own, we select it.

TakeInventory("my_rune", 1);

We analyze the little things.

It remains to disassemble GLDEFS which adds luminescence to actors, and SNDINFO adds sounds.

GLDEFS,I've dealt with in detail here.

FLICKERLIGHT rune_light
{
Color 1 0 0
OffSet 0 8 0
Size 20
SecondarySize 35
Chance 0.2
}

object rune_part
{
	frame PARTA0 {light rune_light}
}

SNDINFO has elementary syntax.

variablenamename_filename
  • variable_name – the name of the sound in the Code Decorate and ACS.
  • file_name – the name of the file without the extension that will be played when the variable_name is called

Actually, here's the SNDINFOcode.

SFIRE SFIRE
ZLOVESCH ZLOVESCH

Final result.

Пожалуйста отключи блокировщик рекламы, или внеси сайт в белый список!

Please disable your adblocker or whitelist this site!