ID:149299
 
I have been working on BYONDHockey for awhile now and I can't seem to get everything ironed out. My latest problem is with this Bump() proc that I use to call my checking proc and alot of puck stuff. I just want to know if there is a problem with this right here...
Bump(var/atom/movable/M)
if(istype(M,/mob/char))
...
if(istype(M,/mob/puck))
//everything here works fine, its in the above portion that I'm having trouble.


If somebody could just tell me if there is something wrong with that I would appreciate it.

Canar
It would help if you would specify what is wrong.

-Rcet
In response to Rcet
ok, the proc is called when a char bumps another char, except... its not taking the actions that I want it to... I didnt want to do this because I dont like putting whole pieces of code on the forum but here is the entire portion...
Bump(var/atom/movable/M)
if(istype(M,/mob/char))
if(M:havepuck==1)//the problem could be here, im not sure exactly
src.havepuck=1
M:havepuck=0
src.overlays += /obj/havepuck
src.overlays += /obj/halo
for(var/I in M.overlays)
M.overlays -= I
for(var/obj/puck/I in M)
M.contents -= I
src.contents += I
flick('C.dmi',M)
flick("chardown",M)
M.density = 0
sleep(5)
M.density = 1
if(istype(M,/obj/puck))//everything after this works fine
M:lifeon=0
src.contents += M
src.overlays += /obj/havepuck
src.overlays += /obj/halo

The gameplay system in this game was so hard to develop that I had to get help from a partner of mine, Doombringer. He helped workout a few other problems but left me with a mess in this bump proc. I tried changing what I thought to be errors but I cant spot the problem here.

any help would really be appreciated.

Canar
In response to Canar
Im not exactly sure whats wrong here.. But you shouldn't use the : operator here, I don't think. Just use the . operator instead.

-Rcet
In response to Rcet
without the ":" it cant check the var's that I want it too because "M" is a var to begin with. I might be wrong on that because I dont use ":" too often. I just know I tried it both ways and I don't get compile errors with ":" and with "." I get errors because its not checking the vars of a var. Again im not too sure on all of that but there really is no way that I know of to get around the ":". The system is too complicated to rework this whole bump proc so I can't make it simple... I tried, I almost ruined months of work. If anyone has any suggestions I could really use them. Thanks anyway Rcet.

Canar
In response to Canar
You can get rid of the : operator by make a new var of the correct type:

if(istype(M,/mob/char))
<font color=#ffffa0>var/mob/char/C = M // C is just another alias for M</font>
if(C.havepuck==1)

I don't think that line was the problem though. The best way to track the problem would be to stick temporary messages in right after the if statement to see if it gets past it.

if(istype(M,/mob/char))
var/mob/char/C = M // C is just another alias for M
if(C.havepuck==1)
<font color=#ffffa0>world << "made it past if(C.havepuck == 1)"</font>

The problem may be that you are not setting the havepuck var. Your Bump() does not set src.havepuck when src bump()s into a puck.


Minor note: You can change
for(var/I in M.overlays)
M.overlays -= I
into
M.overlays = list()
to save your poor cpu the extra cycles it takes to walk the list and perform the list subraction.
In response to Canar
Canar wrote:
without the ":" it cant check the var's that I want it too because "M" is a var to begin with. I might be wrong on that because I dont use ":" too often. I just know I tried it both ways and I don't get compile errors with ":" and with "." I get errors because its not checking the vars of a var.

That's not the reason for the error. The reason is, it doesn't know that M is actually a /mob/char type, so it doesn't know whether it has a haspuck var or not. As Shadowdarke suggested, you should cast M to a specific type and use that:
var/mob/char/C=M

The compiler knows that C is a /mob/char, so it knows C.haspuck is valid.

Lummox JR
In response to Lummox JR
ok thanks to both of you, but it wasn't the problem anyway. it was the havepuck part. its not setting it when the player gets the puck. its moving the puck to the players contents (because in the shoot proc it looks for the puck in the players contents) but its never setting havepuck to anything. I can just change this right here to look for the puck in the contents instead of the whole havepuck var right?
In response to Canar
Canar wrote:
ok thanks to both of you, but it wasn't the problem anyway. it was the havepuck part. its not setting it when the player gets the puck. its moving the puck to the players contents (because in the shoot proc it looks for the puck in the players contents) but its never setting havepuck to anything. I can just change this right here to look for the puck in the contents instead of the whole havepuck var right?

Indeed you can, if the puck is in their contents. (I didn't read the whole proc, so I don't know if that's the case.) That would be fairly simple to do:
if(locate(/mob/puck) in M.contents)
...

Lummox JR
In response to Lummox JR
yea thanks again both of you because I finally got that fixed now. I am going to be having a bug test soon, now that I have all the bugs I know about fixed. feel free to stop by and help me out some more if you want.

Canar
In response to Shadowdarke
Minor note: You can change
for(var/I in M.overlays)
M.overlays -= I
into
M.overlays = list()
to save your poor cpu the extra cycles it takes to walk the list and perform the list subraction.

ok now im having trouble with the puck,(completely not related to the previous problem.) I think doing this list thing you are talking about here will work but I'm not exactly sure how to do that. Could you be a little bit more specific please. Thanks.

Canar