PDA

View Full Version : Spawn with shieldbelt



Taboen
01-02-2008, 08:00 AM
I am using this code to let people spawn with all weapons, but I want to add a shieldbelt to it. And it gives an error when doing so.


function PostBeginPlay()
{
// Perform a check if the config is there and if not, write a default config.
if (CfgCheck!="ConfigCheck_001") {
CfgCheck="ConfigCheck_001";
bUseInfiniteAmmo=false;
EnforcerAmmo=60;
BioAmmo=30;
ShockAmmo=20;
LinkAmmo=100;
StingerAmmo=75;
FlakAmmo=15;
RocketAmmo=12;
SniperAmmo=9;
bNoArrows=true;
}
SaveConfig();

Super.PostBeginPlay();
// Give everybody a default weapon if the Ammo is set higher than 0.

// DefaultInventory[DefaultInventory.Length] = class'UTGame.UTArmorPickup_Helmet'; // <= Doesnt work, type mismatch in '='
if(BioAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTWeap_BioRifle_Content';
if(ShockAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_ShockRifle';
if(LinkAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_LinkGun';
if(StingerAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_Stinger';
if(FlakAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_FlakCannon';
if(RocketAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_RocketLauncher';
if(SniperAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_SniperRifle';
}

function SetPlayerDefaults(Pawn PlayerPawn)
{
// bInfiniteAmmo is a recognized variable. If the config states bUseInfiniteAmmo=true this will trigger the bInfiniteAmmo.
if(bUseInfiniteAmmo)
{
UTInventoryManager(PlayerPawn.InvManager).bInfinit eAmmo=true;
}
// If bUseInfiniteAmmo=false than add ammo to every weapon.
else
{
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(EnforcerAmmo-50,class'UTGame.UTWeap_Enforcer');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(BioAmmo-25,class'UTGameContent.UTWeap_BioRifle_Content');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(ShockAmmo-20,class'UTGame.UTWeap_ShockRifle');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(LinkAmmo-50,class'UTGame.UTWeap_Linkgun');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(StingerAmmo-100,class'UTGame.UTWeap_Stinger');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(FlakAmmo-10,class'UTGame.UTWeap_FlakCannon');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(RocketAmmo-9,class'UTGame.UTWeap_RocketLauncher');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(SniperAmmo-10,class'UTGame.UTWeap_SniperRifle');
}
Super.SetPlayerDefaults(PlayerPawn);
}

BTW this is in a gametype not a mutator.
"Type mismatch in '=' " - what to do?
Help is appreciated.

Wormbo
01-02-2008, 08:18 AM
"Type mismatch in '=' " obviously points out a type mismatch in an assignment on the specified line. I suggest you look up the types of the variable you try to assign to and of the expression you are assigning to the variable.

Taboen
01-02-2008, 09:41 AM
"Type mismatch in '=' " obviously points out a type mismatch in an assignment on the specified line. I suggest you look up the types of the variable you try to assign to and of the expression you are assigning to the variable.

I'm guessing you mean the DefaultInventory.Length part. What do I change Length to?

I searched for what to fill in there but I don't know where to find that.
Searched through UTWeapon.uc Weapon.uc ...

Wormbo
01-02-2008, 09:02 PM
Again, compare the data types of both sides of the assignment and check whether the left side type matches (or at least is a super class of) the right side type.

For your information: the left side is not "Length", it's "DefaultInventory[DefaultInventory.Length]", so you need to find out the type of the DefaultInventory array.

Taboen
01-03-2008, 10:35 AM
Again, compare the data types of both sides of the assignment and check whether the left side type matches (or at least is a super class of) the right side type.

For your information: the left side is not "Length", it's "DefaultInventory[DefaultInventory.Length]", so you need to find out the type of the DefaultInventory array.

Hmm, I searched for DefaultInventory in every parent of UTCTFGame and it gave no results..

bushbomb
01-03-2008, 10:38 AM
Take a look at this, to give a Pawn a weapon, I can do this


function GivePawnWeapon(class<Weapon> WeaponClass, Pawn P)
{
local UTWeapon Weap;

Weap = UTWeapon(P.FindInventoryType(WeaponClass));
if (Weap == None)
{
Weap = UTWeapon(P.CreateInventory(WeaponClass));
}
Weap.AmmoCount = Weap.MaxAmmoCount;
}

And to give a Pawn armor, I can do this:


UTPawn(P).ShieldBeltArmor = 100;

Are you sure you need to use the inventoryManager to add the shieldbelt?

Taboen
01-03-2008, 11:30 AM
Using 'UTPawn(P).ShieldBeltArmor = 100;' worked!


function PostBeginPlay()
{
// Perform a check if the config is there and if not, write a default config.
if (CfgCheck!="ConfigCheck_001") {
CfgCheck="ConfigCheck_001";
bUseInfiniteAmmo=false;
EnforcerAmmo=60;
BioAmmo=30;
ShockAmmo=20;
LinkAmmo=100;
StingerAmmo=75;
FlakAmmo=15;
RocketAmmo=12;
SniperAmmo=9;
bNoArrows=true;
LogInternal("Rewrote config");
}
SaveConfig();

Super.PostBeginPlay();
// Give everybody a default weapon if the Ammo is set higher than 0.

if(BioAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTWeap_BioRifle_Content';
if(ShockAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_ShockRifle';
if(LinkAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_LinkGun';
if(StingerAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_Stinger';
if(FlakAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_FlakCannon';
if(RocketAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_RocketLauncher';
if(SniperAmmo>0)
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_SniperRifle';
}

function SetPlayerDefaults(Pawn PlayerPawn)
{
UTPawn(PlayerPawn).ShieldBeltArmor = 100;
if(bUseInfiniteAmmo)
{
UTInventoryManager(PlayerPawn.InvManager).bInfinit eAmmo=true;
LogInternal("Infinite ammo");
}
// If bUseInfiniteAmmo=false than add ammo to every weapon.
else
{
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(EnforcerAmmo-50,class'UTGame.UTWeap_Enforcer');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(BioAmmo-25,class'UTGameContent.UTWeap_BioRifle_Content');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(ShockAmmo-20,class'UTGame.UTWeap_ShockRifle');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(LinkAmmo-50,class'UTGame.UTWeap_Linkgun');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(StingerAmmo-100,class'UTGame.UTWeap_Stinger');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(FlakAmmo-10,class'UTGame.UTWeap_FlakCannon');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(RocketAmmo-9,class'UTGame.UTWeap_RocketLauncher');
UTInventoryManager(PlayerPawn.InvManager).AddAmmoT oWeapon(SniperAmmo-10,class'UTGame.UTWeap_SniperRifle');
LogInternal("No infinite ammo");
}
Super.SetPlayerDefaults(PlayerPawn);
}

As you can see, I put it in function SetPlayerDefaults and that was enough.

I think I can even make the armor amount configurable by changing it to UTPawn(P).ShieldBeltArmor = ArmorAmount; with adding a configurable int ArmorAmount.

Thanks! :)

bushbomb
01-03-2008, 02:51 PM
I think I can even make the armor amount configurable by changing it to UTPawn(P).ShieldBeltArmor = ArmorAmount; with adding a configurable int ArmorAmount.

Thanks! :)

No problem :) So many help me, I try to help when I can.

P.S. you may want to edit your first post to change the topic from shieltbelt to shieldbelt.

Taboen
01-03-2008, 06:52 PM
No problem :) So many help me, I try to help when I can.

P.S. you may want to edit your first post to change the topic from shieltbelt to shieldbelt.

Lol, changed :D

Sardonyx
01-03-2008, 11:30 PM
For the record, I suspect that Wormbo wasn't being intentionally obtuse - he was being didactic. Part of what's nice about this community is that they'll help you get answers, but what's even nicer is that some folks (like Wormbo) will even go out of their way to teach you how to get your own answers.


Give a man some code, and you help him for a day
Teach a man to code, and you help him for a lifetime

... or something like that.