sorry if im bothering people with my questions but could you help me with this attack code.
mob/verb/attack(mob/M as mob in oview(1))
usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = rand(1,10)
world << "[damage] damage!"
M.HP -= damage
ive tried a couple things but they didnt work so could anyone get it straightened out for me.
ID:179873
Oct 16 2001, 3:28 pm
|
|
In response to Demonic Shoe
|
|
no, it still says M/:/HP:bad var.
|
In response to DuDE6688
|
|
DuDE6688 wrote:
no, it still says M/:/HP:bad var. Try doing M.HP instead. |
In response to Nadrew
|
|
thats what it was in the begining
|
In response to DuDE6688
|
|
DuDE6688 wrote:
thats what it was in the begining Ok where do you have the HP var defined? |
In response to Nadrew
|
|
right above the attack code. like this
var HP = 100 |
In response to DuDE6688
|
|
DuDE6688 wrote:
right above the attack code. like this It should be mob The way you have it calls it as a global var. |
In response to Nadrew
|
|
now my death check is is wrong.
proc DeathCheck() if (HP <= 0) world << "We laugh upon [src] for their misfotune." this is the error test.dm:24:error:HP:bad var |
In response to DuDE6688
|
|
try src.hp
|
In response to DuDE6688
|
|
DuDE6688 wrote:
now my death check is is wrong. if(src.HP<=0) because the HP var is set for certain mobs. |
In response to Nebathemonk
|
|
Nebathemonk wrote:
try src.hp it still dosent work |
In response to Nadrew
|
|
Nadrew wrote:
if(src.HP<=0) The call as it is now would equate to src.HP anyway, so this wouldn't change a blessed thing. Lummox JR |
In response to DuDE6688
|
|
DuDE6688 wrote:
now my death check is is wrong. Strikes me that this is the same problem as the one Nadrew pointed out: The proc is probably global, and so there's no mob with HP to refer to. Make sure this proc block is inside your mob's code, not outside. If you have further problems, please post the entire source (or a big segment, anyway, with the relevant parts) so we can see what exactly is where. Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
DuDE6688 wrote: That was the only thing I was wrong is that he was using a global var for a certain mob so I had him change it to be for individual mob then he was still trying to use a global var in his Deathcheck proc so I asked him to change that to work with single mobs too it may not work how I put it because I had no clue of how he had other things coded I was just giving him a idea of how to fix it not the exact soulution. |
In response to Lummox JR
|
|
ok heres about all of my coding except turfs and save file
one file mob/verb/say (msg as text) world << "[usr]: [msg]" mob/verb/attack(mob/M as mob in oview(1)) if (M.HP <= 0) usr << "[M] has already been dealt with." else usr << "You thrust your weapon at [M]!" oview() << "[usr] thrusts at [M]!" var/damage = rand(1,10) world << "You take [damage] point damage!" M.HP -= damage proc DeathCheck() if (M.HP <= 0) world << "We laugh upon [src] for their misfotune." second file /mob/hovercraft icon = 'hover bot.dmi' density = 0 /mob/fighterbot icon = 'mobil fighter1.dmi' mob var HP = 100 |
In response to DuDE6688
|
|
DuDE6688 wrote:
ok heres about all of my coding except turfs and save file You must define M in this proc because it is not defined here and only in the Attack verb you could change M to usr and call it like this in the attack verb DeathCheck(M). |
In response to Nadrew
|
|
Nadrew wrote:
That was the only thing I was wrong is that he was using a global var for a certain mob so I had him change it to be for individual mob then he was still trying to use a global var in his Deathcheck proc so I asked him to change that to My brain has the consistency of pudding right now, which means it's impossible to read run-on sentences. Please use some punctuation so I can follow what the heck you're saying. Lummox JR |
In response to DuDE6688
|
|
DuDE6688 wrote:
mob/verb/say (msg as text) Yep, there's the problem right there. As I suspected, you have proc/DeathCheck() defined globally; it doesn't go with a mob. To match the rest of your code, change proc to mob/proc and it should be fine. Lummox JR |
Sorry if i am wrong