yes i am having troub;e with some code for pac man. I am trying to make the ghost and i want you to transport to the lobby when touched by one,play lobby midi, and move randomly
heres what i have and it doesn't work. plz help
mob/ghosts/pinkGhost
icon = 'mob.dmi'
icon_state = "pinkghost"
Entered()
usr.PTS=0
usr.loc = locate(15,19,2)
usr<<"Sorry You lost all your points. Please try again"
usr<<sound('dw3castl.mid',1)
New()
walk_rand(src,7)
density = 0
ID:178790
![]() Apr 4 2002, 3:33 pm
|
|
![]() Apr 4 2002, 3:48 pm
|
|
Entered is not going to do it. Look up Bump() in the reference. Also, get rid of "usr"... doesn't belong in there anywhere.
|
It's just a matter of swapping some words.
mob/player Bump(var/atom/A) //called when player bumps into something if(istype(A,/mob/ghost)) //if it bumped into ghost PTS=0 loc = locate(15,19,2) src<<"Sorry You lost all your points. Please try again" src<<sound('dw3castl.mid',1) |
ok like i did that exactly and made all the ghost names match and such but it would seem it doesn't work a blast
|
Oops, sorry about that. What I showed you would be if the player bumped into the ghost, not if the ghost bumped into the player.
mob/ghost Bump(var/atom/A) //called when a ghost bumps into something if(istype(A,/mob/player)) //if it bumped into player var/mob/player/P = A P.PTS=0 P.loc = locate(15,19,2) P<<"Sorry You lost all your points. Please try again" P<<sound('dw3castl.mid',1) |
Because you don't know what the ghosts are going to be bumping into (or at least I don't) you can't assume they will bump into a player. You have to use the checks I put in to make sure your only trying to effect players.
In this case P is just a temporary variable that I defined to let you treat what the ghost bumped into as a player (or whatever your default player mob is). One way to get arround doing that (but Spuzzum might not like it :p) is to just do it like this: Bump(var/mob/player/P) if(istype(P,/mob/player)) P.PTS = 0 //the rest like it was before That will tell the compiler to assume what it's bumping into is a player. You'll have to modify the types based upon what type your expecting the player to be in your game though. |
Why not make a smarter ghost?
mob/Player This ghost will select a target and, unless another player moves very close to the ghost, will relentlessly persue the target (instead of just walking randomly.) Good luck! -Lord of Water |
Ok i only have one problem lord of water. I just defined the PC as
mob icon = "mob.dmi" icon_state = "pacman" how can i make this match your ghost bump code? yes and when i add all my move and music play commands under the bump target i always get incorrect indentation! aye yie yie time to go back to byond reference in a useless wallow of head pain |
1 more thing! thank you for all the help. please still do what you can with the problem though because the code still is buggish
|
To make my code work, make the PC be /mob/Player instead of /mob. Also, I've updaded my code above to use your sound and message. Hope it works for you now!
-Lord of Water |
Oh thank you so much. now pac man is coming along nicely and its time to work on asteroids soon!!!!
<(^__^)> |
**coughs** Air Mapster has a game called Dungman exactly the same as pac man http://www.byond.com/hub/hub.cgi?hub=airmapster/dungman **coughs**
|
i am doing more then just pac-man ok its several arcade games in a single byond eniviroment. AKA asteroids,pac-man and such
|
ok well all the coding and such works now except i am getting words wierdest runtime error. Curse my rotten luck. i realize from the error its a density problem but whatcha gonna do
runtime error: Cannot read null.density proc name: New (/testGhost/New) usr: null src: the testGhost (/testGhost) call stack: the testGhost (/testGhost): New(the ground (28,2,3) (/turf/ground)) RagnarofBurland logs out. runtime error: Cannot read null.client proc name: Bump (/testGhost/Bump) usr: null src: the testGhost (/testGhost) call stack: the testGhost (/testGhost): Bump(null) |
Just a thought, with no code to see and all, but maybe you shouldnt set density to null, try setting it to 0.
|
hey i know this isnt a help thing but when do you expect to put your game out(cuz it sounds fun)
------ -mike ------ |
mob/Player
testGhost icon = 'mob.dmi' icon_state = "testghost" parent_type = /obj density = 1 var mob/Player/target speed = 1 in 1 to 10 Bump(var/atom/A) if(istype(A,/mob/Player)) if(!A:client) world.log << "ERROR: [A] \[[A.type]] does not have a client." return spawn() alert(A:client,"Sorry, you've lost all of your points. Please try again!","Game Over") A << sound('dw3castl.mid',1) del(A:client.mob) New() ..() while(1) sleep(11-speed) var/dist = 1e100 for(var/mob/Player/M in world) if(get_dist(src,M) < dist + ((world.maxx+world.maxy/2)/10)) target = M dist = get_dist(src,M) step_towards(src,target) if(get_dist(src,target) == target.density) Bump(target) //thats the code |