ID:156968
Jun 22 2010, 9:23 am
|
|
How can I assign a mob to the client based on a choice during runtime? My attempts were unsuccessful. Thanks.
|
Jun 22 2010, 10:16 am
|
|
Usually, you should post your attempts. Anyways, I am pretty sure that this is how you do it.
|
In response to Darkjohn66
|
|
That is what I did with my attempt, which does not work because it makes me relog or so it seems.
|
In response to DisturbedSixx
|
|
mob var (client)
mob |
In response to Cody123100
|
|
What would I do if I do not have an old one. I'm trying to create the mob after choosing it in the character creation.
|
In response to DisturbedSixx
|
|
As soon as any client enters into the game, they are assigned a mob based upon world.mob. By default this is simply the /mob type.So unless you set world.mob to 0, every player will have a mob created upon joining. However, if you do set world.mob to 0, simply skip the steps on remembering and deleting the old mob and go straight to creating the new mob. Then relocate the player to a position on the map as needed.
|
In response to Cody123100
|
|
Say I assign this through an object. Say:
obj/thing And then the proc looks something like: mob/proc/MobAssign(TYPE) The only way I can see to link to the proc would be to do usr.MobAssign(Bulbasaur) but then it tells me usr in null through a runtime. I'm getting a bit confused and cannot solve it no matter what I do. |
In response to DisturbedSixx
|
|
Take note that this code is just an example, if you actually use it in your pokemon game I imagine players will get frustrated always playing with default level pokemon. You should really write a design document with planned steps on the checks you need to initiate to make sure things go as planned. There's a lot more work than simply making a pokemon appear on the screen when you click a pokeball, for a few examples: What if the pokeball isn't in the user's contents? What if the pokemon in the pokeball doesn't have default stats? What if the pokemon in the pokeball is holding an item or has a status condition? What if the pokemon in the pokeball is injured/fainted?
obj |
In response to Cody123100
|
|
I have managed to get it working (thanks for the big help) but why do I relog before I get into the game?
|
In response to DisturbedSixx
|
|
If you mean that it's calling Login() again, then it's probably because you have overwritten Login() for the default mob type (/mob). The unoverwritten proc simply checks if the mob has a location and if it doesn't it places it at (1,1,1). Since it is called whenever you try to connect to a mob (whether automatically at client.New() or manually called by changing the player's mob) if you have overwritten it for the default mob it will call your overwritten version everytime you connect to a new mob. For simplicity sake I would suggest that you create a tmp variable that tracks if the player is logged in (0 for false, 1 for true). If true then return, otherwise proceed into login and set the tmp variable to 1.
|
In response to Cody123100
|
|
It actually calls both the Logout() and Login(). Also, it changes the mob from being my key, DisturbedSixx, to the name of the mob path I'm assigning. Can I avoid that?
|
In response to DisturbedSixx
|
|
You can overwrite the name variable. And yes, it would call mob.Logout() too, I forgot that part heheh. You'll need to take that into account too possibly with a tmp variable that detects if you are switching mobs or actually logging out. For example,set the tmp variable to 1 before switching and back to 0 after switching is complete. Make it so that whenever Logout is called while switching is 1 it will not process. Beware however, you also need to consider what will happen if someone logs out while in a pokemon mob; or worse, they logout while switching is set to 1.
|
In response to Cody123100
|
|
Well I will try that out and edit this post and let you know how that works. Also, this isn't to send out pokemon. This will be you choosing the starter and then staying that mob for the remainder of the game.
{EDIT} Yeah doing that tmp var worked for the Logout() but it still calls the Login() and if I apply the same method for Login(), it gives me a black screen. Geez this is harder then I expected it to be... |
In response to DisturbedSixx
|
|
Here's an example.
mob |
In response to Cody123100
|
|
Alright I fixed everything up and it seems to be working. For some reason it feels to me like I'm just masking up some kind of problem but I'll deal with it until it comes up. Thanks.
|
In response to DisturbedSixx
|
|
DisturbedSixx wrote:
Alright I fixed everything up and it seems to be working. For some reason it feels to me like I'm just masking up some kind of problem but I'll deal with it until it comes up. Thanks. The problem is that you are conflating "Login()" with "A player has connected to the game". If you want to do something WHEN A PLAYER CONNECTS, that goes in client/New(). If you want to do something when a player DISCONNECTS, that goes in client/Del(). Again, Login() is called whenever a client is assigned a mob, and Logout() is called whenever a client stops controlling a mob. |
In response to Cody123100
|
|
Cody123100 wrote:
As soon as any client enters into the game, they are assigned a mob based upon world.mob. This is not accurate. This is part of the default action of client/New(). Look it up in the Reference. |