ID:262616
 
I just started trying to make a game on BYOND by learning the basics. But I cant even get my character to appear! He's on the map, because if I press the directions around n hit attack, it says "you hit monster for 7 damage!" Why can't I see my character? Do I have to add the character onto the map? I made an icon for my char, a blue stick figure. someone plz help me!

Here's all my mob code:



mob
person
icon = 'person.dmi' //all mobs will be person.dmi
var
HP = 30 //new var HP is 30

Login() //mob procs must be capitalized!
icon_state = gender //when a player logs in, make their icon's state
..() //the gender of their key

bug //new prototype
icon = 'bug.dmi'
proc
DeathCheck() //checks if the attack was deadly
if (HP <= 0) //if the defender's HP is low enough...
world << "[src] dies!" //show death msg

What am I doing wrong?
1> Make sure to put your code in the



tags(so it is always easy to read on the forums). In the Login() you are setting the icon_state to gender. You are not even setting the sources gender variable. Make sure that to set gender to an applicable icon_state. It is trying to show an icon state that probably does not exist.
In response to Soccerguy13
Soccerguy13 wrote:
You are not even setting the sources gender variable.

That would be because player mobs already have a gender equal to that of their client's key's gender.

Make sure that to set gender to an applicable icon_state. It is trying to show an icon state that probably does not exist.

This is a valid point. You should have icon states for each of the following:
  • "neuter"
  • "male"
  • "female"
  • "plural"


As for something from the original post,
    Login() //mob procs must be capitalized!
icon_state = gender //when a player logs in, make their icon's state
..() //the gender of their key

The part where it says "//the gender of their key" doesn't correctly describe what the ..() procedure is doing. Login() is a built-in proc and, as probably at least 98% of all built-in procs do, it has coding that would normally need to be run built in with it. Using the ..() procedure allows you to carry out all of the built-in commands of mob/Login().

The part where it says "mob procs must be capitalized!" only applies to built-in procs. Procs that you define yourself for mobs can be capitalized in whatever manner suits you.

On another note, in relation to the first post, be sure you are setting world/mob to /mob/person , so that the world knows that by default, your mob should be of the person type.
world
mob = /mob/person // Set default mob to /mob/person



Now you specifically mentioned that the error occurs after you attack. I think it would be appropriate then to post your attack procedure so that we could examine it and root out all possibly deadly flaws for you.

Hiead
Cyvyr-X wrote:
I just started trying to make a game on BYOND by learning the basics. But I cant even get my character to appear! He's on the map, because if I press the directions around n hit attack, it says "you hit monster for 7 damage!" Why can't I see my character? Do I have to add the character onto the map? I made an icon for my char, a blue stick figure. someone plz help me!


----------------------------------------------------------
Well, you're on the right track but you specified it as "mob/Login()" wich will apply to all mobs, players and non. simply the icon state for the npc has been nulled because it has no icon state for neuter. Try this...


mob
person
icon = 'person.dmi' //all mobs will be person.dmi
var
HP = 30 //new var HP is 30

Login()
..()
if(src.client)
icon_state = gender //when a player logs in, make their icon's state

bug //new prototype
icon = 'bug.dmi'
proc
DeathCheck() //checks if the attack was deadly
if (HP <= 0) //if the defender's HP is low enough...
world << "[src] dies!" //show death msg
In response to Hiead
Thanks for all the help!

As for the attack code, there is supposed to be a problem. the tutorial wants me to find and fix.

Again, thank you very much for all of the help!
In response to Cyvyr-X
mob
/mob/person
person
icon = 'person.dmi' //all mobs will be person.dmi

var
HP = 30 //new var HP is 30

Login() //mob procs must be capitalized!
..()
if(src.client)
icon_state = gender //changes from forum
bug //new prototype
icon = 'bug.dmi'
proc
DeathCheck() //checks if the attack was deadly
if (HP <= 0) //if the defender's HP is low enough...
world << "[src] dies!" //show death msg





verb
attack(mob/M as mob in oview(1)) //attack mob within 1 tile of you
usr << "You attack [M]!" //sends message to usr
oview() << "[usr] attacks [M]!" //tells everyone else you attacked [M]
var/damage = rand(1,10) //assign a random # to a new var
world << "[damage] damage!" //tells damage to the world
M.HP -= damage
M.DeathCheck() //uses the proc to chekc for death in the mob

