I cant get the experience gauge in the stat panel to go up and my character doesn't level either. here is my code:
//This is a test world started by Tabu34 on 3/15/04 and yet to be completed...
mob
var/level=0
var/exp=0 // experience (total)
var/expNeeded= 15 // experience for the next level
var/maxHP= 20
var/expgained= 3
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
world << "[src] was killed by [usr]!"
world << "[usr] gains [expgained] experience!"
exp = exp + 3 //adds exp points
if(exp>=expNeeded)
LevelUp()
del(src) //delete whatever just died
InjuredCheck()
if (HP <=15)
icon = 'bugcut.dmi'
else
icon = 'bug.dmi'
LevelUp()
++level
src << "Welcome to level [level]."
maxUHP+=4
UHP=maxUHP
expNeeded*= 2
mob
icon = 'person.dmi' //makes it so all mobs will be created with the person icon
var
HP = 30 //declares a new variable called HP, with a value of 30
wealth = 0 //total money
UHP = 40 //new var Hp for user
maxHp = 30 //max hp for bug
maxUHP = 40 //max hp for user
Del()
var/obj/gold/G = new(loc) //create a new obj from the gold blueprint
G.amount = rand(1,100) //set its amount variable randomly
..() //call the parent
Login()
icon_state = gender //when a player logs in, make their icon's state
..() //the gender of their key. Then call the parent!
world << "[usr] had logged into Testworld!"
bug
icon = 'bug.dmi'
Bump(person.dmi)
attack()
src << "Bug attacks [src]!" //send this message to the usr
oview() << "Bug attacks [src]!" //send this message to everybody else
var/damagebug = rand(1,10) //assign a random # to a new variable
world << "[damagebug] damage!" //tell the damage to the world
UHP -= damagebug //take away the damage from M
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
usr << "[damage] damage!" //tell the damage to the world
M.HP -= damage //take away the damage from M
M.InjuredCheck() //check for injuries w/ proc
M.DeathCheck() //check for death with a proc
say(msg as text) //What the usr says is passed into "msg" as text
world << "[usr]: [msg]" //The world sees chatroom-like output
obj
gold //define a "gold" prototype, which is a kind of obj
icon = 'gold.dmi' //set the default icon
var
amount //declare a new variable called "amount"
verb
get() //obj/gold/verb/get()
set src in view(1) //src must be close
usr << "You pick up [amount] gold."
usr.wealth += amount //add to usr.wealth
del(src) //delete the gold
obj
tree
icon = 'tree.dmi'
density = 1
turf
grass //defines a "grass" prototype, which is a kind of turf...
icon = 'grass.dmi' //and has an icon named 'grass.dmi'. In single quotes!
world //we set one of our world's characteristics:
turf = /turf/grass //its default turf is the grass turf.
mob/Stat() //Call the Stat proc that updates the stat window every Tenth of a second...
stat("Stats:",src.desc) //Place in the stat panel, the word Stats:, and the srcs description.
stat(" HP: ","[UHP]/[maxUHP]" ) //It makes it easier to read if you put a bunch of spaces like that.
stat(" Gold: ","[wealth]")
stat(" Experience: ","[exp]/[expNeeded]")
stat(" Level: ","[level]")
//END OF CODE
i also still cant get the bug to attack me, but that is a secondary problem. Any help that I CAN UNDERSTAND *cough*Lummox JR*cough*. :P
ID:172858
Mar 18 2004, 2:02 pm (Edited on Mar 18 2004, 3:01 pm)
|
|
In response to SSJ4_Gohan_Majin
|
|
Errors? The only errors I see when compiling the code are the icons being missing. Maybe you need to look over the code again, neh?
|
In response to Tiko
|
|
the code has no errors when i compialed, but it doesn't function properly, the usr in the proc works completely fine thank you, and i have icons for everything except i didn't bother to give them to you. You will just have to believe me when i say that i have all of the icons!
|
In response to Tiko
|
|
Tiko wrote:
Errors? The only errors I see when compiling the code are the icons being missing. Maybe you need to look over the code again, neh? I didn't mean when you compile. I meant how each proc is called. Look at this for example: proc exp += exp +3? Wouldn't exp+=3 do? YES! and if(exp>=expneeded) What level up? M.Levelup or src.Levelup()? And the use of usr in proc is a no no. And del(src). Deletes the player after they die(kicks them out of the game). If you want it to happen to only an NPC, which you should add:
if(!M.client)
He shouldn't be deleting a REAL player, only an NPC. YOU should look over the code, and see the bugs. --SSJ4_Gohan_Majin |
The leveling problem comes from DeathCheck(). You're checking and/or leveling up the mob that's about to die. To do this for the attacker you'll first have to be able to access him from the DeathCheck proc(usr will not work) so you'll have to send it as an argument something like this:
mob/verb/Attack(mob/M in oview(1)) This is just an example for you to see how arguments work, now you should be able to avoid putting usr in procs. :) |
In response to Tabu34
|
|
Tabu34 wrote:
the usr in the proc works completely fine thank you No it doesn't. Might I suggest this article by Lummox JR. It will help you understand why most people say not to put usr in procs. :) p.s. There are a lot more articles like it at BYONDscape that you should read if you have the time. They'll help out a lot later on down the road. :) |
In response to SSJ4_Gohan_Majin
|
|
Thanks for the help but... the LevelUp() in:
if(exp>=expNeeded) LevelUp() is referring to the LevelUp proc i have defined elsewhere in the coding. I also have problems with the if (!M.client) del(src) part of your post. M.client isn't defined or so the computer says! You are right on the exp += 3. And thanks on the del proc, because im not killing anthing but the bug quite yet, i didn't think of it! I still haven't solved my problem, however. My 3 problems are (1) The user doesn't gain experience and (2) i dont know how to make the bugs attack the player and finally (3) I dont know how to make the bugs move. Ive tried the wander() proc or whatever it is but it doesn't work. Check my original post for the code because im going to update it now. |
In response to Tabu34
|
|
Tabu34 wrote:
Thanks for the help but... the LevelUp() in: Alright did you see my Battle SYSTEM? If not, http://developer.byond.com/hub/SSJ4_Gohan_Majin/BattleSystem It includes NPC Following & Attacking, Experience Gaining, Leveling, and more! --SSJ4_Gohan_Majin |
In response to SSJ4_Gohan_Majin
|
|
i have seen your battle system, but i tested it and the exp didn't go up at all. I took it and immediately compiled it and everything ran except the exp didn't go up in the stat panel, which is my problem!Also, i dont want the bugs to focus on me i want them to wander randomly. As for the attacking, i understand what to do, but i dont know how to put it into my coding.
|
In response to Tabu34
|
|
Tabu34 wrote:
i have seen your battle system, but i tested it and the exp didn't go up at all. I took it and immediately compiled it and everything ran except the exp didn't go up in the stat panel, which is my problem!Also, i dont want the bugs to focus on me i want them to wander randomly. As for the attacking, i understand what to do, but i dont know how to put it into my coding. Woops. A little bug. Well, check it out now, you do gain experience. Thanks for pointing that out! Well first, make the vars for strength & defense mob/var That's how you fit it in in my system. So, you should use the whole system, and that is how you fit it in with the bug. --SSJ4_Gohan_Majin |
In response to SSJ4_Gohan_Majin
|
|
it almost all worked...
here is my revised code: //This is a test world started by Tabu34 on 3/15/04 and yet to be completed... mob var/level=0 var/exp=0 // experience (total) var/expNeeded= 15 // experience for the next level var/maxHP= 20 var/expgained= 3 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 world << "[src] was killed by Tabu34!" world << "Tabu34 gains [expgained] experience!" exp+= 3 //adds exp points if(exp>=expNeeded) LevelUp() if(!M.client) del(src) //delete whatever just died InjuredCheck() if (HP <=15) icon = 'bugcut.dmi' else icon = 'bug.dmi' LevelUp() ++level src << "Welcome to level [level]." maxUHP+=4 UHP=maxUHP expNeeded*= 2 mob icon = 'person.dmi' //makes it so all mobs will be created with the person icon name = "player" var HP = 30 //declares a new variable called HP, with a value of 30 wealth = 0 //total money UHP = 40 //new var Hp for user maxHp = 30 //max hp for bug maxUHP = 40 //max hp for user strength = 3//change to the amount you want the player to have defense = 2//same here Del() var/obj/gold/G = new(loc) //create a new obj from the gold blueprint G.amount = rand(1,100) //set its amount variable randomly ..() //call the parent Login() icon_state = gender //when a player logs in, make their icon's state ..() //the gender of their key. Then call the parent! world << "[usr] had logged into Testworld!" bug icon = 'bug.dmi' strength = 5 defense = 3 var/mob/character/Player New() . = ..() spawn() move() proc/move() while(src) var/Found = FALSE for(Player in oview(5,src)) step_towards(src,'person.dmi') Found = TRUE break if(Found != TRUE) step_rand(src) sleep(10) sleep(5) Bump(mob/M) if(istype(M,/mob/)) attack(M) proc/attack(mob/U) var/damage = rand(1,strength) UHP -= damage U <<"You are being attacked by [src.name]!" src.exp += rand(5,10) src.LevelUp() DeathCheck() 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 usr << "[damage] damage!" //tell the damage to the world M.HP -= damage //take away the damage from M M.InjuredCheck() //check for injuries w/ proc M.DeathCheck() //check for death with a proc say(msg as text) //What the usr says is passed into "msg" as text world << "[usr]: [msg]" //The world sees chatroom-like output obj gold //define a "gold" prototype, which is a kind of obj icon = 'gold.dmi' //set the default icon var amount //declare a new variable called "amount" verb get() //obj/gold/verb/get() set src in view(1) //src must be close usr << "You pick up [amount] gold." usr.wealth += amount //add to usr.wealth del(src) //delete the gold obj tree icon = 'tree.dmi' density = 1 turf grass //defines a "grass" prototype, which is a kind of turf... icon = 'grass.dmi' //and has an icon named 'grass.dmi'. In single quotes! world //we set one of our world's characteristics: turf = /turf/grass //its default turf is the grass turf. mob/Stat() //Call the Stat proc that updates the stat window every Tenth of a second... stat("Stats:",src.desc) //Place in the stat panel, the word Stats:, and the srcs description. stat(" HP: ","[UHP]/[maxUHP]" ) //It makes it easier to read if you put a bunch of spaces like that. stat(" Gold: ","[wealth]") stat(" Experience: ","[exp]/[expNeeded]") stat(" Level: ","[level]") //END OF CODE it gives me these errors: Testworld.dm:17:error:M.client:undefined var ///line 17 Testworld.dm:63:error:Player:undefined type: Player ///line 63 Testworld.dm:75:error:attack :duplicate definition ///line 75 Testworld.dm:84:error:attack :previous definition ///line 84 please help im sooo close!!! |
In response to Tabu34
|
|
You're not close, read my first response again.
DeathCheck() //checks to see if an attack is deadly Who is M? "if(!M.client)" You're about to delete src which means you'll want to check if src is a client. "if(!src.client)" will work, but so will "if(!client)". That's because src is the default, which brings me to the next point. "if(exp>=expNeeded)" is checking if the src needs to gain a level, but the src is the person about to die. You'll have to send the attacker into DeathCheck() as an argument, I explained how to do this in my first response. |
In response to Jnco904
|
|
Jnco904 wrote:
You're not close, read my first response again. > DeathCheck() //checks to see if an attack is deadly Who is M? "if(!M.client)" the player is the only one that can level up, so i thought that i wouldn't need to tell who leveled up, But the if(exp>=expneeded) part adds to the variable exp, and the only exp is the player's.Ive decided to to make another death check for the bug's attack so i dont have to change the existing one, but how do i make the player respawn at the beginning of the map? [edit] i also now have another problem. My bugs move, but all they do is go strait down, and they wont attack me!once they stop they are all piled up, and wont move! |
Tabu34 wrote:
I cant get the experience gauge in the stat panel to go up and my character doesn't level either. here is my code:? proc No put usr in proc. Ungh. bug The default point of reference for oview() is usr; you need to change it to src. M.DeathCheck() //check for death with a proc DeathCheck() needs to know who the attacker is, because relying on usr is wrong. Lummox JR |
In response to Tiko
|
|
Tiko wrote:
Errors? The only errors I see when compiling the code are the icons being missing. Maybe you need to look over the code again, neh? An error is anything that doesn't function as it should in a program. Compile-time errors are just a small subset of that. In general there are three types of errors:
|
In response to Lummox JR
|
|
if you check my post from 3/18/04, its the fifth up the line, it has my revised code, and that is fixed!
|
--SSJ4_Gohan_Majin