ID:144394
 
Code:


Problem description: How do i make a code so it tells when someone Kills someone? Example: Blah has been killed by Blah.

1) WTF does the topic title have to do with this?

2) If you're asking this, this most likely means you're ripping. Dont. Do It.
Otherwise, if you wrote your attacking&death code yourself, you obviously should be able to do this.
In response to Kaioken
yea it's a rip.. so how do you do it Kaioken?
In response to Uniden
I don't know because of the same reason YOU don't know (and you shouldn't have this problem...its your game).

You know what is the reason? I don't know your code. Unfortunately, you don't either.
In response to Kaioken
wow i just looked at the title and wondered what i was thinking of..
In response to Uniden
mob
var
hp = 4

mob
verb
Attack(mob/M in oview(1))
M.hp-=1
M.Check()

mob
proc
Check(mob/M)
if(!M.hp)
[src] has killed [M]!

I think that works...
In response to Revojake
Revojake wrote:
mob
> var
> hp = 4
>
> mob
> verb
> Attack(mob/M in oview(1))
> M.hp-=1
> M.Check()
>
> mob
> proc
> Check(mob/M)
> if(!M.hp)
> [src] has killed [M]!
>

I think that works...

mob
proc
Check(mob/M)
if(!M.hp)
[src] has killed [M]!

You shouldn't post your umm unhelpful code unless it works did you even test it...
In response to A.T.H.K
I just pulled it off the top of my head >_>
In response to Revojake
Stop posting with the !hp stuff, if someone has -5 hp it is true.
In response to Xx Dark Wizard xX
Almost but not quite, you did make a few mistakes.. especially with "[src] has killed [M]!", you never stated who got that message nor were there quotes around it.. not to mention you should add .name as well :|:
mob
var
hp = 4
MHp = 4 //You'll see why I added this very soon

mob
verb
Straight_Punch() //This will show you how to attack in one direction without having a mob list show up.
var/mob/M = locate(/mob) in get_step(src,src.dir) //Tries to locate ONE mob in the step ahead of the usr (hence the dir)
if(!M) return //If a mob is NOT found (M=null), we stop the program from continuing onwards.. ! is a boolean checker
M.thp(1,src) //I _HIGHLY_ recommend the use of 'general' procedures for things like taking health.. \
reason: Less screwups, less space being used, less time being wasted [imagine copying MANY things over instead of where you could make a few lines and than make one line to refer it all], and if you want to update, you need to update one spot instead of dangload of lines


mob
proc
thp(dmg=0,mob/M) //thp = take HP
src.hp=min(max(0,src.hp-max(0,dmg)),src.Mhp)
/*Let's break the above down:
min() picks the lowest value from the list.. eg: min(25,12,21) would return 12..

max() returns the highest value from the list.. eg: max(0,-21,11) would return 11..

max(0,dmg) => Makes the highest damage possible 0.. why? Think about it:
dmg=21 ==> max(0,21) = 21
dmg=0 ==> max(0,0) = 0
dmg=-12 ==> max(0,-12) = 0 <-- remember, 0 > -12 and max() picks the highest number.

max(0,src.hp-max(0,dmg) => Makes the lowest possible amount of health lost equal to 0.. we don't want them to gain health in a take HP proc, don't we? ;)

min(..,src.Mhp) => Always makes the HIGHEST possible health value equal to the Max HP.. just in case.. you should know how by now why.. (if you don't: if(hp < M) than hp = hp.. but if hp > Mhp than hp = Mhp due to the min() picking the lowest value*/


if(src.hp<=0) //Even though we made the lowest possible health = 0, it's very wise to cover all possible extents we can
src.Death(M)
Death(mob/M) // M = killer
if(M.hp>0)return //no need to kill a person who has life still.. safety checks = always a goodthing to have
world<<"\red[src.name] has killed [M==src?"\himself" : M.name]!"
/*I really don't know why people don't get the compact if statement (the ? and : part)

X?Y : Z
is the samething as
if(X)
Y
else
Z

..so:
dmg*= hp>100 ? 2 : 1

the above is saying like:
if(hp>100) dmg*=2
else dmg*=1

Got it?

The \himself is a text macro reference.. a very useful one I find too... it refers to the atom's gender variable (built-in but you CAN change the default variable) which returns either "himself", "herself", "themselves" or "itself", depending on the gender..

\red if also another text macro, basically like a <font color="red">

The reason for adding .name to [src]/[M] is I think it makes the name proper (no 'the _').. that and why should you refer to the whole mob when you just need it's name? :/*/

src.loc = locate(1,1,1) //Respawn point
src.died++ //adds 1 to src's death count
if(M!=src) //if M is not src
M.gainEXP(round(src.level/M.level)*rand()) //some random formula giving M exp for src's death.. this is a reference to another 'general' proc which you have to make in order to use
M.kill++ //Killers count goes up >_>

Links for refencing:
Boolean
MinMax information (click here for DM Ref. for min() or max()
get_step()
text macros

We know you meant well Rev but please, try not to post broken codes.. as for what DW ws trying to say.. read the boolean part above

- GhostAnime
In response to GhostAnime
I know you guys meant well, though I don't think you helped, just look at the dude's post;

Uniden wrote:
Code:
>

Problem description: How do i make a code so it tells when someone Kills someone? Example: Blah has been killed by Blah.


Note he didn't ask how to code in attacks/kills. He only wanted to know how to add a message to his ripped game (and he didn't even post any code). Now if I were you and wanted to help I'd refer him to the DM Guide and recommend he makes his own game.
call a deathcheck proc after damage is dealt.
In response to Chue
Because you are already have if(hp>=1)return, there's no point for else if(hp<=0) because you already stop the code from happening if it's higher than one..

I like how precausious (sp?) you are but please.. think of the bytes :P

- GhostAnime
In response to GhostAnime
GhostAnime wrote:
Because you are already have if(hp>=1)return, there's no point for else if(hp<=0) because you already stop the code from happening if it's higher than one..

I like how precausious (sp?) you are but please.. think of the bytes :P

No offense to him, but I'd define his behaviour "stupid", not "precaucious (sp?)", and he should know coding better before posting sample code, and read the DM Guide, since not only did he still use 'else' despite using 'return' (which is a somewhat common mistake), BUT in an 'else' statement, he used the negative of the if() that the 'else' was referring for...
In response to Kaioken
Kaioken wrote:
he should know coding better before posting sample code.

Thank you.
In response to A.T.H.K
It was nothing, don't mention it. ;)
In response to GhostAnime
What would happen if the players hp wasn't over 1? Say it went into the negatives?

What I see is, is that he probably meant that after damage was dealt, it called the proc, and checked for health and all. Then if the health is such and such, then such and such would happen.

I'm not good at coding, nor do I understand enough to create my own game, but that is how I see it.
In response to Krimson Fury
Looks like he edited out his code snippet..

Anyways, as to answer your question: 'return' immediately stops that code block from continuing forward.. so if the hp was 1 or greater (hp>=1), it would call return which would stop the rest from happening, which is all the good nifty death stuff involved... thus if the hp was < 1, it would continue forward to its' demise.

if(hp>=1) return //Everything below will NOT happen because the return stopped it
world<<"I rule you"



- GhostAnime
In response to GhostAnime
http://developer.byond.com/hub/Zilal/ZBT


Simple... read that... It's one of the steps to un-noobifying yourself... go to developer.byond.com and click the link for you people who can't read... it says
"New users click here" .... CLICK IT and click making a dream or whatever, look at the steps at the bottom, and have fun
In response to GhostAnime
By the way, you should probably use only the > (or <) operator when you can, its probably 0.00001 faster than >= (and <=). :D
if(hp > 0) return
Page: 1 2