'Please murder me slowly' pieces of code

How, what and why to code in BYOND.

Moderators: MisterPerson, Code Maintainers

User avatar
Aranclanos
 
Joined: Tue Apr 15, 2014 4:55 pm
Byond Username: Aranclanos

'Please murder me slowly' pieces of code

Postby Aranclanos » Sun Sep 14, 2014 10:38 pm #28836

Image

Each time that any object moves to a floor turf, is checks if it's a human. If it's a human, it checks if they're wearing clown shoes, just to make the clown step sound.

Each time that any object moves.
I accept donations, click here



Scott
Github User
 
Joined: Fri Apr 18, 2014 1:50 pm
Byond Username: Xxnoob
Github Username: xxalpha

Re: 'Please murder me slowly' pieces of code

Postby Scott » Sun Sep 14, 2014 11:08 pm #28839

Why isn't the sound reproduced by the clown shoes instead?

I like how the only comment on that mess is not helpful at all.

User avatar
MisterPerson
Board Moderator
 
Joined: Tue Apr 15, 2014 4:26 pm
Byond Username: MisterPerson

Re: 'Please murder me slowly' pieces of code

Postby MisterPerson » Mon Sep 15, 2014 1:11 am #28864

That code is old. I think it was in r4407. Lemme pull out my favorite though:

Code: Select all
proc/time_stamp(var/format = "hh:mm:ss")
   return time2text(world.timeofday, format)

proc/gameTimestamp(var/format = "hh:mm:ss") // Get the game time in text
   return time2text(world.time - timezoneOffset + 432000, format)

/* Preserving this so future generations can see how fucking retarded some people are
proc/time_stamp()
   var/hh = text2num(time2text(world.timeofday, "hh")) // Set the hour
   var/mm = text2num(time2text(world.timeofday, "mm")) // Set the minute
   var/ss = text2num(time2text(world.timeofday, "ss")) // Set the second
   var/ph
   var/pm
   var/ps
   if(hh < 10) ph = "0"
   if(mm < 10) pm = "0"
   if(ss < 10) ps = "0"
   return"[ph][hh]:[pm][mm]:[ps][ss]"
*/
I code for the code project and moderate the code sections of the forums.

Why realism is stupid:
Spoiler:
Wiz, the project lead of Europa Universalis IV:

Immersion/flavor is playing a WW2 shooter and using a mosin-nagant instead of a laser gun - this is important.

Realism is playing a WW2 shooter and having to spend 2 months in hospital everytime you get shot - stupid and detrimental to gameplay. Nobody actually wants a realistic game, which is why realism arguments are so selectively used.
Source: http://forum.paradoxplaza.com/forum/ind ... t-19679470

User avatar
Stickymayhem
In-Game Game Master
 
Joined: Mon Apr 28, 2014 6:13 pm
Byond Username: Stickymayhem

Re: 'Please murder me slowly' pieces of code

Postby Stickymayhem » Mon Sep 15, 2014 1:29 am #28869

Aranclanos wrote:Image

Each time that any object moves to a floor turf, is checks if it's a human. If it's a human, it checks if they're wearing clown shoes, just to make the clown step sound.

Each time that any object moves.


Does that code mean clown shoes don't squeak on unsimulated turf?
Image

Omni Tears

Spoiler:
Image
Image
Image

User avatar
Jordie0608
Site Admin
 
Joined: Tue Apr 15, 2014 1:33 pm
Location: Spiderland, Australia
Byond Username: Jordie0608
Github Username: Jordie0608

Re: 'Please murder me slowly' pieces of code

Postby Jordie0608 » Mon Sep 15, 2014 3:04 am #28881

Apparently not.

The old SSU update_icon proc was great.

Code: Select all
/obj/machinery/suit_storage_unit/update_icon()
   var/hashelmet = 0
   var/hassuit = 0
   var/hashuman = 0
   if(HELMET)
      hashelmet = 1
   if(SUIT)
      hassuit = 1
   if(OCCUPANT)
      hashuman = 1
   icon_state = text("suitstorage[][][][][][][][][]",hashelmet,hassuit,hashuman,src.isopen,src.islocked,src.isUV,src.ispowered,src.isbroken,src.issuperUV)
Forum Admin
Send me a PM if you have any issues, concerns or praise of fishfood to express about the forums.

User avatar
Miauw
 
Joined: Sat Apr 19, 2014 11:23 am
Byond Username: Miauw62

Re: 'Please murder me slowly' pieces of code

Postby Miauw » Wed Sep 17, 2014 5:10 pm #29329

brb digging around in my saycode pr

  • Anyway, saycode used to loop through all hearers, see if they could understand the speaker through a bunch of istypes, then loop through each list seperately to tell them the message.
    This was even worse for radio code, where there were seperate lists for people who heard the message garbled, heard it when the speaker was wearing a voice-changer, heard it normally and people who didnt understand it.
  • Also, people using show_message(message, 2) on dead players (2 means "dont send the message if the hearer is deaf")
  • Code: Select all
           if(!radio_controller)
              sleep(30) // Waiting for the radio_controller to be created.
           if(!radio_controller)
              src.name = "broken radio headset"
              return

    probably the most hilarious code i've ever seen
  • There's also silent being checked by every mob seperately for some reason, and say() in general being a monolith so all the overrides were really really shitty.
    Code: Select all
     /mob/living/carbon/slime/say(var/message)
       if (silent)
          return
       else
          return ..()

    Yeah, this could have been checked once at the carbon() level, but instead of doing the sane thing it checks everywhere.
  • Anything involving istype(src)
  • Code: Select all
       if (length(message) >= 2)
          if ((copytext(message, 1, 3) == ":b") || (copytext(message, 1, 3) == ":B") || \
             (copytext(message, 1, 3) == "#b") || (copytext(message, 1, 3) == "#B") || \
             (copytext(message, 1, 3) == ".b") || (copytext(message, 1, 3) == ".B"))
             if(istype(src, /mob/living/silicon/pai))
                return ..(message, "R")
             message = copytext(message, 3)
             message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN))
             robot_talk(message)
          else if ((copytext(message, 1, 3) == ":h") || (copytext(message, 1, 3) == ":H") || \
                (copytext(message, 1, 3) == "#h") || (copytext(message, 1, 3) == "#H") || \
                (copytext(message, 1, 3) == ".h") || (copytext(message, 1, 3) == ".H"))
             if(isAI(src)&&client)//For patching directly into AI holopads.
                var/mob/living/silicon/ai/U = src
                message = copytext(message, 3)
                message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN))
                U.holopad_talk(message)
             else//Will not allow anyone by an active AI to use this function.
                src << "This function is not available to you."
                return

    Do I need to explain?


E:
Almost forgot the best of them all:
Image
This proc always cracks me up.
<wb> For one, the spaghetti is killing me. It's everywhere in food code, and makes it harder to clean those up.

<Tobba> I stared into BYOND and it farted

User avatar
Cheridan
 
Joined: Tue Apr 15, 2014 6:04 am
Byond Username: Cheridan

Re: 'Please murder me slowly' pieces of code

Postby Cheridan » Wed Sep 17, 2014 9:13 pm #29380

Miauw wrote:
E:
Almost forgot the best of them all:
Image
This proc always cracks me up.


>no indication what "yes" means
>that parent call after the return

beat me to death with hitler's brain
Image


/tg/station spriter, admin, and headcoder. Feel free to contact me via PM with questions, concerns, or requests.

User avatar
Miauw
 
Joined: Sat Apr 19, 2014 11:23 am
Byond Username: Miauw62

Re: 'Please murder me slowly' pieces of code

Postby Miauw » Sun Sep 21, 2014 1:41 pm #30035

Code: Select all
/datum/game_mode/proc/random_radio_frequency()
   return 1337 // WHY??? -- Doohl

Just found this while browsing through nuke code.
<wb> For one, the spaghetti is killing me. It's everywhere in food code, and makes it harder to clean those up.

<Tobba> I stared into BYOND and it farted

User avatar
MisterPerson
Board Moderator
 
Joined: Tue Apr 15, 2014 4:26 pm
Byond Username: MisterPerson

Re: 'Please murder me slowly' pieces of code

Postby MisterPerson » Thu Sep 25, 2014 10:18 am #30890

Not /tg/station related, but I just have to share for anyone who hasn't seen it yet.

https://www.daniweb.com/software-develo ... my-program
I code for the code project and moderate the code sections of the forums.

Why realism is stupid:
Spoiler:
Wiz, the project lead of Europa Universalis IV:

Immersion/flavor is playing a WW2 shooter and using a mosin-nagant instead of a laser gun - this is important.

Realism is playing a WW2 shooter and having to spend 2 months in hospital everytime you get shot - stupid and detrimental to gameplay. Nobody actually wants a realistic game, which is why realism arguments are so selectively used.
Source: http://forum.paradoxplaza.com/forum/ind ... t-19679470

User avatar
Remie Richards
 
Joined: Thu Apr 17, 2014 7:11 pm
Location: England, UK, Earth, Sol, Milky Way, Local Group, Virgo Supercluster, Known Universe
Byond Username: CrimsonVision

Re: 'Please murder me slowly' pieces of code

Postby Remie Richards » Thu Sep 25, 2014 3:44 pm #30928

MisterPerson wrote:Not /tg/station related, but I just have to share for anyone who hasn't seen it yet.

https://www.daniweb.com/software-develo ... my-program



float x;
float xx;
float xxx;
float xxxx;
float xxxxx;
etc.

Wow.
私は完璧

Lo6a4evskiy
 
Joined: Fri Apr 18, 2014 6:40 pm
Byond Username: Lo6a4evskiy

Re: 'Please murder me slowly' pieces of code

Postby Lo6a4evskiy » Thu Sep 25, 2014 4:46 pm #30939

I mean, why not do something like x0, x1, x2, even if you do that kind of thing? I suppose something should be said about how stubborn this guy is, copypasting all that code.
Miauw wrote:
Code: Select all
/datum/game_mode/proc/random_radio_frequency()
   return 1337 // WHY??? -- Doohl

Just found this while browsing through nuke code.

It's not actually called anywhere in the code, probably something that was never finished.

User avatar
paprika
Rarely plays
 
Joined: Fri Apr 18, 2014 10:20 pm
Location: in down bad
Byond Username: Paprka

Re: 'Please murder me slowly' pieces of code

Postby paprika » Sat Sep 27, 2014 2:18 am #31384

Maybe this is why clowns were removed from bay
Oldman Robustin wrote:It's an established meme that coders don't play this game.

User avatar
MisterPerson
Board Moderator
 
Joined: Tue Apr 15, 2014 4:26 pm
Byond Username: MisterPerson

Re: 'Please murder me slowly' pieces of code

Postby MisterPerson » Tue Oct 07, 2014 8:54 am #34437

This isn't wrong or even that expensive but it's incredibly ugly. Behold, the old code that was called every time someone clicked the limb targetter on the bottom right corner of the screen.

