logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Weapon order (under the same number) (Read 6097 times)
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Weapon order (under the same number)
Jan 27th, 2013 at 6:00pm
Print Post  
My mod includes new weapons -> and those weapons run along with the old ones. Unfortunately in most cases they are direct upgrades.

Unfortunately why -> the weapon weapon switching works is complete non-sense to me. Say I've got a Stinger, and a New Stinger. The New Stinger is more powerful, but goes on the same slot (3).

When I press 3 and I'm holding another weapon, it might give me the stinger... but it might also give me the new stinger.

The thing is, which one it gives me keeps changing. If you throw the weapons a few times and pick them back up, the orders will change. Sometimes, if you hold the Dispersion Pistol and press 3, it'll give you the normal one, but if I was holding the Flak Cannon, it'll give me the New Stinger.

Complete non-sense.

So. I'm wondering if there is a solution around this. Having multiple weapons in a slot is just part of my mod. But not having the ability to predict which weapon you get when you press the button is a huge issue. You WANT to know if you need to press 3 once or twice to get the New Stinger, and it needs to remain that way, no matter what.


Is there any way to get around this?
  
Back to top
 
IP Logged
 
GreatEmerald
Oldunreal MasterPoster
*
Offline


The Great Emerald

Posts: 5361
Location: Vilnius, Lithuania
Joined: May 21st, 2007
Gender: Male
Re: Weapon order (under the same number)
Reply #1 - Jan 27th, 2013 at 6:46pm
Print Post  
Does that also happen with UPak weapons? Maybe they also ran into this issue and wrote some code to prevent it.
Otherwise, sounds like it gives you the weapon that is "in front" or "in the back" relative to whether your current weapon is in an earlier slot or in a later slot. You probably can reorder weapons on pickup, so that for instance your new stinger would always be considered "on top", but it will always switch to the bottom one if you switch from DP/Automag anyway...
  
Back to top
WWW  
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Weapon order (under the same number)
Reply #2 - Jan 29th, 2013 at 4:32pm
Print Post  
That explains how the engine handles it...

Well... how -can- I change the order in which the weapons are? Is that really possible? If I could dynamically change the order of every of a player's weapon I could figure something out.
  
Back to top
 
IP Logged
 
GreatEmerald
Oldunreal MasterPoster
*
Offline


The Great Emerald

Posts: 5361
Location: Vilnius, Lithuania
Joined: May 21st, 2007
Gender: Male
Re: Weapon order (under the same number)
Reply #3 - Jan 29th, 2013 at 5:02pm
Print Post  
It should be. Check what happens when something gets picked up. There should be a function that registers it as inventory, so you would be able to override that with a custom one.
  
Back to top
WWW  
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Weapon order (under the same number)
Reply #4 - Feb 14th, 2013 at 4:37pm
Print Post  
Took a while for me to get to that.

Well, I looked around everywhere. I have zero understanding of inventory and weapon management and how its handled. Sounded simple from your words but I couldn't find relevant variables.
  
Back to top
 
IP Logged
 
GreatEmerald
Oldunreal MasterPoster
*
Offline


The Great Emerald

Posts: 5361
Location: Vilnius, Lithuania
Joined: May 21st, 2007
Gender: Male
Re: Weapon order (under the same number)
Reply #5 - Feb 14th, 2013 at 6:25pm
Print Post  
Well, when an item is picked up, then there are two things that are interacting - a Pawn and an Inventory. It makes more sense to have the Inventory be the one that handles the pickup logic. Since we are interested in the time it's laying on the ground as a pickup, we look at the state Pickup. The function that gets called when two actors come in contact (and they have collision) is called function Touch. From here, the line 608 is what handles all the logic. So we need to go to function SpawnCopy. Since it's not inside the Pickup state, look outside the scope. It's on line 296. Here the only interesting line is 314. So let's see function GiveTo. And here you have it, line 292, "Other.AddInventory( Self );".

So let's go find that. Other is of type Pawn. AddInventory is on line 609. And here it is shown that inventory adding is controlled by the Pawn.Inventory linked list, where the link to the next item on the list is Pawn.Inventory.Inventory (the variable actually defined in Actor). So by rearranging the chain you might get some results. Albeit it could be either dangerous or tricky to pull off when online.

Alternatively, you can look at what happens when you switch weapons. That might be safer/easier to change.
  
Back to top
WWW  
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Weapon order (under the same number)
Reply #6 - Feb 15th, 2013 at 12:27am
Print Post  
Thanks a lot. I think that confirms I'll give up on this idea, however. Re-arranging the list sounds risky if thats even really possible, its not something I've ever tried to do -> but I don't really see how I'd do anything good with that. Its not how I expected it to be.

The SwitchWeapon function in PlayerPawn seems easy to work it. But I always refused to use new PlayerPawn since it won't work with JCoopZ and the like.

Looking at the code, I'd actually say a feature request for this in a 227 patch would make more sense.
  
Back to top
 
