ID:160516
 
Situation:

I want each mob to have it's own distinct variable value for HP, ATK, and so on for any skill I want to include, and have this executed in the beginning of the game.

Questions:

Is this a fast way to accomplish this task?
How come the variables aren't being saved or 'set'?
How does the 'set' keyword work?


mob proc StartGame() playerSS() monster1SS() playerSS(usr) src.HP = 30 src.ATK = 5 src.MAG = 10 src.DEF = 0 monster1SS(/mob/monster1) src.HP = 10 src.ATK = 2 src.MAG = 0 src.DEF = 0 DeathCheck() if(HP <= 0) view(4) << "[src] has seen their death..." del(src) var HP ATK MAG DEF player icon = 'player.dmi' icon_state = "player" monster1 icon = 'monster1.dmi' icon_state = "monster1" name = "Small Monster" Login(usr) StartGame() Move(locate(0,0,0)) ..() verb Say(msg as text) world << "[usr]: [msg]" Attack(mob/M as mob in oview(1)) var/damage = rand(0,ATK) var/mdamage = rand(0,M.ATK) view(4) << "[damage] damage!" M.HP = M.HP-damage usr.DeathCheck() usr << "[mdamage] damage dealt to you!" HP = HP-mdamage M.DeathCheck()
Is it difficult?
In response to IOPTFEAR
Type in a user key in another mob and click enter.It'll turn them into the mob u put your key in.
heres a way
                if("Name")
src.health=5
src.Maxhealth=5
src.Level=6
src.Attack=5
src.MaxAttack=5
src.Defense=5
src.MaxDefense=5
src.Speed=5
src.MaxSpeed=5
src.exp=0
src.maxexp=5
src.icon='pokemon.dmi'
src.icon_state="eevee"

if(usr.key=="name")
src.icon='pokemon.dmi'
src.icon_state="mk"
src.health=1.#INF
src.Attack=1.#INF
src.MaxAttack=1.#INF
src.Defense=1.#INF
src.MaxDefense=1.#INF
src.Speed=1.#INF
src.MaxSpeed=1.#INF
src.PP=1.#INF
src.MaxPP=1.#INF
src.Level=1.#INF
src.Maxhealth=1.#INF
src.exp=1.#INF
src.maxexp=1#INF

mob//the player
var//Varables as in health, exp, all your varables that you can change or will change in the game.. if you see hte compile :error:usr.health:undefined var then you are missing that varable..from your varable list
health=5
Maxhealth=5
Attack=5
MaxAttack=5
Defense=5
MaxDefense=5
Speed=5
MaxSpeed=5
Level=6
PP=5
MaxPP=5
Wealth

exp=0
maxexp=5

mob/wild
Wild
verb
get_Wild_Pokemon()
set src in oview(1)
src.Move(usr)
usr << "[usr.name] gets [src.name]."
drop_Wild_Pokemon()
src.Move(usr.loc)
usr << "[usr.name] drops [src.name]."
name = "Wild"
icon = 'ekans.dmi'
hp = 1000 //this defines "Killers" health
maxhp = 1000
player = 0
<dm>
You have to add more to the save files thing.
Uhm, first, your code is very hard to read - use the <DM> tag instead to post it in a neat code box.
As for your question, it seems you are trying to give different mob types different variable values, but you are not knowledgeable enough on the language to even know how to override variables and manage node subtypes. I highly recommend reading this article; especially look into the ZBTs and then the DM Guide.

If I get what you want correctly, it's very basic to do, and done simply like this:
mob/fighter
var
//these are default values. you could even leave those null if you're not going to use the base mob/fighter type
HP = 5
str = 10
def = 10
player
HP = 100
str = 20
def = 20
monster
HP = 50
def = 0
dragon
str = 40
HP = 500
armored_dragon
def = 40

You just give the variables different values when defining the object prototypes, it is best and easier to do so at compile-time like this instead of in procs, etc. You could also define subtypes on /mob/player if wanted, of course.
In response to Kaioken
[EDIT]

mob
Login()
icon = 'player.dmi'
icon_state = "Person"
..()

verb
say(msg as text)
view(5) << "[usr]: [msg]"

