ID:150736
 
proc
DeathCheck()
if(hp <= 0)
usr << "[src] is already dead!"
else
if(icon == 'blue.dmi')
src.loc = locate(199,99,1)
src << "You must wait for 30 seconds before Resurrecting."
usr.cash+=8
usr << "You gain $8 from tagging [src]!"
world << "[src] was tagged by [usr]!"
sleep(300)
src.loc = locate(10,186,1)
world << "[src] Has Resurrected!"
if(icon == 'red.dmi')
src.loc = locate(199,99,1)
src << "You must wait for 30 seconds before Resurrecting."
usr.cash+=8
usr << "You gain $8 from tagging [src]!"
world << "[src] was tagged by [usr]!"
sleep(300)
src.loc = locate(191,19,1)
world << "[src] Has Resurrected!"
if(icon == 'ref.dmi')
world << "[usr] tried shooting the ref!"
mob/var
hp = 1

Well everything compiles fine, but when I run the game and a player shoots at someone it displays a [player attacked] is already dead! message. Not sure what I am doing wrong, thanx for any help.
usr << "[src] is already dead!"


Look carefully at that line. The answer is there.
In response to Deadron
On 8/3/01 10:15 pm Deadron wrote:
usr << "[src] is already dead!"


Look carefully at that line. The answer is there.

should usr << be changed to src << ??
In response to Oblivian
On 8/3/01 10:38 pm Oblivian wrote:
On 8/3/01 10:15 pm Deadron wrote:
usr << "[src] is already dead!"


Look carefully at that line. The answer is there.

should usr << be changed to src << ??

Try it and see if it helps.
In response to Deadron
On 8/3/01 10:40 pm Deadron wrote:
On 8/3/01 10:38 pm Oblivian wrote:
On 8/3/01 10:15 pm Deadron wrote:
usr << "[src] is already dead!"


Look carefully at that line. The answer is there.

should usr << be changed to src << ??

Try it and see if it helps.

yep, fixed it.. thanx and ill never use usr again :)
In response to Oblivian
changing that to src helped, but now it wont move the player to the observation area after dying.. Im thinking my combat system sux.. :) Heres the code to one weapon.. and to deathcheck, please help im desperate! :P
tippman_98
verb
fire(mob/M as mob in oview(6))
set desc = "Fire your weapon"
set category = "Commands"
usr << "You shoot at [M]!"
oview() << "[usr] shoots at [M]!"
var/damage = rand(0,1)
view() << "[damage] hit."
M.hp -= damage
M.DeathCheck()

and the deathcheck..

proc
DeathCheck()
if(hp <= 0)
src << "[src] has already been tagged!"
else
if(icon == 'blue.dmi')
src.loc = locate(199,99,1)
src << "You must wait for 30 seconds before Resurrecting."
usr.cash+=8
usr << "You gain $8 from tagging [src]!"
world << "[src] was tagged by [usr]!"
sleep(300)
src.loc = locate(10,186,1)
world << "[src] Has Resurrected!"
if(icon == 'red.dmi')
src.loc = locate(199,99,1)
src << "You must wait for 30 seconds before Resurrecting."
usr.cash+=8
usr << "You gain $8 from tagging [src]!"
world << "[src] was tagged by [usr]!"
sleep(300)
src.loc = locate(191,19,1)
world << "[src] Has Resurrected!"
if(icon == 'ref.dmi')
world << "[usr] tried shooting the ref!"
mob/var
hp = 1
In response to Oblivian
On 8/3/01 10:49 pm Oblivian wrote:
On 8/3/01 10:40 pm Deadron wrote:
On 8/3/01 10:38 pm Oblivian wrote:
On 8/3/01 10:15 pm Deadron wrote:
usr << "[src] is already dead!"


Look carefully at that line. The answer is there.

should usr << be changed to src << ??

Try it and see if it helps.

yep, fixed it.. thanx and ill never use usr again :)

Fixed it? Are you sure?

Well I'm sure you're no longer getting the "already dead" message, because now it is being sent to the mob you attacked. And of course now you'll never get that message, unless someone tries to attack you and you're already dead!

My guess is that your original problem is that hp were never set on your target.
In response to Skysaw
On 8/4/01 6:35 am Skysaw wrote:
On 8/3/01 10:49 pm Oblivian wrote:
On 8/3/01 10:40 pm Deadron wrote:
On 8/3/01 10:38 pm Oblivian wrote:
On 8/3/01 10:15 pm Deadron wrote:
usr << "[src] is already dead!"


Look carefully at that line. The answer is there.

should usr << be changed to src << ??

Try it and see if it helps.

yep, fixed it.. thanx and ill never use usr again :)

Fixed it? Are you sure?

Well I'm sure you're no longer getting the "already dead" message, because now it is being sent to the mob you attacked. And of course now you'll never get that message, unless someone tries to attack you and you're already dead!

My guess is that your original problem is that hp were never set on your target.

I added usr.hp = 1 after the player resurrects.. it seems to reset the hp now(if thats what u meant), but the deathcheck is still messed up, dont know if i'm ever gonna get this to work. All I want is when a player gets tagged(one shot) it moves him to the resurrection area for 30 secs, then moves him back to his/her base.
In response to Oblivian
On 8/3/01 10:55 pm Oblivian wrote:
changing that to src helped, but now it wont move the player to the observation area after dying.. Im thinking my combat system sux.. :) Heres the code to one weapon.. and to deathcheck, please help im desperate! :P
tippman_98
verb
fire(mob/M as mob in oview(6))
set desc = "Fire your weapon"
set category = "Commands"
usr << "You shoot at [M]!"
oview() << "[usr] shoots at [M]!"
var/damage = rand(0,1)
view() << "[damage] hit."
M.hp -= damage
M.DeathCheck()

