Well I am working on a battle system.
I have a problem how to define two different mobs in the world basing on a owner ref var.
So if the mobs owner is the usr it is marked as mob/M and if the user isnt the owner it is marked as mob/N.
Question is if something like that is possible.
Sorry if my english is bad.
ID:155943
Jan 28 2011, 12:33 pm
|
|
for(var/mob/A in world) //For every mob in the world I think that's what you meant if I'm correct. If not, please give us more information so I can help you out further. - Raimo. |
In response to Raimo
|
|
Raimo wrote:
> for(var/mob/A in world) //For every mob in the world I promise i'm not trying to sound snub or snarky, I mean no disrespect in the least, but you have a few things that arn't needed. for(var/mob/A in world) does not need "var/mob/A", simply "mob/A" is automatically understood to be a variable if(A.owner==usr) isn't even needed as long as your world.mob directory is /mob/player, every client that logs into the server is automatically understood to be /mob/player. Any verb in the player should have src used rather than usr. Yes they do the same thing while in a player mob, but it's bad coding practice and can sometimes lead to errors and misdirections of commands at runtime. var/mob/M=A is another un-needed line, when you could just as easily use src. Looking for your own mob using for(mob/A in world) would be extremely unwise, considering you're looking through ALL mobs, If you have a couple hundred monsters and 20 players on a server, you're looking at a ton of lag creates needlessly, which if several people are attacking different targets at the same time, can create even more unwanted latency, probably making the game unplayable with enough players. Simply using the system i posted is self contained within the attacking player. Dramatically reducing the amount of CPU needed to attack. |
In response to DarkLily762
|
|
Thx for the help but I already fixed that problem yesterday.
And I meant two mobs that are assigned to two users. Like each player owns a creature. I didnt ment the player himself. Anyways I solved the problem and almost finished the battle system. I am making it for a pokemon game of mine :D |
In response to Kisuo
|
|
Ah, that's great, sorry we didn't help much though, i honestly didn't quite understand the question and got a bit confused. Next time, if you have a question with something, can you be a lot more specific? Longer, more detailed, descriptions help. Anyways, if you ever have any questions, I'm freely available on MSN whenever. [email protected]
Yours Truly, -Lily S. Deliroso |
In response to DarkLily762
|
|
You want in get_step(src,src.dir) and not in src.dir.
|
This however is about as basic as i can make it without insulting your intelligence, what i suggest is devise your own system, but following this as a guide would be helpful at first. This also makes it to where players cannot attack other players, though you can edit this for PvP use, say for 1v1 duels or something. I hope i'm not throwing too much at you at once.
Spell combat however is a little more tricky, it requires targeting procs, range systems, and the like, but it's easily managable aswell.
Edit: My mistake, simply using in the code...
Attack(mob/mnstr/M in src.dir)
...would produce an error without a target under that tree in front of the player, this is how i would remedy that:
If I were you, i might break up the mnstr type path into even more such as Dragons, Elementals, Humanoids, ect. This allows you to insert type specific attacks or weapons, such as a sword that does extra damage to a Dragon, or armor that deflects more damage from an Elemental.
This is just my opinion however, make it your own creation and thinking. What you would do from here is put ALL of your enemy mobs under this type path, it's just good coding practice.