ID:141326
 
Code:
mob/var
LVL = 1
HP = 30
MP = 50
EXP = 0
Cash = 0
STR = 5
DEF = 5
EXPN = 100

mob
icon = 'Person.dmi'


Stat()
stat("LVL",LVL)
stat("HP",HP)
stat("MP",MP)
stat("EXP",EXP)
stat("Cash",Cash)
stat("STR",STR)
stat("DEF",DEF)
stat("EXP NEEDED",EXPN)


Del()
var/obj/gold/G = new(loc)
G.amount = rand(1,10)
..()


Login()
icon_state = gender
..()


proc
DeathCheck()
if (HP <= 0)
world << "[src] dies!"
usr.EXP += 10
usr:lvlcheck()
del(src)



lvlcheck()
if(usr.EXP >=usr.EXPN) // if usr's exp is, or is bigger than what needed..
usr.LVL +=1 // add a lvl
usr.EXP = 0 // reset exp
usr.EXPN = usr.EXPN * 1.15 // double needed exp
usr.STR += rand(1,6)
usr.HP += rand(20,50)
usr.MP += rand(15,40)
usr.DEF += rand(1,7)
//insert bonuses here. Ie: strength, speed, etc.. Ex: usr.speed += 10

This is all fine, it adds on stats as needed, but my problem comes up here

    verb
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
if (M.HP <= 0) //if M's HP are at or below 0...
usr << "[M] is already dead!"

usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = usr.STR * 1.5 - M.DEF * 2
world << "[damage] damage!"
M.HP -= damage
M.DeathCheck()


ok so

            var/damage = usr.STR * 1.5 - M.DEF * 2
what i want is my str points multiplied 1.5 times, then taken away from the mobs def multiplied 2 times


        Wsay(msg as text)    
world << "[usr]: [msg]"

obj
gold //define a "gold" prototype, which is a kind of obj
icon = 'gold.dmi' //set the default icon
var
amount
verb
get() //obj/gold/verb/get()
set src in view(1) //src must be close
usr << "You pick up [amount] gold."
usr.Cash += amount //add to usr.wealth
del(src) //delete the gold
i want to be able to define how much gold is dropped by each diff monster

turf
grass
icon = 'grass.dmi'

tree
icon = 'tree.dmi'

woodenfloor
icon = 'Wooden Floor.dmi'

world
turf = /turf/grass



monster
wasp
icon = 'wasp.dmi'
var
M.DEF = 4
M.HP = 20

greendevil
icon = 'green devil.dmi'
var
M.DEF= 7
M.HP= 50


can you tell me why these arnt working, i tryed just putting them as

 
monster
wasp
icon = 'wasp.dmi'
var
DEF = 4
HP = 20

greendevil
icon = 'green devil.dmi'
var
DEF= 7
HP= 50


and i have also tryed taking out the monster part

PS: how would i get my stats to affect the amount of damage i do
can you tell me why these arnt working, i tryed just putting them as

If you can form your problem in:

"I want it to do (this), but instead it does (this)."

One problem at a time, instead of saying "I want to do this, and this. Why isn't it working?", It would be a lot easier to help you.

Major flaw that I see (unless intended, which I doubt.) is your monsters are not under the mob type.

Where you have:
monster
wasp
icon = 'wasp.dmi'
var
M.DEF = 4
M.HP = 20


since monster is not indented under anything, you're just defining a new datum of type /monster.

There's a very very good chance that you meant to have this as:

mob/monster
wasp
icon = 'wasp.dmi'
M.DEF = 4
M.HP = 20


Note that I also took out the var line, because those variables are already defined the parent type, /mob. You are just setting their values.

Basically it all comes down to an understanding of object trees, parent types, inheritance, and all that good stuff. I'd suggest you brush up on whatever chapter of the DM guide that covers that kinda stuff.
In response to Zagreus
ok, basicaly i want each monster to have seperate skill levels etc and money drops, but i cannot figure out how to get it workin, as i have tryed putting var after the monster, the obv you can see what i tried to do for the attack with this
In response to Shiniru
I would suggest using grammar when doing your game.

Like in the stat panel you are saying LVL as a stat. Spell it properly, and say Level:




