Ok, I am having some trouble using the Bump function. I have written code so that it works when I have one type of mob(the player), but now I am making a game with monsters, and so I have other types of Mobs. The problem is I cant get the players attacks to hurt when they hit the mob. For example, one attack is a magic spell which is shot similar to a gun, and when the spell(moving ogject) hits a mob I want the hit mob to take damage. But when I try to access the hit mobs variables, such as hp it says undefiend variable. Here is how I am writing the Bump function. I am putting the function under each seperate object. I tried putting it under the individual mob, but I could not figure out how to tell the difference in objects hitting him. Heres the little bump code:
obj
magic
density = 1
icon = 'magic.dmi'
Bump(M)
world << "IM HIT!"//for testing
del(src)
M.hp--
M.hp is considered and undefiend var. But I have it defined under the mob. And isnt that how I access the variable, by using the "M." and then put the variable I want to access. If I could get some help on this that would be awesome. Or even a small tip would be great. Thnx to all for help, and sorry about the long post, I have a dendincy to just babble on.
ID:171862
![]() Jul 31 2004, 5:23 am
|
|
i changed my code so that it looks like that..and when i attempt to access the variables it still gives me the same error. I might have defined the multiple mobs incorrectly, but Bump works fine when I dont try and access a var. I am glad you tried to help, and I am sure I needed that..but it is still not working right. Very Strange...
Do you guys suggest I use procs for something like this...I have not used them much, but after looking at some example code, they seem very common. |
Airjoe, you still haven't declared M as a mob! You only checked to see if it was a mob, so you could do it a few ways, here are some:
Bump(mob/M) |
So should the code now look like this:
Bump(mob/M) if(ismob(M)) var/mob/Mob=M world << "IM HIT!" del(src) M.hp-- // Still not sure what this should reall be, M.hp? Mob.hp? If this is what it should look like, then it still does not work. M.hp is still considered an undefined var. And if I make it Mob.hp then it says: 210:error:Mob.hp: compile failed (possible infinite cross-reference loop) And I have no clue what that means. I GREATLY appreciate all the help i am getting. I have this feeling I messed another part of the code up..or did i do something wrong with the above code? |
Bump(mob/M) It should look like that, and perhaps the problem is that you don't have "hp" defined for mobs? |
Well, although I love your help, del(src) deletes the little ball of magic, without that is say IM HIT a few times, which isnt good. And I am pretty sure I defined hp for the mobs. I have it like this:
mob player // human player var/hp = 100 test // test mob var/hp = 100 And I have defined under world that player is the human mob: world mob=/mob/player And when the humna player attacks, a small ball of magic comes out, it then Bumps into the test mob and should then take hp from the test. Thnx again for all those helping me. |
if(ismob(M))
You never told it M was a mob.