IP Logged
 
GreatEmerald
Oldunreal MasterPoster
*
Offline


The Great Emerald

Posts: 5361
Location: Vilnius, Lithuania
Joined: May 21st, 2007
Gender: Male
Re: Weapon order (under the same number)
Reply #7 - Feb 15th, 2013 at 10:36am
Print Post  
Are you sure you can't change the switching logic from your own weapons? Looking at the weapon switching functions, it seems that the pawn switches to whatever is set to PendingWeapon when ChangeWeapon() is called. Changing the PendingWeapon should not be too difficult, although I haven't looked at what happens when you press the button to switch weapons. It would be logical to have weapons themselves handling the switching, and that is how it works in UT2004, but I haven't looked into how it works in Unreal yet.
  
Back to top
WWW  
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Weapon order (under the same number)
Reply #8 - Feb 16th, 2013 at 5:54pm
Print Post  
I've looked and looked but I've seen no solution.

I can intercept the ChangedWeapon in a dummy item or I could do it in a weapon, but that doesn't mean I can change anything meaningful. How -do- you change pendingweapon? Its a weapon, not a class<weapon>, and I can't seem to find any way to change it, or even compare it.

I can't understand enough about it.
  
Back to top
 
IP Logged
 
GreatEmerald
Oldunreal MasterPoster
*
Offline


The Great Emerald

Posts: 5361
Location: Vilnius, Lithuania
Joined: May 21st, 2007
Gender: Male
Re: Weapon order (under the same number)
Reply #9 - Feb 17th, 2013 at 4:40pm
Print Post  
PendingWeapon is a weapon in your inventory. Or a Weapon in your Inventory Smiley You can access all the inventory of a pawn (or any other Actor, although I don't see why any other actors would need to have inventory...) by accessing Pawn.Inventory. It's a linked list, with the next item being Pawn.Inventory.Inventory, and so on. A Weapon(Pawn.Inventory) == true is a weapon in the pawn's inventory.

So here's a sample code:
Code
Select All
if (MyPawn.PendingWeapon.InventoryGroup == MyInventoryGroup)
{
  for (I = MyPawn.Inventory; I != None; I = I.Inventory)
  {
    if (MyWeapon(I) != None)
    {
      MyPawn.PendingWeapon = Weapon(I);
      break;
    }
  }
} 

  
Back to top
WWW  
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Weapon order (under the same number)
Reply #10 - Feb 17th, 2013 at 5:42pm
Print Post  
I think I'm more confused than I was. I have no idea how to use any of this, sorry :/ I tried, but I'm not getting it at all. Well, I think I can tell if the player has one of a kind of weapon, but thats it, not how to bring it back to PendingWeapon.
  
Back to top
 
IP Logged
 
GreatEmerald
Oldunreal MasterPoster
*
Offline


The Great Emerald

Posts: 5361
Location: Vilnius, Lithuania
Joined: May 21st, 2007
Gender: Male
Re: Weapon order (under the same number)
Reply #11 - Feb 17th, 2013 at 7:40pm
Print Post  
Simply assign. PendingWeapon is just a reference to an actor. Type "weapon" means that it expects to be assigned to a spawned actor of class Weapon. So PendingWeapon = MyWeapon will make PendingWeapon point to MyWeapon.
  
Back to top
WWW  
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Weapon order (under the same number)
Reply #12 - Feb 18th, 2013 at 1:12am
Print Post  
Yeah, okay, but how do you choose the right weapon out of the existing weapons? The code you posted made sense for that, looking at it, but I don't know how to use it.
  
Back to top
 
IP Logged
 
GreatEmerald
Oldunreal MasterPoster
*
Offline


The Great Emerald

Posts: 5361
Location: Vilnius, Lithuania
Joined: May 21st, 2007
Gender: Male
Re: Weapon order (under the same number)
Reply #13 - Feb 18th, 2013 at 6:16am
Print Post  
That depends on how you want it to work and where you override the function. Generally you need to check if the PendingWeapon has the same InventoryGroup as your custom weapon (that indicates the same slot), then check if you need to reassign the PendingWeapon to either your custom weapon or the other weapon in the slot. For instance, if you always assign PendingWeapon to your custom weapon, then the player will always have your weapon on top, and won't even be able to select the other weapon. And if you assign PendingWeapon to your custom weapon when the selected weapon is not already your custom weapon, then it should work by making your weapon be constantly on top and yet allowing to switch between the two weapons.
  
Back to top
WWW  
IP Logged
 
SFJake
Full Member
***
Offline


Oldunreal member

Posts: 248
Joined: Aug 15th, 2010
Gender: Male
Re: Weapon order (under the same number)
Reply #14 - Feb 18th, 2013 at 7:26am
Print Post  
If I read the word weapon again I think I'm going to pass out.

I got all that, but I don't know how else to put it. I don't know how to assign that weapon to PendingWeapon. I don't get that. My problem is more a matter of syntax than logic.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo