Announcement

Collapse
No announcement yet.

Help with death messages (weapons

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with death messages (weapons

    How do i add random messages IE when some dies form a weapon, uses an item or connects, disconnects, and suicides? (yes i am using reaper bot, but only to test most of this out.)

    void () ClientConnect =
    {

    local string tmp;
    local float num;

    bprint (self.netname);
    bprint (" has joined the fight\n");
    self.id = FindGood();
    self.impulse = 204.000;
    initscore ();
    if ( intermission_running ) {

    ExitIntermission ();

    }

    };

    void () ClientDisconnect =
    {

    local float num;

    if ( gameover )
    {

    return ;

    }
    bprint (self.teamname);
    bprint (self.netname);
    bprint (" left the game with ");
    MakeGood(self.id);
    bprint (ftos (self.frags));
    bprint (" kills\n");
    sound (self,CHAN_BODY,"player/tornoff2.wav",TRUE,ATTN_NONE);
    self.classname = "nobody";
    set_suicide_frame ();

    };

    void (entity targ, entity attacker) ClientObituary =
    {

    local float rnum;
    local string deathstring;
    local string deathstring2;
    local string deathstring3;
    local string deathstring4;
    local string deathstring5;
    local string deathstring6;

    rnum = random ();
    if ( ((targ.classname == "player") || (targ.classname == "dmbot")) ) {

    if ( (attacker.classname == "teledeath") )
    {
    bprint (targ.netname);
    local float zufall;
    zufall = random(); // randomize death messages
    if (zufall > 0.75)
    bprint (" was telefraged by ");
    else if (zufall > 0.5)
    bprint (" got in the way of ");
    else if (zufall > 0.25)
    bprint (" experienced birthing by ");
    else
    bprint (" had his personal space invaded by ");
    bprint (attacker.owner.netname);
    bprint ("\n");
    if ( (attacker.owner.classname == "dmbot") )
    {

    TELEFRAGFLAG = TRUE;

    }
    attacker.owner.frags = (attacker.owner.frags + TRUE);
    countkill (attacker.owner,targ);
    if (attacker.owner.classname == "dmbot")
    {
    WriteByte( MSG_ALL, MSG_UPDATEFRAGS );
    WriteByte( MSG_ALL, attacker.owner.id );
    WriteShort( MSG_ALL, attacker.owner.frags );
    }

    return ;

    }
    if ( (attacker.classname == "teledeath2") )
    {

    bprint ("Satan's power deflects ");
    bprint (targ.teamname);
    bprint (targ.netname);
    bprint ("'s telefrag\n");
    countkill (targ,targ);
    targ.frags = (targ.frags - TRUE);
    if (targ.classname == "dmbot")
    {
    WriteByte( MSG_ALL, MSG_UPDATEFRAGS );
    WriteByte( MSG_ALL, targ.id );
    WriteShort( MSG_ALL, targ.frags );
    }

    return ;

    }
    if ( ((attacker.classname == "player") || (attacker.classname == "dmbot")) )
    {

    if ( (targ == attacker) ) {

    attacker.frags = (attacker.frags - TRUE);
    if (attacker.classname == "dmbot")
    {
    WriteByte( MSG_ALL, MSG_UPDATEFRAGS );
    WriteByte( MSG_ALL, attacker.id );
    WriteShort( MSG_ALL, attacker.frags );
    }

    countkill (attacker,attacker);
    bprint (targ.teamname);
    bprint (targ.netname);
    if ( ((targ.weapon == FL_GODMODE) && (targ.waterlevel > TRUE)) ) {

    bprint (" discharges into the water.\n");
    return ;

    }
    if ( (targ.weapon == FL_INWATER) ) {

    bprint (" tries to put the pin back in\n");

    }
    else
    {

    if ( rnum )
    {

    bprint (" becomes bored with life\n");

    }
    else
    {

    bprint (" checks if his weapon is loaded\n");

    }


    }
    return ;

    }
    else
    {

    attacker.frags = (attacker.frags + TRUE);

    if (attacker.classname == "dmbot")
    {
    WriteByte( MSG_ALL, MSG_UPDATEFRAGS );
    WriteByte( MSG_ALL, attacker.id );
    WriteShort( MSG_ALL, attacker.frags );
    }

    countkill (attacker,targ);
    rnum = attacker.weapon;
    if ( (rnum == IT_AXE) )
    {
    deathstring = " was ax-murdered by ";
    deathstring = " was sliced by ";
    deathstring = " was diced by ";
    deathstring2 = "\n";
    }
    if ( (rnum == IT_SHOTGUN) )
    {
    deathstring = " chewed on ";
    deathstring2 = "'s lead\n";

    deathstring = " sucked on ";
    deathstring2 = "'s shottie\n";

    }
    if ( (rnum == IT_SUPER_SHOTGUN) )
    {

    deathstring = " ate 2 loads of ";
    deathstring2 = "'s shotgun shells\n";

    }
    if ( (rnum == IT_NAILGUN) )
    {

    deathstring = " was nailed by ";
    deathstring2 = "'s nailgun\n";

    }
    if (rnum == IT_SUPER_NAILGUN)
    {
    deathstring = " was nailed to the wall by ";
    deathstring2 = "'s supernail gun\n";
    }
    if ( (rnum == IT_GRENADE_LAUNCHER) )
    {

    deathstring = " eats ";
    deathstring2 = "'s pineapple\n";
    if ( (targ.health < -40.000) )
    {

    deathstring = " was gibbed by ";
    deathstring2 = "'s grenade\n";

    }

    }
    if (rnum == IT_ROCKET_LAUNCHER)
    {
    deathstring = " found ";
    deathstring2 = "'s rocket up his ass\n";
    if (targ.health < -40)
    {
    deathstring = " was destroyed by ";
    deathstring2 = "'s rocket\n" ;
    }
    }
    if ( (rnum == IT_LIGHTNING) ) {

    deathstring = " accepts ";
    if ( (attacker.waterlevel > TRUE) )
    {

    deathstring2 = "'s discharge\n";

    }
    else
    {

    deathstring2 = "'s shaft\n";

    }

    }
    bprint (targ.teamname);
    bprint (targ.netname);
    bprint (deathstring);
    bprint (attacker.teamname);
    bprint (attacker.netname);
    bprint (deathstring2);

    }
    return ;

    } else {

    targ.frags = (targ.frags - TRUE);
    if (targ.classname == "dmbot")
    {
    WriteByte( MSG_ALL, MSG_UPDATEFRAGS );
    WriteByte( MSG_ALL, targ.id );
    WriteShort( MSG_ALL, targ.frags );
    }

    rnum = targ.watertype;
    countkill (targ,targ);
    bprint (targ.teamname);
    bprint (targ.netname);
    if ( (rnum == CONTENT_WATER) ) {

    if ( (random () < 0.500) ) {

    bprint (" sleeps with the fishes\n");

    } else {

    bprint (" sucks it down\n");

    }
    return ;

    } else {

    if ( (rnum == CONTENT_SLIME) ) {

    if ( (random () < 0.500) ) {

    bprint (" gulped a load of slime\n");

    } else {

    bprint (" can't exist on slime alone\n");

    }
    return ;

    } else {

    if ( (rnum == CONTENT_LAVA) ) {

    if ( (targ.health < -15.000) ) {

    bprint (" burst into flames\n");
    return ;

    }
    if ( (random () < 0.500) ) {

    bprint (" turned into hot slag\n");

    } else {

    bprint (" visits the Volcano God\n");

    }
    return ;

    }

    }

    }
    if ( (attacker.flags & FL_MONSTER) ) {

    if ( (attacker.classname == "monster_army") ) {

    bprint (" was shot by a Grunt\n");

    }
    if ( (attacker.classname == "monster_demon1") ) {

    bprint (" was eviscerated by a Fiend\n");

    }
    if ( (attacker.classname == "monster_dog") ) {

    bprint (" was mauled by a Rottweiler\n");

    }
    if ( (attacker.classname == "monster_dragon") ) {

    bprint (" was fried by a Dragon\n");

    }
    if ( (attacker.classname == "monster_enforcer") ) {

    bprint (" was blasted by an Enforcer\n");

    }
    if ( (attacker.classname == "monster_fish") ) {

    bprint (" was fed to the Rotfish\n");

    }
    if ( (attacker.classname == "monster_hell_knight") ) {

    bprint (" was slain by a Death Knight\n");

    }
    if ( (attacker.classname == "monster_knight") ) {

    bprint (" was slashed by a Knight\n");

    }
    if ( (attacker.classname == "monster_ogre") ) {

    bprint (" was destroyed by an Ogre\n");

    }
    if ( (attacker.classname == "monster_oldone") ) {

    bprint (" became one with Shub-Niggurath\n");

    }
    if ( (attacker.classname == "monster_shalrath") ) {

    bprint (" was exploded by a Vore\n");

    }
    if ( (attacker.classname == "monster_shambler") ) {

    bprint (" was smashed by a Shambler\n");

    }
    if ( (attacker.classname == "monster_tarbaby") ) {

    bprint (" was slimed by a Spawn\n");

    }
    if ( (attacker.classname == "monster_vomit") ) {

    bprint (" was vomited on by a Vomitus\n");

    }
    if ( (attacker.classname == "monster_wizard") ) {

    bprint (" was scragged by a Scrag\n");

    }
    if ( (attacker.classname == "monster_zombie") ) {

    bprint (" joins the Zombies\n");

    }
    return ;

    }
    if ( (attacker.classname == "explo_box") ) {

    bprint (" blew up\n");
    return ;

    }
    if ( ((attacker.solid == SOLID_BSP) && (attacker != world)) )
    {

    local float zufall;
    zufall = random(); // randomize death messages
    if (zufall > 0.75)
    bprint (" was squished\n");
    else if (zufall > 0.5)
    bprint (" did the monster mash\n");
    else if (zufall > 0.25)
    bprint (" was squashed\n");
    else
    bprint (" is more compact\n");
    return;
    }
    if ( (targ.deathtype == "falling") ) {

    targ.deathtype = "";
    bprint (" fell to his death\n");
    return ;

    }
    if ( ((attacker.classname == "trap_shooter") || (attacker.classname == "trap_spikeshooter")) ) {

    bprint (" was spiked\n");
    return;

    }
    if ( (attacker.classname == "fireball") ) {

    bprint (" ate a lavaball\n");
    return ;

    }
    if ( (attacker.classname == "trigger_changelevel") ) {

    bprint (" tried to leave\n");
    return ;

    }
    local float zufall;
    zufall = random(); // randomize death messages
    if (zufall > 0.75)
    bprint (" died\n");
    else if (zufall > 0.5)
    bprint (" went to the wrong place\n");
    else if (zufall > 0.25)
    bprint (" went somewhere it wasn't supposed to be in\n");

    }

    }

    };
    I am like a stray dog, lost in between what I do and what I should do.
    But sometimes, all you need is Imagination.


  • #2
    as you can see, thanks to Seven i've added Zufall to work as random death messages which works for the most part except i cannot print randomly when i either kill someone with a weapon but then everything prints when ever I commit suicide.
    I've also added death strings for the weapons but it didn't print the others (that was the problem with weapons.)

    bprint (self.netname);
    bprint (self.netname);
    local float zufall;
    zufall = random(); // randomize death messages
    if (zufall > 0.75)
    bprint (" wins the Darwin Awards\n");
    if (zufall > 0.5)
    bprint (" Budd Dwyered\n");
    if (zufall > 0.25)
    bprint (" did the game a favor\n");
    if (zufall > 0.35)
    bprint (" is suicidal\n");
    if (zufall > 0.45)
    bprint (" thought life was tough\n");
    if (zufall > 0.55)
    bprint (" hates himself\n");
    if (zufall > 0.65)
    bprint (" is emo\n");
    set_suicide_frame ();
    self.modelindex = modelindex_player;
    self.frags = self.frags - 2; // extra penalty
    I'm also curious about you can add more death messages in the monster field as well.
    I am like a stray dog, lost in between what I do and what I should do.
    But sometimes, all you need is Imagination.

    Comment


    • #3
      Halp.


      I am like a stray dog, lost in between what I do and what I should do.
      But sometimes, all you need is Imagination.

      Comment


      • #4
        Each of those IF conditions are being tested, and then the code executed if they are true.
        lists like that are fine if every option is mutually exclusive.
        Here they are not. For instance, the first two, if its larger than 0.75 is checked, and whatever is printed, then if its larger than 0.5 is checked, then whatever is printed...
        1 is larger than both, so both are printed.

        You need some sort of escape. You can put a return statement under each if, and then the first one found to be true will be used. But then

        set_suicide_frame ();
        self.modelindex = modelindex_player;
        self.frags = self.frags - 2; // extra penalty

        these calls wont be made. What I would do is wrap everything above that into a seperate function that returns a string. and bprint that string.

        I hate to be that guy..but if you're playing with code....be prepared to play with code.
        Gnounc's Project Graveyard Gnounc's git repo

        Comment


        • #5
          Hello Shambler234,

          If you use multiple "if" checks in a row, without "else" in front, every positive check will be executed.
          That is exactly what gnounc said.
          You *can* do this if you have a reason.
          In your case it would be better to use "else if" after the first "if".

          Furthermore you should not switch from one direction to the other.
          Your checks are:
          if (zufall > 0.75)
          ...
          if (zufall > 0.5)
          ...
          if (zufall > 0.25)
          ...
          if (zufall > 0.35)
          ...
          if (zufall > 0.45)
          ...
          if (zufall > 0.55)
          ...
          if (zufall > 0.65)
          ...
          You go down from "1" to "0.25" and then up again to "0.65" ?
          That makes no sense.
          Because if a value is bigger than 0.75 it is also bigger than 0.65 and 0.5 and 0.55 and 0.45 ... and so on. That is why multiple deathmessages are printed.


          The example code I gave you is in one direction, using the "else if" checks:
          local float zufall;
          zufall = random(); // randomize death messages
          if (zufall > 0.75)
          bprint (" was squished\n");
          else if (zufall > 0.5)
          bprint (" did the monster mash\n");
          else if (zufall > 0.25)
          bprint (" was squashed\n");
          else
          bprint (" is more compact\n");
          Each death message has a chance of 25% to be printed here. And only 1 message will be printed.
          If you use this principle on all death messages, it will work as intended.

          It doesnt matter if a monster killed the player or a weapon or a teleporter or anything. Just be sure to keep your { } around each block so that they are tight together and are used for that specific death case.

          Have fun with your new death messages

          I remember Canadian*Sniper also created new death messages many years ago...

          Comment


          • #6
            local float monoz;
            monoz = random(); // randomize death messages
            if (monoz > 0.75)
            bprint (" was killed by monoz, what's new?\n");
            else if (monoz > 0.5)
            bprint (" rode monoz's rocket, welcome to the club\n");
            else if (monoz> 0.25)
            bprint (" was squashed by zero.exe\n");
            else
            bprint (" is more compact due to monoz\n");



            else
            stuffcmd ("profile")
            Cbuf_AddText (va("say ZeroQuake GL version 1.10\n"));

            Comment

            Working...
            X