Code: Select all
/obj/screen/zone_sel/Click(location, control,params)
   var/list/PL = params2list(params)
   var/icon_x = text2num(PL["icon-x"])
   var/icon_y = text2num(PL["icon-y"])

   if(icon_y < 2)
      return
   if(icon_y < 4)
      if(icon_x > 9 && icon_x < 16)
         selecting = "r_leg"
      else if(icon_x > 15 && icon_x < 23)
         selecting = "l_leg"
      else
         return
   else if(icon_y < 11)
      if(icon_x > 11 && icon_x < 21)
         if(icon_x < 16)
            selecting = "r_leg"
         else
            selecting = "l_leg"
      else
         return
   else if(icon_y < 12)
      if(icon_x > 7 && icon_x < 12)
         selecting = "r_arm"
      else if(icon_x > 11 && icon_x < 14)
         selecting = "r_leg"
      else if(icon_x < 19)
         selecting = "groin"
      else if(icon_x > 18 && icon_x < 21)
         selecting = "l_leg"
      else if(icon_x > 20 && icon_x < 25)
         selecting = "l_arm"
      else
         return
   else if(icon_y < 13)
      if(icon_x > 7 && icon_x < 25)
         if(icon_x < 13)
            selecting = "r_leg"
         else if(icon_x < 20)
            selecting = "groin"
         else if(icon_x < 21)
            selecting = "l_leg"
      else
         return
   else if(icon_y < 14)
      if(icon_x > 11 && icon_x < 21)
         selecting = "groin"
      else if(icon_x > 7 && icon_x < 12)
         selecting = "r_arm"
      else if(icon_x > 20 && icon_x < 25)
         selecting = "l_arm"
      else
         return
   else if(icon_y < 16)
      if(icon_x > 7 && icon_x < 25)
         if(icon_x < 20)
            selecting = "chest"
      else
         return
   else if(icon_y < 23)
      if(icon_x > 7 && icon_x < 25)
         if(icon_x < 12)
            selecting = "r_arm"
         else if(icon_x < 21)
            selecting = "chest"
         else
            selecting = "l_arm"
      else
         return
   else if(icon_y < 24)
      if(icon_x > 11 && icon_x < 21)
         selecting = "chest"
      else
         return
   else if(icon_y < 25)
      if(icon_x > 11 && icon_x < 21)
         if(icon_x < 16)
            selecting = "head"
         else if(icon_x < 17)
            selecting = "mouth"
         else
            selecting = "head"
      else
         return
   else if(icon_y < 26)
      if(icon_x > 11 && icon_x < 21)
         if(icon_x < 15)
            selecting = "head"
         else if(icon_x < 18)
            selecting = "mouth"
         else
            selecting = "head"
      else
         return
   else if(icon_y < 27)
      if(icon_x > 11 && icon_x < 21)
         if(icon_x < 15)
            selecting = "head"
         else if(icon_x < 16)
            selecting = "eyes"
         else if(icon_x < 17)
            selecting = "mouth"
         else if(icon_x < 18)
            selecting = "eyes"
         else
            selecting = "head"
      else
         return
   else if(icon_y < 28)
      if(icon_x > 11 && icon_x < 21)
         if(icon_x < 14)
            selecting = "head"
         else if(icon_x < 19)
            selecting = "eyes"
         else
            selecting = "head"
      else
         return
   else if(icon_y < 29)
      if(icon_x > 11 && icon_x < 21)
         if(icon_x < 15)
            selecting = "head"
         else if(icon_x < 16)
            selecting = "eyes"
         else if(icon_x < 17)
            selecting = "head"
         else if(icon_x < 18)
            selecting = "eyes"
         else
            selecting = "head"
      else
         return
   else if(icon_y < 31)
      if(icon_x > 11 && icon_x < 21)
         selecting = "head"

   update_icon()


For reference sake here's what it is now:

Code: Select all
/obj/screen/zone_sel/Click(location, control,params)
   var/list/PL = params2list(params)
   var/icon_x = text2num(PL["icon-x"])
   var/icon_y = text2num(PL["icon-y"])
   var/old_selecting = selecting //We're only going to update_icon() if there's been a change

   switch(icon_y)
      if(1 to 9) //Legs
         switch(icon_x)
            if(10 to 15)
               selecting = "r_leg"
            if(17 to 22)
               selecting = "l_leg"
            else
               return 1
      if(10 to 13) //Hands and groin
         switch(icon_x)
            if(8 to 11)
               selecting = "r_arm"
            if(12 to 20)
               selecting = "groin"
            if(21 to 24)
               selecting = "l_arm"
            else
               return 1
      if(14 to 22) //Chest and arms to shoulders
         switch(icon_x)
            if(8 to 11)
               selecting = "r_arm"
            if(12 to 20)
               selecting = "chest"
            if(21 to 24)
               selecting = "l_arm"
            else
               return 1
      if(23 to 30) //Head, but we need to check for eye or mouth
         if(icon_x in 12 to 20)
            selecting = "head"
            switch(icon_y)
               if(23 to 24)
                  if(icon_x in 15 to 17)
                     selecting = "mouth"
               if(26) //Eyeline, eyes are on 15 and 17
                  if(icon_x in 14 to 18)
                     selecting = "eyes"
               if(25 to 27)
                  if(icon_x in 15 to 17)
                     selecting = "eyes"

   if(old_selecting != selecting)
      update_icon()
   return 1
I code for the code project and moderate the code sections of the forums.

Why realism is stupid:
Spoiler:
Wiz, the project lead of Europa Universalis IV:

Immersion/flavor is playing a WW2 shooter and using a mosin-nagant instead of a laser gun - this is important.

Realism is playing a WW2 shooter and having to spend 2 months in hospital everytime you get shot - stupid and detrimental to gameplay. Nobody actually wants a realistic game, which is why realism arguments are so selectively used.
Source: http://forum.paradoxplaza.com/forum/ind ... t-19679470

User avatar
Remie Richards
 
Joined: Thu Apr 17, 2014 7:11 pm
Location: England, UK, Earth, Sol, Milky Way, Local Group, Virgo Supercluster, Known Universe
Byond Username: CrimsonVision

Re: 'Please murder me slowly' pieces of code

Postby Remie Richards » Tue Oct 07, 2014 4:04 pm #34493

switch()s and the "to" keyword, friends of us all.
私は完璧

User avatar
MisterPerson
Board Moderator
 
Joined: Tue Apr 15, 2014 4:26 pm
Byond Username: MisterPerson

Re: 'Please murder me slowly' pieces of code

Postby MisterPerson » Wed Oct 08, 2014 1:52 am #34645

Bonus content. Behold, the oldish Click() code. I say oldish because we used to have code even older than this which was even worse, but I'm not digging for it right now.

700 lines of madness. This shit was ran every time anyone clicked on (almost) anything.

Code: Select all
/atom/Click(location,control,params)
   //world << "atom.Click() on [src] by [usr] : src.type is [src.type]"
   if(usr.client.buildmode)
      build_click(usr, usr.client.buildmode, location, control, params, src)
      return
//   if(using_new_click_proc)  //TODO ERRORAGE (see message below)
//      return DblClickNew()
   return DblClick(location, control, params)

var/using_new_click_proc = 0 //TODO ERRORAGE (This is temporary, while the DblClickNew() proc is being tested)

/atom/proc/DblClickNew()
   if(!usr)   return
// TODO DOOHL: Intergrate params to new proc. Saved for another time because var/valid_place is a fucking brainfuck

   //Spamclick server-overloading prevention delay... THING
   if (world.time <= usr:lastDblClick+1)
      return
   else
      usr:lastDblClick = world.time

   //paralysis and critical condition
   if(usr.stat == 1)   //Death is handled in attack_ghost()
      return

   if(!istype(usr, /mob/living/silicon/ai))
      if (usr.paralysis || usr.stunned || usr.weakened)
         return

   //handle the hud separately
   if(istype(src,/obj/screen))
      if( usr.restrained() )
         if(ishuman(usr))
            src.attack_hand(usr)
         else if(isAI(usr))
            src.attack_ai(usr)
         else if(isrobot(usr))
            src.attack_ai(usr)
         else if(isobserver(usr))
            src.attack_ghost(usr)
         else if(ismonkey(usr))
            src.attack_paw(usr)
         else if(isalienadult(usr))
            src.attack_alien(usr)
         else if(isslime(usr))
            src.attack_slime(usr)
         else if(isanimal(usr))
            src.attack_animal(usr)
         else
            usr << "This mob type does not support clicks to the HUD. Contact a coder."
      else
         if(ishuman(usr))
            src.hand_h(usr, usr.hand)
         else if(isAI(usr))
            src.hand_a(usr, usr.hand)
         else if(isrobot(usr))
            src.hand_a(usr, usr.hand)
         else if(isobserver(usr))
            return
         else if(ismonkey(usr))
            src.hand_p(usr, usr.hand)
         else if(isalienadult(usr))
            src.hand_al(usr, usr.hand)
         else if(isslime(usr))
            return
         else if(isanimal(usr))
            return
         else
            usr << "This mob type does not support restrained clicks to the HUD. Contact a coder."
      return

   //Gets equipped item or used module of robots
   var/obj/item/W = usr.get_active_hand()

   //Attack self
   if (W == src && usr.stat == 0)
