ID:147080
 
mob
Bump(mob/src)
if(istype(src,/turf))
return
if(istype(src,/mob/Black_Queen))
src.hp-=1
world << "<font size=3>Black queen is under attack!"
blackcheck()
if(istype(src,/mob/Red_Queen))
src.hp-=1
world << "<font size=3>Red queen is under attack!"
redcheck()
else
usr<<"You attacked [usr]!"
usr.hp-=1
src<<"[src] attacked you!"

I tried doing else fi and it does'nt work.That's as close as I can get it.This is what happens when I log into as red and attack queen.
Red queen is under attack!
Red queen is under attack!
Red queen is under attack!
Red queen is under attack!
Red queen is under attack!
Red queen is under attack!

About it..Now with black..
Black queen is under attack!
You attacked CodingSkillz!
Black queen is under attack!
You attacked CodingSkillz!
Black queen is under attack!
CodingSkillz has killed the black queen,Reds win!
She does die here but the text is messed up.

Well, if you look at your code, the else is part of the last if statement, so when it checks false (ie with black_queen), the else happens. Also usr in there will probably produce some undersirable results.

There are a couple of ways to fix your loop. Maybe the simplest would be to use a switch() statement based on type.
In response to Jmurph
Could you possible give me an example,I try to avoid switch statements.
Your usr/src usage is way screwed up.

Firstly, NEVER name an argument "src". That's just asking for trouble. Name it "A" or "obstacle" or something. And the argument to Bump() could be any atom, not just a mob.

Secondly, don't use usr in movement procs. That includes Bump(), as well as Enter(), Entered(), Exit(), Exited(), and Move() itself.

Thirdly, remember that you technically can bump into an /area or an /obj, so make sure you exclude those cases as well. It's probably best to just exclude everything that isn't a mob.

Fourthly, you really need to sit back and think about who you're referring to. In Bump(), src is the movable atom who did the bumping. The first argument to Bump() is the atom that got bumped by src. So you want to be subtracting HP from the argument to Bump().

All summed up: (I also took the liberty of unifying all your death checking code into one proc, and overriding it for queen ants. This neccesitated making the black and red queens inherit from a common ancestor, /mob/queen. Hope you don't mind; it's a slightly more object-oriented design, which I prefer.)

(Edit: I mixed up M and src in a couple of places. Fixed.)

mob
Bump(atom/A)
// "src" has bumped into "A"

// Don't do anything to non-mobs
if (!istype(A,/mob)) return
var/mob/M = A // Typecast to /mob

// Damage the target
M.hp -= 1

// Tell people about the attack
if (istype(M, /mob/queen))
world << "[M] is under attack!"
else
M << "[src] attacked you!"
src << "You attacked [M]!"

// Do a death check on the target
M.DeathCheck()

mob/proc/DeathCheck()
if (src.hp < 0)
// We died, blah blah blah

mob/queen
DeathCheck()
if (src.hp < 0)
world << "[src] died! OH NOES!"

mob/queen/black
name="Black Queen"

mob/queen/red
name="Red Queen"
In response to CodingSkillz2
Basically, a switch statement is an extended if statement with a possible else at the end.
From the reference:

Format:
switch(E)
if(A1,A2,...) Statement1
if(B1,B2,...) Statement1
else Statement3
The "switch" instruction is a compact notation for a lengthy "else-if" chain. The expression E is compared to the values A1, A2, B1, B2, etc. When a match is found, the following statement (or code block) is executed. An optional "else" statement is run if no match is found. Once a matching switch condition is found, no further conditions will be tested. The "break" instruction may be used to exit from the switch statement.

The values A1, A2, etc. must be constants. As a convenience, a range of values may be specified in the form: A1 to An.

The switch instruction is MUCH more efficient than a lengthy "else-if" chain, because the expression E is evaluated only once. The conditional values may be any constant expression, such as a number or text string.

Example:
switch (2)
if(1) world << "ONE"
if(4) world << "FOUR"
if(2,3) world << "TWO or THREE"
if(5 to 10) world << "FIVE to TEN"
else world << "not ONE to TEN"

This outputs:

TWO or THREE
In response to Jmurph
Thanks to all of you for your help,I've learned alot.
In response to Crispy
One quick thing though,why does'nt it say src is being attacked if queen?
In response to CodingSkillz2
Please say doesn't instead of does'nt
In response to CodingSkillz2
Eek! Whoops, good catch. I mixed up src and M in those two lines. I'll edit the post.