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.

Replacing UT weapons (Even when they're given out!)

Discussion in 'Programming' started by Shiit, Jan 6, 2002.

  1. Shiit

    Shiit Shiit

    Joined:
    Dec 19, 2000
    Messages:
    168
    Likes Received:
    0
    I couldn't help notice that the ReplaceWith(...) doesn't do Inventory class items that are at Location (0,0,0). Sadly, this means all weapons that are spawned seperatly and given to a player directly! (All weapons in LastManStanding, all weapons in weapon giver muties) I've tried fixing this function, but found out why Epic hadn't in the first place:
    The ReplaceWith(...) function is called directly after a class is spawned (Probably from within the Spawn(...) function) and, therefore, before any variables can be set. So, when a weapon is spawned by an object (usually a GameInfo) and it is stored in a pointer, the ReplaceWith(...) function is called before the GameType calls GiveTo(...). Result: If you remove the old inventory item and spawn a new one, the local pointer the GameType uses to call GiveTo(...) is no longer correct (It'll be None), and GiveTo(...) will never be called. However, you can't call it yourself because the Owner variable isn't yet set.
    Dilemma!
    So, my question is: How can you correctly replace an inventory item that is about to be given to a player? (I could think of a VERY sloppy method, that features an info class that replaces the item 1 tick later, and give it to the player afterwards, since the Owner var is set be then. But is there a less sloppy method?)
     
  2. eXoR

    eXoR Lead coder

    Joined:
    Oct 22, 2001
    Messages:
    36
    Likes Received:
    0
    You could try a spawnnotify.
     
  3. Shiit

    Shiit Shiit

    Joined:
    Dec 19, 2000
    Messages:
    168
    Likes Received:
    0
    I'm afraid a spawnnotify works in the same manner as a mutator's checkreplacement. :(
    I'll just take the sloppy approach.
     
  4. Postal

    Postal I apear to have lost my pin.

    Joined:
    Nov 14, 1999
    Messages:
    1,388
    Likes Received:
    0
    for example, if you wanted to oh replace the impact hammer with a machette, I would insted of using a replace call, destroy all impact hammers(people dont put them in maps I hope), then have a seperate spawning of the machette and add that to the players inv
     
  5. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,913
    Likes Received:
    36
    Nope, SpawnNotify can work with an actor before that actor itself knows it was spawned. With this great thing you can even control what the Spawn() function returns!
     
  6. Shiit

    Shiit Shiit

    Joined:
    Dec 19, 2000
    Messages:
    168
    Likes Received:
    0
    Hmm... Yes... SpawnNotification(...) does return a pointer to the replaced actor... Is this also the pointer Spawn(...) returns? I'll try it!
     
  7. Papapishu

    Papapishu 我是康

    Joined:
    Jun 18, 2001
    Messages:
    2,043
    Likes Received:
    0
    Does this work with arena mutator?
    Like if someone wants to play instagib and I place a manchete in theis inventory, would it stay there, or would it be removed?
     
  8. Shiit

    Shiit Shiit

    Joined:
    Dec 19, 2000
    Messages:
    168
    Likes Received:
    0
    It would be removed, I guess. Anyway, that approach doesn't work in, for example, RocketArena (a mod that was actually coded pretty unslick. I'm encountering problems regularly caused by it's code, not my own. For example, it doesn't have allow you to use the Mutie's Modifyplayer function), since it gives weapons every now and then, and doesn't quite notify the mutator.
    Well, the main problem's out of the way now, as the SpawnNotify did exactly what I needed.
     
  9. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,913
    Likes Received:
    36
    The mutator's AlwaysKeep() and CheckReplacement() functions get called from the PreBeginPlay() function of the actor AFTER it has been spawned and maybe replaced by a SpawnNotify. If you want to avoid the Arena mutator problem either use the Mutator.AlwaysKeep() function (return true) or skip the actor's PreBeginPlay() function if you created that actor.
     

Share This Page