ID:170560
 
this is the code i am modeling my kill all/revive all verbs. when i go to use it, it kills only one person, and in my revive all, it only revives one person. if only mad a few changes and added a few others.

        Kill_All()
set category = "GM"
set name = "Kill Everybody"
switch(alert("Are you sure you want to Kill everyone?","Kill Everyone?","Yes","No"))
if("Yes")
for(var/mob/M in world)
if(M.client)
M.powerlevel = 0
Die()
world << "[usr.name] has Killed everyone!"

        Revive_All(mob/M in world)
set category = "GM"
set name = "Revive Everybody"
switch(alert("Are you sure you want to Revive everyone?","Revive All","Yes","No"))
if("Yes")
for(M.dead ==1)
M.loc = locate(77,77,1)
M << "<b>You feel your body getting revived!!!"
M.dead = 0
M.overlays -= /obj/halo
M.overlays -= 'halo.dmi'
M.overlays -= /obj/halo
M.overlays -= 'halo.dmi'
M.overlays -= /obj/halo
M.overlays -= 'halo.dmi'
world << "Everyone has been Revived by [usr.name]!"


the revive all has been put together from 2 other codes, i tried and it didnt work. any help or ideas would be appreciated.
Put spawn()
before any proc that you want to sorda branch off into the PROC() and the rest of the code
example:
spawn()
tab Die()

Tell meh if that works.
In response to Flame Sage
thats a no-go, it still only kills me instead of killing everyone.
In response to Psychotic
Oh! Thats easy, its because you are also a mob, put.

if(M == usr)
(tab)..()
else
(tab)go on with the rest.
In response to Flame Sage
ok, even if i have the spawn() in here, it says it killed alot of people, but noone dies. i checked all my npc's, and they are alive as well as my enimies. this is what i have so far:
        Kill_All()
set category = "GM"
set name = "Kill Everybody"
switch(alert("Are you sure you want to Kill everyone?","Kill Everyone?","Yes","No"))
if("Yes")
for(var/mob/M in world)
if(M ==usr)
..()
else
M.powerlevel = 0
Die()
world << "[usr.name] has Killed everyone!"


is this how you meant, or do i have it wrong?
In response to Psychotic
Show me your "Die()" proc's args, I don't think you've called it correctly.
In response to Hell Ramen
Better yet, show the entire Die() proc.
In response to Crispy
theres nothing wrong with my Die(), it works with every other thing ill start searching for it if you really wanna see it.

would it make any difference as M.Die()
In response to Psychotic
Just show it, if you use usr, it'll work sometimes, but then not work to my belief.
In response to Hell Ramen
ok here goes:

        Die()
