PDA

View Full Version : Battlefield game mode (Based on Warfare from UT3)



InhexSTER
02-28-2010, 12:43 PM
I want to make i game mode as seen in Battlefield 2. In order to do so i have started to look at Onslaught source from UT3, when i try to compile it i get these errors:

E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtFlag.uc( 1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtGame.uc( 1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtGodBeam. uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtGRI.uc(1 ) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtHUD.uc(1 ) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtHUDMessa ge.uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtObjectiv e.uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtMapInfo. uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtMiningRo bot.uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtMiningRo botController.uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtNodeEnha ncement.uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtNodeHeal EffectBase.uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtNodeTele porter.uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtPRI.uc(1 ) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtSquadAI. uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtTarydium Mine.uc(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnslaughtTeamAI.u c(1) : Error, Unexpected 'п'
E:\UDK\UDK-2010-02\Development\Src\WW2\Classes\UTOnsScoreboardPane l.uc(1) : Error, Unexpected 'п'
obviously there is no character П in its code

LennardF1989
02-28-2010, 12:52 PM
Open them with a Hex editor (like HxD) and remove the first character from the files. Or open them in an other tool than notepad...

InhexSTER
02-28-2010, 12:56 PM
Yeah, i toticed that when i delete all contents files is still 3 bytes instead of 0. Thanks for help.

Blaaguuu
02-28-2010, 01:28 PM
Are you actually using some of the script files from UT3? I'm not positive, but I would assume that is against the UDK license agreement.

InhexSTER
02-28-2010, 01:30 PM
I am not going to be using them, I am writing code based on them. So basically I would totally modify them.

InhexSTER
02-28-2010, 01:36 PM
Basically only functionality i need from UT3 is how capturing nodes work (player just would have to stand within some radius of point). Other then that it will be completely different game mode

geodav
02-28-2010, 03:04 PM
save your files as unicode this should get rid of that error

InhexSTER
02-28-2010, 03:19 PM
I believe this one will be hard to implement cause there is a lot onslaught code. going through could take weeks. but hope i can do it :)

InhexSTER
02-28-2010, 08:19 PM
So i guess i start from scratch will slowly build up this game mode.
So basically my idea shouldn't be too hard to implement.
I am not planing on implementing vehicles so i guess i could use UTTeamGame
1. I need to set up some static mesh to be a flag(non-movable) (placeable nav point)
2. Create a radius around it so once a player is inside this radius Capture value start to fill up every second and then once its at 100 set flag material to according team
3. If one team has more captured points then other start deducting spawn points
4. Team who has no spawn point loses.

So what i would need help with is points 1 and 2. Also i believe that i am not going to do any AI for my game. So it should make it simpler

Any suggestions, help, tutorials are greatly appreciated.

LennardF1989
03-01-2010, 01:54 AM
Argh, I typed like a huge post but my browser refreshed, so here is a simplified version as I don't feel like typing again.

To solve 1 and 2 make an custom placeable actor for your flag, like FlagCapturePoint.

Make it have an integer for the capture value, and an integer holding how many capturing players are within radius (possibly another one for the player that already own the flag). Upon PostBeginPlay in the Gametype you can do a ForEach on these to count how many flags there are in the current level (and thus figure out a win situation or how fast the tick-points of each team decreases).

In the actor add a Tick-event which does the following things:
- Iterate over all Pawns and calculate their distance to the flag, you do this as follows:


float distance = VSize(Pawn.Location - self.Location);

- Increase the respective playercount-integers and possibly store a refeference to the player so you can force them to show a HUD-thing later perhaps.
- Next do some funky formula to calculate a new capture-threshold which gets added to the current value (or subtracted up till 0 in case of making the flag neutral first) every second. You can go completely wild, but be sure to not continue with this "funky formula" if playercount-integers are 0, for performance.

You might say: Why not do this in the Pawn itself? Because this is gametype-gameplay-element which the pawn shouldn't know off, only the HUD would need to know about the fact it might happen that it has to display a capture-icon, maybe not even that. It's really a case of code-seperation.

Besides, it might happen you have overlapping radiuses, this way the Pawn/PC doesn't have to worry about that, as each flag does it all by itself.

InhexSTER
03-01-2010, 11:19 AM
thanks for replies and ideas
I am trying to assign a static mesh to make flagcapturepoint, but in the editor static mesh doesnt show up, only icon of objetivepoint


class WW2_FlagCapturePoint extends UTGameObjective
placeable;

defaultproperties
{

begin object class=StaticMeshComponent name=FlagMesh
StaticMesh=StaticMesh'LT_Mech.SM.Mesh.S_LT_Mech_SM _Powerpole01'
bNotifyRigidBodyCollision=true
HiddenGame=FALSE
ScriptRigidBodyCollisionThreshold=0.001
LightingChannels=(Dynamic=TRUE)
end object


}

LennardF1989
03-01-2010, 03:06 PM
You forgot
Components.Add(FlagMesh) right below the object in defaultproperties.

And you'd be better of extending right of Actor, as you shouldn't need any higher classes for this to work, you only need Tick afterall, nothing more.

InhexSTER
03-01-2010, 03:24 PM
Thanks it worked :), For capture radius would I define collision cylinder or make some kind of trigger with touch/untoch events?

Also having problem with static mesh it is unlit

LennardF1989
03-01-2010, 04:13 PM
Read what I typed, from the tick-event you iterate over all pawns in WorldInfo (ForEach) and calculate their distance from the flag.

InhexSTER
03-01-2010, 04:33 PM
Ok, I get the idea, so based on player distance to flag i can execute different code. What i have problem with is Pawn.Location . Looks like i have to cast it? because it says bad or missing token for Pawn.Location

LennardF1989
03-01-2010, 05:52 PM
Ok, you did it, you made me write code for you... put this in your flag class:


const CAPTURE_RADIUS = 256; //256 units

event Tick(float Deltatime)
{
local Pawn tmpPawn;
local float tmpDistance;

foreach WorldInfo.AllActors(class'Pawn', tmpPawn)
{
tmpDistance = VSize(tmpPawn.Location - self.Location);

if(tmpDistance <= CAPTURE_RADIUS)
{
`Log(tmpPawn @ "is within radius.");
}
else
{
`Log(tmpPawn @ "is NOT within radius.");
}
}
}

InhexSTER
03-01-2010, 05:59 PM
Thank you a lot LennardF1989, will never forget your help.

InhexSTER
03-01-2010, 09:19 PM
I tried a lot of things to make my StaticMesh accept lightning, but had no luck with that. Why my mesh is unlit?
Currently this is my code for describing mesh


Begin Object class=StaticMeshComponent name=FlagMesh
StaticMesh=StaticMesh'LT_Mech.SM.Mesh.S_LT_Mech_SM _Powerpole01'
Scale=0.5
CastShadow=FALSE
bCastDynamicShadow=FALSE
bAcceptsLights=TRUE
bForceDirectLightMap=TRUE
LightingChannels=(BSP=TRUE,Dynamic=FALSE,Static=TR UE,CompositeDynamic=TRUE)
End Object

Components.Add(FlagMesh)

InhexSTER
03-01-2010, 11:58 PM
Also i would like capturing process would done over time (like 10 seconds to capture flag and show your team flag on it)
but looks like SetTimer function doest work in a Tick event. Is it right?

LennardF1989
03-02-2010, 02:03 AM
Tick has a deltatime, which is the time passed between the current and last frame. Add that value to a global variable and then check if it passed 10 seconds, if it did, the thing has been captured.

InhexSTER
03-02-2010, 01:51 PM
Thanks for idea to use DeltaTime, figured out how to use that.
Is there anywhere good explanation on casting? I always have trouble figuring how to cast variables from class to class :( Cant get my CaptureProgress variable from FlagCapturePoint.uc to UTHUD. or even better would be to cast it first to MyGameInfo and then to UTHUD

LennardF1989
03-02-2010, 07:55 PM
I don't think you're looking for the term casting, casting is converting one object to an other like MyPawn(Pawn) or MyGame(Game).