Index: rts/Game/GameHelper.cpp =================================================================== --- rts/Game/GameHelper.cpp (revision 3878) +++ rts/Game/GameHelper.cpp (working copy) @@ -109,8 +109,8 @@ float dist1 = dist; if (dist1 > radius) dist1 = radius; - float mod =(radius-dist1)/(radius-dist1*edgeEffectiveness); - float mod2=(radius-dist2)/(radius-dist2*edgeEffectiveness); + float mod =(dist1*edgeEffectiveness+radius-dist1)/(radius); + float mod2=(dist2*edgeEffectiveness+radius-dist2)/(radius); dif/=dist; // dist > (*ui)->radius+0.1f, see above dif.y+=0.12f; Index: rts/Sim/Units/Unit.cpp =================================================================== --- rts/Sim/Units/Unit.cpp (revision 3878) +++ rts/Sim/Units/Unit.cpp (working copy) @@ -124,7 +124,10 @@ crashing(false), cob(0), bonusShieldDir(1,0,0), - bonusShieldSaved(10), + bonusShieldSaved(0), + bonusShieldSavedAdd(0.05f), + bonusShieldMaxDamage(1.9f), + bonusShieldDifDamage(0.5f), group(0), lastDamage(-100), lastFireWeapon(0), @@ -389,7 +392,7 @@ moveType->Update(); recentDamage*=0.9f; - bonusShieldSaved+=0.005f; + bonusShieldSaved+=bonusShieldSavedAdd; if(stunned) return; @@ -577,7 +580,7 @@ health=maxHealth; } - bonusShieldSaved+=0.05f; + bonusShieldSaved+=bonusShieldSavedAdd*10.0f; residualImpulse*=0.6f; if (scriptCloak >= 3) { @@ -686,22 +689,24 @@ float damage=damages[armorType]; - if(damage<0){ -// logOutput.Print("Negative damage"); - return; - } + if(damage>0){ - if(attacker){ - SetLastAttacker(attacker); - float3 adir=attacker->pos-pos; - adir.Normalize(); - bonusShieldDir+=adir*bonusShieldSaved; //not the best way to do it(but fast) - bonusShieldDir.Normalize(); -// logOutput.Print("shield mult %f %f %i %i", 2-adir.dot(bonusShieldDir),bonusShieldSaved,id,attacker->id); - bonusShieldSaved=0; - damage*=1.4f-adir.dot(bonusShieldDir)*0.5f; + if(attacker && bonusShieldSavedAdd){ + SetLastAttacker(attacker); + float3 adir=attacker->pos-pos; + adir.Normalize(); + bonusShieldDir+=adir*bonusShieldSaved; //not the best way to do it(but fast) + bonusShieldDir.Normalize(); +// logOutput.Print("shield mult %f %f %i %i", 1.4f-adir.dot(bonusShieldDir)*.5f,bonusShieldSaved,id,attacker->id); + bonusShieldSaved=0; + damage*=bonusShieldAvgDamage-adir.dot(bonusShieldDir)*bonusShieldDifDamage; + } + + restTime=0; } + float experienceMod=1; + damage*=curArmorMultiple; float3 hitDir = impulse; @@ -729,34 +734,47 @@ cob->Call(COBFN_HitByWeapon, cobargs); } - restTime=0; - - float experienceMod=1; - if(damages.paralyzeDamageTime){ - paralyzeDamage+=damage; - experienceMod=0.1f; //reduce experience for paralyzers - if(health-paralyzeDamage<0){ - if(stunned) - experienceMod=0; //dont get any experience for paralyzing paralyzed enemy - stunned=true; - if(paralyzeDamage>health+(maxHealth*0.025f*damages.paralyzeDamageTime)){ - paralyzeDamage=health+(maxHealth*0.025f*damages.paralyzeDamageTime); + if(damage>0){ + paralyzeDamage+=damage; + experienceMod=0.1f; //reduce experience for paralyzers + if(health-paralyzeDamage<0){ + if(stunned) + experienceMod=0; //dont get any experience for paralyzing paralyzed enemy + stunned=true; + if(paralyzeDamage>health+(maxHealth*0.025f*damages.paralyzeDamageTime)){ + paralyzeDamage=health+(maxHealth*0.025f*damages.paralyzeDamageTime); + } } + }else{ + if(paralyzeDamage>0){ + experienceMod=0.1f; //gives experience for healing paralysis + }else{ + experienceMod=0; + } } } else { - // Dont log overkill damage (so dguns/nukes etc dont inflate values) - float statsdamage = std::min(health, damage); - if (attacker) + if(damage>0){ + // Dont log overkill damage (so dguns/nukes etc dont inflate values) + float statsdamage = std::min(health, damage); + if (attacker) gs->Team(attacker->team)->currentStats.damageDealt += statsdamage; - gs->Team(team)->currentStats.damageReceived += statsdamage; - health-=damage; + gs->Team(team)->currentStats.damageReceived += statsdamage; + health-=damage; + }else{ + if(maxHealth>health){ + health=std::min(maxHealth,health-=damage); + experienceMod=0.1f; //units get some, but not much, experience for healing + }else{ + experienceMod=0; + } + } } recentDamage+=damage; if(attacker!=0 && !gs->Ally(allyteam,attacker->allyteam)){ // logOutput.Print("%s has %f/%f h attacker %s do %f d",tooltip.c_str(),health,maxHealth,attacker->tooltip.c_str(),damage); - attacker->experience+=0.1f*power/attacker->power*(damage+min(0.f,health))/maxHealth*experienceMod; + attacker->experience+=0.1f*power/attacker->power*(fabs(damage)+min(0.f,health))/maxHealth*experienceMod; attacker->ExperienceChange(); ENTER_UNSYNCED; if (((!unitDef->isCommander && uh->lastDamageWarning+100frameNum) || Index: rts/Sim/Units/Unit.h =================================================================== --- rts/Sim/Units/Unit.h (revision 3878) +++ rts/Sim/Units/Unit.h (working copy) @@ -268,6 +268,9 @@ float3 bonusShieldDir; //units takes less damage when attacked from this dir (encourage flanking fire) float bonusShieldSaved; //how much the bonus shield can turn upon an attack(zeroed when attacked, slowly increase) + float bonusShieldSavedAdd; //how much bonusShieldSaved builds up each slowupdate + float bonusShieldAvgDamage; //average factor to multiply damage by + float bonusShieldDifDamage; //(max damage - min damage)/2 bool armoredState; float armoredMultiple; Index: rts/Sim/Units/UnitDef.h =================================================================== --- rts/Sim/Units/UnitDef.h (revision 3878) +++ rts/Sim/Units/UnitDef.h (working copy) @@ -345,6 +345,11 @@ float refuelTime; //time to fully refuel unit float minAirBasePower; //min build power for airbases that this aircraft can land on + float3 bonusShieldDir; //units takes less damage when attacked from this dir (encourage flanking fire) + float bonusShieldSavedAdd; //how much bonusShieldSaved builds up each update (and 10x as much each slowupdate) + float bonusShieldMaxDamage; //maximum factor to multiply damage by + float bonusShieldMinDamage; //minimum factor to multiply damage by + std::vector sfxExplGens; //list of explosiongenerators for use in scripts int maxThisUnit; //number of units of this type allowed simultaniously in the game Index: rts/Sim/Units/UnitDefHandler.cpp =================================================================== --- rts/Sim/Units/UnitDefHandler.cpp (revision 3878) +++ rts/Sim/Units/UnitDefHandler.cpp (working copy) @@ -434,6 +434,11 @@ tdfparser.GetDef(ud.refuelTime, "5", "UNITINFO\\refueltime"); tdfparser.GetDef(ud.minAirBasePower, "0", "UNITINFO\\minairbasepower"); + ud.bonusShieldDir=tdfparser.GetFloat3(float3(1,0,0), "UNITINFO\\BonusShieldDir"); + tdfparser.GetDef(ud.bonusShieldSavedAdd, "0.005", "UNITINFO\\bonusShieldSavedAdd"); + tdfparser.GetDef(ud.bonusShieldMaxDamage, "1.9", "UNITINFO\\bonusShieldMaxDamage"); + tdfparser.GetDef(ud.bonusShieldMinDamage, "0.9", "UNITINFO\\bonusShieldMinDamage"); + tdfparser.GetTDef(ud.maxThisUnit, MAX_UNITS, "UNITINFO\\UnitRestricted"); if (gameSetup) { Index: rts/Sim/Units/UnitLoader.cpp =================================================================== --- rts/Sim/Units/UnitLoader.cpp (revision 3878) +++ rts/Sim/Units/UnitLoader.cpp (working copy) @@ -153,6 +153,12 @@ unit->armorType=ud->armorType; unit->floatOnWater = ud->floater || (ud->movedata && ((ud->movedata->moveType == MoveData::Hover_Move) || (ud->movedata->moveType == MoveData::Ship_Move))); unit->maxSpeed = ud->speed/30.0; + unit->bonusShieldDir=ud->bonusShieldDir; + unit->bonusShieldDir.Normalize(); + unit->bonusShieldSaved=ud->bonusShieldSavedAdd*1000; + unit->bonusShieldSavedAdd=ud->bonusShieldSavedAdd; + unit->bonusShieldAvgDamage=ud->(bonusShieldMaxDamage + ud->bonusShieldMinDamage)*0.5f; + unit->bonusShieldDifDamage=ud->(bonusShieldMaxDamage - ud->bonusShieldMinDamage)*0.5f; if(ud->highTrajectoryType==1) unit->useHighTrajectory=true; Index: rts/Sim/Weapons/WeaponDefHandler.cpp =================================================================== --- rts/Sim/Weapons/WeaponDefHandler.cpp (revision 3878) +++ rts/Sim/Weapons/WeaponDefHandler.cpp (working copy) @@ -247,9 +247,6 @@ weaponDefs[id].areaOfEffect=atof(sunparser->SGetValueDef("8", weaponname + "\\areaofeffect").c_str())*0.5f; weaponDefs[id].edgeEffectiveness=atof(sunparser->SGetValueDef("0", weaponname + "\\edgeEffectiveness").c_str()); - // prevent 0/0 division in CGameHelper::Explosion - if (weaponDefs[id].edgeEffectiveness > 0.999f) - weaponDefs[id].edgeEffectiveness = 0.999f; weaponDefs[id].projectilespeed = atof(sunparser->SGetValueDef("0", weaponname + "\\weaponvelocity").c_str())/GAME_SPEED; weaponDefs[id].startvelocity = max(0.01f,(float)atof(sunparser->SGetValueDef("0", weaponname + "\\startvelocity").c_str())/GAME_SPEED); weaponDefs[id].weaponacceleration = atof(sunparser->SGetValueDef("0", weaponname + "\\weaponacceleration").c_str())/GAME_SPEED/GAME_SPEED;