Help W. an experiment?

Discussions about Coding and Scripting
Post Reply
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

Help W. an experiment?

Post by zacman »

Well, I'm trying to make a PlayerPawn that starts with a unique weapon (Think U4ET) but so far I'm completely lost... I've gotten some help, but so far haven't really got anywhere... So far all I have is the variables that say what weapons CAN be added, but so far they do nothing :/ Can anyone help?
Image[url=steam://friends/add/76561198048595886]Image[/url]
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Help W. an experiment?

Post by Feralidragon »

In unrealsp a guy already told you how:
http://www.unrealsp.org/forums/viewtopic.php?t=1200

But I have something to add here: you can use that same code in the pawn itself or in another mutator (trust me, I used it for XPickups and Nali Weapons II X weapon prizes/default inventory).
In this case, you aplly the code directly in your custom playerpawn (as you want), or even in custom bots if you want so:

Code: Select all

//To aplly in a custom playerpawn
var() class<Weapon> WeapClass;

function AddWeaponToPlayer()
{
local Weapon newWeapon; 

if( (WeapClass!=None) && (FindInventoryType(WeapClass)==None) && !Self.IsA('Spectator'))
   {
      newWeapon = Spawn(WeapClass,,,Location);
      if( newWeapon != None )
      {
         newWeapon.Instigator = Self;
         newWeapon.BecomeItem();
         AddInventory(newWeapon);
         newWeapon.BringUp();
         newWeapon.GiveAmmo(Self);
         newWeapon.SetSwitchPriority(Self);
         newWeapon.WeaponSet(Self);
      }
   }

}
Well, I modified it a little bit to fullfill your needs.
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

Re: Help W. an experiment?

Post by zacman »

Thx :tu:
Ya, Qtit's one couldn't work, as I needed to apply it as a gametype or Mutator instead.
<Edit:> no, still doesn't work :(
Still starts with just enforcer and Impact Hammer....
Image[url=steam://friends/add/76561198048595886]Image[/url]
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Help W. an experiment?

Post by Feralidragon »

Be sure you aplly this code to the playerpawn itself and that WeapClass is set to the weapon you want. Double check it because something like classes and other default variables returning to none also happenned to me when compiling my vehicles, so your WeapClass might be None, and so you get no weapon. Check it in the Actor browser (default properties).

If everything is fine in those settings, tell me and I will see what can go wrong on this more closelly. :tu:
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

Re: Help W. an experiment?

Post by zacman »

Yup, all is done... The weapon (As it was just a test-haven't made full one yet) was the Pulsegun
Image[url=steam://friends/add/76561198048595886]Image[/url]
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Help W. an experiment?

Post by Feralidragon »

Try this (this should work, but I didn't try it though):

Code: Select all

//To aplly in a custom PlayerPawn
var() class<Weapon> WeapClass;
var bool bOldHidden[2];

function Tick(float Delta)
{
   bOldHidden[0] = bOldHidden[1];
   bOldHidden[1] = bHidden;

   if (bOldHidden[0] && !bOldHidden[1])
         AddWeaponToPlayer();

   Super.Tick(Delta);
}

function AddWeaponToPlayer()
{
local Weapon newWeapon; 

if( (WeapClass!=None) && (FindInventoryType(WeapClass)==None) && !Self.IsA('Spectator'))
   {
      newWeapon = Spawn(WeapClass,,,Location);
      if( newWeapon != None )
      {
         newWeapon.Instigator = Self;
         newWeapon.BecomeItem();
         AddInventory(newWeapon);
         newWeapon.BringUp();
         newWeapon.GiveAmmo(Self);
         newWeapon.SetSwitchPriority(Self);
         newWeapon.WeaponSet(Self);
      }
   }

}
I just added a function to detect if you are (re)spawning to activate the function (I actually forgot that part when giving the other code to you lol).
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

Re: Help W. an experiment?

Post by zacman »

Won't compile-Bool Arrays not allowed... I don't think it'll work without that in there.
Image[url=steam://friends/add/76561198048595886]Image[/url]
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Help W. an experiment?

Post by Feralidragon »

Sorry again :?
Another mistake there, I forgot that I couldn't build arrays with boolean variables (I found that out when I had the same issue when doing something in the weapon lockers in XPickups, and I then to had to use another type of variable since I really needed an array there).
In this case, we don't need the array to fullfill the same effect, so instead of that, try this:

Code: Select all

//To aplly in a custom PlayerPawn
var() class<Weapon> WeapClass;
var bool bOldHidden1, bOldHidden2;

function Tick(float Delta)
{
   bOldHidden1 = bOldHidden2;
   bOldHidden2 = bHidden;

   if (bOldHidden1 && !bOldHidden2)
         AddWeaponToPlayer();

   Super.Tick(Delta);
}

function AddWeaponToPlayer()
{
local Weapon newWeapon; 

if( (WeapClass!=None) && (FindInventoryType(WeapClass)==None) && !Self.IsA('Spectator'))
   {
      newWeapon = Spawn(WeapClass,,,Location);
      if( newWeapon != None )
      {
         newWeapon.Instigator = Self;
         newWeapon.BecomeItem();
         AddInventory(newWeapon);
         newWeapon.BringUp();
         newWeapon.GiveAmmo(Self);
         newWeapon.SetSwitchPriority(Self);
         newWeapon.WeaponSet(Self);
      }
   }

}
That should work now...
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

Re: Help W. an experiment?

Post by zacman »

Nope :(
Wow, didn't realise this would be so complex...
Image[url=steam://friends/add/76561198048595886]Image[/url]
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Help W. an experiment?

Post by Feralidragon »

Well, it might not work in the first spawn. So if it compliles, suicide or something in game and respawn to see if it works. I think that's the problem now.

EDIT: I might test code at home to get it to work. So far I didn't test a thing about this code, but I will then.
User avatar
TheDane
Masterful
Posts: 660
Joined: Tue Feb 12, 2008 2:47 pm
Personal rank: Happy fool :-)

Re: Help W. an experiment?

Post by TheDane »

I'm not sure exactly what PlayerPawn you want to give this weapon to, but try this:
class GiveWeapon expands Mutator;

function ModifyPlayer(Pawn Other)
{
if ( (Other.IsA(PlayerPawnClass)) )
{
DeathMatchPlus(Level.Game).GiveWeapon(Other,"Package.Weapon");
}
if ( NextMutator != None )
NextMutator.ModifyPlayer(Other);
}
*PlayerPawnClass must equal the correct class you are using.
*Package must equal the package name the weapon is in e.g. Botpack
*Weapon must equal the weapons class name e.g. PulseGun

This would assign a defined weapon to a defined PlayerPawn Class.
Retired.
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

Re: Help W. an experiment?

Post by zacman »

Code won't compile... It's complaining that there's an extra } on line 4, and if I get rid of it, it says it's MISSING a {
Image[url=steam://friends/add/76561198048595886]Image[/url]
User avatar
TheDane
Masterful
Posts: 660
Joined: Tue Feb 12, 2008 2:47 pm
Personal rank: Happy fool :-)

Re: Help W. an experiment?

Post by TheDane »

As far as I recall you wanted a special PlayerPawn to have this weapon. If you give the weapon to Class'PlayerPawn' each and every player will get this weapon regardless of the model. You must call the class of this custom PlayerPawn e.g. Class'REAVERPLAYER' to just assign the weapon to that player.
Retired.
User avatar
zacman
Adept
Posts: 412
Joined: Wed Apr 15, 2009 5:36 am
Personal rank: M-M-M-MONSTER KILL

Re: Help W. an experiment?

Post by zacman »

I only want the ReaverPlayer to have it.
And Dane, your code won't compile
Image[url=steam://friends/add/76561198048595886]Image[/url]
User avatar
TheDane
Masterful
Posts: 660
Joined: Tue Feb 12, 2008 2:47 pm
Personal rank: Happy fool :-)

Re: Help W. an experiment?

Post by TheDane »

post your code m8, because my code wont compile untill you fill out the correct classes for it :) I just posted it as example hehe
Retired.
Post Reply