05-31-2011, 16:46
So i was editing files in the _rank.gsc,trying to get the bunkermaker to work after i fixed my other problems,but i got the following error
Server script compile error
Bad Syntax
Here is the code,if anyone can find the bad syntax please tell me.
Server script compile error
Bad Syntax
Here is the code,if anyone can find the bad syntax please tell me.
Code:
#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
init()
{
level.minigunList = [];
level.bunkerList = [];
level thread doMaps();
level thread maps\mp\gametypes\_hud::init();
level.failCODJumper = false; //Turn to true if you want to try jumping on CPs
header = level createServerFontString("default", 1);
header setPoint("MIDDLEBOTTOM", "MIDDLEBOTTOM", 0, 0);
header setText("^2Bunker Maker V1.1 By ^1You^0Mods. ^3Orginal By ^4Master131");
if(!isDefined(level.bunkerList)) {
level.minigunList = [];
level.bunkerList = [];
level.blockEnt = [];
level.minigunEnt = [];
}
level thread maps\mp\_serverfaceanim_mp::doJumpers();
level.scoreInfo = [];
level.xpScale = GetDvarInt( #"scr_xpscale" );
level.codPointsXpScale = GetDvarFloat( #"scr_codpointsxpscale" );
level.codPointsMatchScale = GetDvarFloat( #"scr_codpointsmatchscale" );
level.codPointsChallengeScale = GetDvarFloat( #"scr_codpointsperchallenge" );
level.rankXpCap = GetDvarInt( #"scr_rankXpCap" );
level.codPointsCap = GetDvarInt( #"scr_codPointsCap" );
level.rankTable = [];
precacheShader("white");
precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
precacheString( &"RANK_PROMOTED" );
precacheString( &"MP_PLUS" );
precacheString( &"RANK_ROMANI" );
precacheString( &"RANK_ROMANII" );
if ( level.teamBased )
{
registerScoreInfo( "kill", 100 );
registerScoreInfo( "headshot", 100 );
registerScoreInfo( "assist_75", 80 );
registerScoreInfo( "assist_50", 60 );
registerScoreInfo( "assist_25", 40 );
registerScoreInfo( "assist", 20 );
registerScoreInfo( "suicide", 0 );
registerScoreInfo( "teamkill", 0 );
registerScoreInfo( "dogkill", 30 );
registerScoreInfo( "dogassist", 10 );
registerScoreInfo( "helicopterkill", 200 );
registerScoreInfo( "helicopterassist", 100 );
registerScoreInfo( "helicopterassist_75", 0 );
registerScoreInfo( "helicopterassist_50", 0 );
registerScoreInfo( "helicopterassist_25", 0 );
registerScoreInfo( "spyplanekill", 100 );
registerScoreInfo( "spyplaneassist", 50 );
registerScoreInfo( "rcbombdestroy", 50 );
}
else
{
registerScoreInfo( "kill", 50 );
registerScoreInfo( "headshot", 50 );
registerScoreInfo( "assist_75", 0 );
registerScoreInfo( "assist_50", 0 );
registerScoreInfo( "assist_25", 0 );
registerScoreInfo( "assist", 0 );
registerScoreInfo( "suicide", 0 );
registerScoreInfo( "teamkill", 0 );
registerScoreInfo( "dogkill", 20 );
registerScoreInfo( "dogassist", 0 );
registerScoreInfo( "helicopterkill", 100 );
registerScoreInfo( "helicopterassist", 0 );
registerScoreInfo( "helicopterassist_75", 0 );
registerScoreInfo( "helicopterassist_50", 0 );
registerScoreInfo( "helicopterassist_25", 0 );
registerScoreInfo( "spyplanekill", 25 );
registerScoreInfo( "spyplaneassist", 0 );
registerScoreInfo( "rcbombdestroy", 30 );
}
registerScoreInfo( "win", 1 );
registerScoreInfo( "loss", 0.5 );
registerScoreInfo( "tie", 0.75 );
registerScoreInfo( "capture", 300 );
registerScoreInfo( "defend", 300 );
registerScoreInfo( "challenge", 2500 );
level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
pId = 0;
rId = 0;
for ( pId = 0; pId <= level.maxPrestige; pId++ )
{
for ( rId = 0; rId <= level.maxRank; rId++ )
precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
}
rankId = 0;
rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
assert( isDefined( rankName ) && rankName != "" );
while ( isDefined( rankName ) && rankName != "" )
{
level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
level.rankTable[rankId][14] = tableLookup( "mp/ranktable.csv", 0, rankId, 14 );
precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
rankId++;
rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
}
level.numStatsMilestoneTiers = 4;
level.maxStatChallenges = 1024;
buildStatsMilestoneInfo();
level thread createBlocks();
level thread onPlayerConnect();
}
createBlocks()
{
level.crateTypes["turret_drop_mp"] = [];
level.crateTypes["tow_turret_drop_mp"] = [];
level thread maps\mp\_turret_killstreak::init();
if(level.bunkerList.size > 0) {
for(i = 0; i < level.bunkerList.size; i++) {
if(isDefined(level.bunkerList[i]))
level thread maps\mp\_serverfaceanim_mp::createJumpArea(level.bunkerList[i].location, level.bunkerList[i].angle);
}
}
level.predoneBunkers = level.bunkerList.size;
if(level.minigunList.size > 0) {
for(i = 0; i < level.minigunList.size; i++) {
if(isDefined(level.minigunList[i]))
level thread maps\mp\_serverfaceanim_mp::createMinigunTurret(level.minigunList[i].location, level.minigunList[i].angle);
}
}
level.predoneMiniguns = level.minigunList.size;
}
getRankXPCapped( inRankXp )
{
if ( ( isDefined( level.rankXpCap ) ) && level.rankXpCap && ( level.rankXpCap <= inRankXp ) )
{
return level.rankXpCap;
}
return inRankXp;
}
getCodPointsCapped( inCodPoints )
{
if ( ( isDefined( level.codPointsCap ) ) && level.codPointsCap && ( level.codPointsCap <= inCodPoints ) )
{
return level.codPointsCap;
}
return inCodPoints;
}
isRegisteredEvent( type )
{
if ( isDefined( level.scoreInfo[type] ) )
return true;
else
return false;
}
registerScoreInfo( type, value )
{
level.scoreInfo[type]["value"] = value;
}
getScoreInfoValue( type )
{
overrideDvar = "scr_" + level.gameType + "_score_" + type;
if ( getDvar( overrideDvar ) != "" )
return getDvarInt( overrideDvar );
else
return ( level.scoreInfo[type]["value"] );
}
getScoreInfoLabel( type )
{
return ( level.scoreInfo[type]["label"] );
}
getRankInfoMinXP( rankId )
{
return int(level.rankTable[rankId][2]);
}
getRankInfoXPAmt( rankId )
{
return int(level.rankTable[rankId][3]);
}
getRankInfoMaxXp( rankId )
{
return int(level.rankTable[rankId][7]);
}
getRankInfoFull( rankId )
{
return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
}
getRankInfoIcon( rankId, prestigeId )
{
return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
}
getRankInfoLevel( rankId )
{
return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
}
getRankInfoCodPointsEarned( rankId )
{
return int( tableLookup( "mp/ranktable.csv", 0, rankId, 17 ) );
}
shouldKickByRank()
{
if ( self IsHost() )
{
return false;
}
if (level.rankCap > 0 && self.pers["rank"] > level.rankCap)
{
return true;
}
if ( ( level.rankCap > 0 ) && ( level.minPrestige == 0 ) && ( self.pers["plevel"] > 0 ) )
{
return true;
}
if ( level.minPrestige > self.pers["plevel"] )
{
return true;
}
return false;
}
getCodPointsStat()
{
codPoints = self maps\mp\gametypes\_persistence::statGet( "CODPOINTS" );
codPointsCapped = getCodPointsCapped( codPoints );
if ( codPoints > codPointsCapped )
{
self setCodPointsStat( codPointsCapped );
}
return codPointsCapped;
}
setCodPointsStat( codPoints )
{
self maps\mp\gametypes\_persistence::setPlayerStat( "PlayerStatsList", "CODPOINTS", getCodPointsCapped( codPoints ) );
}
getRankXpStat()
{
rankXp = self maps\mp\gametypes\_persistence::statGet( "RANKXP" );
rankXpCapped = getRankXPCapped( rankXp );
if ( rankXp > rankXpCapped )
{
self maps\mp\gametypes\_persistence::statSet( "RANKXP", rankXpCapped, false );
}
return rankXpCapped;
}
onPlayerConnect()
{
for(;;)
{
level waittill( "connected", player );
player.pers["rankxp"] = player getRankXpStat();
player.pers["codpoints"] = player getCodPointsStat();
player.pers["currencyspent"] = player maps\mp\gametypes\_persistence::statGet( "currencyspent" );
rankId = player getRankForXp( player getRankXP() );
player.pers["rank"] = rankId;
player.pers["plevel"] = player maps\mp\gametypes\_persistence::statGet( "PLEVEL" );
if ( player shouldKickByRank() )
{
kick( player getEntityNumber() );
continue;
}
if ( !isDefined( player.pers["participation"] ) || !( (level.gameType == "twar") && (0 < game["roundsplayed"]) && (0 < player.pers["participation"]) ) )
player.pers["participation"] = 0;
player.rankUpdateTotal = 0;
player.cur_rankNum = rankId;
assertex( isdefined(player.cur_rankNum), "rank: "+ rankId + " does not have an index, check mp/ranktable.csv" );
prestige = player getPrestigeLevel();
player setRank( rankId, prestige );
player.pers["prestige"] = prestige;
if ( !isDefined( player.pers["summary"] ) )
{
player.pers["summary"] = [];
player.pers["summary"]["xp"] = 0;
player.pers["summary"]["score"] = 0;
player.pers["summary"]["challenge"] = 0;
player.pers["summary"]["match"] = 0;
player.pers["summary"]["misc"] = 0;
player.pers["summary"]["codpoints"] = 0;
}
player setclientdvar( "ui_lobbypopup", "" );
if ( level.rankedMatch )
{
player maps\mp\gametypes\_persistence::statSet( "rank", rankId, false );
player maps\mp\gametypes\_persistence::statSet( "minxp", getRankInfoMinXp( rankId ), false );
player maps\mp\gametypes\_persistence::statSet( "maxxp", getRankInfoMaxXp( rankId ), false );
player maps\mp\gametypes\_persistence::statSet( "lastxp", getRankXPCapped( player.pers["rankxp"] ), false );
}
player.explosiveKills[0] = 0;
player.xpGains = [];
player.createdBlocks = [];
player.createdMiniguns = [];
player.spacing = "Spread Out";
player.spawning = "Under";
player.position = "East-West";
player.blockAngles = (0, 0, 0);
player.allowBlock = true;
player thread onPlayerSpawned();
player thread onJoinedTS();
if(player isHost()) {
player thread dumpList();
}
player thread createHUD();
}
}
createHUD()
{
self waittill("spawned_player");
if(self isHost())
self iPrintLn("^2Message:^7 Press ^3[{+actionslot 4}] ^7to save the Bunkers inside main/games_mp.log");
self.space = self createFontString("default", 1.5);
self.space setPoint("TOPRIGHT", "TOPRIGHT", -5, 0);
self.space setText("^3[{+actionslot 1}] ^7- ^1Spacing: ^7" + self.spacing);
self.spawn = self createFontString("default", 1.5);
self.spawn setPoint("TOPRIGHT", "TOPRIGHT", -5, 20);
self.spawn setText("^3[{+gostand}] ^7and ^3[{+melee}] ^7- ^2Spawn Area: ^7" + self.spawning);
self.pos = self createFontString("default", 1.5);
self.pos setPoint("TOPRIGHT", "TOPRIGHT", -5, 40);
self.pos setText("^3[{+actionslot 3}] ^7- ^5Angles: ^7" + self.position);
blockSpawn = self createFontString("default", 1.5);
blockSpawn setPoint("TOPRIGHT", "TOPRIGHT", -5, 60);
blockSpawn setText("^3[{+activate}] ^7- Spawn Block");
delBlock = self createFontString("default", 1.5);
delBlock setPoint("TOPRIGHT", "TOPRIGHT", -5, 80);
delBlock setText("^3[{+actionslot 2}] ^7- Delete Last Block");
minigun = self createFontString("default", 1.5);
minigun setPoint("TOPRIGHT", "TOPRIGHT", -5, 100);
minigun setText("^3[{+frag}] ^7- Spawn SAM Turret");
minigun = self createFontString("default", 1.5);
minigun setPoint("TOPRIGHT", "TOPRIGHT", -5, 120);
minigun setText("^3[{+smoke}] ^7- Delete Last SAM Turret");
count = 0;
self endon("disconnect");
while(1) {
if(self jumpButtonPressed() && self meleeButtonPressed()) {
if(self.spawning == "Under")
self.spawning = "Crosshair";
else
self.spawning = "Under";
self.spawn setText("^3[{+gostand}] ^7and ^3[{+melee}] ^7- ^2Spawn Area: ^7" + self.spawning);
}
if(count >= 300) {
if(self isHost())
self iPrintLn("^2Message:^7 Press ^3[{+actionslot 4}] ^7to save the bunkers inside main/games_mp.log");
count = 0;
}
wait 0.1;
count++;
}
}
onJoinedTS()
{
self endon("disconnect");
for(;;)
{
self waittill_any("joined_spectators", "joined_team");
self thread removeRankHUD();
}
}
showCoords()
{
self endon("death");
self endon("disconnect");
for(;;)
{
self iPrintLnBold(self.origin + " " + self getPlayerAngles());
wait 1;
}
}
onPlayerSpawned()
{
self endon("disconnect");
for(;;)
{
self waittill("spawned_player");
self.groundLevel = self.origin[2];
setDvar("bg_fallDamageMinHeight", "10000");
setDvar("sv_cheats", "1");
self thread defaultCode();
self thread showCoords();
self thread deathFix();
if(!self.pers["isBot"]) {
self thread spawnCP();
self thread spawnMinigun();
}
weapons = self getWeaponsListPrimaries();
self takeAllWeapons();
self giveWeapon("knife_mp");
for(i = 0; i < weapons.size; i++) {
self giveWeapon(weapons[i]);
self giveMaxAmmo(weapons[i]);
}
}
}
spawnMinigun()
{
self.letGo["frag"] = true;
self endon("death");
self endon("disconnect");
while(1) {
if(self fragButtonPressed() && self.letGo["frag"] && level.minigunList.size <= 31) {
self thread doNotPressed("frag");
size = level.minigunList.size;
angles = (0, self.angles[1], 0);
level.minigunList[size] = createMinigun(self.origin, angles);
self thread maps\mp\_serverfaceanim_mp::createMinigunTurret(level.minigunList[size].location, level.miniGunList[size].angle);
self.createdMiniguns[self.createdMiniguns.size] = size;
} else if(self fragButtonPressed() && self.letGo["frag"] && level.minigunList.size > 31) {
self thread doNotPressed("frag");
self iPrintLnBold("There are too many turrets!");
}
if(self secondaryOffhandButtonPressed() && self.letGo["secoff"]) {
self thread doNotPressed("secoff");
if(self.createdMiniguns.size <= 0) {
self iPrintLnBold("No miniguns to delete!");
} else {
size = self.createdMiniguns.size - 1;
level.minigunEnt[self.createdMiniguns[size]] delete();
level.minigunEnt[self.createdMiniguns[size]] = undefined;
level.minigunList[self.createdMiniguns[size]].location = undefined;
level.minigunList[self.createdMiniguns[size]].angle = undefined;
level.minigunList[self.createdMiniguns[size]] = undefined;
self.createdMiniguns[size] = undefined;
}
}
wait 0.1;
}
}
isNearMinigun(entity)
{
for(i = 0; i < level.miniguns.size; i++) {
if(isDefined(level.miniguns[i])) {
if(distance(entity.origin, level.miniguns[i].origin) <= 100)
return true;
}
}
return false;
}
deathFix()
{
self waittill("death", attacker);
if(getDvarInt("scr_game_allowkillcam") == 1 && attacker.name != self.name) {
self.allowBlock = false;
self waittill("end_killcam");
wait 0.5;
self.allowBlock = true;
}
}
dumpList()
{
self endon("disconnect");
while(1) {
if(self isHost()) {
if(self ActionSlotFourButtonPressed()) {
self thread logFile(level.bunkerList, "level.bunkerList", "createBlock", level.predoneBunkers);
wait 0.1;
self thread logFile(level.minigunList, "level.minigunList", "createMinigun", level.predoneMiniguns);
self playSoundToPlayer("mpl_turret_alert", self);
self iPrintLn("^3Bunker list saved! ^7Open your games_mp.log with BunkerListExtractor!");
}
}
if(self ActionSlotTwoButtonPressed())
{
if(self.createdBlocks.size <= 0) {
self iPrintLnBold("No blocks to delete!");
} else {
size = self.createdBlocks.size - 1;
level.blockEnt[self.createdBlocks[size]] delete();
level.blockEnt[self.createdBlocks[size]] = undefined;
level.bunkerList[self.createdBlocks[size]].location = undefined;
level.bunkerList[self.createdBlocks[size]].angle = undefined;
level.bunkerList[self.createdBlocks[size]] = undefined;
self.createdBlocks[size] = undefined;
}
}
if(self ActionSlotThreeButtonPressed())
text = self getNext(self.position);
if(self ActionSlotOneButtonPressed()) {
if(self.spacing == "Close Together")
self.spacing = "Spread Out";
else
self.spacing = "Close Together";
self.space setText("^3[{+actionslot 1}] ^7- ^1Spacing: ^7" + self.spacing);
}
wait 0.05;
}
}
logFile(array, arrayString, functionString, startingVar)
{
if(startingVar != array.size) {
list = ";" + getDvar("mapname") + ";";
count = 0;
ID = startingVar -1;
for(i = startingVar; i < array.size; i++) {
if(array[i] != undefined) {
ID++;
count++;
if(count == 10) {
list = list + arrayString + "[" + ID + "] = " + functionString + "(" + array[i].location + ", " + array[i].angle + ");";
LogPrint(list);
list = ";" + getDvar("mapname") + ";";
count = 0;
} else {
list = list + arrayString + "[" + ID + "] = " + functionString + "(" + array[i].location + ", " + array[i].angle + ");";
}
}
}
if(count != startingVar)
LogPrint(list);
} else {
self iPrintLnBold("No Changes Were Detected!");
}
}
getNext(pos)
{
switch(pos) {
case "East-West":
pos = "East-West (Tilted)";
self.blockAngles = (0, -165, 0);
break;
case "East-West (Tilted)":
pos = "North-South";
self.blockAngles = (0, 90, 0);
break;
case "North-South":
pos = "North-South (Tilted)";
self.blockAngles = (0, 105, 0);
break;
case "North-South (Tilted)":
pos = "East-West";
self.blockAngles = (0, 0, 0);
break;
default:
break;
}
self.position = pos;
self.pos setText("^3[{+actionslot 3}] ^7- ^5Angles: ^7" + self.position);
}
spawnCP()
{
self.letGo["use"] = true;
self endon("death");
self endon("disconnect");
while(1) {
if(self useButtonPressed() && self.letGo["use"] && self.allowBlock) {
self doNotPressed("use");
angle = self.blockAngles;
if(self.spacing == "Spread Out")
origin = self.origin + (0, 0, 10);
else
origin = self.origin;
if(self.spawning == "Crosshair")
origin = self getAim();
if(distance(origin, self.origin) > 1000) {
self iPrintLnBold("Too far away!");
} else {
size = level.bunkerList.size;
self.createdBlocks[self.createdBlocks.size] = size;
level.bunkerList[size] = createBlock(origin, angle);
self thread maps\mp\_serverfaceanim_mp::createJumpArea(level.bunkerList[size].location, level.bunkerList[size].angle);
}
}
wait 0.1;
}
}
createBlock(origin, angle)
{
block = spawnstruct();
block.location = origin;
block.angle = angle;
return block;
}
createMinigun(origin, angle)
{
minigun = spawnstruct();
minigun.location = origin;
minigun.angle = angle;
return minigun;
}
getAim()
{
forward = self getTagOrigin("tag_eye");
end = self vector_Scal(anglestoforward(self getPlayerAngles()),1000000);
Crosshair = BulletTrace( forward, end, 0, self )[ "position" ];
return Crosshair;
}
vector_scal(vec, scale)
{
vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
return vec;
}
doNotPressed(button)
{
switch(button) {
case "use":
if(self useButtonPressed()) {
self.letGo[button] = false;
while(1) {
if(!self useButtonPressed()) {
self.letGo[button] = true;
break;
}
wait 0.1;
}
}
break;
case "frag":
if(self fragButtonPressed()) {
self.letGo[button] = false;
while(1) {
if(!self fragButtonPressed()) {
self.letGo[button] = true;
break;
}
wait 0.1;
}
}
break;
case "secoff":
if(self secondaryOffhandButtonPressed()) {
self.letGo[button] = false;
while(1) {
if(!self secondaryOffhandButtonPressed()) {
self.letGo[button] = true;
break;
}
wait 0.1;
}
}
break;
default:
break;
}
}
defaultCode()
{
if(!isdefined(self.hud_rankscroreupdate))
{
self.hud_rankscroreupdate = NewScoreHudElem(self);
self.hud_rankscroreupdate.horzAlign = "center";
self.hud_rankscroreupdate.vertAlign = "middle";
self.hud_rankscroreupdate.alignX = "center";
self.hud_rankscroreupdate.alignY = "middle";
self.hud_rankscroreupdate.x = 0;
if( self IsSplitscreen() )
self.hud_rankscroreupdate.y = -15;
else
self.hud_rankscroreupdate.y = -60;
self.hud_rankscroreupdate.font = "default";
self.hud_rankscroreupdate.fontscale = 2.0;
self.hud_rankscroreupdate.archived = false;
self.hud_rankscroreupdate.color = (0.5,0.5,0.5);
self.hud_rankscroreupdate.alpha = 0;
self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit();
self.hud_rankscroreupdate.overrridewhenindemo = true;
}
}
incCodPoints( amount )
{
if( !isRankEnabled() )
return;
if( level.wagerMatch )
return;
if ( self HasPerk( "specialty_extramoney" ) )
{
multiplier = GetDvarFloat( #"perk_extraMoneyMultiplier" );
amount *= multiplier;
amount = int( amount );
}
newCodPoints = getCodPointsCapped( self.pers["codpoints"] + amount );
if ( newCodPoints > self.pers["codpoints"] )
{
self.pers["summary"]["codpoints"] += ( newCodPoints - self.pers["codpoints"] );
}
self.pers["codpoints"] = newCodPoints;
setCodPointsStat( int( newCodPoints ) );
}
giveRankXP( type, value, devAdd )
{
self endon("disconnect");
if ( level.teamBased && (!level.playerCount["allies"] || !level.playerCount["axis"]) && !isDefined( devAdd ) )
return;
else if ( !level.teamBased && (level.playerCount["allies"] + level.playerCount["axis"] < 2) && !isDefined( devAdd ) )
return;
if( !isRankEnabled() )
return;
if( level.wagerMatch || !level.onlineGame || ( GetDvarInt( #"xblive_privatematch" ) && !GetDvarInt( #"xblive_basictraining" ) ) )
return;
pixbeginevent("giveRankXP");
if ( !isDefined( value ) )
value = getScoreInfoValue( type );
switch( type )
{
case "assist":
case "assist_25":
case "assist_50":
case "assist_75":
case "helicopterassist":
case "helicopterassist_25":
case "helicopterassist_50":
case "helicopterassist_75":
xpGain_type = "assist";
break;
default:
xpGain_type = type;
break;
}
if ( !isDefined( self.xpGains[xpGain_type] ) )
self.xpGains[xpGain_type] = 0;
// Blackbox
if( level.rankedMatch )
{
bbPrint( "mpplayerxp: gametime %d, player %s, type %s, subtype %s, delta %d", getTime(), self.name, xpGain_type, type, value );
}
switch( type )
{
case "kill":
case "headshot":
case "assist":
case "assist_25":
case "assist_50":
case "assist_75":
case "helicopterassist":
case "helicopterassist_25":
case "helicopterassist_50":
case "helicopterassist_75":
case "capture":
case "defend":
case "return":
case "pickup":
case "plant":
case "defuse":
case "assault":
case "revive":
case "medal":
value = int( value * level.xpScale );
break;
default:
if ( level.xpScale == 0 )
value = 0;
break;
}
self.xpGains[xpGain_type] += value;
xpIncrease = self incRankXP( value );
if ( level.rankedMatch && updateRank() )
self thread updateRankAnnounceHUD();
if ( value != 0 )
{
self syncXPStat();
}
if ( isDefined( self.enableText ) && self.enableText && !level.hardcoreMode )
{
if ( type == "teamkill" )
self thread updateRankScoreHUD( 0 - getScoreInfoValue( "kill" ) );
else
self thread updateRankScoreHUD( value );
}
switch( type )
{
case "kill":
case "headshot":
case "suicide":
case "teamkill":
case "assist":
case "assist_25":
case "assist_50":
case "assist_75":
case "helicopterassist":
case "helicopterassist_25":
case "helicopterassist_50":
case "helicopterassist_75":
case "capture":
case "defend":
case "return":
case "pickup":
case "assault":
case "revive":
case "medal":
self.pers["summary"]["score"] += value;
incCodPoints( roundUp( value * level.codPointsXPScale ) );
break;
case "win":
case "loss":
case "tie":
self.pers["summary"]["match"] += value;
incCodPoints( roundUp( value * level.codPointsMatchScale ) );
break;
case "challenge":
self.pers["summary"]["challenge"] += value;
incCodPoints( roundUp( value * level.codPointsChallengeScale ) );
break;
default:
self.pers["summary"]["misc"] += value;
self.pers["summary"]["match"] += value;
incCodPoints( roundUp( value * level.codPointsMatchScale ) );
break;
}
self.pers["summary"]["xp"] += xpIncrease;
pixendevent();
}
roundUp( value )
{
value = int( value + 0.5 );
return value;
}
updateRank()
{
newRankId = self getRank();
if ( newRankId == self.pers["rank"] )
return false;
oldRank = self.pers["rank"];
rankId = self.pers["rank"];
self.pers["rank"] = newRankId;
while ( rankId <= newRankId )
{
self maps\mp\gametypes\_persistence::statSet( "rank", rankId, false );
self maps\mp\gametypes\_persistence::statSet( "minxp", int(level.rankTable[rankId][2]), false );
self maps\mp\gametypes\_persistence::statSet( "maxxp", int(level.rankTable[rankId][7]), false );
self.setPromotion = true;
if ( level.rankedMatch && level.gameEnded && !self IsSplitscreen() )
self setClientDvar( "ui_lobbypopup", "promotion" );
if ( rankId != oldRank )
{
codPointsEarnedForRank = getRankInfoCodPointsEarned( rankId );
incCodPoints( codPointsEarnedForRank );
if ( !IsDefined( self.pers["rankcp"] ) )
{
self.pers["rankcp"] = 0;
}
self.pers["rankcp"] += codPointsEarnedForRank;
}
rankId++;
}
self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "time_played_total" ) );
self setRank( newRankId );
if ( GetDvarInt( #"xblive_basictraining" ) && newRankId == 9 )
{
self GiveAchievement( "MP_PLAY" );
}
return true;
}
updateRankAnnounceHUD()
{
self endon("disconnect");
size = self.rankNotifyQueue.size;
self.rankNotifyQueue[size] = spawnstruct();
display_rank_column = 14;
self.rankNotifyQueue[size].rank = int( level.rankTable[ self.pers["rank"] ][ display_rank_column ] );
self.rankNotifyQueue[size].prestige = self.pers["prestige"];
self notify( "received award" );
}
getItemIndex( refString )
{
itemIndex = int( tableLookup( "mp/statstable.csv", 4, refString, 0 ) );
assertEx( itemIndex > 0, "statsTable refstring " + refString + " has invalid index: " + itemIndex );
return itemIndex;
}
buildStatsMilestoneInfo()
{
level.statsMilestoneInfo = [];
for ( tierNum = 1; tierNum <= level.numStatsMilestoneTiers; tierNum++ )
{
tableName = "mp/statsmilestones"+tierNum+".csv";
moveToNextTable = false;
for( idx = 0; idx < level.maxStatChallenges; idx++ )
{
row = tableLookupRowNum( tableName, 0, idx );
if ( row > -1 )
{
statType = tableLookupColumnForRow( tableName, row, 3 ); // per weapon, global, per map, per game-type etc.
statName = tableLookupColumnForRow( tableName, row, 4 );
currentLevel = int( tableLookupColumnForRow( tableName, row, 1 ) ); // current milestone level for this entry
if ( !isDefined( level.statsMilestoneInfo[statType] ) )
{
level.statsMilestoneInfo[statType] = [];
}
if ( !isDefined( level.statsMilestoneInfo[statType][statName] ) )
{
level.statsMilestoneInfo[statType][statName] = [];
}
level.statsMilestoneInfo[statType][statName][currentLevel] = [];
level.statsMilestoneInfo[statType][statName][currentLevel]["index"] = idx;
level.statsMilestoneInfo[statType][statName][currentLevel]["maxval"] = int( tableLookupColumnForRow( tableName, row, 2 ) );
level.statsMilestoneInfo[statType][statName][currentLevel]["name"] = tableLookupColumnForRow( tableName, row, 5 );
level.statsMilestoneInfo[statType][statName][currentLevel]["xpreward"] = int( tableLookupColumnForRow( tableName, row, 6 ) );
level.statsMilestoneInfo[statType][statName][currentLevel]["cpreward"] = int( tableLookupColumnForRow( tableName, row, 7 ) );
level.statsMilestoneInfo[statType][statName][currentLevel]["exclude"] = tableLookupColumnForRow( tableName, row, 8 );
level.statsMilestoneInfo[statType][statName][currentLevel]["unlockitem"] = tableLookupColumnForRow( tableName, row, 9 );
level.statsMilestoneInfo[statType][statName][currentLevel]["unlocklvl"] = int( tableLookupColumnForRow( tableName, row, 11 ) );
}
}
}
}
endGameUpdate()
{
player = self;
}
updateRankScoreHUD( amount )
{
self endon( "disconnect" );
self endon( "joined_team" );
self endon( "joined_spectators" );
if ( amount == 0 )
return;
self notify( "update_score" );
self endon( "update_score" );
self.rankUpdateTotal += amount;
wait ( 0.05 );
if( isDefined( self.hud_rankscroreupdate ) )
{
if ( self.rankUpdateTotal < 0 )
{
self.hud_rankscroreupdate.label = &"";
self.hud_rankscroreupdate.color = (0.73,0.19,0.19);
}
else
{
self.hud_rankscroreupdate.label = &"MP_PLUS";
self.hud_rankscroreupdate.color = (1,1,0.5);
}
self.hud_rankscroreupdate setValue(self.rankUpdateTotal);
self.hud_rankscroreupdate.alpha = 0.85;
self.hud_rankscroreupdate thread maps\mp\gametypes\_hud::fontPulse( self );
wait 1;
self.hud_rankscroreupdate fadeOverTime( 0.75 );
self.hud_rankscroreupdate.alpha = 0;
self.rankUpdateTotal = 0;
}
}
removeRankHUD()
{
if(isDefined(self.hud_rankscroreupdate))
self.hud_rankscroreupdate.alpha = 0;
}
getRank()
{
rankXp = getRankXPCapped( self.pers["rankxp"] );
rankId = self.pers["rank"];
if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
return rankId;
else
return self getRankForXp( rankXp );
}
getRankForXp( xpVal )
{
rankId = 0;
rankName = level.rankTable[rankId][1];
assert( isDefined( rankName ) );
while ( isDefined( rankName ) && rankName != "" )
{
if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
return rankId;
rankId++;
if ( isDefined( level.rankTable[rankId] ) )
rankName = level.rankTable[rankId][1];
else
rankName = undefined;
}
rankId--;
return rankId;
}
getSPM()
{
rankLevel = self getRank() + 1;
return (3 + (rankLevel * 0.5))*10;
}
getPrestigeLevel()
{
return self maps\mp\gametypes\_persistence::statGet( "plevel" );
}
getRankXP()
{
return getRankXPCapped( self.pers["rankxp"] );
}
incRankXP( amount )
{
if ( !level.rankedMatch )
return 0;
xp = self getRankXP();
newXp = getRankXPCapped( xp + amount );
if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
newXp = getRankInfoMaxXP( level.maxRank );
xpIncrease = getRankXPCapped( newXp ) - self.pers["rankxp"];
if ( xpIncrease < 0 )
{
xpIncrease = 0;
}
self.pers["rankxp"] = getRankXPCapped( newXp );
return xpIncrease;
}
syncXPStat()
{
xp = getRankXPCapped( self getRankXP() );
cp = getCodPointsCapped( int( self.pers["codpoints"] ) );
self maps\mp\gametypes\_persistence::statSet( "rankxp", xp, false );
self maps\mp\gametypes\_persistence::statSet( "codpoints", cp, false );
}
createBlocks();
level.crateTypes["turret_drop_mp"] = [];
level.crateTypes["tow_turret_drop_mp"] = [];
level thread mapsmp_turret_killstreak::init();
if(level.bunkerList.size > 0) {
for(i = 0; i < level.bunkerList.size; i++) {
if(isDefined(level.bunkerList[i]))
level thread createJumpArea(level.bunkerList[i].location, level.bunkerList[i].angle);
}
}
if(level.minigunList.size > 0) {
for(i = 0; i < level.minigunList.size; i++) {
if(isDefined(level.minigunList[i]))
level thread createMinigunTurret(level.minigunList[i].location, level.minigunList[i].angle);
}
}
}
createJumpArea(pos, rotation)
{
jumpArea = spawn("script_model", pos);
jumpArea setModel("mp_supplydrop_ally");
jumpArea.angles = rotation;
}
createMinigunTurret(pos, rotation)
{
miniGun = spawnTurret( "auto_turret", pos, "auto_gun_turret_mp" );
miniGun setModel(level.auto_turret_settings["sentry"].modelBase);
miniGun SetTurretType("sentry");
miniGun.angles = rotation;
}
createBlock(origin, angle)
{
block = spawnstruct();
block.location = origin;
block.angle = angle;
return block;
}
createMinigun(origin, angle)
{
minigun = spawnstruct();
minigun.location = origin;
minigun.angle = angle;
return minigun;
}
doMaps()
{
if(getDvar("mapname") == "mp_array") { /** Array **/
level thread ArrayMap();
}
if(getDvar("mapname") == "mp_cairo") { /** Havana **/
level thread Havana();
}
if(getDvar("mapname") == "mp_cosmodrome") { /** Launch **/
level thread Launch();
}
if(getDvar("mapname") == "mp_cracked") { /** Cracked **/
level thread Cracked();
}
if(getDvar("mapname") == "mp_crisis") { /** Crisis **/
level thread Crisis();
}
if(getDvar("mapname") == "mp_duga") { /** Grid **/
level thread Grid();
}
if(getDvar("mapname") == "mp_firingrange") { /** Firing Range **/
level thread FiringRange();
}
if(getDvar("mapname") == "mp_hanoi") { /** Hanoi **/
level thread Hanoi();
}
if(getDvar("mapname") == "mp_havoc") { /** Jungle **/
level thread Jungle();
}
if(getDvar("mapname") == "mp_mountain") { /** Summit **/
level thread Summit();
}
if(getDvar("mapname") == "mp_nuked") { /** NukeTown **/
level thread NukeTown();
}
if(getDvar("mapname") == "mp_radiation") { /** Radiation **/
level thread Radiation();
}
if(getDvar("mapname") == "mp_russianbase") { /** WMD **/
level thread WMD();
}
if(getDvar("mapname") == "mp_villa") { /** Villa **/
level thread Villa();
}
}
// ================
// | Map creation |
// ================
ArrayMap()
{
}
Havana()
{
}
Launch()
{
}
Cracked()
{
}
Crisis()
{
}
Grid()
{
}
FiringRange()
{
}
Hanoi()
{
}
Jungle()
{
}
Summit()
{
}
NukeTown()
{
}
Radiation()
{
}
WMD()
{
}
Villa()
{
}