ID:155943
 
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.
If i understand correctly, you want the player to attack a monster in the world using a verb. If i were creating a very simple targeting system, i might use something like this for melee combat:
mob
player
verb
Attack(mob/mnstr/M in src.dir) //this makes the src object(the player) to attack whatever mob is in front of him or her that is under the tree /mob/mnstr at the time. If theres no mob with that directory, if automatically cancels the verb.
var/hit = rand(1,100) //just because i like percentiles :P
if(hit > 5) //5% miss rate
var/dam = rand(10,15) //Damage
M.HP -= dam
M.Deathcheck() //or whatever proc you're using to check for a mob's death

mob
mnstr
Goblin
//[Insert stats or whatever for your Goblin mob]


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:
         Attack(mob/M in src.dir)
if(ispath(M,/mob/mnstr)) //this tests weather the mobs type path is /mob/mnstr
//Verb functions
else //If the mobs type path is /mob/player or anything else, it gives you a "No Target" Message and cancels the verbs function.
src << "\red<b>No Target"
return

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.
for(var/mob/A in world) //For every mob in the world
if(A.owner==usr) //If the mob's owner is the user
var/mob/M=A //Then the var M is assigned to the mob
else //If the mob's owner isn't the user but something else
var/mob/N=A //the var N is assigned the mob.


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
> if(A.owner==usr) //If the mob's owner is the user
> var/mob/M=A //Then the var M is assigned to the mob
> else //If the mob's owner isn't the user but something else
> var/mob/N=A //the var N is assigned the mob.
>


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.