ID:264857
 
Code:
obj/Skills
icon = 'Skills.dmi'
density = 1
var
delay = 1
length=12
dmg=2
splash
mob/player/owner
New(_loc,mob/_owner)

if(_owner)
src.dir = _owner.dir
if(usr.Weapontype == "Bow")
flick("arrow",usr)
else
flick("blast",usr)
if(!src.loc) src.loc = get_step(usr,usr.loc)
src.owner = _owner

Move()
src.length--
if(!src.length) del src
return ..()
Bump(atom/O)
if(ismob(O) && src.owner)
var/mob/M = O
var/damage = round(rand(src.owner.Rei/O:Rei*7))+src.owner.Rei/20
if(damage <= 0)
damage = 1
O:Hp-=damage
s_damage(O, damage, "#FFFAFA")
O:Bars(O)
if(prob(50))
new/obj/Crater(O.loc)
if(damage <= 0)
damage = 1
if(src.owner.flash ==1)
switch(rand(1,10))
if(1)
src.loc=locate(x+1,y+1,z)
if(3)
src.loc=locate(x-1,y-1,z)
if(4)
src.loc=locate(x+1,y,z)
if(5)
src.loc=locate(x,y+1,z)
if(6)
src.loc=locate(x-1,y,z)
if(7)
src.loc=locate(x+1,y-1,z)
if(10)
src.loc=locate(x-1,y+1,z)
if(O:client)
O:UpDateHp()
O:Attacked(src.owner)
if(O:Hp <= 0)
M.Death(src.owner)
src.owner.Level_up()
else if(isobj(O))
new/obj/Effects/Smoke(O.loc)
if(prob(30))
new/obj/Smoke(O.loc)


Problem description:
the projectile starts on the same tile as mob and it is slow
i want the projectile to start 1 tile in front of the mob and also to be faster and also deletes at the end the the users screen
            if(!src.loc) src.loc = get_step(usr,usr.loc)


You are using get_step() wrong here. Look it up in the reference. Also, you need to not be using usr in procs, you already have a perfectly serviceable _owner variable here. Also, the first argument to the new() directive (and also therefore the first argument to New()), if it's an atom, will be the location of the newly created object, so src.loc will only be null if you pass null or no argument (or an invalid argument, like a text string) to new()

As for the movement speed, that's clearly handled elsewhere, but it should literally be a matter of changing a single number.
In response to Garthor
its gonna take me like 3 days to decrypt this message -_-' but Thanks for pointing me in a direction
In response to The ComEdiAn
He is telling you that both parameters for get_dir() must be actual atoms and not references to their locations.
In response to Duelmaster409
That is staggeringly incorrect. I did not mention get_dir() and there is no difference between "actual atoms" and "references to their locations". The location of an atom IS an atom (well, unless it's null), and all variables except for numerical values (and maybe something obscure I'm forgetting) are references.
In response to Garthor
You did mention get dir:

"You are using get_step() wrong here. Look it up in the reference."

edit: Oh boy, yeah I see the problem. Aauurgh! However what I said previously is still applicable to get_step(), I believe.


Regardless, what you're saying is if I were to store mob.loc in a variable, the mob would be stored and not the location? Unless you're dealing with turfs, the location of an atom would not be an atom, it would be its location.
In response to Duelmaster409
            if(!src.loc) src.loc = walk(src,_owner.dir)


Problem description:
ok i have this but now it saying error: missing expresstion
In response to The ComEdiAn
That is not how walk() works. Look it up in the Reference.
In response to The ComEdiAn
Why is there an underscore? Forgive me if I'm missing something but I don't think that underscore should be there behind "owner.dir".
In response to Duelmaster409
Duelmaster409 wrote:
Regardless, what you're saying is if I were to store mob.loc in a variable, the mob would be stored and not the location? Unless you're dealing with turfs, the location of an atom would not be an atom, it would be its location.

The loc of an atom is another atom. Look it up in the Reference.
In response to Duelmaster409
There is an underscore there because that is the name of the variable.
In response to Garthor
Format: walk(Ref,Dir,Lag=0)
it seems like it would work fine with the code i have
In response to The ComEdiAn
I guess the subtlety you missed is that it does not return a value, so assigning a variable to it (such as src.loc = walk()) is invalid.
In response to Garthor
Ohh ok that makes sense let me delete that part and then............agggh i dont even see a projectile on the screen any more...i see garthor you have sabotage me
In response to The ComEdiAn
That would likely be a result of not setting the location at any point.
In response to Garthor
Thanks Problem Solved how bout if i want it to delete if it hits the edge of the usr screen
In response to The ComEdiAn
The ComEdiAn wrote:
Thanks Problem Solved how bout if i want it to delete if it hits the edge of the usr screen

I just wrote a long paragraph. Typically you shouldn't delete your post when you figure out what was wrong. I'll just copy what I wrote out so people can use it as a reference or in case you need more help.

Look up how get_step works in the reference, that's what it's there for.

get_step proc
See also:
step proc
walk proc
Format:
get_step(Ref,Dir)
Returns:
The location of the new position.
Args:
Ref: Starting point or object.
Dir: One of NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST.
Calculate the position of a step from Ref in the direction Dir.


So let's break it down for you. You had src.loc = get_step(usr, usr.loc), see how the proper format is get_step(Ref,Dir) and the ref is the starting point which would be usr. Then dir is simply usr.dir.

Walk()'s format is so:


walk proc
See also:
get_step proc
step proc
Format:
walk(Ref,Dir,Lag=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 1/10 seconds between movement.
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.


For this we have walk(Ref,Dir,Lag). After you set the loc to be in front of the usr you want to make it walk() in a certain direction. Ref would be src because that is the object that is moving, depending on how you want your system to work, you will have to use get_dir() (look it up in the reference) or just usr.dir. For lag set it to whatever you want it to be.

I'm not sure if you want walk, walk_to, walk_towards, step, step_to, or step_towards so my advice is to look through the reference and determine which one you fits your game.

----

For your other problem look up Bump() and then when it hits something delete it.
In response to The ComEdiAn
This problem has been solved in various ways. Look it up using the Search function and choose your pick.