Skip to content

Commit

Permalink
Evocom - hotfix to improve cortex commanders shield behavior and anim…
Browse files Browse the repository at this point in the history
…ation (#3221)

change the way cortex commander transfers damage to shield

it used to be that the commander would just be armored while shield was up to reduce damage from attacks that ignored shield.

Now, the damage dealt to the commander is accurately transferred to the shield.

Due to technical limitations, overkill damage that's bigger than the shield is ignored. So a single attack of 10000000 damage would deplete the shield, but that's it.

Once below the shield threshold (4% or so) then damage is taken like normal

Also added RestoreAfterDelay() equivalent to reset torso and head position
  • Loading branch information
SethDGamre authored Jun 23, 2024
1 parent 888ff39 commit 83166b4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.
74 changes: 39 additions & 35 deletions scripts/Units/corcomhilvl.bos
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
piece torso, lfirept, rbigflash, nanospray, nanolathe, luparm, ruparm, pelvis,
rthigh, lthigh, biggun, lleg, l_foot, rleg, r_foot, head, teleport, aimx1, aimy1, nanol1, nanol2, nanol3, leye, reye, eyeflare, cagelight, cagelight_emit, headmount, hatpoint, crown, medalsilver, medalbronze, medalgold, torsofrontmarker;

static-var bMoving, bAiming, Busy, gun_6, gun_3, gun_2, gun_eye, counter, shieldUp,
static-var bMoving, bAiming, Busy, gun_6, gun_3, gun_2, gun_eye, counter,
bIsBuilding, buildPitch, buildHeading, maxSpeed, currentSpeed, animSpeed, justMoved, shotcount;

// for the AimPrimary script, to skip wait-for-turn if needed
Expand Down Expand Up @@ -769,23 +769,6 @@ UnitSpeed(){
}
}


UnitTimer()
{
while (TRUE)
{
shieldUp = get SHIELD_POWER;
if (shieldUp > 40000000){
set ARMORED to 1;
sleep 500;
}
else{
set ARMORED to 0;
sleep 3000;
}
}
}

Create()
{
hide rbigflash;
Expand Down Expand Up @@ -835,7 +818,6 @@ Create()
currentSpeed = 100;
//call-script TeleportControl();
start-script UnitSpeed();
start-script UnitTimer();
}

lua_UnitScriptLight(lightIndex, count)
Expand Down Expand Up @@ -944,6 +926,22 @@ ResumeBuilding()
return (0);
}

HitByWeaponId(anglex, anglez, weaponid, dmg) // angle[x|z] is always [-500;500],
{
var shieldPower, shieldDamage;

shieldPower = get SHIELD_POWER;

if (shieldPower > 40000000){
set SHIELD_POWER to (shieldPower - ( dmg * 635 )); //635x is the multiplier by which damage is scaled according to shields
get PRINT(shieldPower, dmg);
return (0);
}
if (shieldPower <= 40000000){
return (100); //the return value is a percentage of the damage. 100 = 100%
}
}

AimFromPrimary(piecenum)
{
piecenum = torso;
Expand Down Expand Up @@ -989,6 +987,7 @@ AimPrimary(heading, pitch)
{
start-script ResumeBuilding();
}
start-script RestorePosition();
return (1);
}

Expand Down Expand Up @@ -1023,6 +1022,7 @@ AimTertiary(heading, pitch)
//turn ruparm to x-axis <0> speed <360>;
wait-for-turn aimy1 around y-axis;
//wait-for-turn biggun around x-axis;
start-script RestorePosition();
return (1);
}

Expand Down Expand Up @@ -1079,6 +1079,7 @@ AimSecondary(heading, pitch)
{
start-script ResumeBuilding();
}
start-script RestorePosition();
return (1);
}

Expand Down Expand Up @@ -1117,22 +1118,24 @@ QueryWeapon5(piecenum)
}

AimWeapon5(heading, pitch)
{
signal SIG_AIM2;
set-signal-mask SIG_AIM2;
bAiming = TRUE;
turn head to y-axis heading speed <300.000000>;
turn head to x-axis <-5.000000> - pitch speed <250.000000>;
if ( (get ABS(last_primary_heading - heading)>1800) OR (get ABS(last_primary_pitch - pitch)>1500) )
{
wait-for-turn head around y-axis;
wait-for-turn head around x-axis;
}
last_primary_heading=heading;
last_primary_pitch=pitch;
gun_eye = eyeflare;
return (1);
}
{
signal SIG_AIM2;
set-signal-mask SIG_AIM2;
bAiming = TRUE;
turn head to y-axis heading speed <300.000000>;
turn head to x-axis <-5.000000> - pitch speed <250.000000>;
if ( (get ABS(last_primary_heading - heading)>1800) OR (get ABS(last_primary_pitch - pitch)>1500) )
{
wait-for-turn head around y-axis;
wait-for-turn head around x-axis;
}
last_primary_heading=heading;
last_primary_pitch=pitch;
gun_eye = eyeflare;
start-script RestoreHeadPosition();
return (1);
}

FireWeapon5()
{
sleep 100;
Expand Down Expand Up @@ -1178,6 +1181,7 @@ AimWeapon6(heading, pitch)
//turn ruparm to x-axis <0> speed <360>;
wait-for-turn aimy1 around y-axis;
//wait-for-turn biggun around x-axis;
start-script RestorePosition();
return (1);
}

Expand Down
Binary file modified scripts/Units/corcomhilvl.cob
Binary file not shown.

0 comments on commit 83166b4

Please sign in to comment.