1
2
ID:173907
Oct 29 2003, 4:54 pm
|
|
Can anyone show me an example of a shooting verb. I want the bullet to go where the mob is facing, I keep getting an input to choose which mob to shoot around me, but i dont want no pop up.
|
In response to Siientx
|
|
Thanks, But when i run it i have the shoot verb before i even pick up an object and i cant really edit the code because its was made with "spaces" not "tab".
|
In response to Pagemaster
|
|
Actually i found an searched the forums and found a piece of code easier to read posted by "Spuzzum". But like he said the bullets go to the end of the map then just sit there lol and i have the shoot command before i even pick up my gun.
Here is the code..well actually half of my items page. obj/weapons var speed damage explode splash direction Gun icon = 'Weapons.dmi' icon_state = "gun" speed = 3 damage = 100 obj/bullet New(loc, dir) ..(loc) src.dir = dir walk(src,dir) icon = 'weapons.dmi' icon_state = "bullets" Bump(loc) usr.hp -= 50//do damage to loc here by the way the bullets go though my project npcs del(src) mob/verb/shoot() new /obj/bullet(src.loc, src.dir) |
In response to Pagemaster
|
|
Pagemaster wrote:
obj/weapons Splash damage? What kind of bullets ya using in that? =] If you need to convert spaces to tabs, highlight the spaces and press tab enough to get it in line. I had to do that for well over 200 lines when I went to optimize my RPG i was making. It can be a pain, just be sure not to make indentation errors. |
In response to Yota
|
|
Yota wrote:
Pagemaster wrote: I dont know what splash is i saw it in a demo i was just keeping it there for future ideas. I found out that trick yesterday but it didnt help whenever i converted the spaces to tabs there were errors(By the way when i press tab 2 arrows show up ">>" in gray. But those are not my real issues i want to make it so my bullets dont just stay there when they hit a wall(i bet spuzzum would know the answer to that since it was in his post) and when i pick up my gun then i have the shoot verb(right now right when i log in i have the "shoot" verb without even picking up a gun).I |
In response to Pagemaster
|
|
I dont mean to bump but theres no use creating another thread that is the same topic.
PROBLEMS: 1.when i press "Equip" i dont get the Shoot command. 2.When the bullets hit the end of the map they stay there. Here is my Code: obj/var/equip mob/var/arms mob/var/armsequip obj/var/attackadd var speed damage explode splash direction obj weapons guns icon = 'Weapons.dmi' Hand_Gun icon_state = "1" speed = 3 damage = 100 proc shoot() set src in usr new /obj/bullet(src.loc, src.dir) verb equip() set category = "Commands" if(usr.armsequip == 1) usr << "Your already Equiping somthing!" if(usr.arms == null) if(alert("Are you sure you want to equip [src]?","Equip??","Yes","No") == "Yes") // usr.contents += shoot view(6) << "[usr] equips his [src]." usr.arms = src.name usr.armsequip = 1 suffix += "{Equiped}" src.equip = 1 remove() set category = "Commands" if(usr.arms == null) usr << "You have nothing equiped there." if(src.suffix == null) usr << "It is not equiped" if(usr.arms == src.name) if(alert("sure you want to remove [src]?","Remove??","Yes","No") == "Yes") usr.arms = null usr.armsequip = 0 // usr.str-= src.attackadd suffix = null src.equip = 0 discription2() set name = "discription" usr << "<font size = 1>a gun thats cool[src.dis]"</font size = 1> obj/weapons verb/Getweapon() set name = "get" set src in oview(1) usr.contents += src usr<<"You get [src]!!" verb/Dropweapon() set name = "drop" set src in usr if(src.equip == 1) usr << "You cannot drop something that is equiped" else src.loc = usr.loc usr<<"You dropped [src]!" obj/bullet New(loc, dir) ..(loc) src.dir = dir walk(src,dir) icon = 'weapons.dmi' icon_state = "bullets" Bump(loc) usr.hp -= 50//do damage to loc here del(src) |
In response to Pagemaster
|
|
No put usr in Bump(). Ungh.
Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
No put usr in Bump(). Ungh. if i put usr in bump() ex:"Bump(usr) it says usr.hp is an undefined var and i still have those other problems to worry about. Bump(usr) usr.hp -= 50//do damage to loc here del(src) |
In response to Pagemaster
|
|
He said "No put usr in Bump(). Ungh." which is caveman speak for "Do not put usr in Bump(). Okay?"
|
In response to Jon88
|
|
IE:
Bump(mob/M) |
In response to Enigmaster2002
|
|
oo, thanks.
But do you know the answers to my other 2 questions? |
In response to Pagemaster
|
|
obj That should do. |
In response to Enigmaster2002
|
|
obj
bullet //The bullet itself. icon - 'bullet.dmi' density=1 Bump(mob/M) <font color = blue>var/damage = rand(1,50)</font color = blue> <font color = red>M.HP -= damage]</font color = red> <font color = blue>72:error: ]: expecting }</font color = blue><font color = red> 71:error: location of top most unmatched {</font color = red> 6 errors and 0 warnings Those were my 2 responses, thanks anyway. |
In response to Pagemaster
|
|
<font color = red>M.HP -= damage]</font> I'll give you a couple seconds to look at line 72 and see if there is anything there that shouldn't be there. =P |
In response to Spuzzum
|
|
Spuzzum wrote:
<font color = red>M.HP -= damage]</font> I think see where your coming from, but if i replace "]" with "}" it says "inconsistent indentation or extra '}'" and i know its not the indentation,lol. |
In response to Pagemaster
|
|
Pagemaster wrote:
(By the way when i press tab 2 arrows show up ">>" in gray. ... That's the character DM uses to show tabs. There's only one tab for each of thoes characters. if i replace "]" with "}" it says "inconsistent indentation or extra '}'" and i know its not the indentation,lol. I don't know why it says to put } there. Just remove the [ and see it that way. Bump(mob/M) ^ That is an indentation error. It thinks that you want that in a block between { and }. Remove the ] and the extra indentation, then the errors should be gone. |
In response to Yota
|
|
Yota wrote:
if i replace "]" with "}" it says "inconsistent indentation or extra '}'" and i know its not the indentation,lol. <font color = red>Well I did that, but now it says i undefined gun like 4 times and my hp var is undefined: here is the code i recieved earlier.</font color = red> obj/var/equip mob/var/arms mob/var/armsequip obj/var/attackadd var speed damage explode splash direction obj Hand_Gun icon = 'Weapons.dmi' icon_state = "1" speed = 3 damage = 100 verb //Attaching the verb to the object prevents one from getting the verb before getting it. Equip() set src in usr if(usr.gun == null) //Make sure he doesnt have a gun already equipped. usr.gun = src return if(usr.gun == src) //If hes got this gun equipped. usr.gun = null //Unequip it. return remove() set category = "Combat" if(usr.arms == null) usr << "You have nothing equiped there." if(src.suffix == null) usr << "It is not equiped" if(usr.arms == src.name) if(alert("sure you want to remove [src]?","Remove??","Yes","No") == "Yes") usr.arms = null usr.armsequip = 0 // usr.str-= src.attackadd suffix = null src.equip = 0 discription2() set name = "discription" usr << "<font size = 1>A gun thats cool.[src.dis]"</font size = 1> obj/weapons verb/Getweapon() set category = "Combat" set name = "get" set src in oview(1) usr.contents += src usr<<"You get [src]!!" verb/Dropweapon() set name = "drop" set src in usr if(src.equip == 1) usr << "You cannot drop something that is equiped" else src.loc = usr.loc usr<<"You dropped [src]!" mob proc projectile(obj/projectile,var/dir,var/delay) //The proc that makes the bullets work. sleep(1) walk(projectile,dir) sleep(delay) del(projectile) obj bullet //The bullet itself. icon = 'weapons.dmi' icon_state = "bullets" density = 1 Bump(mob/M) var/damage = rand(1,50) M.HP -= damage var gun = null<font color = red><-- and heY! here it is already defined...-_-'</font color = red> Items.dm:21.error:usr.gun:undefined var Items.dm:22.error:usr.gun:undefined var Items.dm:24.error:usr.gun:undefined var Items.dm:25.error:usr.gun:undefined var Items.dm:74:error:M.HP:undefined var <font color = red>Words in my coding may appear like they are not indented enough, but thats because of the html you use on these forums'.</font color = red> |
In response to Pagemaster
|
|
I think see where your coming from, but if i replace "]" with "}" it says "inconsistent indentation or extra '}'" and i know its not the indentation,lol. One thing to know is that the compiler isn't perfect -- it recognises errors, but it often mistakes them for something else. In that case, the problem line shouldn't have the closing bracket at all -- there shouldn't be anything on the end of it. |
In response to Spuzzum
|
|
Spuzzum wrote:
I think see where your coming from, but if i replace "]" with "}" it says "inconsistent indentation or extra '}'" and i know its not the indentation,lol. Theres a post i made of what happened when i took away the bracket,do you know the answers to those 2 other errors? |
1
2
var/movingdir
bullet
icon = 'bullet.dmi'
Move()
..()
if(src.x == world.maxx)
if(src.movingdir == EAST)
del src
if(src.y == world.maxy)
if(src.movingdir == NORTH)
del src
if(src.y == 1)
if(src.movingdir == SOUTH)
del src
if(src.x == 1)
if(src.movingdir == WEST)
del src
Bump(mob/M)
if(ismob(M))
//do damage or whatever here
sleep(0)
del src
proc
Move_Proc()
if(src)
if(src.x == 1)
if(src.movingdir == WEST)
del src
if(src.y == 1)
if(src.movingdir == SOUTH)
del src
if(src.x == world.maxx)
if(src.movingdir == EAST)
del src
if(src.y == world.maxy)
if(src.movingdir == NORTH)
del src
walk(src,src.movingdir,2)
mob
verb
Shoot()
var/mob/B = new/mob/bullet(src.loc)
B.movingdir = src.dir
B.Move_Proc()
There we go pagey! Enjoy.
Siientx