Post by vyckstjudas on Dec 15, 2012 1:23:25 GMT -5
Tossing Bomb
Intro: Just like last tutorial, this one is also about shooting projectile but it's for Tossing Bomb. Unlike knife, bomb is thrown in an arc so after it's 'released', it jumps then fall down.
Although the name is bomb, you can use grenade, rock or anything.
Just like throwing knife, character and bomb are 2 DIFFERENT entities. That means, you need to make another entity for the bomb. And, this method is applicable for any kind of entities so no need to check character's type.
Procedure: Let's start with the bomb entity, here's an example:
Code: [Select]
name Grenade
speed 13
jumpheight 3
type none
shadow 1
anim idle
loop 1
delay 10
offset 12 13
hitflash spark
burn 2 2 20 20 15 1
hitfx data/sounds/burnt.wav
frame data/chars/misc/gren04.gif
frame data/chars/misc/gren05.gif
frame data/chars/misc/gren06.gif
frame data/chars/misc/gren07.gif
frame data/chars/misc/gren08.gif
frame data/chars/misc/gren01.gif
frame data/chars/misc/gren02.gif
frame data/chars/misc/gren03.gif
anim attack1
delay 4
offset 60 68
hitflash spark
hitfx data/sounds/burnt.wav
sound data/chars/ralf/xplosion.wav
frame data/chars/misc/sx01.gif
frame data/chars/misc/sx02.gif
frame data/chars/misc/sx03.gif
frame data/chars/misc/sx04.gif
burn 25 12 60 73 15 1
frame data/chars/misc/sx05.gif
frame data/chars/misc/sx06.gif
frame data/chars/misc/sx07.gif
frame data/chars/misc/sx08.gif
frame data/chars/misc/sx09.gif
frame data/chars/misc/sx10.gif
frame data/chars/misc/sx11.gif
frame data/chars/misc/sx12.gif
frame data/chars/misc/sx13.gif
frame data/chars/misc/sx14.gif
frame data/chars/misc/sx15.gif
attack 0
frame data/chars/misc/sx16.gif
frame data/chars/misc/sx17.gif
frame data/chars/misc/sx18.gif
frame data/chars/misc/sx19.gif
anim attack2
delay 4
offset 40 48
sound data/chars/ralf/xplosion.wav
frame data/chars/misc/sx01.gif
frame data/chars/misc/sx02.gif
frame data/chars/misc/sx03.gif
frame data/chars/misc/sx04.gif
frame data/chars/misc/sx05.gif
frame data/chars/misc/sx06.gif
frame data/chars/misc/sx07.gif
frame data/chars/misc/sx08.gif
frame data/chars/misc/sx09.gif
frame data/chars/misc/sx10.gif
frame data/chars/misc/sx11.gif
frame data/chars/misc/sx12.gif
frame data/chars/misc/sx13.gif
frame data/chars/misc/sx14.gif
frame data/chars/misc/sx15.gif
frame data/chars/misc/sx16.gif
frame data/chars/misc/sx17.gif
frame data/chars/misc/sx18.gif
frame data/chars/misc/sx19.gif
This text is for Grenade. Speed determines how fast it flies forward while jumpheight determines how high it jumps before falling down and type is 'none' although it's not important.
Unlike knife, bomb (Grenade) uses 3 animations. IDLE is played when bomb is flying or jumping, ATTACK1 is played if bomb landed without hitting anything before and ATTACK2 is played if bomb hits opponent. As you can see, attackbox is declared in IDLE and ATTACK1. Attackbox in IDLE is for attacking opponent while flying, it can also be used as trigger to play ATTACK2. Attackbox in ATTACK1 is for attacking opponent after landing, normally in form of explosion.
Grenade can have animated IDLE animation like normal attack animation. However, unlike normal entity, this bomb dies after it hits anything.
Since it's an entity, it must be declared in models.txt:
Code: [Select]
know Grenade data/chars/misc/grenade.txt
Actually, it can be declared with 'load' but let's choose 'know' cause this bomb will be 'loaded' by the character who's tossing it. To load it like that simply declare this command in respective character's text header.
Code: [Select]
load Grenade
When the character is loaded, Grenade will also be loaded together. After that, we need to set Grenade as this character's bomb like this:
Code: [Select]
bomb Grenade
To toss this grenade, character must use 'tossframe'. The command must be declared in desired animation like this example:
Code: [Select]
anim attack2
range 120 160
rangez -35 35
delay 15
tossframe 1 50
offset 41 119
bbox 18 24 35 96
frame data/chars/lesus/toss01.gif
delay 8
frame data/chars/lesus/toss02.gif
delay 16
frame data/chars/lesus/toss03.gif
delay 8
frame data/chars/lesus/toss04.gif
frame data/chars/lesus/toss05.gif
'Tossframe 1 50' means Grenade is tossed at 2nd frame at 50 pixels high from character's altitude. Yes, it's relative to character instead of to ground. That means if the character is jumping while tossing, tossed bomb will start high.
You can declare 'tossframe' in other animations too but only one 'tossframe' per animation.
Extra: There are extra commands that you can add to modify both bomb and tossing animation. For bomb, some of them are:
- hitenemy (to control which other entities this bomb can hit)
- candamage (to control what type this bomb can hit)
- lifespan (to control how long this bomb lives)
- nomove (to make static bomb)
All of them are declared in bomb's text header if you use them.
Although all mentioned above are optional, it's recommended to declare 'candamage' to ensure the bomb can hit desired entity.
Aside from those, bomb can use SPAWN. SPAWN could be used if you want bomb to have special spawn effect.
For tossing animation, there is 'custbomb' command which changes tossed bomb just for respective animation. Use it together with 'tossframe' of course.
Limitation: One big flaw of 'tossframe' command is it only allows tossing bomb once per animation.
Once again a disclaimer: Just about everything I'm putting up right now was originally written By Bloodbane. All due credit belongs to him. On a side note... Pertaining to Tossing bombs and the like :
I generally try to make all my projectiles "bombs". I don't know the impact it has on memory use, but I'll explain why.
Lets say I want my character "Joe OpenBoR" to throw a knife...
When I make the actual "Knife" entity, I'll write it up like it's a bomb. Using "jumpheight 0" , "Antigravity 100" , and "Speed X?X", This knife will now behave like a normal forward moving projectile, but it'll also have separate animations for hitting an enemy (ATTACK1), and hitting the ground/wall (ATTACK2).
To get "Joe" to throw it, you gotta declare it like you would a normal bomb. Therefore:
Load Knife (or bullet, arrow, ninja hot dog, whatever...)
Bomb Knife (or bullet, arrow, ninja hot dog, whatever...)
And you'll have to use "Tossframe" with the animation you want him to fling it in. This way I don't need to make a million "flash" entities for "hitflash", nor do I have to worry about "hitfx". Also, I don't have to constantly keep an eye on what entities shoot or toss. Just saves me a headache. BTW If my grammar sucks I apologize. Too much beer.
Intro: Just like last tutorial, this one is also about shooting projectile but it's for Tossing Bomb. Unlike knife, bomb is thrown in an arc so after it's 'released', it jumps then fall down.
Although the name is bomb, you can use grenade, rock or anything.
Just like throwing knife, character and bomb are 2 DIFFERENT entities. That means, you need to make another entity for the bomb. And, this method is applicable for any kind of entities so no need to check character's type.
Procedure: Let's start with the bomb entity, here's an example:
Code: [Select]
name Grenade
speed 13
jumpheight 3
type none
shadow 1
anim idle
loop 1
delay 10
offset 12 13
hitflash spark
burn 2 2 20 20 15 1
hitfx data/sounds/burnt.wav
frame data/chars/misc/gren04.gif
frame data/chars/misc/gren05.gif
frame data/chars/misc/gren06.gif
frame data/chars/misc/gren07.gif
frame data/chars/misc/gren08.gif
frame data/chars/misc/gren01.gif
frame data/chars/misc/gren02.gif
frame data/chars/misc/gren03.gif
anim attack1
delay 4
offset 60 68
hitflash spark
hitfx data/sounds/burnt.wav
sound data/chars/ralf/xplosion.wav
frame data/chars/misc/sx01.gif
frame data/chars/misc/sx02.gif
frame data/chars/misc/sx03.gif
frame data/chars/misc/sx04.gif
burn 25 12 60 73 15 1
frame data/chars/misc/sx05.gif
frame data/chars/misc/sx06.gif
frame data/chars/misc/sx07.gif
frame data/chars/misc/sx08.gif
frame data/chars/misc/sx09.gif
frame data/chars/misc/sx10.gif
frame data/chars/misc/sx11.gif
frame data/chars/misc/sx12.gif
frame data/chars/misc/sx13.gif
frame data/chars/misc/sx14.gif
frame data/chars/misc/sx15.gif
attack 0
frame data/chars/misc/sx16.gif
frame data/chars/misc/sx17.gif
frame data/chars/misc/sx18.gif
frame data/chars/misc/sx19.gif
anim attack2
delay 4
offset 40 48
sound data/chars/ralf/xplosion.wav
frame data/chars/misc/sx01.gif
frame data/chars/misc/sx02.gif
frame data/chars/misc/sx03.gif
frame data/chars/misc/sx04.gif
frame data/chars/misc/sx05.gif
frame data/chars/misc/sx06.gif
frame data/chars/misc/sx07.gif
frame data/chars/misc/sx08.gif
frame data/chars/misc/sx09.gif
frame data/chars/misc/sx10.gif
frame data/chars/misc/sx11.gif
frame data/chars/misc/sx12.gif
frame data/chars/misc/sx13.gif
frame data/chars/misc/sx14.gif
frame data/chars/misc/sx15.gif
frame data/chars/misc/sx16.gif
frame data/chars/misc/sx17.gif
frame data/chars/misc/sx18.gif
frame data/chars/misc/sx19.gif
This text is for Grenade. Speed determines how fast it flies forward while jumpheight determines how high it jumps before falling down and type is 'none' although it's not important.
Unlike knife, bomb (Grenade) uses 3 animations. IDLE is played when bomb is flying or jumping, ATTACK1 is played if bomb landed without hitting anything before and ATTACK2 is played if bomb hits opponent. As you can see, attackbox is declared in IDLE and ATTACK1. Attackbox in IDLE is for attacking opponent while flying, it can also be used as trigger to play ATTACK2. Attackbox in ATTACK1 is for attacking opponent after landing, normally in form of explosion.
Grenade can have animated IDLE animation like normal attack animation. However, unlike normal entity, this bomb dies after it hits anything.
Since it's an entity, it must be declared in models.txt:
Code: [Select]
know Grenade data/chars/misc/grenade.txt
Actually, it can be declared with 'load' but let's choose 'know' cause this bomb will be 'loaded' by the character who's tossing it. To load it like that simply declare this command in respective character's text header.
Code: [Select]
load Grenade
When the character is loaded, Grenade will also be loaded together. After that, we need to set Grenade as this character's bomb like this:
Code: [Select]
bomb Grenade
To toss this grenade, character must use 'tossframe'. The command must be declared in desired animation like this example:
Code: [Select]
anim attack2
range 120 160
rangez -35 35
delay 15
tossframe 1 50
offset 41 119
bbox 18 24 35 96
frame data/chars/lesus/toss01.gif
delay 8
frame data/chars/lesus/toss02.gif
delay 16
frame data/chars/lesus/toss03.gif
delay 8
frame data/chars/lesus/toss04.gif
frame data/chars/lesus/toss05.gif
'Tossframe 1 50' means Grenade is tossed at 2nd frame at 50 pixels high from character's altitude. Yes, it's relative to character instead of to ground. That means if the character is jumping while tossing, tossed bomb will start high.
You can declare 'tossframe' in other animations too but only one 'tossframe' per animation.
Extra: There are extra commands that you can add to modify both bomb and tossing animation. For bomb, some of them are:
- hitenemy (to control which other entities this bomb can hit)
- candamage (to control what type this bomb can hit)
- lifespan (to control how long this bomb lives)
- nomove (to make static bomb)
All of them are declared in bomb's text header if you use them.
Although all mentioned above are optional, it's recommended to declare 'candamage' to ensure the bomb can hit desired entity.
Aside from those, bomb can use SPAWN. SPAWN could be used if you want bomb to have special spawn effect.
For tossing animation, there is 'custbomb' command which changes tossed bomb just for respective animation. Use it together with 'tossframe' of course.
Limitation: One big flaw of 'tossframe' command is it only allows tossing bomb once per animation.
Once again a disclaimer: Just about everything I'm putting up right now was originally written By Bloodbane. All due credit belongs to him. On a side note... Pertaining to Tossing bombs and the like :
I generally try to make all my projectiles "bombs". I don't know the impact it has on memory use, but I'll explain why.
Lets say I want my character "Joe OpenBoR" to throw a knife...
When I make the actual "Knife" entity, I'll write it up like it's a bomb. Using "jumpheight 0" , "Antigravity 100" , and "Speed X?X", This knife will now behave like a normal forward moving projectile, but it'll also have separate animations for hitting an enemy (ATTACK1), and hitting the ground/wall (ATTACK2).
To get "Joe" to throw it, you gotta declare it like you would a normal bomb. Therefore:
Load Knife (or bullet, arrow, ninja hot dog, whatever...)
Bomb Knife (or bullet, arrow, ninja hot dog, whatever...)
And you'll have to use "Tossframe" with the animation you want him to fling it in. This way I don't need to make a million "flash" entities for "hitflash", nor do I have to worry about "hitfx". Also, I don't have to constantly keep an eye on what entities shoot or toss. Just saves me a headache. BTW If my grammar sucks I apologize. Too much beer.