ID:263093
 
Code:
mob
proc
yes()
switch(usr.class)

if("Soldier")
var/mob/newmob=new/mob/player/Soldier
newmob.gender=newgender
newmob.name=newname
newmob.class=newclass
usr.client.mob=newmob
del src

if("Royalty")
switch(src.key)
if("Satans Spawn")
var/mob/newmob=new/mob/player/Satans_Spawn
newmob.gender=newgender //line 451
newmob.name=newname
newmob.class=newclass
usr.client.mob=newmob
del src


Problem description:

Now on to the problem. Up until now that has been the code that decides whether or not to make a character Royalty. (It is a DW styled game where you choose your class via on screen display, using a variable to store which class you choose.) When I choose to make a Royalty class, I get a runtime error reading:

runtime error: Cannot modify null.gender.
proc name: yes (/mob/proc/yes)
source file: char creation.dm,451
usr: Satans Spawn (/mob/choosing)
src: Satans Spawn (/mob/choosing)
call stack:
AAA (/mob/choosing): yes()
Satans Spawn (/client): Center()


However, when I choose to create a Soldier classed Character, everything goes through normally.

Can anyone see what may be causing this error to appear out of no where?

§atans§pawn
For one thing, you're using usr in a proc. Don't.
In response to Jp
For it to have a gender, it needs to be connected to a client, so it can actually retreive the gender from BYOND.
In response to Jp
Jp wrote:
For one thing, you're using usr in a proc. Don't.

Sorry... Like I said it is old code. I haven't got around to making sure I have src replacing usr wherever I can. This I don't believe to be the problem though. It has worked perfectly fine for months up until now when it suddenly went offline on me for some unknown reason.

I also did a couple of checks to ensure that usr and src are the same, just in case it was the problem.

I do not have time to fix that at the moment, however later on today I think that will be my project. Going over all my code and replacing usr where I can... Hopefully

§atans§pawn
In response to Mysame
Mysame wrote:
For it to have a gender, it needs to be connected to a client, so it can actually retreive the gender from BYOND.

Incorrect. Any atom can have gender.

At a guess, I'd say the problem is with the new() syntax being used. You'll note it's new/path, not new/path(), let alone new/path(newloc), which could be causing some compiler issues.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
At a guess, I'd say the problem is with the new() syntax being used. You'll note it's new/path, not new/path(), let alone new/path(newloc), which could be causing some compiler issues.

Lummox JR

Code:

mob
proc
yes()
switch(usr.class)

if("Soldier")
var/mob/newmob=new/mob/player/Soldier
newmob.gender=newgender
newmob.name=newname
newmob.class=newclass
usr.client.mob=newmob
del src

if("Royalty")
switch(src.key)
if("Satans Spawn")
var/mob/newmob=new/mob/player/Satans_Spawn() //I believe \
this is what you meant

newmob.gender=newgender //line 451
newmob.name=newname
newmob.class=newclass
usr.client.mob=newmob
del src


I altered it to how you said may fix it, but I still get the same problem, which I figured that I would, because the Soldier class (as well as all of the other classes) work fine. The Royalty class is the only one that is producing the runtime error.

I also tried to add in a location for the newmob to be sent to, which also did not work ( var/mob/newmob=new/mob/player/Satans_Spawn(0,0,0) )


§atans§pawn
In response to Satans Spawn
Satans Spawn wrote:
I also tried to add in a location for the newmob to be sent to, which also did not work ( var/mob/newmob=new/mob/player/Satans_Spawn(0,0,0) )

Not exactly surprising, since 0,0,0 is not a valid location, and you forgot to use locate() there.

It sounds like maybe your special mob's New() proc is deleting the mob, or returning a bad value, before the next line ever runs.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Not exactly surprising, since 0,0,0 is not a valid location, and you forgot to use locate() there.

I tried again with var/newmob=new/mob/player/Satans_spawn(locate(1,1,1)) and still got the same problem.

It sounds like maybe your special mob's New() proc is deleting the mob, or returning a bad value, before the next line ever runs.

I actually already checked that. This is what I have for the special mob.

mob/player
Satans_Spawn
New()
..()
verbs+=new/mob/extra_verbs/verb/Spell()
contents.Add(new/obj/weapons/Sword_Of_Fate, new/obj/shield/Shield_Of_Gods, new/obj/helmet/Winged_Helm, new/obj/armor/Angelic_Armor)


I must be off to work now however, so just in case that you can't think of anything else I would like to thank you for the time that you have put into helping me thus far.

§atans§pawn
In response to Satans Spawn
Why you're instantiating a verb is a complete mystery. You add the path of the verb to the verbs list, not new/verb().

Also, that contents.Add() block is atrocious. Instead, just create each object the correct way by passing their new location (src) in new().

Lummox JR