Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Arm Medium Tank (Stumpy)
- -- //Arm Medium Tank (Stumpy)
- --piece base,flare,turret;
- local base, flare, turret = piece "base", piece "flare", piece "turret"
- --static-var restore_delay;
- local restore_delay = Spring.UnitScript.GetLongestReloadTime(unitID) * 2
- --#define SIG_AIM 2
- local SIG_AIM = 2
- --#define SMOKEPIECE1 base
- --#include "smokeunit.h"
- --#include "exptype.h"
- --#include "rockunit.h"
- function script.RockUnit(unitID, x, z) return GG.UnitScript.RockUnit(unitID, x, z, base)
- --#include "hitweap.h"
- function script.HitByWeapon(unitID, x, z) return GG.UnitScript.HitByWeapon(unitID, x, z, base)
- --[[Create()
- {
- hide flare;
- restore_delay=3000;
- start-script SmokeUnit();
- }]]
- function script.Create(unitID)
- Hide(unitID, flare)
- StartThread(unitID, GG.UnitScript.SmokeUnit)
- end
- --[[SetMaxReloadTime(time)
- {
- restore_delay = time * 2;
- }]]
- --[[RestoreAfterDelay()
- {
- sleep restore_delay;
- turn turret to y-axis 0 speed <90>;
- turn barrel to x-axis 0 speed <50>;
- }]]
- local function RestoreAfterDelay()
- Sleep(unitID, restore_delay)
- Turn(unitID, turret, y_axis, 0, math.rad(90))
- Turn(unitID, barrel, x_axis, 0, math.rad(50))
- end
- --[[AimPrimary(heading,pitch)
- {
- signal SIG_AIM;
- set-signal-mask SIG_AIM;
- turn turret to y-axis heading speed <90>;
- turn barrel to x-axis (0-pitch) speed <50>;
- wait-for-turn turret around y-axis;
- wait-for-turn barrel around x-axis;
- start-script RestoreAfterDelay();
- return(TRUE);
- }]]
- function script.AimWeapon1(unitID, heading, pitch)
- Signal(unitID, SIG_AIM)
- SetSignalMask(unitID, SIG_AIM)
- Turn(unitID, turret, y_axis, heading, math.rad(90))
- Turn(unitID, barrel, x_axis, -pitch, math.rad(50))
- WaitForTurn(unitID, turret, y_axis)
- WaitForTurn(unitID, barrel, x_axis)
- StartThread(unitID, RestoreAfterDelay)
- return true
- end
- --[[FirePrimary()
- {
- show flare;
- move barrel to z-axis [-2.4] speed [500];
- sleep 150;
- hide flare;
- wait-for-move barrel along z-axis;
- move barrel to z-axis [0] speed [3.0];
- }]]
- function script.FireWeapon1(unitID)
- Show(unitID, flare)
- Move(unitID, barrel, z_axis, -2.4, 500) -- move rates are not actually a direct conversion, if you are using OTA linear constant
- Sleep(unitID, 150)
- Hide(unitID, flare)
- WaitForMove(unitID, barrel, z_axis)
- Move(unitID, barrel, z_axis, 0, 3)
- end
- --[[AimFromPrimary(piecenum)
- {
- piecenum=turret;
- }]]
- function script.AimFromWeapon1() return turret end
- --[[QueryPrimary(piecenum)
- {
- piecenum=flare;
- }]]
- function script.QueryWeapon1() return flare end
- --[[SweetSpot(piecenum)
- {
- piecenum=base;
- }]]
- --[[Killed( severity, corpsetype )
- {
- hide flare;
- if (severity <= 25)
- {
- corpsetype = 1;
- explode barrel type BITMAPONLY | BITMAP1;
- explode base type BITMAPONLY | BITMAP2;
- explode flare type BITMAPONLY | BITMAP3;
- explode turret type BITMAPONLY | BITMAP4;
- return( 0 );
- }
- if (severity <= 50)
- {
- corpsetype = 2;
- explode barrel type FALL | BITMAP1;
- explode base type BITMAPONLY | BITMAP2;
- explode flare type FALL | BITMAP3;
- explode turret type SHATTER | BITMAP4;
- return( 0 );
- }
- if (severity <= 99)
- {
- corpsetype = 3;
- explode barrel type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
- explode base type BITMAPONLY | BITMAP2;
- explode flare type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
- explode turret type SHATTER | BITMAP4;
- return( 0 );
- }
- corpsetype = 3;
- explode barrel type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
- explode base type BITMAPONLY | BITMAP2;
- explode flare type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
- explode turret type SHATTER | EXPLODE_ON_HIT | BITMAP4;
- return( 0 );
- }]]
- function script.Killed(unitID, recentDamage, maxHealth)
- local severity = recentDamage / maxHealth * 100
- Hide(unitID, flare)
- if severity <= 25 then
- --Explode(unitID, barrel, BITMAPONLY | BITMAP1)
- return 1
- elseif severity <= 50 then
- --Explode(unitID, barrel, FALL | BITMAP1)
- return 2
- elseif severity <= 99 then
- --Explode(unitID, barrel, FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1)
- return 3
- else
- --Explode(unitID, barrel, FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1)
- return 3
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment