ID:146423
 
Code:
mob/player
var/shot = NORTH
icon = 'player.dmi'
Login()
usr.Move(locate(2,5,1))
world << "[usr] has entered Drawl."
icon_state = input("Choose your color","Color") in list("Red","Green","Blue","Purple","Gold","Gray","Cyan")
new /obj/fire1(usr) //give player a spell to cast
verb
castnorth() //using directional casting verbs so it doesn't have to be usr.dir
shot = NORTH
Spell(arglist(usr.contents))
castsouth()
shot = SOUTH
Spell(arglist(usr.contents))
castwest()
shot = WEST
Spell(arglist(usr.contents))
casteast()
shot = EAST
Spell(arglist(usr.contents))
proc/Spell(S)
var/obj/P = new S(usr.loc) //problem here
while(P)
step(P,shot)
var/turf/T = P.loc
if(T.density==1)
del(P)
break
for(var/mob/M as mob in T)
if(M==src)
continue
else
M.health -= P.spelldamage
M.deathcheck()

-snip-

obj
var/spelldamage
fire1
icon = 'fire1.dmi'
spelldamage = 3


Problem description:
If you didn't notice this is supposed to shoot a projectile :D
The problem here is that in the game when you use one of the cast verbs, the proc crashes saying that an object of type /obj/fire1 cant be created. I originally thought there was a problem with assigning S from arglist(usr.contents), but it seems to be referencing it fine...any ideas?

NOTE: The reason for getting the projectile from usr.contents is that I'm going to use usr inventory to switch spells

Seems to me that the problem is that youve crammed too many different things together.

Try grouping the damage proc under the spell itself. Its not creating the spell because, well, it isnt complete. This may sound confusing, but atleast thats what I noticed. Perhaps a more expirienced coder will see this and offer more complete help.
mob/player
var/shot = NORTH
icon = 'player.dmi'
Login()
usr.Move(locate(2,5,1))
world << "[usr] has entered Drawl."
icon_state = input("Choose your color","Color") in list("Red","Green","Blue","Purple","Gold","Gray","Cyan")
verb
castnorth() //using directional casting verbs so it doesn't have to be usr.dir
var/obj/fire1/B = new(loc)
projectile(B,NORTH,40) //args = object,direction,range

proc/projectile(obj/projectile,var/dir,var/delay)
sleep(1) //I got this proc from a missile library, dunno why it sleeps here
//it just does, ok?
walk(projectile,dir) //makes the projectile walk in desired direction
sleep(delay) //sleeps for the object's range
//object moves 1 tile per tick, so sleep for 40 ticks it moves 40 tiles
del(projectile) // delete the object if it reaches its range

-snip-

obj
var/spelldamage
fire1
icon = 'fire1.dmi'
spelldamage = 3
Bump(M) //this should replace that Spell(S) stuff
if(istype(M,/mob)) //here you should probably add different behaviour
var/mob/T = M //based on whether it's a player or a monster or whatever
M.health -= spelldamage
M.deathcheck()
del(src)//deletes itself if it bumps into anything solid

The above code should work, but if it doesn't it'll at least give you something to start from. I don't know why you created the fire object in the player's inventory, and I would recommend creating a seperate object type for spells, e.g. obj/spell/fire1, this would allow you to define default behaviour for spells and increase your code's efficiency. Also, you might wanna think of how your player casts their spells, personally I use a statpanel with clickable objects, and I don't like the idea of havng different commands for different directions, why create extra work for the player?
Why in the world would you want multiple forms of the same verb if the only thing changing is a direction? What's wrong with using usr.dir? If the player isn't facing the right direction, just change your movement system so they can turn without having to move.

Lummox JR
In response to Lummox JR
The reason I wanted to use different verbs is so I can set up macros, allowing the player to use one hand for movement and one hand for firing. It's not supposed to be an rpg, just a fantasy-action game ;)
In response to Fartmonger
It's actually less work for the player because they will be using macros - I wanted to make easy to move and fire simultaneously - and its in the inventory because I was going to use it for spell selection, but now I'm reconsidering. My idea was that by having the projectile in one's inventory, you could simply duplicate one for the player to fire, but uh...I guess that's not working out :D

Anyway, thank you so much for the help, I probably won't copy your code but I'll certainly take ideas from it.