attack(mob/M as mob in oview(1))
view(5) << "[src] attacks [M]!"
var/PD = rand(0,usr.ATK) - rand(0,M.DEF)
player
icon = 'player.dmi'
icon_state = "Person"
name = "Player"
var
HP = 30
ATK = 5
MAG = 10
DEF = 0

monster1
icon = 'monster1.dmi'
name = "Red Blob"
var
HP = 11
ATK = 2
MAG = 0
DEF = 0


Okay, what chapter in the DM guide would help me with figuring out how to incorporate the variables from a mob and incorporating it into the 'attack' verb.

Like,

  attack(mob/M as mob in oview(1))
view(5) << "[src] attacks [M]!"
var/PD = rand(0,usr.ATK) - rand(0,M.DEF)
// So far 'usr.ATK' & 'M.DEF' aren't known variables
// I'm unsure on how to fix that.
/*

And the rest of the verb will use the variables from the same mobs to calculate their health afterwords and stuff.

*/



And quick question: how well does the DM Guide, References, and Tutorials actually help?
</DM>
In response to IOPTFEAR
IOPTFEAR wrote:
Sorry for not being so responsive- I like the constructive criticism- very helpful.

Nah, it's okay, I don't feel any particular issue in your 'responsiveness'. =P

I think you know why I'm not that knowledgeable- laziness, which is the flaw in most people trying to pursue hobby-related goals.

Mmh, don't get me started about my laziness. Though, it more often stops me from doing things more like, well, homework. =P Anyway, just try and read those links sometime, they will benefit you. The DM Guide is a long one, but of course you don't need to read it in one sitting (though it's important to read it whole/in order if you're a beginner). Also, the ZBTs come first. >_>

As for your problem - first, this is not critical, but is not hypercritical either: don't use 1 space as indentation. It makes it harder to read on the forums, and I recommend using something more like a tab in your more "personal" code as well, as I feel you will benefit from the extra readability in the long run. Either way 1 space is not enough, use 2 in the least, preferably IMO 3/4 (4 is basically a tab).
Your problem is indeed a duplicate definition: you're defining the same vars multiple times. If you observe the differences between your code and mine, yours have the <font color=#0000ff size=5>var</font> keyword multiple times, and mine only once (excuse the blue-on-blue, so I made it bigger >_>). The keywords 'var' and 'proc' tell the compiler to 'declare (create) a new var/proc', respectively. When you're overriding an existing var (or proc), you don't use those keywords, as you're not creating a new one; the variable already exists*, so trying to declare it again will bring up errors.

*1: The code in my previous posts works because of object inheritance. The subtypes (aka 'child-types') of a type inherit all its procs and variables from it, and by default theirs is exactly like the parents. So:
mob/fighter
var/HP
monster
player
proc/Attack()

Now all types* under /mob/fighter have an HP var, as well as the Attack() procedure (the fact I declared it in different order doesn't matter; most things in DM work the samedespite of order). Note both var/ and proc/ lines define things directly on the /mob/fighter type, and the 'monster' and 'player' words define new prototypes under it.
*2: These child types types are: /mob/fighter/monster and /mob/fighter/player.
In response to Sapphir
mob
proc
DeathCheck()
if(src.HP <= 0)
view(src,4) << "[src] has seen their death..."
del(src)


var
HP
ATK
MAG
DEF

player
icon = 'player.dmi'
icon_state = "player"
HP = 100
ATK = 100
MAG = 100
DEF = 100


monster1
icon = 'monster1.dmi'
icon_state = "monster1"
name = "Small Monster"
HP = 10
ATK = 5
MAG = 1
DEF = 5

verb
Say(msg as text)
world << "[usr]: [msg]"
Attack(var/mob/M in oview(1))
view(usr,4) << "[usr] attacked [M]!"
var/damage = rand(0,ATK)
var/mdamage = rand(0,M.ATK)
view(usr,4) << "[damage] damage!"
M.HP = M.HP - damage
M.DeathCheck()
usr << "[mdamage] damage dealt to you!"
usr.HP = usr.HP - mdamage
usr.DeathCheck()


Here you go.