//      spawn (0)      //causes runtimes under heavy lag
      W.attack_self(usr)
      return

   //Attackby, attack_hand, afterattack, etc. can only be done once every 1 second, unless an object has the NODELAY or USEDELAY flags set
   //This segment of code determins this.
   if(W)
      if( !( (src.loc && src.loc == usr) || (src.loc.loc && src.loc.loc == usr) ) )
         //The check above checks that you are not targeting an item which you are holding.
         //If you are, (example clicking a backpack), the delays are ignored.
         if(W.flags & USEDELAY)
            //Objects that use the USEDELAY flag can only attack once every 2 seconds
            if (usr.next_move < world.time)
               usr.prev_move = usr.next_move
               usr.next_move = world.time + 20
            else
               return   //A click has recently been handled already, you need to wait until the anti-spam delay between clicks passes
         else if(!(W.flags & NODELAY))
            //Objects with NODELAY don't have a delay between uses, while most objects have the standard 1 second delay.
            if (usr.next_move < world.time)
               usr.prev_move = usr.next_move
               usr.next_move = world.time + 10
            else
               return   //A click has recently been handled already, you need to wait until the anti-spam delay between clicks passes
   else
      //Empty hand
      if (usr.next_move < world.time)
         usr.prev_move = usr.next_move
         usr.next_move = world.time + 10
      else
         return   //A click has recently been handled already, you need to wait until the anti-spam delay between clicks passes

   //Is the object in a valid place?
   var/valid_place = 0
   if ( isturf(src) || ( src.loc && isturf(src.loc) ) || ( src.loc.loc && isturf(src.loc.loc) ) )
      //Object is either a turf of placed on a turf, thus valid.
      //The third one is that it is in a container, which is on a turf, like a box,
      //which you mouse-drag opened. Also a valid location.
      valid_place = 1

   if ( ( src.loc && (src.loc == usr) ) || ( src.loc.loc && (src.loc.loc == usr) ) )
      //User has the object on them (in their inventory) and it is thus valid
      valid_place = 1

   //Afterattack gets performed every time you click, no matter if it's in range or not. It's used when
   //clicking targets for guns and such. If you are clicking on a target that's not in range
   //with an item in your hands only afterattack() needs to be performed.
   //If the range is valid, afterattack() will be handled in the separate mob-type
   //sections below, however only after attackby(). Attack_hand and simmilar procs are handled
   //in the mob-type sections below, as some require you to be in range to work (human, monkey..) while others don't (ai, cyborg)
   //Also note that afterattack does not differentiate between the holder/attacker's mob-type.
   if( W && !valid_place)
      W.afterattack(src, usr, (valid_place ? 1 : 0))
      return

   if(ishuman(usr))
      var/mob/living/carbon/human/human = usr
      //-human stuff-

      if(human.stat)
         return

      if(human.in_throw_mode)
         return human.throw_item(src)

      var/in_range = in_range(src, human) || src.loc == human

      if (in_range)
         if (!( human.restrained() || human.lying ))
            if (W)
               attackby(W,human)
               if (W)
                  W.afterattack(src, human)
            else
               attack_hand(human)
         else
            hand_h(human, human.hand)
      else
         if ( (W) && !human.restrained() )
            W.afterattack(src, human)


   else if(isAI(usr))
      var/mob/living/silicon/ai/ai = usr
      //-ai stuff-

      if(ai.stat)
         return

      if (ai.control_disabled)
         return

      if( !ai.restrained() )
         attack_ai(ai)
      else
         hand_a(ai, ai.hand)

   else if(isrobot(usr))
      var/mob/living/silicon/robot/robot = usr
      //-cyborg stuff-

      if(robot.stat)
         return

      if (robot.lockcharge)
         return



      if(W)
         var/in_range = in_range(src, robot) || src.loc == robot
         if(in_range)
            attackby(W,robot)
         if (W)
            W.afterattack(src, robot)
      else
         if( !robot.restrained() )
            attack_robot(robot)
         else
            hand_r(robot, robot.hand)

   else if(isobserver(usr))
      var/mob/dead/observer/ghost = usr
      //-ghost stuff-

      if(ghost)
         if(W)
            if(usr.client && usr.client.holder)
               src.attackby(W, ghost)            //This is so admins can interact with things ingame.
            else
               src.attack_ghost(ghost)            //Something's gone wrong, non-admin ghosts shouldn't be able to hold things.
         else
            if(usr.client && usr.client.holder)
               src.attack_admin(ghost)            //This is so admins can interact with things ingame.
            else
               src.attack_ghost(ghost)            //Standard click as ghost


   else if(ismonkey(usr))
      var/mob/living/carbon/monkey/monkey = usr
      //-monkey stuff-

      if(monkey.stat)
         return

      if(monkey.in_throw_mode)
         return monkey.throw_item(src)

      var/in_range = in_range(src, monkey) || src.loc == monkey

      if (in_range)
         if ( !monkey.restrained() )
            if (W)
               attackby(W,monkey)
               if (W)
                  W.afterattack(src, monkey)
            else
               attack_paw(monkey)
         else
            hand_p(monkey, monkey.hand)
      else
         if ( (W) && !monkey.restrained() )
            W.afterattack(src, monkey)

   else if(isalienadult(usr))
      var/mob/living/carbon/alien/humanoid/alien = usr
      //-alien stuff-

      if(alien.stat)
         return

      var/in_range = in_range(src, alien) || src.loc == alien

      if (in_range)
         if ( !alien.restrained() )
            if (W)
               attackby(W,alien)
               if (W)
                  W.afterattack(src, alien)
            else
               attack_alien(alien)
         else
            hand_al(alien, alien.hand)
      else
         if ( (W) && !alien.restrained() )
            W.afterattack(src, alien)

   else if(islarva(usr))
      var/mob/living/carbon/alien/larva/alien = usr
      if(alien.stat)
         return

      var/in_range = in_range(src, alien) || src.loc == alien

      if (in_range)
         if ( !alien.restrained() )
            attack_larva(alien)

   else if(isslime(usr))
      var/mob/living/carbon/slime/slime = usr
      //-slime stuff-

      if(slime.stat)
         return

      var/in_range = in_range(src, slime) || src.loc == slime

      if (in_range)
         if ( !slime.restrained() )
            if (W)
               attackby(W,slime)
               if (W)
                  W.afterattack(src, slime)
            else
               attack_slime(slime)
         else
            hand_m(slime, slime.hand)
      else
         if ( (W) && !slime.restrained() )
            W.afterattack(src, slime)


   else if(isanimal(usr))
      var/mob/living/simple_animal/animal = usr
      //-simple animal stuff-

      if(animal.stat)
         return

      var/in_range = in_range(src, animal) || src.loc == animal

      if (in_range)
         if ( !animal.restrained() )
            attack_animal(animal)

/atom/DblClick(location, control, params) //TODO: DEFERRED: REWRITE
   if(!usr)   return

   // ------- TIME SINCE LAST CLICK -------
   if (world.time <= usr:lastDblClick+1)
//      world << "BLOCKED atom.DblClick() on [src] by [usr] : src.type is [src.type]"
      return
   else
//      world << "atom.DblClick() on [src] by [usr] : src.type is [src.type]"
      usr:lastDblClick = world.time

   //Putting it here for now. It diverts stuff to the mech clicking procs. Putting it here stops us drilling items in our inventory Carn
   if(istype(usr.loc,/obj/mecha))
      if(usr.client && (src in usr.client.screen))
         return
      var/obj/mecha/Mech = usr.loc
      Mech.click_action(src,usr)
      return

   // ------- DIR CHANGING WHEN CLICKING ------
   if( iscarbon(usr) && !usr.buckled )
      if( src.x && src.y && usr.x && usr.y )
         var/dx = src.x - usr.x
         var/dy = src.y - usr.y

         if(dy || dx)
            if(abs(dx) < abs(dy))
               if(dy > 0)   usr.dir = NORTH
               else      usr.dir = SOUTH
            else
               if(dx > 0)   usr.dir = EAST
               else      usr.dir = WEST
         else
            if(pixel_y > 16)      usr.dir = NORTH
            else if(pixel_y < -16)   usr.dir = SOUTH
            else if(pixel_x > 16)   usr.dir = EAST
            else if(pixel_x < -16)   usr.dir = WEST




   // ------- AI -------
   else if (istype(usr, /mob/living/silicon/ai))
      var/mob/living/silicon/ai/ai = usr
      if (ai.control_disabled)
         return

   // ------- CYBORG -------
   else if (istype(usr, /mob/living/silicon/robot))
      var/mob/living/silicon/robot/bot = usr
      if (bot.lockcharge) return
   ..()


   // ------- SHIFT-CLICK -------

   if(params)
      var/parameters = params2list(params)

      if(parameters["shift"]){
         if(!isAI(usr))
            ShiftClick(usr)
         else
            AIShiftClick(usr)
         return
      }

      // ------- ALT-CLICK -------

      if(parameters["alt"]){
         if(!isAI(usr))
            AltClick(usr)
         else
            AIAltClick(usr)
         return
      }

      // ------- CTRL-CLICK -------

      if(parameters["ctrl"]){
         if(!isAI(usr))
            CtrlClick(usr)
         else
            AICtrlClick(usr)
         return
      }

      // ------- MIDDLE-CLICK -------

      if(parameters["middle"]){
         if(!isAI(usr))
            MiddleClick(usr)
            return
      }

   // ------- THROW -------
   if(usr.in_throw_mode)
      return usr:throw_item(src)

   // ------- ITEM IN HAND DEFINED -------
   var/obj/item/W = usr.get_active_hand()
/*   Now handled by get_active_hand()
   // ------- ROBOT -------
   if(istype(usr, /mob/living/silicon/robot))
      if(!isnull(usr:module_active))
         W = usr:module_active
      else
         W = null
*/
   // ------- ATTACK SELF -------
   if (W == src && usr.stat == 0)
      W.attack_self(usr)
      if(usr.hand)
         usr.update_inv_l_hand(0)   //update in-hand overlays
      else
         usr.update_inv_r_hand(0)
      return

   // ------- PARALYSIS, STUN, WEAKENED, DEAD, (And not AI) -------
   if (((usr.paralysis || usr.stunned || usr.weakened) && !istype(usr, /mob/living/silicon/ai)) || usr.stat != 0)
      return

   // ------- CLICKING STUFF IN CONTAINERS -------
   if ((!( src in usr.contents ) && (((!( isturf(src) ) && (!( isturf(src.loc) ) && (src.loc && !( isturf(src.loc.loc) )))) || !( isturf(usr.loc) )) && (src.loc != usr.loc && (!( istype(src, /obj/screen) ) && !( usr.contents.Find(src.loc) ))))))
      if (istype(usr, /mob/living/silicon/ai))
         var/mob/living/silicon/ai/ai = usr
         if (ai.control_disabled || ai.malfhacking)
            return
      else
         return

   // ------- 1 TILE AWAY -------
   var/t5
   // ------- AI CAN CLICK ANYTHING -------
   if(istype(usr, /mob/living/silicon/ai))
      t5 = 1
   // ------- CYBORG CAN CLICK ANYTHING WHEN NOT HOLDING STUFF -------
   else if(istype(usr, /mob/living/silicon/robot) && !W)
      t5 = 1
   else
      t5 = in_range(src, usr) || src.loc == usr

