Post by vyckstjudas on Dec 15, 2012 0:50:06 GMT -5
Throwing/Shooting Knives/Projectiles
Intro: I'm sure all of you have seen characters who can shoot projectiles in brawler games. The projectiles varies from knives, grenades, stars, rocks, bullets to bombs and laser shots. They are also shot in various ways i.e thrown, shot, tossed etc. This tutorial will explain how to set projectile shooting. OpenBoR supports 3 ways of shooting projectile:
1. Throwing knife (Projectile flies straight forward)
2. Throwing stars (Projectile falls down)
3. Tossing bombs (Projectile flies in arc)
This section explains about 'Throwing knife'. Oh, despite of the name, you can use missiles, bullets or anything else aside of knife. Also, the knife can also be thrown on ground turning it into shot.
Before I start, I must imply that character and projectile are 2 DIFFERENT entities. That means, you need to make another entity for the projectile.
Also, this method is applicable for any kind of entities so no need to check character's type.
Procedure: Like said before, projectile is another entity so let's make one like this example:
Code: [Select]
name Bullet
speed 30
type none
shadow 0
anim idle
delay 100
offset 5 3
attack 0 0 10 6 10 1
frame data/chars/misc/bullet.gif
This text is for Bullet projectile. Speed determines how fast it flies forward, type is not important but let's choose 'none', shadow is set 0 so it won't cast shadow but it's optional.
Bullet only has IDLE animation but it's enough cause it won't play other animation (except under special settings). In this animation, aside from common commands (frame,offset,delay), there's attackbox. This attackbox determines the attacking properties of this projectile. IOW when this projectile is fired or thrown, it's already attacking.
Bullet can have animated IDLE animation, looping, multiple hits etc like normal attack animation. However, unlike normal entity, this projectile dies after it hits anything.
Since it's an entity, it must be declared in models.txt:
Code: [Select]
know Bullet data/chars/misc/bullet.txt
Actually, it can be declared with 'load' but let's choose 'know' cause this projectile will be 'loaded' by the character who's throwing it. To load it like that simply declare this command in respective character's text header.
Code: [Select]
load Bullet
When the character is loaded, Bullet will also be loaded together. After that, we need to set Bullet as this character's knife like this:
Code: [Select]
knife Bullet
To throw this Bullet, character must use 'throwframe'. The command must be declared in desired animation like this example:
Code: [Select]
anim attack1
range 60 200
delay 6
offset 40 115
throwframe 3 82
bbox 20 9 36 102
frame data/chars/topan/shoot01.gif
bbox 26 9 34 102
frame data/chars/topan/shoot02.gif
delay 10
bbox 31 9 34 102
frame data/chars/topan/shoot03.gif
delay 15
sound data/sounds/dor2.wav
frame data/chars/topan/shoot04.gif
delay 6
frame data/chars/topan/shoot03.gif
bbox 26 9 34 102
frame data/chars/topan/shoot02.gif
bbox 20 9 36 102
frame data/chars/topan/shoot01.gif
'Throwframe 3 82' means Bullet is thrown at 4th frame at 82 pixels high from character's altitude. Yes, it's relative to character instead of to ground. That means if the character is jumping while throwing, thrown projectile will start high.
You can declare 'throwframe' in other animations too but only one 'throwframe' per animation.
Extra: There are extra commands that you can add to modify both projectile and shooting animation. For projectile some of them are:
- hitenemy (to control which other entities this projectile can hit)
- candamage (to control what type this projectile can hit)
- remove (to set if this projectile dies on hit or continue flying after hit)
- lifespan (to control how long this projectile lives)
- nomove (to make static projectile)
All of them are declared in projectile's text header if you use them.
Although all mentioned above are optional, it's recommended to declare 'candamage' to ensure the projectile can hit desired entity.
Aside from those, projectile can use SPAWN and FOLLOW (like explained above). SPAWN could be used if you want projectile to have special spawn effect. FOLLOW could be used if projectile changes animation after hitting something. You must use 'remove 0' together for this otherwise projectile would disappear before it could followup. Bear in mind that projectile is moving regardless of animation it's playing.
For shooting animation, there is 'custknife' command which changes thrown knife just for respective animation. Use it together with 'throwframe' of course.
Limitation: One big flaw of 'throwframe' command is it only allows throwing projectile once per animation.
Intro: I'm sure all of you have seen characters who can shoot projectiles in brawler games. The projectiles varies from knives, grenades, stars, rocks, bullets to bombs and laser shots. They are also shot in various ways i.e thrown, shot, tossed etc. This tutorial will explain how to set projectile shooting. OpenBoR supports 3 ways of shooting projectile:
1. Throwing knife (Projectile flies straight forward)
2. Throwing stars (Projectile falls down)
3. Tossing bombs (Projectile flies in arc)
This section explains about 'Throwing knife'. Oh, despite of the name, you can use missiles, bullets or anything else aside of knife. Also, the knife can also be thrown on ground turning it into shot.
Before I start, I must imply that character and projectile are 2 DIFFERENT entities. That means, you need to make another entity for the projectile.
Also, this method is applicable for any kind of entities so no need to check character's type.
Procedure: Like said before, projectile is another entity so let's make one like this example:
Code: [Select]
name Bullet
speed 30
type none
shadow 0
anim idle
delay 100
offset 5 3
attack 0 0 10 6 10 1
frame data/chars/misc/bullet.gif
This text is for Bullet projectile. Speed determines how fast it flies forward, type is not important but let's choose 'none', shadow is set 0 so it won't cast shadow but it's optional.
Bullet only has IDLE animation but it's enough cause it won't play other animation (except under special settings). In this animation, aside from common commands (frame,offset,delay), there's attackbox. This attackbox determines the attacking properties of this projectile. IOW when this projectile is fired or thrown, it's already attacking.
Bullet can have animated IDLE animation, looping, multiple hits etc like normal attack animation. However, unlike normal entity, this projectile dies after it hits anything.
Since it's an entity, it must be declared in models.txt:
Code: [Select]
know Bullet data/chars/misc/bullet.txt
Actually, it can be declared with 'load' but let's choose 'know' cause this projectile will be 'loaded' by the character who's throwing it. To load it like that simply declare this command in respective character's text header.
Code: [Select]
load Bullet
When the character is loaded, Bullet will also be loaded together. After that, we need to set Bullet as this character's knife like this:
Code: [Select]
knife Bullet
To throw this Bullet, character must use 'throwframe'. The command must be declared in desired animation like this example:
Code: [Select]
anim attack1
range 60 200
delay 6
offset 40 115
throwframe 3 82
bbox 20 9 36 102
frame data/chars/topan/shoot01.gif
bbox 26 9 34 102
frame data/chars/topan/shoot02.gif
delay 10
bbox 31 9 34 102
frame data/chars/topan/shoot03.gif
delay 15
sound data/sounds/dor2.wav
frame data/chars/topan/shoot04.gif
delay 6
frame data/chars/topan/shoot03.gif
bbox 26 9 34 102
frame data/chars/topan/shoot02.gif
bbox 20 9 36 102
frame data/chars/topan/shoot01.gif
'Throwframe 3 82' means Bullet is thrown at 4th frame at 82 pixels high from character's altitude. Yes, it's relative to character instead of to ground. That means if the character is jumping while throwing, thrown projectile will start high.
You can declare 'throwframe' in other animations too but only one 'throwframe' per animation.
Extra: There are extra commands that you can add to modify both projectile and shooting animation. For projectile some of them are:
- hitenemy (to control which other entities this projectile can hit)
- candamage (to control what type this projectile can hit)
- remove (to set if this projectile dies on hit or continue flying after hit)
- lifespan (to control how long this projectile lives)
- nomove (to make static projectile)
All of them are declared in projectile's text header if you use them.
Although all mentioned above are optional, it's recommended to declare 'candamage' to ensure the projectile can hit desired entity.
Aside from those, projectile can use SPAWN and FOLLOW (like explained above). SPAWN could be used if you want projectile to have special spawn effect. FOLLOW could be used if projectile changes animation after hitting something. You must use 'remove 0' together for this otherwise projectile would disappear before it could followup. Bear in mind that projectile is moving regardless of animation it's playing.
For shooting animation, there is 'custknife' command which changes thrown knife just for respective animation. Use it together with 'throwframe' of course.
Limitation: One big flaw of 'throwframe' command is it only allows throwing projectile once per animation.