# HG changeset patch # User Henek # Date 1292610422 -3600 # Node ID 05c32ee166b6780075cb4645817fb2342eff8b94 # Parent d300ea498486a6238c9459a130f120fdc28ba811 added replacement of "_" to " " in gameplay scripts diff -r d300ea498486 -r 05c32ee166b6 QTfrontend/gamecfgwidget.cpp --- a/QTfrontend/gamecfgwidget.cpp Fri Dec 17 09:26:02 2010 +0100 +++ b/QTfrontend/gamecfgwidget.cpp Fri Dec 17 19:27:02 2010 +0100 @@ -58,6 +58,7 @@ for (int i = 0; i < scriptList->size(); ++i) { QString script = (*scriptList)[i].remove(".lua", Qt::CaseInsensitive); QList scriptInfo; + scriptInfo.push_back(script); QFile scriptCfgFile(QString("%1/Scripts/Multiplayer/%2.cfg").arg(datadir->absolutePath()).arg(script)); if (scriptCfgFile.exists() && scriptCfgFile.open(QFile::ReadOnly)) { QString scheme; @@ -80,7 +81,7 @@ scriptInfo.push_back("locked"); scriptInfo.push_back("locked"); } - Scripts->addItem(script, scriptInfo); + Scripts->addItem(script.replace("_", " "), scriptInfo); } connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int))); @@ -271,7 +272,7 @@ if (Scripts->currentIndex() > 0) { - bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->currentText()).toUtf8(); + bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex()).toList()[0].toString()).toUtf8(); } QByteArray result; @@ -473,8 +474,8 @@ { if(index > 0) { - QString scheme = Scripts->itemData(Scripts->currentIndex()).toList()[0].toString(); - QString weapons = Scripts->itemData(Scripts->currentIndex()).toList()[1].toString(); + QString scheme = Scripts->itemData(Scripts->currentIndex()).toList()[1].toString(); + QString weapons = Scripts->itemData(Scripts->currentIndex()).toList()[2].toString(); if (scheme == "locked") { diff -r d300ea498486 -r 05c32ee166b6 share/hedgewars/Data/Scripts/Multiplayer/RandomWeapon.cfg --- a/share/hedgewars/Data/Scripts/Multiplayer/RandomWeapon.cfg Fri Dec 17 09:26:02 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -Default -locked diff -r d300ea498486 -r 05c32ee166b6 share/hedgewars/Data/Scripts/Multiplayer/RandomWeapon.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/RandomWeapon.lua Fri Dec 17 09:26:02 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -local weapons = { amGrenade, amClusterBomb, amBazooka, amBee, amShotgun, - amMine, amDEagle, amDynamite, amFirePunch, amWhip, amPickHammer, - amBaseballBat, amAirAttack, amMineStrike, amTeleport, amMortar, amCake, - amSeduction, amWatermelon, amHellishBomb, amNapalm, amDrill, amBallgun, - amRCPlane, amSniperRifle, amMolotov, amBirdy, amBlowTorch, - amGasBomb, amFlamethrower, amSMine, amHammer, amDrillStrike } - -local lastRound = -1 -local weapon = 0 - -function onGameInit() - GameFlags = band(bor(GameFlags, gfResetWeps), bnot(gfInfAttack + gfPerHogAmmo)) -end - -function onAmmoStoreInit() - SetAmmo(amSkip, 9, 0, 0, 0) - - SetAmmo(amParachute, 0, 1, 0, 1) - SetAmmo(amGirder, 0, 1, 0, 2) - SetAmmo(amSwitch, 0, 1, 0, 1) - SetAmmo(amLowGravity, 0, 1, 0, 1) - SetAmmo(amExtraDamage, 0, 1, 0, 1) - SetAmmo(amInvulnerable, 0, 1, 0, 1) - SetAmmo(amExtraTime, 0, 1, 0, 1) - SetAmmo(amLaserSight, 0, 1, 0, 1) - SetAmmo(amVampiric, 0, 1, 0, 1) - SetAmmo(amJetpack, 0, 1, 0, 1) - SetAmmo(amPortalGun, 0, 1, 0, 1) - SetAmmo(amResurrector, 0, 1, 0, 1) - - for i, w in pairs(weapons) do - SetAmmo(w, 0, 0, 0, 1) - end -end - -function onNewTurn() - if lastRound ~= TotalRounds then - weapon = GetRandom(table.maxn(weapons)) + 1 - lastRound = TotalRounds - end - AddAmmo(CurrentHedgehog, weapons[weapon]) -end diff -r d300ea498486 -r 05c32ee166b6 share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.cfg Fri Dec 17 19:27:02 2010 +0100 @@ -0,0 +1,2 @@ +Default +locked diff -r d300ea498486 -r 05c32ee166b6 share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua Fri Dec 17 19:27:02 2010 +0100 @@ -0,0 +1,42 @@ +local weapons = { amGrenade, amClusterBomb, amBazooka, amBee, amShotgun, + amMine, amDEagle, amDynamite, amFirePunch, amWhip, amPickHammer, + amBaseballBat, amAirAttack, amMineStrike, amTeleport, amMortar, amCake, + amSeduction, amWatermelon, amHellishBomb, amNapalm, amDrill, amBallgun, + amRCPlane, amSniperRifle, amMolotov, amBirdy, amBlowTorch, + amGasBomb, amFlamethrower, amSMine, amHammer, amDrillStrike } + +local lastRound = -1 +local weapon = 0 + +function onGameInit() + GameFlags = band(bor(GameFlags, gfResetWeps), bnot(gfInfAttack + gfPerHogAmmo)) +end + +function onAmmoStoreInit() + SetAmmo(amSkip, 9, 0, 0, 0) + + SetAmmo(amParachute, 0, 1, 0, 1) + SetAmmo(amGirder, 0, 1, 0, 2) + SetAmmo(amSwitch, 0, 1, 0, 1) + SetAmmo(amLowGravity, 0, 1, 0, 1) + SetAmmo(amExtraDamage, 0, 1, 0, 1) + SetAmmo(amInvulnerable, 0, 1, 0, 1) + SetAmmo(amExtraTime, 0, 1, 0, 1) + SetAmmo(amLaserSight, 0, 1, 0, 1) + SetAmmo(amVampiric, 0, 1, 0, 1) + SetAmmo(amJetpack, 0, 1, 0, 1) + SetAmmo(amPortalGun, 0, 1, 0, 1) + SetAmmo(amResurrector, 0, 1, 0, 1) + + for i, w in pairs(weapons) do + SetAmmo(w, 0, 0, 0, 1) + end +end + +function onNewTurn() + if lastRound ~= TotalRounds then + weapon = GetRandom(table.maxn(weapons)) + 1 + lastRound = TotalRounds + end + AddAmmo(CurrentHedgehog, weapons[weapon]) +end