//   world << "according to dblclick(), t5 is [t5]"

   // ------- ACTUALLY DETERMINING STUFF -------
   if (((t5 || (W && (W.flags & USEDELAY))) && !( istype(src, /obj/screen) )))

      // ------- ( CAN USE ITEM OR HAS 1 SECOND USE DELAY ) AND NOT CLICKING ON SCREEN -------

      if (usr.next_move < world.time)
         usr.prev_move = usr.next_move
         usr.next_move = world.time + 10
      else
         // ------- ALREADY USED ONE ITEM WITH USE DELAY IN THE PREVIOUS SECOND -------
         return

      // ------- DELAY CHECK PASSED -------

      if ((src.loc && (get_dist(src, usr) < 2 || src.loc == usr.loc)))

         // ------- CLICKED OBJECT EXISTS IN GAME WORLD, DISTANCE FROM PERSON TO OBJECT IS 1 SQUARE OR THEY'RE ON THE SAME SQUARE -------

         var/direct = get_dir(usr, src)
         var/obj/item/weapon/dummy/D = new /obj/item/weapon/dummy( usr.loc )
         var/ok = 0
         if ( (direct - 1) & direct)

            // ------- CLICKED OBJECT IS LOCATED IN A DIAGONAL POSITION FROM THE PERSON -------

            var/turf/Step_1
            var/turf/Step_2
            switch(direct)
               if(5.0)
                  Step_1 = get_step(usr, NORTH)
                  Step_2 = get_step(usr, EAST)

               if(6.0)
                  Step_1 = get_step(usr, SOUTH)
                  Step_2 = get_step(usr, EAST)

               if(9.0)
                  Step_1 = get_step(usr, NORTH)
                  Step_2 = get_step(usr, WEST)

               if(10.0)
                  Step_1 = get_step(usr, SOUTH)
                  Step_2 = get_step(usr, WEST)

               else
            if(Step_1 && Step_2)

               // ------- BOTH CARDINAL DIRECTIONS OF THE DIAGONAL EXIST IN THE GAME WORLD -------

               var/check_1 = 0
               var/check_2 = 0
               if(step_to(D, Step_1))
                  check_1 = 1
                  for(var/obj/border_obstacle in Step_1)
                     if(border_obstacle.flags & ON_BORDER)
                        if(!border_obstacle.CheckExit(D, src))
                           check_1 = 0
                           // ------- YOU TRIED TO CLICK ON AN ITEM THROUGH A WINDOW (OR SIMILAR THING THAT LIMITS ON BORDERS) ON ONE OF THE DIRECITON TILES -------
                  for(var/obj/border_obstacle in get_turf(src))
                     if((border_obstacle.flags & ON_BORDER) && (src != border_obstacle))
                        if(!border_obstacle.CanPass(D, D.loc, 1, 0))
                           // ------- YOU TRIED TO CLICK ON AN ITEM THROUGH A WINDOW (OR SIMILAR THING THAT LIMITS ON BORDERS) ON THE TILE YOU'RE ON -------
                           check_1 = 0

               D.loc = usr.loc
               if(step_to(D, Step_2))
                  check_2 = 1

                  for(var/obj/border_obstacle in Step_2)
                     if(border_obstacle.flags & ON_BORDER)
                        if(!border_obstacle.CheckExit(D, src))
                           check_2 = 0
                  for(var/obj/border_obstacle in get_turf(src))
                     if((border_obstacle.flags & ON_BORDER) && (src != border_obstacle))
                        if(!border_obstacle.CanPass(D, D.loc, 1, 0))
                           check_2 = 0


               if(check_1 || check_2)
                  ok = 1
                  // ------- YOU CAN REACH THE ITEM THROUGH AT LEAST ONE OF THE TWO DIRECTIONS. GOOD. -------

               /*
                  More info:
                     If you're trying to click an item in the north-east of your mob, the above section of code will first check if tehre's a tile to the north or you and to the east of you
                     These two tiles are Step_1 and Step_2. After this, a new dummy object is created on your location. It then tries to move to Step_1, If it succeeds, objects on the turf you're on and
                     the turf that Step_1 is are checked for items which have the ON_BORDER flag set. These are itmes which limit you on only one tile border. Windows, for the most part.
                     CheckExit() and CanPass() are use to determine this. The dummy object is then moved back to your location and it tries to move to Step_2. Same checks are performed here.
                     If at least one of the two checks succeeds, it means you can reach the item and ok is set to 1.
               */
         else
            // ------- OBJECT IS ON A CARDINAL TILE (NORTH, SOUTH, EAST OR WEST OR THE TILE YOU'RE ON) -------
            if(loc == usr.loc)
               ok = 1
               // ------- OBJECT IS ON THE SAME TILE AS YOU -------
            else
               ok = 1

               //Now, check objects to block exit that are on the border
               for(var/obj/border_obstacle in usr.loc)
                  if(border_obstacle.flags & ON_BORDER)
                     if(!border_obstacle.CheckExit(D, src))
                        ok = 0

               //Next, check objects to block entry that are on the border
               for(var/obj/border_obstacle in get_turf(src))
                  if((border_obstacle.flags & ON_BORDER) && (src != border_obstacle))
                     if(!border_obstacle.CanPass(D, D.loc, 1, 0))
                        ok = 0
            /*
               See the previous More info, for... more info...
            */

         //del(D)
         // Garbage Collect Dummy
         D.loc = null
         D = null

         // ------- DUMMY OBJECT'S SERVED IT'S PURPOSE, IT'S REWARDED WITH A SWIFT DELETE -------
         if (!( ok ))
            // ------- TESTS ABOVE DETERMINED YOU CANNOT REACH THE TILE -------
            return 0

      if (!( usr.restrained() || (usr.lying && usr.buckled!=src) ))
         // ------- YOU ARE NOT REASTRAINED -------

         if (W)
            // ------- YOU HAVE AN ITEM IN YOUR HAND - HANDLE ATTACKBY AND AFTERATTACK -------
            var/ignoreAA = 0 //Ignore afterattack(). Surgery uses this.
            if (t5)
               ignoreAA = src.attackby(W, usr)
            if (W && !ignoreAA)
               W.afterattack(src, usr, (t5 ? 1 : 0), params)

         else
            // ------- YOU DO NOT HAVE AN ITEM IN YOUR HAND -------
            if (istype(usr, /mob/living/carbon/human))
               // ------- YOU ARE HUMAN -------
               src.attack_hand(usr, usr.hand)
            else
               // ------- YOU ARE NOT HUMAN. WHAT ARE YOU - DETERMINED HERE AND PROPER ATTACK_MOBTYPE CALLED -------
               if (istype(usr, /mob/living/carbon/monkey))
                  src.attack_paw(usr, usr.hand)
               else if (istype(usr, /mob/living/carbon/alien/humanoid))
                  if(usr.m_intent == "walk" && istype(usr, /mob/living/carbon/alien/humanoid/hunter))
                     usr.m_intent = "run"
                     usr.hud_used.move_intent.icon_state = "running"
                     usr.update_icons()
                  src.attack_alien(usr, usr.hand)
               else if (istype(usr, /mob/living/carbon/alien/larva))
                  src.attack_larva(usr)
               else if (istype(usr, /mob/living/silicon/ai) || istype(usr, /mob/living/silicon/robot))
                  src.attack_ai(usr, usr.hand)
               else if(istype(usr, /mob/living/carbon/slime))
                  src.attack_slime(usr)
               else if(istype(usr, /mob/living/simple_animal))
                  src.attack_animal(usr)
      else
         // ------- YOU ARE RESTRAINED. DETERMINE WHAT YOU ARE AND ATTACK WITH THE PROPER HAND_X PROC -------
         if (istype(usr, /mob/living/carbon/human))
            src.hand_h(usr, usr.hand)
         else if (istype(usr, /mob/living/carbon/monkey))
            src.hand_p(usr, usr.hand)
         else if (istype(usr, /mob/living/carbon/alien/humanoid))
            src.hand_al(usr, usr.hand)
         else if (istype(usr, /mob/living/silicon/ai) || istype(usr, /mob/living/silicon/robot))
            src.hand_a(usr, usr.hand)

   else
      // ------- ITEM INACESSIBLE OR CLICKING ON SCREEN -------
      if (istype(src, /obj/screen))
         // ------- IT'S THE HUD YOU'RE CLICKING ON -------
         usr.prev_move = usr.next_move
         usr:lastDblClick = world.time + 2
         if (usr.next_move < world.time)
            usr.next_move = world.time + 2
         else
            return

         // ------- 2 DECISECOND DELAY FOR CLICKING PASSED -------

         if (!( usr.restrained() ))

            // ------- YOU ARE NOT RESTRAINED -------
            if ((W && !( istype(src, /obj/screen) )))
               // ------- IT SHOULD NEVER GET TO HERE, DUE TO THE ISTYPE(SRC, /OBJ/SCREEN) FROM PREVIOUS IF-S - I TESTED IT WITH A DEBUG OUTPUT AND I COULDN'T GET THIST TO SHOW UP. -------
               src.attackby(W, usr)
               if (W)
                  W.afterattack(src, usr,, params)
            else
               // ------- YOU ARE NOT RESTRAINED, AND ARE CLICKING A HUD OBJECT -------
               if (istype(usr, /mob/living/carbon/human))
                  src.attack_hand(usr, usr.hand)
               else if (istype(usr, /mob/living/carbon/monkey))
                  src.attack_paw(usr, usr.hand)
               else if (istype(usr, /mob/living/carbon/alien/humanoid))
                  src.attack_alien(usr, usr.hand)
         else
            // ------- YOU ARE RESTRAINED CLICKING ON A HUD OBJECT -------
            if (istype(usr, /mob/living/carbon/human))
               src.hand_h(usr, usr.hand)
            else if (istype(usr, /mob/living/carbon/monkey))
               src.hand_p(usr, usr.hand)
            else if (istype(usr, /mob/living/carbon/alien/humanoid))
               src.hand_al(usr, usr.hand)
      else
         // ------- YOU ARE CLICKING ON AN OBJECT THAT'S INACCESSIBLE TO YOU AND IS NOT YOUR HUD -------
         if((LASER in usr:mutations) && usr:a_intent == "harm" && world.time >= usr.next_move)
            // ------- YOU HAVE THE LASER MUTATION, YOUR INTENT SET TO HURT AND IT'S BEEN MORE THAN A DECISECOND SINCE YOU LAS TATTACKED -------

            var/turf/T = get_turf(usr)
            var/turf/U = get_turf(src)


            if(istype(usr, /mob/living/carbon/human))
               usr:nutrition -= rand(1,5)
               usr:handle_regular_hud_updates()

            var/obj/item/projectile/beam/A = new /obj/item/projectile/beam( usr.loc )
            A.icon = 'icons/effects/genetics.dmi'
            A.icon_state = "eyelasers"
            playsound(usr.loc, 'sound/weapons/taser2.ogg', 75, 1)

            A.firer = usr
            A.def_zone = usr:get_organ_target()
            A.original = src
            A.current = T
            A.yo = U.y - T.y
            A.xo = U.x - T.x
            spawn( 1 )
               A.process()

            usr.next_move = world.time + 6
   return


For easier readability, here's a pastebin: http://pastebin.com/qSqVPh6V
I code for the code project and moderate the code sections of the forums.

Why realism is stupid:
Spoiler:
Wiz, the project lead of Europa Universalis IV:

Immersion/flavor is playing a WW2 shooter and using a mosin-nagant instead of a laser gun - this is important.

Realism is playing a WW2 shooter and having to spend 2 months in hospital everytime you get shot - stupid and detrimental to gameplay. Nobody actually wants a realistic game, which is why realism arguments are so selectively used.
Source: http://forum.paradoxplaza.com/forum/ind ... t-19679470

User avatar
oranges
Code Maintainer
 
Joined: Tue Apr 15, 2014 9:16 pm
Location: #CHATSHITGETBANGED
Byond Username: Optimumtact
Github Username: optimumtact

Re: 'Please murder me slowly' pieces of code

Postby oranges » Wed Oct 08, 2014 8:22 pm #34848

I submit the washing machine code.