if(src.powerlevel <= 0)
if(src.npp == 1||src.npp == null)
src << "<b>You feel like your about to die, but the letters <i>N P P</i> appear in your brain."
if(src.npp == 0)
src.trainpl = (src.maxpowerlevel * 1.5)
src.trainpl = round(src.trainpl)
if(src.race == "Saibaman")
usr.zenni += 50
usr << "<b>You get 50 zenni from that kill."
usr.maxpowerlevel += (rand(1,10))
src.loc=locate(0,0,0)
sleep(100)
del(src)
if(src.race == "Saiya-jin (NPC)")
usr.zenni += 2500
usr << "<b>You get 2500 zenni from that kill."
usr.maxpowerlevel += (rand(1,200))
src.loc=locate(0,0,0)
sleep(2000)
new /mob/monsters/Raditz(locate(25,138,1))
del(src)
if(src.race == "Scottish Cheese")
del(src)
if(src.race == "Buu (NPC)")
usr.zenni += 5000
usr << "<b>You get 5000 zenni from that kill."
usr.maxpowerlevel += (rand(1,1000))
src.loc=locate(0,0,0)
src.random = rand(1,5)
if(src.race == "Vegeta x(NPC)")
usr.zenni += 500000
usr << "<b>You get 500000 zenni from that kill."
usr.maxpowerlevel += (rand(1,1000000))
src.loc=locate(0,0,0)
src.random = rand(1,5)
if(src.random == 5)
switch(input("You are worthy of my attack. Do you wish to learn 'Big Bang Attack'?", "Vegeta", text) in list ("Yes","No"))
if("Yes")
usr.contents += new /obj/BigBang
alert("You learn Big Bang attack!")
usr.kame = 0
sleep(2000)
else
if(src.race == "Android")
src << "<b>You get blown to pieces, and you begin to get built by Dr. Gero!"
if(src.gotdb1==1)
src.gotdb1=0
new /obj/dragonballs/earth1(locate(src.x,src.y,src.z))
if(src.gotdb2==1)
src.gotdb2=0
new /obj/dragonballs/earth2(locate(src.x,src.y,src.z))
if(src.gotdb3==1)
src.gotdb3=0
new /obj/dragonballs/earth3(locate(src.x,src.y,src.z))
if(src.gotdb4==1)
src.gotdb4=0
new /obj/dragonballs/earth4(locate(src.x,src.y,src.z))
if(src.gotdb5==1)
src.gotdb5=0
new /obj/dragonballs/earth5(locate(src.x,src.y,src.z))
if(src.gotdb6==1)
src.gotdb6=0
new /obj/dragonballs/earth6(locate(src.x,src.y,src.z))
if(src.gotdb7==1)
src.gotdb7=0
new /obj/dragonballs/earth7(locate(src.x,src.y,src.z))
checkchips
if(src.chips>0)
src.chips-=1
new /obj/Androidchip(locate(src.x,src.y,src.z))
goto checkchips
if(src.haschip==1)
new /obj/Androidchip(locate(src.x,src.y,src.z))
src.haschip=0
src.loc=locate(0,0,0)
src.dead=1
src<<"You have been sent here to wait while Dr.Gero rebuilds you."
sleep(1000)
src.loc=locate(33,72,2)
src.dead=0
else
if(src.dead == 1)
src << "You have died again!"
src.icon_state = ""
src.spar = 0
src.dead = 1
src.safe = 1
src.ko = 0
src.grav = 0
src.density = 1
src.powerlevel = src.maxpowerlevel
if(src.gotdb1==1)
src.gotdb1=0
new /obj/dragonballs/earth1(locate(src.x,src.y,src.z))
if(src.gotdb2==1)
src.gotdb2=0
new /obj/dragonballs/earth2(locate(src.x,src.y,src.z))
if(src.gotdb3==1)
src.gotdb3=0
new /obj/dragonballs/earth3(locate(src.x,src.y,src.z))
if(src.gotdb4==1)
src.gotdb4=0
new /obj/dragonballs/earth4(locate(src.x,src.y,src.z))
if(src.gotdb5==1)
src.gotdb5=0
new /obj/dragonballs/earth5(locate(src.x,src.y,src.z))
if(src.gotdb6==1)
src.gotdb6=0
new /obj/dragonballs/earth6(locate(src.x,src.y,src.z))
if(src.gotdb7==1)
src.gotdb7=0
new /obj/dragonballs/earth7(locate(src.x,src.y,src.z))
src.loc=locate(17,2,2)
if(src.dead == 0)
if(src.name == usr.name)
view(6) << "<font color = red><i>[src] dies right infront of you!"
world << "<font color = red><b>Info: [src] has killed himself."
if(usr.gotdb1==1)
usr.gotdb1=0
new /obj/dragonballs/earth1(locate(usr.x,usr.y,usr.z))
if(usr.gotdb2==1)
usr.gotdb2=0
new /obj/dragonballs/earth2(locate(usr.x,usr.y,usr.z))
if(usr.gotdb3==1)
usr.gotdb3=0
new /obj/dragonballs/earth3(locate(usr.x,usr.y,usr.z))
if(usr.gotdb4==1)
usr.gotdb4=0
new /obj/dragonballs/earth4(locate(usr.x,usr.y,usr.z))
if(usr.gotdb5==1)
usr.gotdb5=0
new /obj/dragonballs/earth5(locate(usr.x,usr.y,usr.z))
if(usr.gotdb6==1)
usr.gotdb6=0
new /obj/dragonballs/earth6(locate(usr.x,usr.y,usr.z))
if(usr.gotdb7==1)
usr.gotdb7=0
new /obj/dragonballs/earth7(locate(usr.x,usr.y,usr.z))
usr.verbs-= /mob/dbz/verb/Summon_Shenlong
else
view(6) << "<font color = red><i>[src] dies right infront of you!"
world << "<font color = red><b>Info: [src] has been killed by [usr]."
src.loc=locate(17,2,2)
src.powerlevel = src.maxpowerlevel
src.icon_state = ""
src.spar = 0
src.safe = 1
src.dead = 1
src.overlays += 'halo.dmi'
src.grav = 0
src.density = 1
src.ko = 0
for(var/mob/characters/M in oview(6))
if(usr.befriend == M.name)
if(M.angered == 1)
usr.powerlevel += 0
if(M.angered == 0)
view(10) << "<b><font color = blue>[M.name]: THATS ENOUGH!!!!!!!!!!!!"
view(10) << "<i><b><font color = red>[M.name] explodes in anger as he sees his best friend die!"
M.underlays += /obj/whiteaura
M.powerlevel = (M.powerlevel * 4)
M.purity += 20
M.will += 20
M.ragename = src.name
M.angered= 1
M.honor += 20
M.SSJ()
M << "<font color = red><font size = 5>Hate <font color = blue>fills your soul as you see your best friend, [src.name], die infront of you."
sleep(600)
M.underlays -= /obj/whiteaura
M.angered = 0
if(M.powerlevel <= M.maxpowerlevel)
M.powerlevel += 0
if(M.powerlevel > M.maxpowerlevel)
M.powerlevel = M.maxpowerlevel
else
if(usr.angered == 1)
usr.powerlevel += 0
if(usr.angered == 0)
view(6) << "<b><font color = blue>[M.name]: aaaAAAHHHHH!!!!!!!!!!"
view(6) << "<i><b><font color = red>[M.name] explodes in anger as a huge aura surrounds him!"
M.underlays += /obj/whiteaura
M.powerlevel = (M.powerlevel * 2)
M.purity += 1
M.angered = 1
M.ragename = src.name
M.will += 1
M.honor += 1
M.SSJ()
M << "<font color = red>Hate <font color = blue>fills your soul as you see [src.alignment] [src.name] die infront of you."
sleep(100)
M.underlays -= /obj/whiteaura
M.angered = 0
if(M.powerlevel <= M.maxpowerlevel)
M.powerlevel += 0
if(M.powerlevel > M.maxpowerlevel)
M.powerlevel = M.maxpowerlevel
else
usr.powerlevel += 0


