View Full Version : Some errors I can't fix
Taboen
12-16-2007, 11:08 AM
Can some people help me with a few errors I get with the following script?
// Made by Dirk 'Taboen' Broenink
// TFM stands for Team Flag Master. There are two ways to win a round, either cap the flag or completely kill the enemy team untill they don't have any lives left. The first team that wins a certain amount of rounds wins the game.
// Version 0.1
class TFM extends UTgame.UTCTFGame;
var config bool bFullAmmo;
function AddDefaultInventory(Pawn p)
{
local Inventory Inv;
Super.AddDefaultInventory(p);
UTGame(WorldInfo.Game).DefaultInventory.Length = 9;
UTGame(WorldInfo.Game).DefaultInventory[0] = Class'UTGame.UTWeap_Enforcer';
UTGame(WorldInfo.Game).DefaultInventory[1] = Class'UTGame.UTWeap_ImpactHammer';
UTGame(WorldInfo.Game).DefaultInventory[2] = Class'UTGame.UTWeap_RocketLauncher';
UTGame(WorldInfo.Game).DefaultInventory[3] = Class'UTGameContent.UTWeap_Avril_Content';
UTGame(WorldInfo.Game).DefaultInventory[4] = Class'UTGameContent.UTWeap_BioRifle_Content';
UTGame(WorldInfo.Game).DefaultInventory[5] = Class'UTGame.UTWeap_FlakCannon';
UTGame(WorldInfo.Game).DefaultInventory[6] = Class'UTGame.UTWeap_LinkGun';
UTGame(WorldInfo.Game).DefaultInventory[7] = Class'UTGame.UTWeap_ShockRifle';
UTGame(WorldInfo.Game).DefaultInventory[8] = Class'UTGame.UTWeap_SniperRifle';
UTGame(WorldInfo.Game).DefaultInventory[9] = Class'UTGame.UTWeap_Stinger';
/* if ( bFullAmmo )
{
For ( Inv=P.Inventory; Inv!=None; Inv=Inv.Inventory ) // <- Error, Unrecognized member 'Inventory' in class 'Pawn'
{
if ( Weapon(Inv) != None )
Weapon(Inv).MaxOutAmmo();
}
}
*/
}
/*function bool CheckReplacement(Actor Other) // <= How to implement this CheckReplacement in the first one?
{
local UTWillowWhisp OtherWhisp;
foreach DynamicActors(class'UTWillowWhisp', OtherWhisp)
{
OtherWhisp.Destroy();
}
return Super.CheckReplacement(Other);
}
*/
function bool CheckReplacement(Actor Other)
{
if (Other.IsA('UTWeap_Redeemer_Content'))
{
return false;
}
return true;
}
function Mutate(string type, PlayerController say)
{
if(type~="amIworking")
{
say.ClientMessage("yes im working"); ////////// prints to screen .....
LogInternal("yes im working"); ////////// prints to log .......
}
}
defaultproperties
{
// DefaultGoalScore=10 - Error: Unknown property. How do I set a defaultgoalscore?
bWeaponStay=False
bAllowTranslocator=False
bAllowHoverboard=False
HUDType=Class'UTCTFHUD'
MapPrefixes(0)="TM"
}
And, if you have more time, I would like to spawn people with a shieltbelt. Preferable a configurable int from 0 to 100 on how much armor exactly. I don't know how to do this yet, I'm doing tutorials at the moment at the same time. But I just wanted to start using my knowledge of the tutorials before I continue. Help would be appreciated.
agentq_71
12-17-2007, 12:49 AM
From what I learned writing Elimination, I believe this is a good way to give players full weapons/ammo:
function PostBeginPlay()
{
Super.PostBeginPlay();
DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTWeap_BioRifle_Content';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_FlakCannon';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_LinkGun';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_RocketLauncher';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_ShockRifle';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_SniperRifle';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_Stinger';
}
function SetPlayerDefaults(Pawn PlayerPawn)
{
UTInventoryManager(PlayerPawn.InvManager).AllAmmo( true);
Super.SetPlayerDefaults(PlayerPawn);
}
To give a default goal score, just do GoalScore=X not DefaultGoalScore.
Taboen
12-17-2007, 06:27 AM
Allright, thanks. And it worked aswell. I did it a bit different though, a configurable amount of ammo it adds to every weapon. Later on I want this to be for every weapon apart, but I still have to figure out how. First, I want to replace the redeemer with nothing. Because CheckReplacement does not work when extending UTCTFGame :confused:
Also, when I set goalscore=10 it does not give any error but the goalscore is 20, whatever I put it on.
This is what I have now:
// Made by Dirk 'Taboen' Broenink
// TFM stands for Team Flag Master. There are two ways to win a round, either cap the flag or completely kill the enemy team untill they don't have any lives left. The first team that wins a certain amount of rounds wins the game. People spawn with configurable ammo / armor.
// Version 0.1
class TFM extends UTgame.UTCTFGame;
var config int AmmoAddition;
function PostBeginPlay()
{
Super.PostBeginPlay();
DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTWeap_BioRifle_Content';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_FlakCannon';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_LinkGun';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_RocketLauncher';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_ShockRifle';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_SniperRifle';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_Stinger';
}
function AddDefaultInventory(Pawn p)
{
local Inventory Inv;
Super.AddDefaultInventory(p);
For ( Inv=P.InvManager.InventoryChain; Inv!=None; Inv=Inv.Inventory )
{
Weapon(Inv).AddAmmo(AmmoAddition);
}
}
/*
====== CheckReplacement does not work when extending UTgame.UTCTFGame
function bool CheckReplacement(Actor Other)
{
if (Other.IsA('UTWeap_Redeemer_Content'))
{
return false;
}
return true;
}
*/
function Mutate(string type, PlayerController say)
{
if(type~="amIworking")
{
say.ClientMessage("yes im working"); ////////// prints to screen .....
LogInternal("yes im working"); ////////// prints to log .......
}
}
defaultproperties
{
GoalScore=10 // <= No errors but the goalscore is 20 whatever I put this on.
AmmoAddition=21
bWeaponStay=False
bAllowTranslocator=False
bAllowHoverboard=False
HUDType=Class'UTCTFHUD'
MapPrefixes(0)="TM"
}
For now I want to be able to set the goalscore correctly and also let CheckReplacement work.
I have just extended CTF as if it is CTF you're playing. All thats changed for now is the defaultproperties and that you spawn with full ammo. Weird thing is, it also changes other stuff. When I make a cap now it doesn't say 'Red team scores!' like it should. Same when the enemy caps. It also doesn't report flagreturns. Only 'Red/Blue flag taken' or 'Denied!'. How is this possible?
Joe Wilcox
12-17-2007, 01:18 PM
Agentq_71's method for all ammo is the best way to do it. Also, CheckReplacement is a mutator function, not a function in the GameInfo so having that there will never get called.
For CTF make sure your extended CTFGame_Content or better everything you are trying to do so far should be done from a mutator instead.
Taboen
12-17-2007, 01:23 PM
Allrigth. But I don't want all ammo, I want configurable ammo for every weapon. :) I'll make a boolean for all ammo though, in case server admins want to put it on all ammo, their choice. Thanks for the info on that.
Joe Wilcox
12-17-2007, 01:55 PM
Then do:
local int AmmoAmount;
local UTWeapon Wep;
Foreach P.InvManager.InventoryActors(class'UTWeapon',Wep)
{
AmmoAmount = FigureOutHowMuchAmmo(Wep);
Wep.AddAmmo(AmmoAmount);
}
You obviously have to write FigureOutHowMuchAmmo().
Taboen
12-18-2007, 11:24 AM
// Made by Dirk 'Taboen' Broenink
// TFM stands for Team Flag Master. There are two ways to win a round, either cap the flag or completely kill the enemy team untill they don't have any lives left. The first team that wins a certain amount of rounds wins the game. People spawn with configurable ammo / armor.
// Version 0.1
class TFM extends UTCTFGame_Content;
var config int AmmoAddition;
function PostBeginPlay()
{
Super.PostBeginPlay();
DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTWeap_BioRifle_Content';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_FlakCannon';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_LinkGun';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_RocketLauncher';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_ShockRifle';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_SniperRifle';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_Stinger';
}
function SetPlayerDefaults(Pawn PlayerPawn)
{
local int AmmoAmount;
local UTWeapon Wep;
Super.SetPlayerDefaults(PlayerPawn);
Foreach PlayerPawn.InvManager.InventoryActors(class'UTWeap on',Wep)
{
AmmoAmount = FigureOutHowMuchAmmo(Wep);
Wep.AddAmmo(AmmoAmount);
}
}
/*
====== CheckReplacement does not work when extending UTgame.UTCTFGame_Content
function bool CheckReplacement(Actor Other)
{
if (Other.IsA('UTWeap_Redeemer_Content'))
{
return false;
}
return true;
}
*/
function Mutate(string type, PlayerController say)
{
if(type~="amIworking")
{
say.ClientMessage("yes im working"); ////////// prints to screen ..... Tested and worked.
LogInternal("yes im working"); ////////// prints to log .......
}
}
defaultproperties
{
GoalScore=10
AmmoAddition=21
bWeaponStay=False
bAllowTranslocator=False
bAllowHoverboard=False
HUDType=Class'UTCTFHUD'
MapPrefixes(0)="TM"
Description="TFM stands for Team Flag Master. There are two ways to win a round, either cap the flag or completely kill the enemy team untill they don't have any lives left. The first team that wins a certain amount of rounds wins the game. People spawn with configurable ammo / armor."
GameName="Team Flag Master"
Name="Default__TFM"
}
Error, Bad or missing expression in '='
What do I change?
I figured I have to provide the date for how much ammo exactly. Also you say it is obvious to use FigureOutHowMuchAmmo() if you dont have this information stored in your head, is there a list of these kind of things?
ambershee
12-18-2007, 11:31 AM
You create a function called exactly that. What more could you possibly need to know?
Taboen
12-18-2007, 11:42 AM
Hmm, so
function FigureOutHowMuchAmmo(Weapon Wep)
{
local int BioAmmo
local int ShockAmmo
etc etc
Super. FigureOutHowMuchAmmo;
class'UTGameContent.UTWeap_BioRifle_Content' = BioAmmo
etc etc
}
Is that what you mean Ambershee? I dont know what I'm doing..
ambershee
12-18-2007, 11:54 AM
I think you need to do some reading up on how the language works;
http://www.moddb.com/members/21982/ambershee/downloads/9298/unrealscript-reference
Essentially, it's on the right lines, but a lot of what you are doing makes no sense at all; why pass a Weapon to your function if you're never going to use it? Why try to 'Super' your function when the function is clearly a new one in your derived class? These are things you should really step back and look at properly.
Joe Wilcox
12-18-2007, 12:54 PM
FigureOutHowMuchAmmo isn't a function in the game. You have to make a new function called "FigureOutHowMuchAmmo()" and have it return the default value given a weapon.
Taboen
12-23-2007, 07:46 AM
Thanks for your advice. I've been working on it. I did it a different way than you suggested though. But it works. Next step will be to make the variables configurable in an ini and set a defaultvalue to it.
Current code:
// Made by Dirk 'Taboen' Broenink
// TFM stands for Team Flag Master. There are two ways to win a round, either cap the flag or completely kill the enemy team untill they don't have any lives left. The first team that wins a certain amount of rounds wins the game. People spawn with configurable ammo / armor.
// Version 0.1
class TFM extends UTCTFGame_Content;
var int EnforcerAmmo;
var int BioAmmo;
var int ShockAmmo;
var int LinkAmmo;
var int StingerAmmo;
var int FlakAmmo;
var int RocketAmmo;
var int SniperAmmo;
var bool bUseInfiniteAmmo;
function PostBeginPlay()
{
Super.PostBeginPlay();
DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTWeap_BioRifle_Content';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_ShockRifle';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_LinkGun';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_Stinger';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_FlakCannon';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_RocketLauncher';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_SniperRifle';
}
function SetPlayerDefaults(Pawn PlayerPawn)
{
if(bUseInfiniteAmmo)
{
UTInventoryManager(PlayerPawn.InvManager).bInfinit eAmmo=true;
}
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);
}
function bool CheckRelevance(Actor Other)
{
return (!Other.IsA('UTWeaponPickupFactory') && !Other.IsA('UTItemPickupFactory') && !Other.IsA('UTWeaponLocker') && !Other.IsA('PickupFactory'));
}
function Mutate(string type, PlayerController say)
{
if(type~="amIworking")
{
say.ClientMessage("yes im working"); ////////// prints to screen ..... Tested and worked.
LogInternal("yes im working"); ////////// prints to log .......
}
}
defaultproperties
{
EnforcerAmmo=10
BioAmmo=15
ShockAmmo=15
LinkAmmo=15
StingerAmmo=500
FlakAmmo=30
RocketAmmo=20
SniperAmmo=10
bUseInfiniteAmmo=true
GoalScore=10
bWeaponStay=False
bAllowTranslocator=False
bAllowHoverboard=False
HUDType=Class'UTCTFHUD'
MapPrefixes(0)="TM"
Description="TFM stands for Team Flag Master. There are two ways to win a round, either cap the flag or completely kill the enemy team untill they don't have any lives left. The first team that wins a certain amount of rounds wins the game. People spawn with configurable ammo / armor."
GameName="Team Flag Master"
Name="Default__TFM"
}
And it works. Oh, still don't know how to let people spawn with shieltbelt. Could anyone give info how how to do stuff like that? :)
EntropicLqd
12-23-2007, 08:04 AM
You do it in exactly the same way as you did with the weapons. Only use the class name of the Shield Belt object instead of a weapon.
You have all of the information you need to be able to do it. All you need to do is spend some time looking through the UnrealScript for the classes within the game.
Also, I'd like to re-iterate what Joe said earlier in the thread. So far everything you are trying to do would be better done using a Mutator rather than a Game Type.
Taboen
12-23-2007, 08:48 AM
You do it in exactly the same way as you did with the weapons. Only use the class name of the Shield Belt object instead of a weapon.
You have all of the information you need to be able to do it. All you need to do is spend some time looking through the UnrealScript for the classes within the game.
Also, I'd like to re-iterate what Joe said earlier in the thread. So far everything you are trying to do would be better done using a Mutator rather than a Game Type.
Okey thanks. And as I said before, I know that. its just that I have many features planned for this mod, and I doubt that will always be possible with a muator. And even if it would be possible as a mutator, I'd like to keep that seperate of the CTF gametype, if people search for CTF they should find CTF not something completely different.
I am trying to do the shieltbelt now :)
Edit:
Added
DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTArmorPickup_ShieldBelt';
to the function postbeginplay and it now gives an error for that line:
Error, type mistmatch in '='
Taboen
12-24-2007, 05:51 PM
This is what I have now, still curious about how to add a shieltbelt :)
// Made by Dirk 'Taboen' Broenink
// TFM stands for Team Flag Master. There are two ways to win a round, either cap the flag or completely kill the enemy team untill they don't have any lives left. The first team that wins a certain amount of rounds wins the game. People spawn with configurable ammo / armor.
// Version 0.1
class TFM extends UTCTFGame_Content config(TFM);
var config string CfgCheck;
var config int EnforcerAmmo;
var config int BioAmmo;
var config int ShockAmmo;
var config int LinkAmmo;
var config int StingerAmmo;
var config int FlakAmmo;
var config int RocketAmmo;
var config int SniperAmmo;
var config int RedeemerAmmo;
var config bool bUseInfiniteAmmo;
function PostBeginPlay()
{
if (CfgCheck!="ConfigCheck") {
CfgCheck="ConfigCheck";
bUseInfiniteAmmo=false;
EnforcerAmmo=60;
BioAmmo=30;
ShockAmmo=20;
LinkAmmo=100;
StingerAmmo=75;
FlakAmmo=15;
RocketAmmo=12;
SniperAmmo=9;
}
SaveConfig();
Super.PostBeginPlay();
// DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTArmorPickup_ShieldBelt'; <= How?
DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTWeap_BioRifle_Content';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_ShockRifle';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_LinkGun';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_Stinger';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_FlakCannon';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_RocketLauncher';
DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_SniperRifle';
}
function SetPlayerDefaults(Pawn PlayerPawn)
{
if(bUseInfiniteAmmo)
{
UTInventoryManager(PlayerPawn.InvManager).bInfinit eAmmo=true;
}
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);
}
function bool CheckRelevance(Actor Other)
{
return (!Other.IsA('UTWeaponPickupFactory') && !Other.IsA('UTItemPickupFactory') && !Other.IsA('UTWeaponLocker') && !Other.IsA('PickupFactory') && !Other.IsA('DroppedPickup'));
}
/*function bool CheckReplacement(Actor Other) // This is a script to remove the white arrows but CheckReplacement doesn't work, that works only in a mutator.
{
local UTWillowWhisp OtherWhisp;
foreach DynamicActors(class'UTWillowWhisp', OtherWhisp)
{
OtherWhisp.Destroy();
}
return true;
Super.CheckReplacement(Other);
}*/
function Mutate(string type, PlayerController say)
{
if(type~="amIworking")
{
say.ClientMessage("yes im working"); ////////// prints to screen ..... Tested and worked.
LogInternal("yes im working"); ////////// prints to log .......
}
}
defaultproperties
{
GoalScore=10
bWeaponStay=False
bAllowTranslocator=False
bAllowHoverboard=False
DeathMessageClass=Class'UTGame.UTDeathMessage'
HUDType=Class'UTCTFHUD'
MapPrefixes(0)="TM"
Description="TFM stands for Team Flag Master. There are two ways to win a round, either cap the flag or completely kill the enemy team untill they don't have any lives left. The first team that wins a certain amount of rounds wins the game. People spawn with configurable ammo / armor."
GameName="Team Flag Master"
Name="Default__TFM"
}
The red parts is what I am trying to solve at the moment.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.