Especially the start proc
Code: Select all
/obj/machinery/washing_machine/verb/start()
    set name = "Start Washing"
    set category = "Object"
    set src in oview(1)

    if( state != 4 )
        usr << "The washing machine cannot run in this state."
        return                                                                                                                                                                                               

    if( locate(/mob,contents) )
        state = 8
    else
        state = 5
    update_icon()
    sleep(200)
    for(var/atom/A in contents)
        A.clean_blood()

    //Tanning!
    for(var/obj/item/stack/sheet/hairlesshide/HH in contents)
        var/obj/item/stack/sheet/wetleather/WL = new(src)
        WL.amount = HH.amount
        qdel(HH)


    if(crayon)
        var/wash_color
        if(istype(crayon,/obj/item/toy/crayon))
            var/obj/item/toy/crayon/CR = crayon
            wash_color = CR.colourName
        else if(istype(crayon,/obj/item/weapon/stamp))
            var/obj/item/weapon/stamp/ST = crayon
            wash_color = ST.item_color
        if(wash_color)
            var/new_jumpsuit_icon_state = ""
            var/new_jumpsuit_item_state = ""
            var/new_jumpsuit_name = ""
            var/new_glove_icon_state = ""
            var/new_glove_item_state = ""
            var/new_glove_name = ""
            var/new_shoe_icon_state = ""
            var/new_shoe_name = ""
            var/new_sheet_icon_state = ""
            var/new_sheet_name = ""
            var/new_softcap_icon_state = ""
            var/new_softcap_name = ""
            var/new_desc = "The colors are a bit dodgy."
            for(var/T in typesof(/obj/item/clothing/under/color))
                var/obj/item/clothing/under/color/J = new T
                //world << "DEBUG: [wash_color] == [J.item_color]"
                if(wash_color == J.item_color)
                    new_jumpsuit_icon_state = J.icon_state
                    new_jumpsuit_item_state = J.item_state
                    new_jumpsuit_name = J.name
                    qdel(J)
                    //world << "DEBUG: YUP! [new_icon_state] and [new_item_state]"
                    break
                qdel(J)
            for(var/T in typesof(/obj/item/clothing/gloves))
                var/obj/item/clothing/gloves/G = new T
                //world << "DEBUG: [wash_color] == [J.item_color]"
                if(wash_color == G.item_color)
                    new_glove_icon_state = G.icon_state
                    new_glove_item_state = G.item_state
                    new_glove_name = G.name
                    qdel(G)
                    //world << "DEBUG: YUP! [new_icon_state] and [new_item_state]"
                    break
                qdel(G)
            for(var/T in typesof(/obj/item/clothing/shoes/sneakers))
                var/obj/item/clothing/shoes/sneakers/S = new T
                //world << "DEBUG: [wash_color] == [J.item_color]"
                if(wash_color == S.item_color)
                    new_shoe_icon_state = S.icon_state
                    new_shoe_name = S.name
                    qdel(S)
                    //world << "DEBUG: YUP! [new_icon_state] and [new_item_state]"
                    break                                                                                                                                                                                   
                qdel(S)
            for(var/T in typesof(/obj/item/weapon/bedsheet))
                var/obj/item/weapon/bedsheet/B = new T
                //world << "DEBUG: [wash_color] == [J.item_color]"
                if(wash_color == B.item_color)
                    new_sheet_icon_state = B.icon_state
                    new_sheet_name = B.name
                    qdel(B)
                    //world << "DEBUG: YUP! [new_icon_state] and [new_item_state]"
                    break
                qdel(B)
            for(var/T in typesof(/obj/item/clothing/head/soft))
                var/obj/item/clothing/head/soft/H = new T
                //world << "DEBUG: [wash_color] == [J.item_color]"
                if(wash_color == H.item_color)
                    new_softcap_icon_state = H.icon_state
                    new_softcap_name = H.name
                    qdel(H)
                    //world << "DEBUG: YUP! [new_icon_state] and [new_item_state]"
                    break
                qdel(H)
            if(new_jumpsuit_icon_state && new_jumpsuit_item_state && new_jumpsuit_name)
                for(var/obj/item/clothing/under/color/J in contents)
                    //world << "DEBUG: YUP! FOUND IT!"
                    J.item_state = new_jumpsuit_item_state
                    J.icon_state = new_jumpsuit_icon_state
                    J.item_color = wash_color
                    J.name = new_jumpsuit_name
                    J.desc = new_desc
            if(new_glove_icon_state && new_glove_item_state && new_glove_name)
                for(var/obj/item/clothing/gloves/G in contents)
                    //world << "DEBUG: YUP! FOUND IT!"
                    G.item_state = new_glove_item_state
                    G.icon_state = new_glove_icon_state
                    G.item_color = wash_color
                    G.name = new_glove_name
                    G.desc = new_desc
            if(new_shoe_icon_state && new_shoe_name)
                for(var/obj/item/clothing/shoes/sneakers/S in contents)
                    //world << "DEBUG: YUP! FOUND IT!"
                    if (S.chained == 1)
                        S.chained = 0
                        S.slowdown = SHOES_SLOWDOWN
                        new /obj/item/weapon/handcuffs( src )
                    S.icon_state = new_shoe_icon_state
                    S.item_color = wash_color
                    S.name = new_shoe_name
                    S.desc = new_desc
            if(new_sheet_icon_state && new_sheet_name)
                for(var/obj/item/weapon/bedsheet/B in contents)
                    //world << "DEBUG: YUP! FOUND IT!"
                    B.icon_state = new_sheet_icon_state
                    B.item_color = wash_color
                    B.name = new_sheet_name
                    B.desc = new_desc
            if(new_softcap_icon_state && new_softcap_name)                                                                                                                                                   
                for(var/obj/item/clothing/head/soft/H in contents)
                    //world << "DEBUG: YUP! FOUND IT!"
                    H.icon_state = new_softcap_icon_state
                    H.item_color = wash_color
                    H.name = new_softcap_name
                    H.desc = new_desc
        qdel(crayon)
        crayon = null
    if( locate(/mob,contents) )
        state = 7
        gibs_ready = 1
    else
        state = 4
    update_icon()
Image

User avatar
paprika
Rarely plays
 
Joined: Fri Apr 18, 2014 10:20 pm
Location: in down bad
Byond Username: Paprka

Re: 'Please murder me slowly' pieces of code

Postby paprika » Wed Oct 08, 2014 11:31 pm #34906

don't remind me please
Oldman Robustin wrote:It's an established meme that coders don't play this game.

User avatar
MisterPerson
Board Moderator
 
Joined: Tue Apr 15, 2014 4:26 pm
Byond Username: MisterPerson

Re: 'Please murder me slowly' pieces of code

Postby MisterPerson » Thu Oct 09, 2014 12:20 am #34914

Oh my god that's awful.
I code for the code project and moderate the code sections of the forums.

Why realism is stupid:
Spoiler:
Wiz, the project lead of Europa Universalis IV:

Immersion/flavor is playing a WW2 shooter and using a mosin-nagant instead of a laser gun - this is important.

Realism is playing a WW2 shooter and having to spend 2 months in hospital everytime you get shot - stupid and detrimental to gameplay. Nobody actually wants a realistic game, which is why realism arguments are so selectively used.
Source: http://forum.paradoxplaza.com/forum/ind ... t-19679470

Perakp
 
Joined: Sat Apr 19, 2014 2:45 pm
Byond Username: Perakp

Re: 'Please murder me slowly' pieces of code

Postby Perakp » Fri Oct 10, 2014 2:55 pm #35304

Sometimes our sanity checks are insane:

Code: Select all
for (var/mob/living/silicon/robot/robo in mob_list)
   if (!robo.connected_ai && robo.mind)
      if (robo.stat != 2)
         world << "<b>[robo.name] (Played by: [robo.mind.key]) survived as an AI-less borg! Its laws were:</b>"
      else
         world << "<b>[robo.name] (Played by: [robo.mind.key]) was unable to survive the rigors of being a cyborg without an AI. Its laws were:</b>"

      if(robo) //How the hell do we lose robo between here and the world messages directly above this?
         robo.laws.show_laws(world)


And apparently it was necessary to add that there? How the hell...

User avatar
oranges
Code Maintainer
 
Joined: Tue Apr 15, 2014 9:16 pm
Location: #CHATSHITGETBANGED
Byond Username: Optimumtact
Github Username: optimumtact

Re: 'Please murder me slowly' pieces of code

Postby oranges » Wed Oct 15, 2014 9:20 pm #36399

Code: Select all
/obj/item/weapon/bombcore/training/proc/reset()
     var/obj/machinery/syndicatebomb/holder = src.loc
     if(istype(holder))
          holder.open_panel = 0
          if(holder.wires)
              holder.wires.Shuffle()
          holder.defused = 0
          holder.update_icon()
          holder.updateDialog()

