ID:2175841
 
(See the best response by Kaiochao.)
Code:
//including as partial to the question
mob/Login()
src.loc = locate(1,1,1)
src.Conjurations += new/mob/Familiars/Slime
src.icon='player.dmi'
src.icon_state=""

mob/var
Level=0
Health=0
Power=0


mob/var/Conjured=0

mob/var/list
Conjurations = new/list(10) //maximum of 10 Conjurations

mob
verb
Conjure(mob/Familiars/M in usr.Conjurations)
if(src.Conjured<=0)
M.loc = locate(src.x,src.y,src.z)
usr<<"Speaking in your enchanted tounge you conjure a [M] to aid you!"
src.client.eye = M
src.client.control = M
src.Conjured+=1
else
src<<"You've already conjured something!"


mob
Familiars
var
Effect=""

Slime
icon='Familiars.dmi'
icon_state=""
Level=1
Health=1
Power=1
Effect="Due to its lack of intimidation, soft state, and ultimately being non-existent on any food-chain the Slime excels for novice Conjurers as a means to scout ahead without drawing out the aggression of enemies."


//including as partial to the question
mob/Stat()
statpanel("[src]")
stat("Health:[Health]",src)


client
var/atom/movable/control
North()
if(control)step(control,NORTH)
else ..()
Northwest()
if(control)step(control,NORTHWEST)
else ..()
Northeast()
if(control)step(control,NORTHEAST)
else ..()
South()
if(control)step(control,SOUTH)
else ..()
Southeast()
if(control)step(control,SOUTHEAST)
else ..()
Southwest()
if(control)step(control,SOUTHWEST)
else ..()
West()
if(control)step(control,WEST)
else ..()
East()
if(control)step(control,EAST)
else ..()
proc/Control(atom/movable/M)
if(M)
control=M
eye=M
else eye = usr
perspective = EYE_PERSPECTIVE


Problem description:
Greetings, third day on learning DM here! Let me say in advance that I apologize for this eyesore of an organization to you upperclass programmers.

I can fortunately say that my code is working, however, I have some questions in regard of how I should go about doing particular things with it I feel are off and ultimately need some direction with. Also let me indicate that I did follow some libraries and searches on how to go about doing the Conjure verb as I'm stuck with things centering around that area.

First question: I've come to the realization that I'm not actually being the Slime itself as evidence of the stat panel where I'm still registered as the Player. I've looked around a bit with the developer help and I've seen mentions of people logging into mobs, so I wanted to ask for some input on that tidbit or suggestions on how to go about it differently. The project I'm doing requires the player to conjure familiars(monsters) that can attack, collect exp, and level from enemies. I've also noticed that the screen goes black when you move too far from the body of the player and I'm lost as heck on that front.

The second problem I'm having/will likely be having is in regards to return familiars to their Conjuration list that are Conjured, but, I admit I haven't started my hand at that and have been clueless on means to go about that.

I look forward to your wisdom!

Best response
If you want to change mobs from the player to the slime, you need to do one of:
M.key = key // or
M.client = client // or
client.mob = M

This then calls src.Logout() (which does nothing by default) and M.Login(), which means you need to prevent /mob/Login() from turning the slime into a player (since /mob/Familiars inherits /mob/Login).

Side-notes:
* Instead of overriding all of the directional client procs, you can just override /client/Move():
client/Move(Loc, Dir)
return control ? step(control, Dir) : ..()

* In /client/proc/Control, usr is used where mob should be used instead.
* In /mob/Login and /mob/verb/Conjure, every occurrence of src. is redundant. x by itself refers to the local variable, src variable, or global variable named "x" (in that order).
* In /mob/Login, you're adding to the Conjurations list, but the Conjurations list is initialized as a list of length 10. This means the Conjurations list ends up as 10 nulls followed by a slime. You probably wanted to limit how long the list can get, but that's not the way to do it.
mob
var
list/Conjurations
MaxConjurations = 10

proc
AddConjuration(mob/Familiars/F)
if(length(Conjurations) >= MaxConjurations)
// At the limit...

else
if(!Conjurations)
// Don't instantiate until needed.
Conjurations = new

if(F in Conjurations)
// Conjurations already contains F. Someone messed up!

Conjurations += F

* In /mob/verb/Conjure, M.loc = loc does the same thing as M.loc = locate(x, y, z). Also, both occurrences of usr should be src.
In response to Kaiochao
Kaiochao wrote:
If you want to change mobs from the player to the slime, you need to do one of:
> M.key = key // or
> M.client = client // or
> client.mob = M
>

This then calls src.Logout() (which does nothing by default) and M.Login(), which means you need to prevent /mob/Login() from turning the slime into a player (since /mob/Familiars inherits /mob/Login).
Side-notes:
* Instead of overriding all of the directional client procs, you can just override /client/Move():
> client/Move(Loc, Dir)
> return control ? step(control, Dir) : ..()
>