In response to Howey
var/damage = usr.STR * 1.5
var/damage2 = M.DEF * 2
var/damage3 = damage - damage2
M.HP = M.HP - damage3
In response to Xyphon101
So what if M.DEF * 2 is larger than usr.STR * 1.5? You heal the person you're hitting?
In response to Jp
...
He just asked how to do the damage.

But..
if(M.DEF >= usr.STR)
damage3 = 0
In response to Xyphon101
Still wouldn't work. Better way to do it would be damage3 = max(0, damage3)
In response to Howey
totally a legal abbreviation

LVL = Lv = Level
In response to Jp
how come nobody told me about max()!?
In response to Expert Novice
That's what the guide/reference's job is for? o.O
ok, so i got the monsters to have seperate stats

new problem

mob/var

LVL = 1
HP = 30
MP = 50
EXP = 0
Cash = 0
STR = 10
DEF = 5
EXPN = 100



mob/monster
wasp
icon = 'wasp.dmi'
DEF = 4
HP = 20


greendevil
icon = 'greendevil.dmi'
DEF = 6
HP = 25



Stat()
stat("LVL",LVL)
stat("HP",HP)
stat("MP",MP)
stat("EXP",EXP)
stat("Cash",Cash)
stat("STR",STR)
stat("DEF",DEF)
stat("EXP NEEDED",EXPN)



Del()
var/obj/gold/G = new(loc)
G.amount = rand(1,10)
..()


Login()
icon_state = gender
..()
world << "[usr] has joined us! GET READY TO ATTACK!"

mob
icon = 'Person.dmi'


proc
DeathCheck()
if (HP <= 0)
world << "[src] dies!"
usr.EXP += 10
usr:lvlcheck()
del(src)



lvlcheck()
if(usr.EXP >=usr.EXPN) // if usr's exp is, or is bigger than what needed..
world << "[usr] has levled up!"
usr.LVL +=1 // add a lvl
usr.EXP = 0 // reset exp
usr.EXPN = usr.EXPN * 1.15 // double needed exp
usr.STR += rand(1,6)
usr.HP += rand(20,50)
usr.MP += rand(15,40)
usr.DEF += rand(1,7)
//insert bonuses here. Ie: strength, speed, etc.. Ex: usr.speed += 10






verb
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
if (M.HP <= 0) //if M's HP are at or below 0...
usr << "[M] is already dead!"

usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = usr.STR * 1.5 - M.DEF * 2
if(M.DEF >= usr.STR)
damage = 0
world << "[damage] damage!"
M.HP -= damage
M.DeathCheck()


Wsay(msg as text)
world << "[usr]: [msg]"

obj
gold //define a "gold" prototype, which is a kind of obj
icon = 'gold.dmi' //set the default icon
var
amount
verb
get() //obj/gold/verb/get()
set src in view(1) //src must be close
usr << "You pick up [amount] gold."
usr.Cash += amount //add to usr.wealth
del(src) //delete the gold


turf
grass
icon = 'grass.dmi'

tree
icon = 'tree.dmi'

woodenfloor
icon = 'Wooden Floor.dmi'

world
turf = /turf/grass


i think my problem is the double post of the monsters having DEF and HP, i think its getting confused and not showing up


any gimmie a hand?
In response to Shiniru
Can you please tell us what the problem is exactly? It's kinda hard to help you if you don't specify what the problem is that you're trying to fix.

Random aside, one flaw I found is within your damage code:

            var/damage = usr.STR * 1.5 - M.DEF * 2
if(M.DEF >= usr.STR)
damage = 0


What if usr.STR is 21 and M.DEF is 20? The damage will be 31.5 - 40. You're better off doing something like this if you want to continue using that same damage equation.

            var/damage = usr.STR * 1.5 - M.DEF * 2
if(damage < 0) //we don't want to heal the mob!
damage = 0
In response to Clowd
Clowd wrote:
Can you please tell us what the problem is exactly? It's kinda hard to help you if you don't specify what the problem is that you're trying to fix.

Random aside, one flaw I found is within your damage code:

>             var/damage = usr.STR * 1.5 - M.DEF * 2
> if(M.DEF >= usr.STR)
> damage = 0
>

What if usr.STR is 21 and M.DEF is 20? The damage will be 31.5 - 40. You're better off doing something like this if you want to continue using that same damage equation.

>             var/damage = usr.STR * 1.5 - M.DEF * 2
> if(damage < 0) //we don't want to heal the mob!
> damage = 0
>


already solved that