ID:1108250
![]() |
|
I was creating a game that would have a bunch of characters in it that all had different stats and moves, like hp,str,def,etc. but so far i've only been able to find examples of how to give all the characters the same stats. Is it possible to make all the characters have unique stats? and if so can someone show me an example or link me to where i can find one plz!!!
|
I also have an attack verb defined:
Attack() and when i use ur method of separating them into classes, i get the errors:Characters.dm:11:error: M.Def: undefined var how do i modify the damage definition for the separation of classes? |
In your attack function, you're only looking for references M of the type /mob. The base /mob class does not have access to variables defined under /mob/character.
There are two ways around this: 1. Define variables (health, strength, and so on) under just the base /mob class. All descendants of /mob will then have access to them. 2. Change the for() loop within Attack() to look for /mob/character-typed references: for(var/mob/character/m in get_step(src, dir)) For a more indepth explanation on variables, variable scope, verbs, and procedures have a look at the Guide, specifically chapters 4, 5, and 6. |
alright it seems like my final obstacle is defining my m.Def. i've defined all the stats for all my classes but it still gives me the error in the attack verb:
Rasengan() Error:Characters.dm:58:error: m.Def: undefined var Characters.dm:65:error: m.Def: undefined var this is the last problem im running into and im about to give up ._. |
I believe so, The way i did it was:
mob character var HP=0 MaxHP=0 Str=0 Def=0 minato HP=90 MaxHP=90 Str=7 Def=2 deidara HP=100 MaxHP=100 Str=6 Def=1 grimmjow HP=110 MaxHP=110 Str=6 Def=3 I just took ur example and applied it to my project. |
You have Def defined under /mob/character, but you're only looping through /mobs; see my earlier post on how to fix it.
|
I fixed the m.Def error, and now a new error shows up without me even changing/adding anything new.
mob proc Deathcheck() if(src.HP <= 0) view() << "[src] dies!" Verbs.dm:9:error: src.HP: undefined var i thought src. was universal so it wouldnt matter that i had it as src.HP but i guess not. Help plz? |
src points to the "container" that holds a variable or procedure. It is always the same type of whatever it is referencing; in this case src = /mob. As with the other issues you had, HP is defined under /mob/character, and the base /mob class does not have this variable.
Deathcheck() would need to be a procedure that descends from /mob/character, rather than just /mob. Again, I recommend having a look at the Guide. Chapter five explains variables and how scoping works, which is the issue you're having here. |
I went to look at the guide as you suggested, and i was able to get rid of that error by making the new proc:
mob/character proc Deathcheck() if(mob/character HP <= 0) world() << "[src] has died" but now i get the error that: Vars.dm:4:error: HP: missing comma ',' or right-paren ')' but i didnt see anything in the guide that would suggest me missing a comma or parenthesis....so what is it that i did wrong? |
if(mob/character HP <= 0) is not valid syntax in the least. That statement would never do anything but give an error.
You'd want to do something along the lines of: mob |
the first thing i tried was to do it your way, but i got a bunch of errors, so i changed it and came down to one error with the way i posted above so i assumed it was right. since my classes are defined under:mob/character
var HP=0 MaxHP=0 Str=0 Def=0 minato HP=90 MaxHP=90 Str=7 Def=2 deidara HP=100 MaxHP=100 Str=6 Def=1 grimmjow HP=110 MaxHP=110 Str=6 Def=3 I just added the mob/character proc Deathcheck() if(HP <= 0) view() << "[src] has died" in my proc file, but i still get the errors that Deathcheck proc is undefined:Characters.dm:14:error: Deathcheck: undefined proc Characters.dm:32:error: Deathcheck: undefined proc Characters.dm:54:error: Deathcheck: undefined proc Characters.dm:61:error: Deathcheck: undefined proc |
1st attempt:
mob/character 2nd attempt: mob/character 3rd attempt: mob/character those are the three places i tried placing it in order to define the deathcheck in: Attack() |
As an aside, please put your code snippets between <dm> tags. This way, the forum can apply proper formatting and syntax highlighting to them.
All three of your attempts are the same and valid. Generally it doesn't matter where you define procedures, as long as they're defined under the right "tree branch". The issue here is that in attack, you're simply calling Deathcheck(). In the case that you're calling it, src is implied to be the one calling the procedure. Internally, it does src.Deathcheck(). What you want to do is call m.Deathcheck(). This will call Deathcheck() with m as the src. |
Then you would create a new instance of a character and set the client's mob to it.