and the deathcheck..

proc
DeathCheck()
if(hp <= 0)
src << "[src] has already been tagged!"
else
if(icon == 'blue.dmi')
src.loc = locate(199,99,1)
src << "You must wait for 30 seconds before Resurrecting."
usr.cash+=8
usr << "You gain $8 from tagging [src]!"
world << "[src] was tagged by [usr]!"
sleep(300)
src.loc = locate(10,186,1)
world << "[src] Has Resurrected!"
if(icon == 'red.dmi')
src.loc = locate(199,99,1)
src << "You must wait for 30 seconds before Resurrecting."
usr.cash+=8
usr << "You gain $8 from tagging [src]!"
world << "[src] was tagged by [usr]!"
sleep(300)
src.loc = locate(191,19,1)
world << "[src] Has Resurrected!"
if(icon == 'ref.dmi')
world << "[usr] tried shooting the ref!"
mob/var
hp = 1

Anyone know what the problem is?
In response to Skysaw
On 8/4/01 6:35 am Skysaw wrote:
On 8/3/01 10:49 pm Oblivian wrote:
On 8/3/01 10:40 pm Deadron wrote:
On 8/3/01 10:38 pm Oblivian wrote:
On 8/3/01 10:15 pm Deadron wrote:
usr << "[src] is already dead!"


Look carefully at that line. The answer is there.

should usr << be changed to src << ??

Try it and see if it helps.

yep, fixed it.. thanx and ill never use usr again :)

Fixed it? Are you sure?

Well I'm sure you're no longer getting the "already dead" message, because now it is being sent to the mob you attacked. And of course now you'll never get that message, unless someone tries to attack you and you're already dead!

My guess is that your original problem is that hp were never set on your target.

The way I code uses usr alot but it only uses it in usr<< things and my stat stuff and no problems yet
In response to Oblivian
when you do the src.loc = locate((destination)) is the problem... it should be usr as in the player, if you are saying that its a src and in a death check wouldnt the src be null? try switching to usr.loc = locate((destination)) for those few points.. should do the trick I think.
In response to Goku401
On 8/4/01 9:24 pm Goku401 wrote:
when you do the src.loc = locate((destination)) is the problem... it should be usr as in the player, if you are saying that its a src and in a death check wouldnt the src be null? try switching to usr.loc = locate((destination)) for those few points.. should do the trick I think.

Thanx, I will try it tommorow to tired tonight to test it. If it works great and thanx for the info! if not i will just rewrite the entire thing, thanx for all the help.


This thread turns almost comical and almost sad farther down... I'm going to take this time to expound on a recurring code problem I see in a lot of people's work, and also try to help you a little bit.

The problem is this: people have no idea what src and usr are, in the context of their procs. Admit it. When you write a code, you just put usr (or src) for everything. Ff that doesn't work, you just go through at semi-random, changing usr to src and src to usr, until you get the code to "work", by which I mean, compile and run free of visible errors. It won't necessarily do what you thought it should do, but it doesn't have any errors.

So let's do this: go through your code, and take out every single instance of the word usr and src. All of them. Leave in all the variables and other code. Now, src is the thing that owns the DeathCheck proc, right? I mean, DeathCheck is called for the thing that's dying, right? So you know that src will always refer to the potentially dying mob. So, everywhere you're referring to that mob, go through and put src.

Now, the attacker is more tricky. Your instincts are to put usr, because you know the attacker is not the src, but as Deadron pointed out, the process of elimination doesn't always work here. If you know for a fact that the usr of the proc that calls DeathCheck will always be the attacker, you can go through and put usr for the attacker. But if you want to be on the safe side (and get yourself in good form for when you write more complicated code), let's make a variable that we -know- will always be the attacker. Change your proc's heading to this:

DeathCheck(mob/attacker)

In the place in your combat code where it's called, put this:

whatever.DeathCheck(usr or src or whatever the attacker is in this code)

In response to LexyBitch
On 8/5/01 6:33 am LexyBitch wrote:
This thread turns almost comical and almost sad farther down... I'm going to take this time to expound on a recurring code problem I see in a lot of people's work, and also try to help you a little bit.

That's a good post...would you be amenable to turning it into a FAQ entry for fixing usr/src problems? It might save people a lot of hassle.
In response to Deadron
On 8/5/01 11:12 am Deadron wrote:
On 8/5/01 6:33 am LexyBitch wrote:
This thread turns almost comical and almost sad farther down... I'm going to take this time to expound on a recurring code problem I see in a lot of people's work, and also try to help you a little bit.

That's a good post...would you be amenable to turning it into a FAQ entry for fixing usr/src problems? It might save people a lot of hassle.

What do I need to do to make it FAQ-friendly?
In response to LexyBitch
On 8/5/01 11:21 am LexyBitch wrote:
On 8/5/01 11:12 am Deadron wrote:
On 8/5/01 6:33 am LexyBitch wrote:
This thread turns almost comical and almost sad farther down... I'm going to take this time to expound on a recurring code problem I see in a lot of people's work, and also try to help you a little bit.

That's a good post...would you be amenable to turning it into a FAQ entry for fixing usr/src problems? It might save people a lot of hassle.

What do I need to do to make it FAQ-friendly?

Mostly just add a paragraph at the top explaining the predicament (usr and src being all mixed up), then casting this as a way to solve it.

The FAQ already has entries on what usr and src are, but it would be great to have an entry like "How do I fix my mixed up usr and src code?"

Then email me the text and I'll add it.