PDA

View Full Version : ServerSetCharacterClass does this work



geodav
02-16-2011, 03:31 PM
ServerSetCharacterClass does this work.
Ok i have 2 factions UTFamilyInfo_Liandri & UTFamilyInfo_IronGuard, both have been added to the UTCharInfo and characters added to the ini file.
the problem is it still mixes the 2 factions on each team although the UTPlayerController.uc quotes
// force bots on player's team to be same faction

but i can't get this to work at all has any one got any idea's why and how to get it to work



reliable server function ServerSetCharacterClass(class<UTFamilyInfo> CharClass)
{
local UTTeamInfo Team;
local UTPlayerReplicationInfo PRI;

PRI = UTPlayerReplicationInfo(PlayerReplicationInfo);

PRI.CharClassInfo = CharClass;

// force bots on player's team to be same faction
if ((WorldInfo.NetMode == NM_Standalone || WorldInfo.NetMode == NM_ListenServer) && IsLocalPlayerController())
{
Team = UTTeamInfo(PlayerReplicationInfo.Team);
if (Team != None)
{
Team.Faction = PRI.CharClassInfo.default.Faction;
}
}
}

cheers Geodav

tegleg
02-16-2011, 04:21 PM
ahh, guess my bit of code didnt work then. so a faction is just the pawn class?
i dont know much about replication, or anything about the UT character stuff for that matter, so i would do something like:

in myPlayerController


function PostBeginPlay()
{
local MyBot b;

ForEach(MyBot, b)
{
if (b.Team == 0)
{ set the pawn class here}
}
}

geodav
02-17-2011, 01:39 PM
this has been a problem since they released UDK, then in the September build they removed all the character loading code from the UTPlayerController.uc and the UTProfile.uc this is why the UTTeamInfo.uc doesn't know which Faction/Family because the PlayerController hasn't loaded the class (i think). I even tried to copy/paste the August code but that didn't do any thing at all


{ set the pawn class here}
uhhh

tegleg
02-17-2011, 01:41 PM
u know that console command you used in the gfxclassmenu

geodav
02-17-2011, 01:47 PM
yes but that was changing the UT40kPlayerReplicationInfo

ConsoleCommand("set UT40kPlayerReplicationInfo CharClassInfo UTFamilyInfo_CWEldar_Troops");

i did try to use ServerSetCharacterClass but i could get the syntac write for it to work

tegleg
02-17-2011, 01:52 PM
this is how i change my pawn in my playercontroller, thanks to blade of course


local pawn p;
local vector l;

p = Pawn;
l = Pawn.Location;
UnPossess();
p.Destroy();

p = Spawn(class'MyPawnClass', , ,l);
Possess(p, true);
it destroys the pawn your using, spawns a new one then posesses it

geodav
02-17-2011, 01:57 PM
any chance you can send me a copy of your playercontroller

tegleg
02-17-2011, 01:59 PM
sure i can
just found this, its more what your after i think
http://forums.epicgames.com/showthread.php?t=760847

geodav
02-17-2011, 02:01 PM
i've been looking at that as well

tegleg
02-17-2011, 02:06 PM
in my player controller that bit of code above is in an exec function so i can change with a button press, like this

exec function FPress()
{
local pawn p;
local vector l;

p = Pawn;
l = Pawn.Location;
UnPossess();
p.Destroy();

p = Spawn(class'MyPawnClass', , ,l);
Possess(p, true);
}
mine is actually much more complicated than that because i chose from an array of pawn classes, so i dont think it would help to send you it

geodav
02-17-2011, 02:44 PM
sorry i'm totally lost, none of the code i try with make the bots be the same Faction as my player, i've no idea if i've missed something or if epic has removed the function completely

tegleg
02-17-2011, 02:59 PM
sorry i havnt had anything to do with the character stuff before

this is a modified version of what i sent you before
btw did it work for the player pawn?


function SetPlayerDefaults(Pawn PlayerPawn)
{
local pawn p;
local vector l;

local MyBotController BC;

super.SetPlayerDefaults(PlayerPawn);

CharClassMenu = new class'UT40k_GFxClassMenu';
ConsoleCommand("set UT40kPlayerReplicationInfo CharClassInfo"$CharClassMenu.CharClass);

ForEach(MyBotController, BC) //go through all the bots
{
if (BC.Team == 0) //if on the players team
{
p = BC.Pawn;
l = BC.Pawn.Location;
p.UnPossess();
p.Destroy();

p = Spawn(CharClassMenu.CharClass, , ,l); //spawn the same class as the player
BC.Possess(p, true);
}
}
}
dont know if this will work but it should do (i think)

geodav
02-17-2011, 03:04 PM
i get the compile error

: Error, Unrecognized type 'MyBotController'

tegleg
02-17-2011, 03:34 PM
change it to your bot controller, if your using UTBot, put UTBot

geodav
02-17-2011, 03:47 PM
sorry now i get this error


[0013.16] Error: F:\UDK\UDK-2011-01\Development\Src\UT40k\Classes\UT40kPlayerContro ller.uc(33) : Error, Unknown Function 'SetPlayerDefaults' in 'Class UTGame.UTPlayerController'


i'm really losing hope with this

tegleg
02-17-2011, 03:50 PM
oh sorry
that bit is in your TeamGame class
you need to put the stuff in gfxclassmenu i sent too