say(msg as text)
world << "[usr]: [msg]" //usr's words in msg. usr name in usr


turf
grass
icon = 'grass.dmi' //grass will hav the icon grass.dmi

world
turf = /turf/grass





That is all my code. A character is still not appearing. I have no idea knowing what's going wrong... This is the first attempt to even try to lean to code games on BYOND.

Please help...
In response to Cheetoz
Cheetoz wrote:

Well, you're on the right track but you specified it as "mob/Login()" wich will apply to all mobs, players and non.

Actually, mob/Login() is only called when a client connects to a mob, or "logs in." New() is the proc that both player and non-player mobs call when they are created.

Hiead
In response to Cyvyr-X
Cyvyr-X wrote:
mob
> /mob/person

What's that? I think you're going for
world
mob = /mob/person

Which would go down at the bottom with your world/turf setting.

Hiead
In response to Hiead
mob
person
icon = 'person.dmi' //all mobs will be person.dmi

var
HP = 30 //new var HP is 30

Login() //all already input procs must be capitalized!
..()
if(src.client)
icon_state = "male" //changes from forum
bug //new prototype
icon = 'bug.dmi'
proc
DeathCheck() //checks if the attack was deadly
if (HP <= 0) //if the defender's HP is low enough...
world << "[src] dies!" //show death msg





verb
attack(mob/M as mob in oview(1)) //attack mob within 1 tile of you
usr << "You attack [M]!" //sends message to usr
oview() << "[usr] attacks [M]!" //tells everyone else you attacked [M]
var/damage = rand(1,10) //assign a random # to a new var
world << "[damage] damage!" //tells damage to the world
M.HP -= damage
M.DeathCheck() //uses the proc to chekc for death in the mob

say(msg as text)
world << "[usr]: [msg]" //usr's words in msg. usr name in usr


turf
grass
icon = 'grass.dmi' //grass will hav the icon grass.dmi

world
turf = /turf/grass
/mob/person
In response to Cyvyr-X
Cyvyr-X wrote:
> world
> turf = /turf/grass
> /mob/person

No, no, no, no, [etc.]

world
turf = /turf/grass
mob = /mob/person


In addition,
mob
person
icon = 'person.dmi' //all mobs will be person.dmi

var
HP = 30 //new var HP is 30

Login() //all already input procs must be capitalized!
..()
if(src.client)
icon_state = "male" //changes from forum


Change that to
mob
person
icon = 'person.dmi' //all mobs will be person.dmi
icon_state = "male"
var
HP = 30 //new var HP is 30


Hiead
In response to Hiead
mob
person
icon = 'person.dmi' //all mobs will be person.dmi

var
HP = 30 //new var HP is 30


bug //new prototype
icon = 'bug.dmi'
proc
DeathCheck() //checks if the attack was deadly
if (HP <= 0) //if the defender's HP is low enough...
world << "[src] dies!" //show death msg





verb
attack(mob/M as mob in oview(1)) //attack mob within 1 tile of you
usr << "You attack [M]!" //sends message to usr
oview() << "[usr] attacks [M]!" //tells everyone else you attacked [M]
var/damage = rand(1,10) //assign a random # to a new var
world << "[damage] damage!" //tells damage to the world
M.HP -= damage
M.DeathCheck() //uses the proc to chekc for death in the mob

say(msg as text)
world << "[usr]: [msg]" //usr's words in msg. usr name in usr


turf
grass
icon = 'grass.dmi' //grass will hav the icon grass.dmi

world
turf = /turf/grass
mob = /mob/person
In response to Cyvyr-X
Cyvyr-X wrote:
mob
> person
> icon = 'person.dmi' //all mobs will be person.dmi

I specifically recall changing that to:
mob
person
icon = 'person.dmi'
icon_state = "male"


> world
> turf = /turf/grass
> mob = /mob/person

</dm>
I sense an indentation error. Try pressing Ctrl + t in the .dm window, and it will show you where your tabs are. Remember, you shouldn't have any spaces in your indent.

Hiead