I have been trying to get this combat system to work in my game for almost a week and can not modify it cleanly so in a death Players get set to a location and monsters are deleted... instead i keep getting this error when players die.... and it only does part of my deathcheck when this happens...it seems as if the event library is messing things up.. can someone help me please tell me what to post if you need more info..
runtime error: Cannot read null.exp
proc name: TakeDamage (/mob/proc/TakeDamage)
usr: null
src: PrinceBoy (/mob/players/Male)
call stack:
PrinceBoy (/mob/players/Male): TakeDamage(the sob (/mob/monster/sob), 27)
the sob (/mob/monster/sob): Attack(PrinceBoy (/mob/players/Male))
the sob (/mob/monster/sob): TakeAction()
the sob (/mob/monster/sob): base EventCycle(373)
GameController (/BaseCamp/GameController): EventCycle()
GameController (/BaseCamp/GameController): EventCycle()
GameController (/BaseCamp/GameController): EventCycle()
ID:149108
Jul 3 2002, 3:03 pm
|
|
In response to ACWraith
|
|
Opps first of all yes it is My code that has the error, deadron's combat system is sweet I just wish I could modify it... heres some code
I really appreciate the help dude.. if u can find the error totally kewl otherwise ill just redo the whole combat system in a few days if i cant find it. Thanks Princeboy // take damage proc proc/TakeDamage(mob/attacker, potential_damage) // Can't kill me if I'm already dead. if (isDead()) view(src) << "[attacker] hits [src]'s dead body!" return // Damage is reduced based on my armor class and defense. var/defense_modifier = armor_class + defense potential_damage -= defense_modifier if (potential_damage > 0) hp -= potential_damage view(src) << "[attacker] hit [src] for [potential_damage] points damage!" if (isDead()) view(src) << "[attacker] killed [src]!" usr.exp+=src.exp usr.gold+=src.gold Die() return else view(src) << "[attacker]'s attack bounces harmlessly off [src]." // Die and Isdead proc proc/Die() if(istype(src,/mob/monster)) view() << "[usr] killed it!" itemdrop() del(src) if(istype(src,/mob/players)) src.loc=locate(5,4,1) src.hp = src.maxhp src.exp = 0 src.gold = 0 proc/isDead() if (hp <= 0) return 1 return 0 // sob mob/monster/sob icon = 'sob.dmi' defense = 10 // total defense_modifier is 6 armor_class = 10 strength = 30 minpower = 1 maxpower = 2 hp = 50 exp = 100 gold = 150 TakeAction() var/action_taken // Before moving, NPC cops see if there is someone to attack within 1 space. for (var/mob/other_mob in oview(1, src)) // But don't attack if it's another cop or they are dead... if (istype(other_mob, /mob/monster) || other_mob.isDead()) continue Attack(other_mob) action_taken = 1 // No one to attack, so see if a non-cop is within 3 spaces to move toward. for (var/mob/other_mob in oview(3, src)) if (istype(other_mob, /mob/monster) || other_mob.isDead()) continue view(src) << "[src] is going after [other_mob]!" step_towards(src, other_mob) action_taken = 1 if (action_taken) return // No one around, so do the default behavior. ..() |
In response to PrinceBoy
|
|
PrinceBoy wrote:
[snip] proc/TakeDamage(mob/attacker, potential_damage)[snip] You did indeed try to use usr in a proc. Try to avoid usr when you can. If you have to use usr, use it only in verbs, mouse clicks, and Login(). You have two warriors called src and attacker. It looks like attacker killed src and is reaping the rewards. If so, replace usr with attacker. As promised - *kicks you in the head* ;) |
In response to ACWraith
|
|
Bingo works now you caught it right on the money. Thanks dude for your time.
Princeboy |
To be honest, it looks like your code, but I can't prove it without seeing it. What has its exp var being checked? (Of course, if it's usr, I'll kick you in the head. ;) ) Has whatever it is been deleted before its exp var is messed with? Posting at least the TakeDamage() proc might help.