Permalink
Browse files

Add missing files for fighter

  • Loading branch information...
ForbodingAngel committed Dec 17, 2017
1 parent f460766 commit 3b4cf2f63032a63c1cc9424ed19c4455821e79f6
@@ -0,0 +1,137 @@
local IterableMap = {}
function IterableMap.New()
local indexByKey = {}
local dataByKey = {}
local indexMax = 0
local unusedKey = 1
local keyByIndex = {}
local api = {}
function api.GetUnusedKey()
while api.InMap(unusedKey) do
unusedKey = unusedKey + 1
end
return unusedKey
end
function api.Add(key, data)
if not key then
return
end
if indexByKey[key] then
-- Overwrites
dataByKey[key] = data
return
end
indexMax = indexMax + 1
keyByIndex[indexMax] = key
dataByKey[key] = data
indexByKey[key] = indexMax
end
function api.Remove(key)
if (not key) or (not indexByKey[key]) then
return
end
local myIndex = indexByKey[key]
local endKey = keyByIndex[indexMax]
keyByIndex[myIndex] = endKey
indexByKey[endKey] = myIndex
keyByIndex[indexMax] = nil
indexByKey[key] = nil
dataByKey[key] = nil
indexMax = indexMax - 1
end
function api.ReplaceKey(oldKey, newKey)
if (not oldKey) or (not indexByKey[oldKey]) or indexByKey[newKey] then
return false
end
keyByIndex[indexByKey[oldKey]] = newKey
indexByKey[newKey] = indexByKey[oldKey]
dataByKey[newKey] = dataByKey[oldKey]
indexByKey[oldKey] = nil
dataByKey[oldKey] = nil
return true
end
-- Get is also set in the case of tables because tables pass by reference
function api.Get(key)
return dataByKey[key]
end
function api.Set(key, data)
if not indexByKey[key] then
Add(key, data)
else
dataByKey[key] = data
end
end
function api.InMap(key)
return (indexByKey[key] and true) or false
end
-- To use Iterator, write "for unitID, data in interableMap.Iterator() do"
-- This approach makes the garbage collector cry so try to use other methods
-- of iteration.
function api.Iterator()
local i = 0
return function ()
i = i + 1
if i <= indexMax then
return keyByIndex[i], dataByKey[keyByIndex[i]]
end
end
end
-- Does the function to every element of the map. A less barbaric method
-- of iteration. Recommended for cleanliness and speed.
-- Using the third argument, index, is a little evil because index should
-- be private.
function api.Apply(funcToApply, ...)
local i = 1
while i <= indexMax do
local key = keyByIndex[i]
if funcToApply(key, dataByKey[key], i, ...) then
-- Return true to remove element
api.Remove(key)
else
i = i + 1
end
end
end
function api.ApplyNoArg(funcToApply)
local i = 1
while i <= indexMax do
local key = keyByIndex[i]
if funcToApply(key, dataByKey[key], i) then
-- Return true to remove element
api.Remove(key)
else
i = i + 1
end
end
end
-- This 'method' of iteration is for barbarians. Seems to have performance
-- similar to Apply.
function api.GetIndexMax()
return indexMax
end
function api.GetKeyByIndex(index)
return keyByIndex[index]
end
return api
end
return IterableMap
View
Binary file not shown.
View
@@ -0,0 +1,171 @@
#define TA // This is a TA script
#include "sfxtype.h"
#include "exptype.h"
piece base, firepoint1, firepoint2, fengine1, fengine2, fengine3, fengine4, rearengines, rengine1, rengine2, leftwing, rightwing, turret1, turret2, barrel1, barrel2;
static-var moving, flames, shooting_num;
#define jethtrail 1025+0
// Signal definitions
#define SIG_AIM 2
SmokeUnit(healthpercent, sleeptime, smoketype)
{
while( get BUILD_PERCENT_LEFT )
{
sleep 400;
}
while( TRUE )
{
healthpercent = get HEALTH;
if( healthpercent < 66 )
{
smoketype = 256 | 2;
if( Rand( 1, 66 ) < healthpercent )
{
smoketype = 256 | 1;
}
emit-sfx 1026 from base;
}
sleeptime = healthpercent * 50;
if( sleeptime < 200 )
{
sleeptime = 200;
}
sleep sleeptime;
}
}
Thrust()
{
while( TRUE )
{
if (flames)
{
emit-sfx jethtrail from fengine1;
emit-sfx jethtrail from fengine2;
emit-sfx jethtrail from fengine3;
emit-sfx jethtrail from fengine4;
}
if (moving)
{
emit-sfx jethtrail from rengine1;
emit-sfx jethtrail from rengine2;
}
sleep 5;
}
}
StartMoving()
{
moving=1;
}
StopMoving()
{
moving=0;
}
MoveRate0()
{
flames=0;
turn rearengines to x-axis <-90.000000> speed <150.000000>;
}
MoveRate1()
{
flames=1;
turn rearengines to x-axis <-70.005495> speed <150.000000>;
}
MoveRate2()
{
flames=1;
turn rearengines to x-axis <0.000000> speed <150.000000>;
}
Create()
{
// start-script Thrust();
shooting_num=1;
start-script SmokeUnit();
}
RestoreAfterDelay() // restore function to turn the turret and so forth back to start
{
sleep 3000;
turn turret1 to y-axis <0> speed <60>;
turn barrel1 to x-axis <0> speed <30>;
turn turret2 to y-axis <0> speed <60>;
turn barrel1 to x-axis <0> speed <30>;
}
AimWeapon1(heading, pitch) // single weapon with 2 fires this tell sit what to do while aiming
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
turn turret1 to y-axis heading speed <225>;
turn turret2 to y-axis heading speed <225>;
turn barrel1 to x-axis <0> - pitch speed <150>;
turn barrel2 to x-axis <0> - pitch speed <150>;
wait-for-turn turret1 around y-axis;
wait-for-turn turret2 around y-axis;
wait-for-turn barrel1 around x-axis;
wait-for-turn barrel2 around x-axis;
start-script RestoreAfterDelay();
return (1);
}
FireWeapon1() // what do while firing, fires 1 barrel then the next , and resets
{
if(shooting_num==1)
{
emit-sfx 1024 from firepoint2;
}
if(shooting_num==2)
{
emit-sfx 1024 from firepoint1;
}
shooting_num=shooting_num+1;
if( shooting_num == 3)
{
shooting_num=1;
}
}
AimFromWeapon1(piecenum) // where it aims the weapon from
{
piecenum = base;
}
QueryWeapon1(piecenum) // where the shot is called from
{
if (shooting_num==1)
{
piecenum=firepoint1;
}
if (shooting_num==2)
{
piecenum=firepoint2;
}
}
Killed(severity, corpsetype) // how it explodes
{
corpsetype = 1;
explode base type EXPLODE_ON_HIT;
explode rearengines type EXPLODE_ON_HIT;
explode leftwing type EXPLODE_ON_HIT;
explode turret1 type EXPLODE_ON_HIT;
explode turret2 type EXPLODE_ON_HIT;
explode rightwing type EXPLODE_ON_HIT;
explode barrel1 type EXPLODE_ON_HIT;
explode barrel2 type EXPLODE_ON_HIT;
}
View
Binary file not shown.

0 comments on commit 3b4cf2f

Please sign in to comment.