1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Fyi

Discussion in 'Programming' started by Papapishu, Jan 10, 2002.

  1. Papapishu

    Papapishu 我是康

    Joined:
    Jun 18, 2001
    Messages:
    2,043
    Likes Received:
    0
    I found an interesting function in the inventory class.
    SpawnCopy(pawn other)
    And an old experiment came to my mind, one where I tried to make a map where the player would start with a special inventory item, like the ducker...
    This might be most interesting for those who both map and code.
    This is how you do:
    If you want, say an instagibrifle given to the players, make your map, and then add an extra room somewhere where noone can enter.
    Place a supershockrifle in there.
    Before placing the playerstarts, open the actor browser, find playerstart, rightclick it and select new package.
    As packagename type MyLevel, so that it's saved in the same level, and call the class whatever you wish...
    Add this script:
    Code:
    function PlayTeleportEffect(actor Incoming, bool bOut)
    {
    local supershockrifle i;
    local bool finished;
    super.PlayTeleportEffect(incoming,bOut);
    fin=false;
    foreach allactors (class'supershockrifle',i)
    {
    if (finished==false)
    {
     finished=true;
     i.spawncopy(pawn(incoming));
     pawn(incoming).switchtobestweapon();
    }
    }
    }
    
    
    The switchtobestweapon is just to make sure that the player automatically selects the shockrifle (if it's the best one that is...)
    Now compile changed scripts and if you get no errors, you can place this class in the level instead of the playerstarts, and every pawn that is spawned there gets a supershockrifle...
     
  2. Brood_of_Evil

    Brood_of_Evil Selene's martyr

    Joined:
    Nov 3, 2001
    Messages:
    147
    Likes Received:
    0
    Hmmm, you don't have have to place a copy of the weapon in the map, I would call that bad practice...instead you can do this.

    Code:
    function PlayTeleportEffect(actor Incoming, bool bOut)
    {
         local SuperShockRifle SR;
    
         if ( Level.Game.bDeathMatch && Incoming.IsA('PlayerPawn') )
             PlayerPawn(Incoming).SetFOVAngle(135);
         Level.Game.PlayTeleportEffect(Incoming, bOut, Level.Game.bDeathMatch );
    
         if(Incoming.IsA('Pawn') 
             && Pawn(Incoming).bIsPlayer 
             && Pawn(Incoming).FindInventoryType(class'SuperShockRifle') == None)
         {
              SR = Spawn(class'SuperShockRifle', Incoming,,Incoming.Location);
              SR.GiveTo(Pawn(Incoming));
              SR.bHeldItem = True;
    
              Pawn(Incoming).SwitchToBestWeapon();
         }
    }
    
    And to make things even cooler, you could add a variable like this:
    Code:
    var () class<TournamentWeapon> SpawnedWeapon;
    
    And change the code like this:
    Code:
    function PlayTeleportEffect(actor Incoming, bool bOut)
    {
         local TournamentWeapon SW;
    
         if ( Level.Game.bDeathMatch && Incoming.IsA('PlayerPawn') )
             PlayerPawn(Incoming).SetFOVAngle(135);
         Level.Game.PlayTeleportEffect(Incoming, bOut, Level.Game.bDeathMatch );
    
         if(Incoming.IsA('Pawn') 
             && Pawn(Incoming).bIsPlayer 
             && Pawn(Incoming).FindInventoryType(SpawnedWeapon) == None
             && SpawnedWeapon != None)
         {
              SW = Spawn(SpawnedWeapon, Incoming,,Incoming.Location);
              SW.GiveTo(Pawn(Incoming));
              SW.bHeldItem = True;
    
              Pawn(Incoming).SwitchToBestWeapon();
         }
    }
    
    That way, the mapper can set which weapon to spawn with each different player start from defaultproperties!! :D
     
    Last edited: Jan 10, 2002
  3. gor

    gor New Member

    Joined:
    Dec 30, 2001
    Messages:
    40
    Likes Received:
    0
    hey thanks for that info, definately something I can use..
     
  4. gor

    gor New Member

    Joined:
    Dec 30, 2001
    Messages:
    40
    Likes Received:
    0
    Took me a while to search back through old threads to find this..


    ok whats happening :- I would like to spawn the player with a pickup instead of a weapon, ok so that works.

    the problem is that the first time you spawn into an online game you dont get given the pickup - only when you respawn from having died..

    Also I would like for the pickup to be automatically activated -
    but it seems like it needs to be selected first.

    please help - if you would talk to me in icq 63691267 I could explain my problem a lot better..

    thanks.
     
  5. navboy

    navboy New Member

    Joined:
    Jan 5, 2001
    Messages:
    340
    Likes Received:
    0
    cool stuff ... i don't understand the difference between these two approaches:

    i.spawncopy(pawn(incoming));

    versus

    SW = Spawn(SpawnedWeapon, Incoming,,Incoming.Location);
    SW.GiveTo(Pawn(Incoming));


    As far as it being a pickup, just a few days ago i did something very much like this giving everybody the DamageAmp ... As far activating it yes i had to add a line like Item.Activate() and that almost worked. But at game beging it seems like it would ignore certain lines from the BEGIN section of the Activated state of the pickup ... For example, sure enough damage scaling was increased, but it will never play the Activated sound even though that line is in the same block of code as the damagescaling. Weird.
     
  6. gor

    gor New Member

    Joined:
    Dec 30, 2001
    Messages:
    40
    Likes Received:
    0
    ..and if you tried the shield belt you would find that the the goldskin mesh would never appear..

    so how to get around this?
     
  7. Brood_of_Evil

    Brood_of_Evil Selene's martyr

    Joined:
    Nov 3, 2001
    Messages:
    147
    Likes Received:
    0
    Try calling the Activate() function on the item after you've spawned and give it to the player
     

Share This Page