It is possible to let certain objects appear on one background only...

1 1 1 1 1 1 1 1 1 1 Rating 3.69 (26 Votes)

 

Spawning objects in general is easy, just add a file in data.txt with an id between 100 and 199, and it'll drop from the sky randomly.

But now we get to the neat things: bg-dependent spawning. You must know about the characteristics of a bg. There are just a few things that make backgrounds totally different from each other, and these are:

* The images (no way!)
* The name (didn't think of it? Oh well, me neither)
* The width
* The zwidth

We don't care about the first two points, as they're just ridiculous and not contributing in any way. The other two, however, open a whole option of possibilities. Let's get to the width-part....

CAUTION! This method is only recommended if your background is the largest in the game, otherwise the DC-code will get a little nasty.

A weapon will drop, like regularly. But instead of being pickable, it'll act as a zero-placer. This means the following:

* The weapon will move with a constant speed (for example dvx: 10) towards one direction
* Every frame, the weapon will create a type-3-object (set the wait to something like 3 or 4 to prevent a crash because of too many objects)
* Four frames are essential for that type-3-object:

50 destroy_other
pic: 999 state: 3005 wait: 4 next: 51 dvx: 0 dvy: 0 dvz: 0 centerx: 50 centery: 50 hit_a: 0 hit_d: 0 hit_j: 0
bdy:
kind: 0 x: 0 y: 4500 w: 100 h: 50
bdy_end:
<frame_end>

51 being_destroyed
pic: 999 state: 3005 wait: 4 next: 52 dvx: 0 dvy: 0 dvz: 0 centerx: 50 centery: 50 hit_a: 0 hit_d: 0 hit_j: 0
itr:
kind: 9 x: 0 y: 4500 w: 59 h: 56 injury: 10 bdefend: 100 vrest: 10 zwidth: 3
itr_end:
<frame_end>

52 other_side
pic: 999 state: 3005 wait: 4 next: 1000 dvx: 0 dvy: 0 dvz: 0 centerx: 50 centery: 50 hit_a: 0 hit_d: 0 hit_j: 0
opoint:
kind: 1 x: -(BGwidth - 50) y: 50 action: (dummy-frame) dvx: 0 oid: (weapon-file) facing: 0
opoint_end:
<frame_end>

40 disappear
pic: 999 state: 3005 wait: 1 next: 1000 dvx: 0 dvy: 0 dvz: 0 centerx: 50 centery: 50 hit_a: 0 hit_d: 0 hit_j: 0
<frame_end>

Basically, what this does: as long as the weapon is on the bg (as soon as the weapon trespasses the boundaries, it'll disappear), it'll spawn objects, which will always kill each other (itr:/k: 9 goes to frame 40 as soon as it is being "hit" by a bdy). When the weapon finally goes over the border, the last object that has been spawned will go through all these frames. It'll remove the pre-last object, and then go to the next frame. What a wonder, there's nothing left to make this object disappear! So, it's gonna go to the next frame where it'll spawn the weapon again. If the background is smaller than you specified, the weapon won't come into existence. If it is that BG, the weapon will appear. There, it'll opoint your special attack.

Note that, depending on your bg-size, this method might take some time. So, if you hit F8, it won't directly do what you want. Just wait a few seconds.......

-----------------------------------------------------------------------

And here comes the "better" method:

Remember the other thing I was talking about? Yes, the zwidth. Each background has a certain zwidth (the difference between the two numbers from zboundary in the background-file). If you want to apply this method to your bg, use a characteristic zwidth. It's actually quite unimportant where the two boundaries are, what we need is the distance between them. For example: "zboundary: 393 502" has an effective area of 109. We're gonna "abuse" that >:D
By the way, the first one that I know of who has used this method was Jerry Hawk in his JW LF2-mod. He released these two backgrounds together with a tutorial in Chinese. Too bad that I didn't know about that and looked for a solution myself.

We still need our spawning-weapon, its sole purpose is to fall from the sky and opoint a type-3-object. Since I like type 2 because it has quite few default frames, I used it. The important frames are these:

20 on_ground
pic: 999 state: 2004 wait: 2 next: 22 dvx: 0 dvy: 0 centerx: 29 centery: 56
<frame_end>

22 on_ground
pic: 999 state: 2004 wait: 1 next: 1000 dvx: 0 dvy: 0 centerx: 29 centery: 56
opoint:
kind: 1 x: 29 y: 56 dvx: 0 action: 50 oid: 171 facing: 0
opoint_end:
<frame_end>

action: 50 is the start of my type-3-object. This time, the type-3-object will check for the right bg. oid: 171 is... well, guess... that specified type-3-object.

Now, in the type-3-object, we're checking if we have the right background. How are we gonna do this? Easy, just do the following steps:

* duplicate the created object.
* make one object go up (back into the screen) and the other go down
* now, let them approach each other
* bdy and itr/k:9 will take care of the rest


Basic knowledge: "hit_j" in type-3-objects works as a z-moving tag. Numbers higher than 50 will move your object to the front, lower than 50 to the back. 50 = 0; no movement.

Example:

50 Start
pic: 999 state: 3005 wait: 0 next: 51 dvx: 0 dvy: 550 centerx: 29 centery: 56
<frame_end>

51 Start
pic: 999 state: 3005 wait: 1 next: 52 dvx: 0 dvy: 550 centerx: 29 centery: 56
opoint:
kind: 1 x: 29 y: 56 action: 55 dvx: 0 dvy: 0 oid: 171 facing: 10
opoint_end:
<frame_end>

52 front
pic: 999 state: 3005 wait: 4 next: 53 dvx: 0 dvy: 550 centerx: 29 centery: 56 hit_j: 99 # => 109
<frame_end>

53 front-backwards
pic: 999 state: 3005 wait: 3 next: 54 dvx: 0 dvy: 550 centerx: 29 centery: 56 hit_j: 40 # => 69
<frame_end>

54 front-backwards
pic: 999 state: 3005 wait: 30 next: 1000 dvx: 0 dvy: 550 dvz: 550 centerx: 29 centery: 56
itr:
kind: 9 x: 0 y: 4500 w: 59 h: 56 injury: 10 bdefend: 100 vrest: 10 zwidth: 3
itr_end:
<frame_end>

55 back
pic: 999 state: 3005 wait: 4 next: 56 dvx: 0 dvy: 550 centerx: 29 centery: 56 hit_j: 1 # => 0
<frame_end>

56 back-forwards
pic: 999 state: 3005 wait: 4 next: 57 dvx: 0 dvy: 550 centerx: 29 centery: 56 hit_j: 62 # => 60
<frame_end>

57 back-forwards
pic: 999 state: 3005 wait: 0 next: 58 dvx: 0 dvy: 550 centerx: 29 centery: 56 hit_j: 61 # => 69
<frame_end>

58 back-forwards
pic: 999 state: 3005 wait: 30 next: 1000 dvx: 0 dvy: 550 dvz: 550 centerx: 29 centery: 56
bdy:
kind: 0 x: 0 y: 4500 w: 59 h: 56
bdy_end:
<frame_end>

One object is moving to the front, the other is moving to the back. From there, these two are moving towards each other. The numbers behind the "#" shall represent the z-pixel that is getting approached to in the specific frame (don't rely on the values, they're just approximately correct).

When these two are overlapping, the bdy-object will be removed due to its next-value, the other one will go to frame 40:

40 tadah
pic: 999 state: 3005 wait: 1 next: 41 dvx: 0 dvy: 550 centerx: 29 centery: 56
<frame_end>

41 tadah
pic: 999 state: 3005 wait: 1 next: 1000 dvx: 0 dvy: 550 centerx: 29 centery: 56
opoint:
kind: 1 x: 29 y: 56 action: 60 dvx: 0 dvy: 0 oid: 171 facing: 10
opoint_end:
<frame_end>

Another property of itr/k:9 is that the object is losing all its hp. In order to use timers in type: 3, you need these hp. Yes, the timer is reducing the hp of the weapon. And, yes, a weapon has also 500hp. Take it as a fact.

So yea, basically, you can now do whatever you want. From frame 60 on, you can let out your creativity ;)

Advantages of this method: faster, random x-positions

That's it! I apologize for getting so long but it was simply inevitable for me :P

Finished, and so I just have to say: happy coding :)


The study example contains the background "Magnificence"; it shows how the second method works.

Background-Dependent Actions

Inspired by Jerry Hawk, tips by MH-Razen

   
© Little Fighter Empire

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.

Ok