Well, I have been putting together an RPG using Byond, and I was using the ZBT guide for RPG's (http://zilal.byondhome.com/tutorials/zbt.html) and I have just started to add the combat system.
I have entered the code as below. This is my first time programming so I don't have much experience.
-------------------------------------
world
mob = /mob/player
mob
player
icon = 'player.dmi'
var
HP = 30 //define a new variable called HP, with a value of 30
Login()
icon_state = gender //when a player logs in, make their icon's state
..() //the gender of their key. Then call the parent!
proc
DeathCheck() //checks to see if an attack is deadly
if (HP <= 0) //if the defender's HP is low enough...
world << "[src] dies!" //do the death messaging
verb
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
usr << "You attack [M]!" //send this message to the usr
oview() << "[usr] attacks [M]!" //send this message to everybody else
var/damage = rand(1,10) //assign a random # to a new variable
world << "[damage] damage!" //tell the damage to the world
M.HP -= damage //take away the damage from M
M.DeathCheck() //check for death with a proc
enemy
icon = 'soldier.dmi'
bug //new prototype
icon = 'bug.dmi' //override the parent's icon, which was 'person.dmi'
--------------------------------------------
However, when I try to 'run' the game, i recieve these errors:
fantasy.dm:30:error:M.HP:undefined var
fantasy.dm:31:error:M.DeathCheck:undefined proc
I believe that this is because the program does not know what 'M' means. However, I do not know how to resolve this problem.
Any advice on how to solve it?
ID:144734
Sep 10 2006, 11:36 am
|
|
In response to Rickoshay
|
|
Rickoshay wrote:
2. try M:DeathCheck() and M:HP if not try src.DeathCheck etc No, you don't ever need to use the colon operator unless in a specific case, where there's a datum that can't be type casted (like a verb or proc). ~~> Unknown Person |
RoadToDawn wrote:
I believe that this is because the program does not know what 'M' means. However, I do not know how to resolve this problem. Yes, 'M' is a /mob type, and you defined your DeathCheck on a /mob/player type. Define M as a /mob/player type, and you're set. ~~> Unknown Person |
In response to Unknown Person
|
|
Don't worry, I re-did the entire tutorial and found I had one word in the wrong place.
Thanks anyway, I've got a long way to go -.- |
2. try M:DeathCheck() and M:HP if not try src.DeathCheck etc
//to use DM tag type <dm>DM code here