ID:161152
 
Can someone make a tutorial and teach me how to code a rocket launcher?
IDWMno wrote:
Can someone make a tutorial and teach me how to code a rocket launcher?

obj/rocket_launcher
There are a few demos or libraries that exist already.

Go to the top right of this screen, and in the search bar type in 'projectiles'. Make sure you select 'resources'.
IDWMno wrote:
Can someone make a tutorial and teach me how to code a rocket launcher?


Try projectiles, that's the next thing I am going to be practising to fully understand programming. There is no such thing as a single code made for a rocket launcher only. It will always be a projectile.
In response to GM Productions
Yeah, it is easier to learn the general idea rather than an actual thing.
A rocket launcher. Same as a gun. Or an arrow from a bow.
But if you think about it more, it can also be a magic spell casting a fire ball. They are all projectiles. They can all work with the same base, and you can use variables to make whatever changes such as speed, icon, damage, whatever.
obj/projectile
icon='arrow.dmi'
var
speed=3
damage=5
effect="pierce"
Bullet
icon='bullet.dmi'
speed=1
damage=10
Fireball
icon='fireball.dmi'
speed=2
damage=5
effect="burn"
//include movement and Bump()
//also the effects such as bleeding for pierce, and burning
In response to Kaiochao
Kaiochao wrote:
They are all projectiles. They can all work with the same base, and you can use variables to make whatever changes such as speed, icon, damage, whatever.

Exactly. Remember you can also make variations through proc overrides, not only variable overrides, to vary the entire behavior. For example:
obj/projectile
Bump(atom/X) src.Affect(X)

proc/Affect(mob/target) //default effect is simple damage.
if(istype(target)
target.TakeDamage(src.damage)
return 1 //let the caller know of success; this is used later
spell
fireball
Affect(mob/trg) //override the proc
if(..()) //do the default behavior - damage, and if it succeeds
//do something extra
trg.CatchFire()
paralyze
Affect(mob/trg)
//this does not call the parent - it does not do the default behavior, damage, at all. only its unique behvaior.
if(istype(trg))
trg.paralyzed = 1