Lets call a method that waits for user input during the MC machine processing loop :(
Image

User avatar
paprika
Rarely plays
 
Joined: Fri Apr 18, 2014 10:20 pm
Location: in down bad
Byond Username: Paprka

Re: 'Please murder me slowly' pieces of code

Postby paprika » Sun Oct 26, 2014 9:32 pm #38933

Code: Select all
usr << browse(body, "window=adminplayeropts;size=550x515")
   feedback_add_details("admin_verb","SPP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

      feedback_add_details("admin_verb","R") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

   feedback_add_details("admin_verb","A") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

   feedback_add_details("admin_verb","SAN") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

   feedback_add_details("admin_verb","TOOC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!


Image
Oldman Robustin wrote:It's an established meme that coders don't play this game.

User avatar
Ikarrus
 
Joined: Fri Apr 18, 2014 2:17 am
Location: Canada
Byond Username: Ikarrus
Github Username: Ikarrus

Re: 'Please murder me slowly' pieces of code

Postby Ikarrus » Mon Oct 27, 2014 7:05 am #38989

Which is fine as long as the second parameter is unique. But that's errocode and we don't have a way to look up game statistics any more
Former Dev/Headmin
Who is this guy?

User avatar
JJRcop
 
Joined: Wed Apr 23, 2014 1:52 am
Byond Username: JJRcop
Github Username: JJRcop

Re: 'Please murder me slowly' pieces of code

Postby JJRcop » Mon Oct 27, 2014 11:11 pm #39113

What is object oriented programming?

Code: Select all
/turf/simulated/floor/proc/MakeDirty()
   if(prob(66))   //fastest possible exit 2/3 of the time
      return

   // These look weird if you make them dirty
   if(istype(src, /turf/simulated/floor/carpet) || istype(src, /turf/simulated/floor/grass) || istype(src, /turf/simulated/floor/beach) || istype(src, /turf/simulated/floor/holofloor) || istype(src, /turf/simulated/floor/plating/snow) || istype(src, /turf/simulated/floor/plating/ironsand))
      return

   if(locate(/obj/structure/grille) in contents)
      return

   var/area/A = loc

            //zero dirt
   if(!istype(A) || istype(A, /area/centcom) || istype(A, /area/holodeck) || istype(A, /area/library) || istype(A, /area/janitor) || istype(A, /area/chapel) || istype(A, /area/mine/explored) || istype(A, /area/mine/unexplored) || istype(A, /area/solar) || istype(A, /area/atmos) || istype(A, /area/medical/virology))
      return

            //high dirt - 1/3
   if(istype(A, /area/toxins/test_area) || istype(A, /area/mine/production) || istype(A, /area/mine/living_quarters) || istype(A, /area/mine/north_outpost) || istype(A, /area/mine/west_outpost) || istype(A, /area/wreck) || istype(A, /area/derelict) || istype(A, /area/djstation))
      new /obj/effect/decal/cleanable/dirt(src)   //vanilla, but it works
      return


   if(prob(80))   //mid dirt  - 1/15
      return


   if(istype(A, /area/engine) || istype(A,/area/assembly) || istype(A,/area/maintenance) || istype(A,/area/construction))
       //Blood, sweat, and oil.  Oh, and dirt.
      if(prob(3))
         new /obj/effect/decal/cleanable/blood/old(src)
      else
         if(prob(35))
            if(prob(4))
               new /obj/effect/decal/cleanable/robot_debris/old(src)
            else
               new /obj/effect/decal/cleanable/oil(src)
         else
            new /obj/effect/decal/cleanable/dirt(src)
      return

   if(istype(A, /area/crew_quarters/toilet) || istype(A, /area/crew_quarters/locker/locker_toilet) || istype(A, /area/crew_quarters/bar))
      if(prob(40))
         if(prob(90))
            new /obj/effect/decal/cleanable/vomit/old(src)
         else
            new /obj/effect/decal/cleanable/blood/old(src)
      else
         new /obj/effect/decal/cleanable/dirt(src)
      return

   if(istype(A, /area/quartermaster))
      if(prob(75))
         new /obj/effect/decal/cleanable/dirt(src)
      else
         new /obj/effect/decal/cleanable/oil(src)
      return



   if(prob(75))   //low dirt  - 1/60
      return



   if(istype(A, /area/turret_protected) || istype(A, /area/security))   //chance of incident
      if(prob(20))
         if(prob(5))
            new /obj/effect/decal/cleanable/blood/gibs/old(src)
         else
            new /obj/effect/decal/cleanable/blood/old(src)
      else
         new /obj/effect/decal/cleanable/dirt(src)
      return


   if(istype(A, /area/crew_quarters/kitchen))   //Kitchen messes
      if(prob(60))
         if(prob(50))
            new /obj/effect/decal/cleanable/egg_smudge(src)
         else
            new /obj/effect/decal/cleanable/flour(src)
      else if(prob(33))
         new /obj/effect/decal/cleanable/dirt(src)
      return

   if(istype(A, /area/medical))   //Kept clean, but chance of blood
      if(prob(66))
         if(prob(5))
            new /obj/effect/decal/cleanable/blood/gibs/old(src)
         else
            new /obj/effect/decal/cleanable/blood/old(src)
      else
         if(prob(30))
            if(istype(A, /area/medical/morgue))
               new /obj/item/weapon/ectoplasm(src)
            else
               new /obj/effect/decal/cleanable/vomit/old(src)
      return

   if(istype(A, /area/toxins))
      if(prob(80))
         new /obj/effect/decal/cleanable/dirt(src)
      else
         new /obj/effect/decal/cleanable/greenglow(src)   //this cleans itself up but it might startle you when you see it.
      return

   //default
   new /obj/effect/decal/cleanable/dirt(src)
   return


code/game/turfs/simulated/dirtystation.dm Line 38
I lurk quite often...

User avatar
Jordie0608
Site Admin
 
Joined: Tue Apr 15, 2014 1:33 pm
Location: Spiderland, Australia
Byond Username: Jordie0608
Github Username: Jordie0608

Re: 'Please murder me slowly' pieces of code

Postby Jordie0608 » Fri Jan 16, 2015 7:22 am #59592

Code: Select all
///proc/UpdateTime() //No idea why i made this a proc.
//   CMinutes = (world.realtime / 10) / 60
//   return 1
Forum Admin
Send me a PM if you have any issues, concerns or praise of fishfood to express about the forums.

User avatar
Thunder11
In-Game Admin
 
Joined: Fri Apr 18, 2014 12:55 pm
Location: Scotland, UK
Byond Username: Thunder12345
Github Username: Thunder12345

Re: 'Please murder me slowly' pieces of code

Postby Thunder11 » Fri Jun 26, 2015 4:26 pm #99108

Code: Select all
/obj/item/weapon/gun/projectile/automatic/c20r/update_icon()
   ..()
   icon_state = "c20r[magazine ? "-[Ceiling(get_ammo(0)/4)*4]" : ""][chambered ? "" : "-e"][suppressed ? "-suppressed" : ""]"
   return
ImageImage
Spoiler:
IcePacks wrote:
MrFoster wrote:Back in my day, we didn't complain about lag! We used it to queue attacks!

That's thinking on your feet, soldier!

Quality Paprika from #coderbus wrote:[11:35.52] <paprika> holy crap so yeah i don't care about your opinion at all

oranges wrote:

Excuse me? Thats for sensible and calm rational debate, not for senseless whining.

Can be found on singulo: !!pQe.6/5m0Y
Ruiner of Fun [Badmin], leave feedback at: viewtopic.php?f=37&t=5578

Scott
Github User
 
Joined: Fri Apr 18, 2014 1:50 pm
Byond Username: Xxnoob
Github Username: xxalpha

Re: 'Please murder me slowly' pieces of code

Postby Scott » Fri Jun 26, 2015 6:40 pm #99133

Jordie0608 wrote:
Code: Select all
///proc/UpdateTime() //No idea why i made this a proc.
//   CMinutes = (world.realtime / 10) / 60
//   return 1


that return though

User avatar
mosquitoman
 
Joined: Fri May 01, 2015 7:52 pm
Byond Username: MosquitoMan

Re: 'Please murder me slowly' pieces of code

Postby mosquitoman » Sun Jun 28, 2015 12:54 am #99493

just found this:

Code: Select all
/obj/item/robot_parts/robot_suit/proc/check_completion()
   if(src.l_arm && src.r_arm)
      if(src.l_leg && src.r_leg)
         if(src.chest && src.head)
            feedback_inc("cyborg_frames_built",1)
            return 1
   return 0

User avatar
DemonFiren
 
Joined: Sat Dec 13, 2014 9:15 pm
Byond Username: DemonFiren

Re: 'Please murder me slowly' pieces of code

Postby DemonFiren » Sun Jun 28, 2015 12:59 am #99498

This is more funny than anything else.
Image
Image
Image
ImageImageImageImageImage

non-lizard things:
Spoiler:
Image

User avatar
Remie Richards
 
Joined: Thu Apr 17, 2014 7:11 pm
Location: England, UK, Earth, Sol, Milky Way, Local Group, Virgo Supercluster, Known Universe
Byond Username: CrimsonVision

Re: 'Please murder me slowly' pieces of code

Postby Remie Richards » Sun Jun 28, 2015 2:53 am #99541

mosquitoman wrote:just found this:

Code: Select all
/obj/item/robot_parts/robot_suit/proc/check_completion()
   if(src.l_arm && src.r_arm)
      if(src.l_leg && src.r_leg)
         if(src.chest && src.head)
            feedback_inc("cyborg_frames_built",1)
            return 1
   return 0


Eh, you can't really fix that much.
you could move the 3 ifs onto one if, that's about it.
私は完璧

Scott
Github User
 
Joined: Fri Apr 18, 2014 1:50 pm
Byond Username: Xxnoob
Github Username: xxalpha

Re: 'Please murder me slowly' pieces of code

Postby Scott » Sun Jun 28, 2015 4:20 am #99563

It's a matter of opinion, I think those ifs look better than one long if. It's organization.

User avatar
oranges
Code Maintainer
 
Joined: Tue Apr 15, 2014 9:16 pm
Location: #CHATSHITGETBANGED
Byond Username: Optimumtact
Github Username: optimumtact

Re: 'Please murder me slowly' pieces of code

Postby oranges » Mon Sep 12, 2016 10:01 pm #210945

Code: Select all
dat += text("<HR>\n>[]<BR>\n<A href='?src=\ref[];type=1'>1</A>-<A href='?src=\ref[];type=2'>2</A>-<A href='?src=\ref[];type=3'>3</A><BR>\n<A href='?src=\ref[];type=4'>4</A>-<A href='?src=\ref[];type=5'>5</A>-<A href='?src=\ref[];type=6'>6</A><BR>\n<A href='?src=\ref[];type=7'>7</A>-<A href='?src=\ref[];type=8'>8</A>-<A href='?src=\ref[];type=9'>9</A><BR>\n<A href='?src=\ref[];type=R'>R</A>-<A href='?src=\ref[];type=0'>0</A>-<A href='?src=\ref[];type=E'>E</A><BR>\n</TT>", message, src, src, src, src, src, src, src, src, src, src, src, src)


This master piece from the secure safe was especially hilarious.
Image

User avatar
PKPenguin321
In-Game Game Master
 
Joined: Tue Jul 01, 2014 7:02 pm
Location: U S A, U S A, U S A
Byond Username: PKPenguin321
Github Username: PKPenguin321

Re: 'Please murder me slowly' pieces of code

Postby PKPenguin321 » Mon Sep 12, 2016 10:21 pm #210949

those 12 src-es at the end lmao
i play Lauser McMauligan. clown name is Cold-Ass Honkey
i have three other top secret characters as well
tell the best admin how good he is
Spoiler:
Image

User avatar
Thunder11
In-Game Admin
 
Joined: Fri Apr 18, 2014 12:55 pm
Location: Scotland, UK
Byond Username: Thunder12345
Github Username: Thunder12345

Re: 'Please murder me slowly' pieces of code

Postby Thunder11 » Mon Sep 12, 2016 10:33 pm #210951

I feel like just seeing that has forever tainted me
ImageImage
Spoiler:
IcePacks wrote:
MrFoster wrote:Back in my day, we didn't complain about lag! We used it to queue attacks!

That's thinking on your feet, soldier!

Quality Paprika from #coderbus wrote:[11:35.52] <paprika> holy crap so yeah i don't care about your opinion at all

oranges wrote:

Excuse me? Thats for sensible and calm rational debate, not for senseless whining.

Can be found on singulo: !!pQe.6/5m0Y
Ruiner of Fun [Badmin], leave feedback at: viewtopic.php?f=37&t=5578

User avatar
phil235
 
Joined: Thu Apr 17, 2014 11:39 am
Byond Username: Phil235

Re: 'Please murder me slowly' pieces of code

Postby phil235 » Tue Sep 13, 2016 12:09 am #210994

Some code I fixed recently in the dismember PR, in the proc /obj/item/weapon/storage/book/bible/attack(mob/living/M, mob/living/carbon/human/user)

Code: Select all
   if (M.stat !=2)
      if(M.mind && (M.mind.assigned_role == "Chaplain"))
         user << "<span class='warning'>You can't heal yourself!</span>"
         return
      if ((istype(M, /mob/living/carbon/human) && prob(60)))
         bless(M)
         if(ishuman(M))
            var/mob/living/carbon/human/H = M
            var/message_halt = 0
            for(var/obj/item/bodypart/affecting in H.bodyparts)
               if(affecting.status == ORGAN_ORGANIC)
                  if(message_halt == 0)
                     M.visible_message("<span class='notice'>[user] heals [M] with the power of [src.deity_name]!</span>")
                     M << "<span class='boldnotice'>May the power of [src.deity_name] compel you to be healed!</span>"
                     playsound(src.loc, "punch", 25, 1, -1)
                     message_halt = 1
               else
                  user << "<span class='warning'>[src.deity_name] refuses to heal this metallic taint!</span>"
                  return
      else
         if(ishuman(M) && !istype(M:head, /obj/item/clothing/head/helmet))
            M.adjustBrainLoss(10)
            M << "<span class='danger'>You feel dumber.</span>"
         M.visible_message("<span class='danger'>[user] beats [M] over the head with [src]!</span>", \
               "<span class='userdanger'>[user] beats [M] over the head with [src]!</span>")
         playsound(src.loc, "punch", 25, 1, -1)
         add_logs(user, M, "attacked", src)

   else if(M.stat == 2)
      M.visible_message("<span class='danger'>[user] smacks [M]'s lifeless corpse with [src].</span>")
      playsound(src.loc, "punch", 25, 1, -1)
   return



Checking THREE times whether M is a human, checking twice that M is dead, and a "M:head" for good measure. All in a single proc.
I'm a tgstation coding maintainer janitor

User avatar
MrStonedOne
Host
 
Joined: Mon Apr 14, 2014 10:56 pm
Byond Username: MrStonedOne
Github Username: MrStonedOne

Re: 'Please murder me slowly' pieces of code

Postby MrStonedOne » Tue Sep 13, 2016 8:08 am #211073

This entire file:

https://github.com/tgstation/tgstation/ ... tumvars.dm


but, more importantly, this chunk of code from mass modify:

Code: Select all
   switch(class)
      if("restore to default")
         O.vars[variable] = initial(O.vars[variable])
         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

      if("edit referenced object")
         return .(O.vars[variable])

      if("text")
         var/new_value = input("Enter new text:","Text",O.vars[variable]) as message|null
         if(new_value == null) return

         var/process_vars = 0
         var/unique = 0
         if(findtext(new_value,"\["))
            process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No")
            if(process_vars == "Yes")
               process_vars = 1
               unique = alert(usr,"Process vars unique to each instance, or same for all?","Variable Association","Unique","Same")
               if(unique == "Unique")
                  unique = 1
               else
                  unique = 0
            else
               process_vars = 0

         var/pre_processing = new_value
         var/list/varsvars = list()

         if(process_vars)
            varsvars = string2listofvars(new_value, O)
            if(varsvars.len)
               for(var/V in varsvars)
                  new_value = replacetext(new_value,"\[[V]]","[O.vars[V]]")

         O.vars[variable] = new_value

         //Convert the string vars for anything that's not O
         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     new_value = pre_processing //reset new_value, ready to convert it uniquely for the next iteration

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[M.vars[V]]")
                        else
                           new_value = O.vars[variable] //We already processed the non-unique form for O, reuse it

                     M.vars[variable] = new_value
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     A.vars[variable] = new_value
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     A.vars[variable] = new_value
                  CHECK_TICK
         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[M.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     M.vars[variable] = new_value
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     A.vars[variable] = new_value
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     A.vars[variable] = new_value
                  CHECK_TICK

      if("num")
         var/new_value = input("Enter new number:","Num",\
               O.vars[variable]) as num|null
         if(new_value == null) return

         if(variable=="luminosity")
            O.SetLuminosity(new_value)
         else
            O.vars[variable] = new_value

         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     if(variable=="luminosity")
                        M.SetLuminosity(new_value)
                     else
                        M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     if(variable=="luminosity")
                        A.SetLuminosity(new_value)
                     else
                        A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     if(variable=="luminosity")
                        A.SetLuminosity(new_value)
                     else
                        A.vars[variable] = O.vars[variable]
                  CHECK_TICK

         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     if(variable=="luminosity")
                        M.SetLuminosity(new_value)
                     else
                        M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     if(variable=="luminosity")
                        A.SetLuminosity(new_value)
                     else
                        A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     if(variable=="luminosity")
                        A.SetLuminosity(new_value)
                     else
                        A.vars[variable] = O.vars[variable]
                  CHECK_TICK

      if("type")
         var/new_value
         new_value = input("Enter type:","Type",O.vars[variable]) as null|anything in typesof(/obj,/mob,/area,/turf)
         if(new_value == null) return
         O.vars[variable] = new_value
         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

      if("file")
         var/new_value = input("Pick file:","File",O.vars[variable]) as null|file
         if(new_value == null) return
         O.vars[variable] = new_value

         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O.type, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O.type, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK
         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

      if("icon")
         var/new_value = input("Pick icon:","Icon",O.vars[variable]) as null|icon
         if(new_value == null) return
         O.vars[variable] = new_value
         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

   if(method)
      if(istype(O,/mob))
         for(var/mob/M in mob_list)
            if(istype(M,O.type))
               M.on_varedit(variable)
            CHECK_TICK

      else if(istype(O,/obj))
         for(var/obj/A in world)
            if(istype(A,O.type))
               A.on_varedit(variable)
            CHECK_TICK

      else if(istype(O,/turf))
         for(var/turf/A in block(locate(1,1,1),locate(world.maxx,world.maxy,world.maxz)))
            if(istype(A,O.type))
               A.on_varedit(variable)
            CHECK_TICK

   else
      if(istype(O, /mob))
         for(var/mob/M in mob_list)
            if(M.type == O.type)
               M.on_varedit(variable)
            CHECK_TICK

      else if(istype(O, /obj))
         for(var/obj/A in world)
            if(A.type == O.type)
               A.on_varedit(variable)
            CHECK_TICK

      else if(istype(O, /turf))
         for(var/turf/A in world)
            if(A.type == O.type)
               A.on_varedit(variable)
            CHECK_TICK

Forum/Wiki Administrator, Server host, Database King, Master Coder


MrStonedOne on Reddit(banned), Steam, IRC, Skype Discord.

[10:55 AM] spookydonut: stonedmc is the work of a criminally insane mad genius

User avatar
Remie Richards
 
Joined: Thu Apr 17, 2014 7:11 pm
Location: England, UK, Earth, Sol, Milky Way, Local Group, Virgo Supercluster, Known Universe
Byond Username: CrimsonVision

Re: 'Please murder me slowly' pieces of code

Postby Remie Richards » Tue Sep 13, 2016 10:46 am #211090

MrStonedOne wrote:This entire file:

https://github.com/tgstation/tgstation/ ... tumvars.dm


but, more importantly, this chunk of code from mass modify:

Code: Select all
   switch(class)
      if("restore to default")
         O.vars[variable] = initial(O.vars[variable])
         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

      if("edit referenced object")
         return .(O.vars[variable])

      if("text")
         var/new_value = input("Enter new text:","Text",O.vars[variable]) as message|null
         if(new_value == null) return

         var/process_vars = 0
         var/unique = 0
         if(findtext(new_value,"\["))
            process_vars = alert(usr,"\[] detected in string, process as variables?","Process Variables?","Yes","No")
            if(process_vars == "Yes")
               process_vars = 1
               unique = alert(usr,"Process vars unique to each instance, or same for all?","Variable Association","Unique","Same")
               if(unique == "Unique")
                  unique = 1
               else
                  unique = 0
            else
               process_vars = 0

         var/pre_processing = new_value
         var/list/varsvars = list()

         if(process_vars)
            varsvars = string2listofvars(new_value, O)
            if(varsvars.len)
               for(var/V in varsvars)
                  new_value = replacetext(new_value,"\[[V]]","[O.vars[V]]")

         O.vars[variable] = new_value

         //Convert the string vars for anything that's not O
         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     new_value = pre_processing //reset new_value, ready to convert it uniquely for the next iteration

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[M.vars[V]]")
                        else
                           new_value = O.vars[variable] //We already processed the non-unique form for O, reuse it

                     M.vars[variable] = new_value
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     A.vars[variable] = new_value
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     A.vars[variable] = new_value
                  CHECK_TICK
         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[M.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     M.vars[variable] = new_value
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     A.vars[variable] = new_value
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     new_value = pre_processing

                     if(process_vars)
                        if(unique)
                           for(var/V in varsvars)
                              new_value = replacetext(new_value,"\[[V]]","[A.vars[V]]")
                        else
                           new_value = O.vars[variable]

                     A.vars[variable] = new_value
                  CHECK_TICK

      if("num")
         var/new_value = input("Enter new number:","Num",\
               O.vars[variable]) as num|null
         if(new_value == null) return

         if(variable=="luminosity")
            O.SetLuminosity(new_value)
         else
            O.vars[variable] = new_value

         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     if(variable=="luminosity")
                        M.SetLuminosity(new_value)
                     else
                        M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     if(variable=="luminosity")
                        A.SetLuminosity(new_value)
                     else
                        A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     if(variable=="luminosity")
                        A.SetLuminosity(new_value)
                     else
                        A.vars[variable] = O.vars[variable]
                  CHECK_TICK

         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     if(variable=="luminosity")
                        M.SetLuminosity(new_value)
                     else
                        M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     if(variable=="luminosity")
                        A.SetLuminosity(new_value)
                     else
                        A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     if(variable=="luminosity")
                        A.SetLuminosity(new_value)
                     else
                        A.vars[variable] = O.vars[variable]
                  CHECK_TICK

      if("type")
         var/new_value
         new_value = input("Enter type:","Type",O.vars[variable]) as null|anything in typesof(/obj,/mob,/area,/turf)
         if(new_value == null) return
         O.vars[variable] = new_value
         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

      if("file")
         var/new_value = input("Pick file:","File",O.vars[variable]) as null|file
         if(new_value == null) return
         O.vars[variable] = new_value

         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O.type, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O.type, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK
         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

      if("icon")
         var/new_value = input("Pick icon:","Icon",O.vars[variable]) as null|icon
         if(new_value == null) return
         O.vars[variable] = new_value
         if(method)
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if ( istype(M , O.type) )
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if ( istype(A , O.type) )
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

         else
            if(istype(O, /mob))
               for(var/mob/M in mob_list)
                  if (M.type == O.type)
                     M.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /obj))
               for(var/obj/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

            else if(istype(O, /turf))
               for(var/turf/A in world)
                  if (A.type == O.type)
                     A.vars[variable] = O.vars[variable]
                  CHECK_TICK

   if(method)
      if(istype(O,/mob))
         for(var/mob/M in mob_list)
            if(istype(M,O.type))
               M.on_varedit(variable)
            CHECK_TICK

      else if(istype(O,/obj))
         for(var/obj/A in world)
            if(istype(A,O.type))
               A.on_varedit(variable)
            CHECK_TICK

      else if(istype(O,/turf))
         for(var/turf/A in block(locate(1,1,1),locate(world.maxx,world.maxy,world.maxz)))
            if(istype(A,O.type))
               A.on_varedit(variable)
            CHECK_TICK

   else
      if(istype(O, /mob))
         for(var/mob/M in mob_list)
            if(M.type == O.type)
               M.on_varedit(variable)
            CHECK_TICK

      else if(istype(O, /obj))
         for(var/obj/A in world)
            if(A.type == O.type)
               A.on_varedit(variable)
            CHECK_TICK

      else if(istype(O, /turf))
         for(var/turf/A in world)
            if(A.type == O.type)
               A.on_varedit(variable)
            CHECK_TICK



Hey! don't include the custom var embed section, I wrote that and it's -fine-
私は完璧

User avatar
MrStonedOne
Host
 
Joined: Mon Apr 14, 2014 10:56 pm
Byond Username: MrStonedOne
Github Username: MrStonedOne

Re: 'Please murder me slowly' pieces of code

Postby MrStonedOne » Wed Sep 14, 2016 2:42 am #211281

No it's not, You do the same code inside like 4 loops for shortcutting the type, when that could be done once and added to a list
Code: Select all
var/list/typecache = list(D.type = 1)
if (method)
    typecache = typecacheof(typecache)
var/list/items
if(istype(O, /turf))
    for(var/turf/T in world)
        if(typecache[T.type])
            items += T
else if(istype(O, /mob))
    for(var/mob/M in mob_list)
        if(typecache[M.type])
            items += M
...

switch (class)
...
    if ("text")
...
    for(var/thing in items)
        var/datum/D = thing
        D.vars[variable] = newvalue



By using a type cache (that we only expand to all subtypes if method is true) we can remove the if(method) thats repeated all over the place.
By using a pre-calculated list, we can prevent having to repeat that else if of istypes()

By repeating your ifs for calculated vars across all the types, you contributed to the mess. =P

Not that you had much of a choice, we didn't know about typecaches then.
Forum/Wiki Administrator, Server host, Database King, Master Coder


MrStonedOne on Reddit(banned), Steam, IRC, Skype Discord.

[10:55 AM] spookydonut: stonedmc is the work of a criminally insane mad genius

User avatar
Remie Richards
 
Joined: Thu Apr 17, 2014 7:11 pm
Location: England, UK, Earth, Sol, Milky Way, Local Group, Virgo Supercluster, Known Universe
Byond Username: CrimsonVision

Re: 'Please murder me slowly' pieces of code

Postby Remie Richards » Wed Sep 14, 2016 2:55 am #211283

It's a lot funnier knowing that it was me who came up with typecaches, and you who was my rubber duck at the time.
私は完璧

User avatar
MimicFaux
 
Joined: Sun Apr 10, 2016 10:49 pm
Location: Spaced by Mass Driver
Byond Username: MimicFaux

Re: 'Please murder me slowly' pieces of code

Postby MimicFaux » Sat Sep 17, 2016 2:08 am #212020

I am grateful for the work you guys do. This is all sorcery to me, and I am but peering into the arcane.
ImageImageImage

User avatar
TwitchTail13
 
Joined: Wed Feb 11, 2015 2:06 am
Byond Username: TwitchTail13

Re: 'Please murder me slowly' pieces of code

Postby TwitchTail13 » Sat Sep 24, 2016 6:41 pm #213407

Aranclanos wrote:Image

Each time that any object moves to a floor turf, is checks if it's a human. If it's a human, it checks if they're wearing clown shoes, just to make the clown step sound.

Each time that any object moves.

No wonder this game is laggy. Yanderedev must have programmed it.
Shaps wrote:The fact that you're asking if you need a reason to kill someone is deeply, deeply troubling

Scott
Github User
 
Joined: Fri Apr 18, 2014 1:50 pm
Byond Username: Xxnoob
Github Username: xxalpha

Re: 'Please murder me slowly' pieces of code

Postby Scott » Sun Sep 25, 2016 3:32 pm #213595

Our scapegoat here is "old coders".

User avatar
The Ultimate Chimera
 
Joined: Wed Feb 03, 2016 6:31 am
Location: The Lifeweb
Byond Username: The Ultimate Chimera

Re: 'Please murder me slowly' pieces of code

Postby The Ultimate Chimera » Sun Sep 25, 2016 6:40 pm #213652

What is the point of this thread?
Your sins are not to be forgiven. Pain and regrets are waiting for you.

Scott
Github User
 
Joined: Fri Apr 18, 2014 1:50 pm
Byond Username: Xxnoob
Github Username: xxalpha

Re: 'Please murder me slowly' pieces of code

Postby Scott » Sun Sep 25, 2016 7:08 pm #213666

To have a laugh.

User avatar
Supermichael777
 
Joined: Sun Feb 01, 2015 3:42 am
Location: Silver II hell
Byond Username: Supermichael777

Re: 'Please murder me slowly' pieces of code

Postby Supermichael777 » Sun Sep 25, 2016 8:05 pm #213690

from CM
Code: Select all
/obj/item/weapon/katana
   name = "katana"
   desc = "A finely made Japanese sword, expertly crafted by a dedicated weaponsmith. It has some foreign letters carved into the hilt."
   icon_state = "katana"
   item_state = "katana"
   flags = FPRINT | CONDUCT
   slot_flags = SLOT_BELT | SLOT_BACK
force = 40


a slightly op weeb sword
wait too many serch results

Code: Select all
/obj/item/weapon/butterfly/katana
   name = "katana"
   desc = "A ancient weapon from Japan."
   icon_state = "samurai"
force = 50


Wait what does butterfly do?

Code: Select all
/obj/item/weapon/butterfly
   name = "butterfly knife"
   desc = "A basic metal blade concealed in a lightweight plasteel grip. Small enough when folded to fit in a pocket."
   icon_state = "butterflyknife"
   item_state = null
   hitsound = null
   var/active = 0
   w_class = 2
   force = 8
   sharp = 0
   edge = 0
   throw_speed = 3
   throw_range = 4
   throwforce = 7
   attack_verb = list("patted", "tapped")
   attack_speed = 4

Code: Select all
/obj/item/weapon/butterfly/attack_self(mob/user)
   active = !active
   if(active)
      user << "<span class='notice'>You flip out your [src].</span>"
      playsound(user, 'sound/weapons/flipblade.ogg', 15, 1)
      force = 15 //bay adjustments
      throwforce = 12
      edge = 1
      sharp = 1
      hitsound = 'sound/weapons/bladeslice.ogg'
      icon_state += "_open"
      w_class = 3
      attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
   else
      user << "<span class='notice'>The butterfly knife can now be concealed.</span>"
      force = initial(force)
      edge = 0
      sharp = 0
      hitsound = initial(hitsound)
      icon_state = initial(icon_state)
      w_class = initial(w_class)
      attack_verb = initial(attack_verb)
add_fingerprint(user)


oh

TLDR; CM has a katana that is literal a folded knife
oranges wrote:It's my game, not yours

Never forget the corruption of these halls

Image
You seem to be under the mistaken impression that I actually care.
Spoiler:
Image


Spoiler:
Omar Beail says, "You guys should fuck for my entertainment"
Classy, TG, Classy

OOC: KorPhaeron: Admins aren't allowed to have friends

OOC: Daman997: I HAVE POSTED VIDEOS OF A MAN FUCKING A SNAKE IN OOC GIVE ME THAT LINK PUSSY

An0n3 wrote:Take the same brand of retardation and invert it and you have people saying "It's okay for a game to cost more because I enjoyed it!
Spoiler:
Q: Why does everyone assume I’m a pervert just for wanting to play as a cat girl?
A: Because they’re degenerate cocksuckers who cannot fathom that another person might have pure intentions in wanting to play as the cat girl master race. Their wish fulfillment fetish-tier races like elves, aasimars, goliaths, and hobgoblins are perfectly fine in their mad, lust-filled minds, such that the purity and perfection of cat girls burns at their evil perverted hearts.

Q: Where are the cat boys?
A: I don’t follow.

User avatar
Ikarrus
 
Joined: Fri Apr 18, 2014 2:17 am
Location: Canada
Byond Username: Ikarrus
Github Username: Ikarrus

Re: 'Please murder me slowly' pieces of code

Postby Ikarrus » Wed Oct 05, 2016 7:59 pm #215920

I fear that one of these days one of my abortions will show up here
Former Dev/Headmin
Who is this guy?

User avatar
Mervill
 
Joined: Sat Oct 29, 2016 7:43 pm
Byond Username: Mervill

Re: 'Please murder me slowly' pieces of code

Postby Mervill » Sat Nov 26, 2016 12:32 am #230058

This is code that I added a few days ago to ai status displays

Code: Select all
/obj/machinery/ai_status_display/attack_ai(mob/living/silicon/ai/user)
   if(isAI(user))
      user.ai_statuschange()


Originally the `if(isAI(user))` was not there ... I stupidly assumed that `attack_ai` would only every be called by the AI but that's not the case.
<MrStonedOne> so many things in the world had to go wrong for all of this to end up here.... if any one thing had gone right, ss13 wouldn't exist

User avatar
oranges
Code Maintainer
 
Joined: Tue Apr 15, 2014 9:16 pm
Location: #CHATSHITGETBANGED
Byond Username: Optimumtact
Github Username: optimumtact

Re: 'Please murder me slowly' pieces of code

Postby oranges » Thu Jan 05, 2017 1:16 am #240882

Code: Select all
/datum/reagent/toxin/mutagen/reaction_mob(mob/living/carbon/M, method=TOUCH, reac_volume)
   if(!..())
      return
   if(!M.has_dna())
      return  //No robots, AIs, aliens, Ians or other mobs should be affected by this.
   if((method==VAPOR && prob(min(33, reac_volume))) || method==INGEST || method==PATCH || method==INJECT)
      M.randmuti()
      if(prob(98))
         M.randmutb()
      else
         M.randmutg()
      M.updateappearance()
      M.domutcheck()
..()
Image

lzimann
 
Joined: Sun Oct 26, 2014 5:13 am
Byond Username: Lzimann
Github Username: lzimann

Re: 'Please murder me slowly' pieces of code

Postby lzimann » Thu Jan 05, 2017 2:37 am #240899

Code: Select all
/proc/is_revolutionary(mob/M)
   return M && istype(M) && M.mind && ticker && ticker.mode && M.mind in ticker.mode.revolutionaries

/proc/is_head_revolutionary(mob/M)
   return M && istype(M) && M.mind && ticker && ticker.mode && M.mind in ticker.mode.head_revolutionaries

/proc/is_revolutionary_in_general(mob/M)
   return is_revolutionary(M) || is_head_revolutionary(M)


Not totally bad but damn, the entire gamemode code is not fun to read.

User avatar
PKPenguin321
In-Game Game Master
 
Joined: Tue Jul 01, 2014 7:02 pm
Location: U S A, U S A, U S A
Byond Username: PKPenguin321
Github Username: PKPenguin321

Re: 'Please murder me slowly' pieces of code

Postby PKPenguin321 » Thu Jan 05, 2017 6:09 am #240938

oranges wrote:
Code: Select all
/datum/reagent/toxin/mutagen/reaction_mob(mob/living/carbon/M, method=TOUCH, reac_volume)
   if(!..())
      return
   if(!M.has_dna())
      return  //No robots, AIs, aliens, Ians or other mobs should be affected by this.
   if((method==VAPOR && prob(min(33, reac_volume))) || method==INGEST || method==PATCH || method==INJECT)
      M.randmuti()
      if(prob(98))
         M.randmutb()
      else
         M.randmutg()
      M.updateappearance()
      M.domutcheck()
..()

What's so bad about this? I usually get these but this one's readable and not awful
i play Lauser McMauligan. clown name is Cold-Ass Honkey
i have three other top secret characters as well
tell the best admin how good he is
Spoiler:
Image

User avatar
oranges
Code Maintainer
 
Joined: Tue Apr 15, 2014 9:16 pm
Location: #CHATSHITGETBANGED
Byond Username: Optimumtact
Github Username: optimumtact

Re: 'Please murder me slowly' pieces of code

Postby oranges » Thu Jan 05, 2017 6:33 pm #241102

PKPenguin321 wrote:
oranges wrote:
Code: Select all
/datum/reagent/toxin/mutagen/reaction_mob(mob/living/carbon/M, method=TOUCH, reac_volume)
   if(!..())
      return
   ...
   ..()

What's so bad about this? I usually get these but this one's readable and not awful
Image

Next

Return to Coding

Who is online

Users browsing this forum: No registered users