ID:146407
 
Code:
mob
var
dead = 0

mob/verb/Attack() // this is not built for pvp yet.
var/mob/M
for(M in get_step(src,src.dir)) break
if(M)
var
/// FORMULAS START HERE ///
A = (src.strength-M.vitality/1.8)
R = (A*2)
C = rand(A,R)
D = (src.attack-M.defense)
damage = (D+C)
crit_damage = (damage*2)
/// FORMULARS END HERE ///
if(M.client)
return 0
if(M.dead == 1)
return 0
if(M.dead == 0)
if(prob(((M.evasion*9.7)/src.accuracy)))
view() << "<small>[src] misses the [M].</small>"
return 0
if(prob(src.dexterity/(M.agility/3.7)))
M.hp-=crit_damage
view() << "<small><b>[src] hits [M] for [crit_damage]!</b></small>"
if(M.hp<=0)
if(M==/mob/npc/Tribal_Thief)
src.experience_given = rand((src.level/M.level)*25,(src.level/M.level)*32)
src.byne_drop = rand(1,20)
src << "<i><small>The Tribal Thief drops [src.byne_drop]</small></i>"
src << "<i><small>You receive [src.experience_given] point\s.</small></i>"
del(M)
else
M.hp-=damage
view() << "<small>[src] hits [M] for [damage]!</small>"
if(M.hp<=0)
if(M==/mob/npc/Tribal_Thief)
src.experience_given = rand((src.level/M.level)*25,(src.level/M.level)*32)
src.byne_drop = rand(1,20)
src << "<i><small>The Tribal Thief drops [src.byne_drop]</small></i>"
src << "<i><small>You receive [src.experience_given] point\s.</small></i>"
del(M)


Problem description:
Ran into a little experience points and currency(byne) drop problem. It flat out won't display the experience points and the byne drop message.

Any ideas?

**The reason why I use this system instead of a pre-defined byne drop and exp given is so the experience is affected by the user's currently level relative to the npc's. I also don't want all npcs to drop byne bills, but for the ones who do, I want it to be a random drop.
RainZero wrote:
Code:
> mob
> var
> dead = 0
>
> mob/verb/Attack() // this is not built for pvp yet.
> var/mob/M
> for(M in get_step(src,src.dir)) break
> if(M)
> var
> /// FORMULAS START HERE ///
> A = (src.strength-M.vitality/1.8)
> R = (A*2)
> C = rand(A,R)
> D = (src.attack-M.defense)
> damage = (D+C)
> crit_damage = (damage*2)
> /// FORMULARS END HERE ///
> if(M.client)
> return 0
> if(M.dead == 1)
> return 0
> if(M.dead == 0)
> if(prob(((M.evasion*9.7)/src.accuracy)))
> view() << "<small>[src] misses the [M].</small>"
> return 0
> if(prob(src.dexterity/(M.agility/3.7)))
> M.hp-=crit_damage
> view() << "<small><b>[src] hits [M] for [crit_damage]!</b></small>"
> if(M.hp<=0)
> if(M==/mob/npc/Tribal_Thief)
> src.experience_given = rand((src.level/M.level)*25,(src.level/M.level)*32)
> src.byne_drop = rand(1,20)
> src << "<i><small>The Tribal Thief drops [src.byne_drop]</small></i>"
> src << "<i><small>You receive [src.experience_given] point\s.</small></i>"
> del(M)
> else
> M.hp-=damage
> view() << "<small>[src] hits [M] for [damage]!</small>"
> if(M.hp<=0)
> if(M==/mob/npc/Tribal_Thief)
> src.experience_given = rand((src.level/M.level)*25,(src.level/M.level)*32)
> src.byne_drop = rand(1,20)
> src << "<i><small>The Tribal Thief drops [src.byne_drop]</small></i>"
> src << "<i><small>You receive [src.experience_given] point\s.</small></i>"
> del(M)
>

Problem description:
Ran into a little experience points and currency(byne) drop problem. It flat out won't display the experience points and the byne drop message.

Any ideas?

**The reason why I use this system instead of a pre-defined byne drop and exp given is so the experience is affected by the user's currently level relative to the npc's. I also don't want all npcs to drop byne bills, but for the ones who do, I want it to be a random drop.



Well I've solved this problem by changing if(M==/mob/...) to if(M.name == "..."). But can someone tell me why the other way didn't work?
In response to RainZero
RainZero wrote:
Well I've solved this problem by changing if(M==/mob/...) to if(M.name == "..."). But can someone tell me why the other way didn't work?

because if(m==mob/blah..) just wont work,
he == operator is built for that. the == operator is built for vars, not to chek if some is a tupe of mob.

Hit F1 ( in dream maker of course) and look up istype :)

Edit: Woops, I wasn't explaining it very clearly, however I edited it :)

O-matic