Thank you! While trying to make these necessary changes in the first bit I encountered that while the slime summons, you continue to control the player. I've tested all three but I think something may be off?


* In /client/proc/Control, usr is used where mob should be used instead.
* In /mob/Login and /mob/verb/Conjure, every occurrence of src. is redundant. x by itself refers to the local variable, src variable, or global variable named "x" (in that order).
* In /mob/Login, you're adding to the Conjurations list, but the Conjurations list is initialized as a list of length 10. This means the Conjurations list ends up as 10 nulls followed by a slime. You probably wanted to limit how long the list can get, but that's not the way to do it.
> mob
> var
> list/Conjurations
> MaxConjurations = 10
>
> proc
> AddConjuration(mob/Familiar/F)
> if(length(Conjurations) >= MaxConjurations)
> // At the limit...
>
> else
> if(!Conjurations)
> // Don't instantiate until needed.
> Conjurations = new
>
> if(F in Conjurations)
> // Conjurations already contains F. Someone messed up!
>
> Conjurations += F
>

* In /mob/verb/Conjure, M.loc = loc does the same thing as M.loc = locate(x, y, z). Also, both occurrences of usr should be src.

Thank you tremendously for this! The game has trouble identifying F and I'm fooling around with it as we speak, but beyond that the only apparent issue is the slime issue above.

I have as it stands:
mob
verb
Conjure(mob/Familiars/M in src.Conjurations)
if(summoned<=0)
M.client = M
M.loc = locate(x,y,z)
src<<"Speaking in your enchanted tounge you conjure a [M] to aid you!"
summoned+=1
else
src<<"You've already conjured something!"


client
var/atom/movable/control
client/Move(Loc, Dir)
return control ? step(control, Dir) : ..()
In response to Tsunderebolt
The game has trouble identifying F
Oops, I wrote mob/Familiar/F instead of mob/Familiars/F. Edited now.

Here's a problem:
M.client = M

This isn't one of what I listed, and it isn't type-correct. M is a mob, and M.client must be a client, so you shouldn't use M as a value for M.client. You either want M.client = client or client.mob = M.
In response to Kaiochao
Kaiochao wrote:
The game has trouble identifying F
Oops, I wrote mob/Familiar/F instead of mob/Familiars/F. Edited now.

I feel completely silly for overlooking that myself.

Here's a problem:
> M.client = M
>

This isn't one of what I listed, and it isn't type-correct. M is a mob, and M.client must be a client, so you shouldn't use M as a value for M.client. You either want M.client = client or client.mob = M.

Thats a lot more sensible. Unfortunately I'm still suffering on the control front however.

mob
verb
Conjure(mob/Familiars/M in src.Conjurations)
if(usr.summoned<=0)
summoned+=1
M.client = client
M.loc = loc
src<<"Speaking in your enchanted tounge you conjure a [M] to aid you!"
else
src<<"You've already conjured something!"


The Slime appears but control is ultimately forfeited to the player. I'm really appreciating your feedback Kaiochao!
In response to Tsunderebolt
So, did you want to actually switch the client's control from the original player mob to the familiar, or no?

Also, just to be sure, if you're changing the client's mob, you don't need any of that "control" code, since the client always controls whatever its mob is. I noticed a bug in your client control stuff, where client.control is never cleared, but seeing as it was mostly irrelevant at this point, I forgot to bring it up.
In response to Kaiochao
Kaiochao wrote:
So, did you want to actually switch the client's control from the original player mob to the familiar, or no?

Also, just to be sure, if you're changing the client's mob, you don't need any of that "control" code, since the client always controls whatever its mob is. I noticed a bug in your client control stuff, where client.control is never cleared, but seeing as it was mostly irrelevant at this point, I forgot to bring it up.

To the familiar, yeah. Hopefully make it reversible as well for the client to regain control of the player in circumstance that the familiar is defeated to which it should return to the Conjuration list and or is dispelled/returned.

I've deleted the control as of notice.

24 Self bump, still having issues with being the familiar.
mob/verb/conjure()
var/mob/enemy/e = new/mob/enemy
e.loc = loc
e.icon_state = "crepes"
e.client = src


Didn't work for me in my test environment, but

mob/verb/conjure()
var/mob/enemy/e = new/mob/enemy
e.loc = loc
e.icon_state = "crepes"
client.mob = m


did. I'd suggest changing your client's mob rather than the mob's client.
In response to Unwanted4Murder
mob/verb/conjure()
// ...
e.client = src

src is a mob, so you can't set client to it.
fffffffff duh. My b, I was only half awake most of the morning while I was posting. lol

mob/verb/conjure()
var/mob/enemy/e = new/mob/enemy
e.loc = loc
e.icon_state = "crepes"
e.client = client


That works, so ignore me. Dunno what the problem is in that case.