helping my brother on his game....he said "Master"
In response to Psychotic
ungh DBZ, atleast work on the games mechics before you start trying to kill everyone using that riped code, believe me, no one will come..
BUT I shall help you..
I believe what you need insted of Death is..
usr.Powerlevel = 0//Just to be on the safeside
usr.Death()
In response to Psychotic
Ewww. No offence, but that's the leading candidate for the worst Die() proc I've ever seen.

The biggest problem is misuse of usr. "But it works fine!" Sure, it works fine; until you use it in a "kill all" verb, and then it behaves really oddly, as you've discovered. This article will tell you everything you never wanted to know (but need to know) about when you shouldn't use usr. I highly recommend that you read it, and then completely remake your Die() proc from the ground up.

The second-biggest problem is that you're duplicating INSANE amounts of code. Never copy and paste large chunks of code; there's always a way to avoid doing so. And if you manage to avoid doing so, your code will be smaller, compile faster, and be easier to change and maintain. (As a random example, say you wanted to add an extra 8th dragonball, in a radical departure from the series. With that code, you have to add it in three places - and that's just in your Die() proc. An ideal method of handling Dragonballs would simply require you to go to one place in your code and change a "7" to an "8". Yes, it's very possible.

The third-biggest problem is your use of "boolean" (true or false) variables. Instead of doing this:

// Dodgy way
if (blahblah==0)
// Do stuff
else
// Do other stuff


It's much more robust if you do this:

// Good robust way
if (!blahblah)
// Do stuff
else
// Do other stuff


Why? Because "blahblah" might not just be 0 or 1. It might, from an unforeseen accident, be null. Or zero-length text, "". Or the text "Hello, how are you today?". Or... well, you get the idea. Sure, it's not MEANT to take those values; but you can't be sure that it won't. So instead of using (blahblah==0) and (blahblah==1), use (!blahblah) and (blahblah). They account for *any* value the variable can take.

Fourth-biggest problem: Use of goto. Goto is evil. Use while() or for() loops.
In response to Flame Sage
Flame Sage wrote:
Oh! Thats easy, its because you are also a mob, put.

if(M == usr)
(tab)..()
else
(tab)go on with the rest.

Uh, no. ..() doesn't mean "do nothing". It means "do what this proc would have done if I hadn't overridden it". You don't use it in new verbs/procs.

There are other ways around this. One:
if(M==usr)
continue
... // do other stuff in this loop

Or:
if(M!=usr)
...


Lummox JR
In response to Flame Sage
What he wasn't clear about is, DONT RIP ZETA!
I might be wrong, but I would think the problem (at least in the revive code) is here:
<code>for(M.dead ==1)</code>. Perhaps you should loop through the mobs in the world? Unless that code actually works. If it does, I really need to learn more about it, because I could really use it.
In response to Crispy
You know, I never found out why using goto is considered bad form. Can you explain that? I know you can do anything you can do with goto using while() or for(), but it's nice to have an explanation.
well it doesnt matter now, i have canned the idea...it seems everything i try to do it still doesnt work properly. its not my game, its my brothers game, and he doing work for his friend. pretty much he what he wanted to do was make a revive all ( for all the gms) and a kill all jus for the admin. why i dunno, the admin asked for the verb. so forget about the kill all verb, and he read everything everyone wrote, and he said thanks for the help.