ID:1955639
 
(See the best response by Kaiochao.)
Hello! I want to create a few projectiles systems but I have no idea where to start could Anyone help me through this?
(Pixel Game)
Trying to Create 2 types of projectiles
1st: A lineal projectile
2nd: Create 8 projectiles and sends 1 each direction

Any help will be appreciated (Atleast something that I can start off with so I can keep testing while I learn)
Refer to the walk() process for projectiles. The elements it takes includes the direction.

mob/verb/Shoot()
for(var/i = 0,i<8,i++)
var/DIR
switch(i)
if(1)DIR = "NORTH"
if(2)//etc...
var/obj/A = new
walk(A,DIR)
In response to Konlet
Best response
Big switch() is unnecessary.
mob
verb/shoot()
walk(new /obj/projectile (loc), dir)

verb/shoot_8()
var global/all_dirs[] = list(NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST)
for(var/d in all_dirs)
walk(new /obj/projectile (loc), d)
It isn't actually creating the projectile it does nothing when I use the verb
Obj: https://gyazo.com/b76cea1746a743339e22d68f4aa5b829
Do I have to add a proc to the obj etc?
In response to Kakarot06
Sorry, I forgot to specify the initial location (which Konlet did too...).
Thanks!
A question is there a way to set a distance it travels and set a speed?
In response to Kakarot06
If you check the DM Reference for the walk() proc, you'll see that there are optional parameters you can provide to set the lag (time between steps, useful for tile movement) and speed (number of pixels per step, enables pixel movement mode). Given the speed, you can limit its distance traveled by stopping/destroying it after a certain amount of time with sleep or spawn.
Or.. We could dumb it down to baby steps..
//updated this.
mob/
var/health = 100
verb/shoot()
var/obj/projectile/O = new()// creates projectile atom/object.
O.loc = src.loc
// makes you the owner of the projectile.
//gives the projectile a icon/appearance.
O.owner = usr ; O.icon = 'fire.dmi'
walk(O,dir,0,2) //walks in the direction you are in.

obj/projectile
var/owner = null // owner variable.
density = 1
Bump(mob/M) // if the projectile comes in contact with the person its infront of.

if(src.owner == M) // checks if it is you so it doesnt effect you.
M << output( "you are the owner." , "output1")
return // stop right there.

else // otherwise

var/damage = 50/25+25 // damage will be 50 divided by 25 plus 25 just plug in math.
M.health-=damage //it inputs the damage value you have set into the get_health system.
M << output( "you hit [M.name]" , "output1") // shows you.
del src // deletes the projectile.

I'm guessing he's a starter so we gotta make it more readable for him .. Nun of that fancy stuff as to we want him to learn gradually not just use everything we give him..
In response to Hebrons
Hebrons wrote:
Or.. We could dumb it down to baby steps..
> mob/verb/shoot()
> var/atom/projectile/O = new()
> O.icon = '//file'
> walk(O,dir)
>

I'm guessing he's a starter so we gotta make it more readable for him .. Nun of that fancy stuff as to we want him to learn gradually not just use everything we give him..

True, i'm dumb in DM too.I know, ready code isn't good way. But i don't undestand in english a lot. When i see code with simpe comment - it's more readable for my. So in my opinion answers should looks like

mob/verb/shoot()
var/atom/projectile/O = new()//Now we create new projectle with type"/atom/projectile/O "
O.icon = '//file'//time to change its icon
walk(O,dir)//now it's time to move our obj.


DM Reference say:

/*

walk proc

See also:
get_step proc
step proc
step_size var (movable atom)

Format:
walk(Ref,Dir,Lag=0,Speed=0)

Args:
Ref: A mob or obj.
Dir: One of NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST, or 0 to halt.
Lag: Delay in world ticks between movement.
Speed: Speed to move, in pixels. 0 uses Ref.step_size.

Move Ref in the direction Dir continuously. Each step will be preceded by Lag time of inactivity.

A call to a walking function aborts any previous walking function called on Ref. To halt walking, call walk(Ref,0).

This function returns immediately, but continues to process in the background.
*/



Sorry for my poor english :P