Ok, so I sat down and began converting my unit reading how the corcom in ca was coded. I am usure why but my unit aims yet never fires. Any ideas? he aims no problem but just won't fire, I cannot see what I am missing.
Code: Select all
-------------------------------------------------------
-- License: Public Domain
-- Author: Steve (Smoth) Smith
-- Date: 3/17/2011
-------------------------------------------------------
-- Piece names
local head = piece 'head'
local base = piece 'base'
local left = piece 'left'
local right = piece 'right'
local l_arm = piece 'l_arm'
local l_forearm = piece 'l_forearm'
local r_arm = piece 'r_arm'
local r_forearm = piece 'r_forearm'
local gun = piece 'gun'
local fire = piece 'fire'
local sheild = piece 'sheild'
local cod = piece 'cod'
local right_l = piece 'right_l'
local left_l = piece 'left_l'
local shin_l = piece 'shin_l'
local shin_r = piece 'shin_r'
local foot_r = piece 'foot_r'
local foot_l = piece 'foot_l'
-- State variables
local ISMOVING, ISAIMING, speedMult = false, false, 2.4
-- Signal definitions
local SIG_AIM = 2
-- effects for emitters
local yellowmuzzelflash = 1024
--local SMOKEPIECE1 = base
--#include "\headers\smoke.h"
--#include "\headers\walk.h"
function script.StartMoving()
ISMOVING = true
end
function script.StopMoving()
ISMOVING = false
end
--------------------------------------------------------
--start ups :)
--------------------------------------------------------
function script.Create()
-- Initial State
Turn(r_forearm, x_axis, math.rad(-15),math.rad(130))
Turn(fire, x_axis,math.rad(90))
LEFTARM = TRUE;
RIGHTARM = TRUE;
HEAVY = TRUE;
--StartThread(MotionControl)
--StartThread(SmokeUnit)
end
function script.AimFromWeapon(num)
return head
end
function script.QueryWeapon(num)
return fire
end
-----------------------------------------------------------------------
--gun functions;
-----------------------------------------------------------------------
local function RestoreAfterDelay()
Sleep(1000)
Turn(base, y_axis, 0, math.rad(135))
Turn(r_forearm, x_axis, math.rad(-15), math.rad(130))
Turn(right, x_axis, 0, math.rad(130))
ISAIMING = false
end
function script.AimWeapon(num, heading, pitch)
Signal(SIG_AIM)
SetSignalMask(SIG_AIM)
ISAIMING = true
--FixArms(0,1)
Turn(base, y_axis, heading, math.rad(105))
Turn(r_forearm, x_axis, math.rad(-45), math.rad(390))
Turn(right, x_axis, math.rad(-45) - pitch, math.rad(390))
WaitForTurn(base, y_axis)
WaitForTurn(right, x_axis)
WaitForTurn(r_forearm, x_axis)
RestoreAfterDelay()
return true
end
function script.FireWeapon(num)
Move(right, z_axis, math.rad(-0.4))
Turn(r_arm, x_axis, math.rad(-5))
EmitSfx(fire, yellowmuzzelflash) --first shot is actual weapon
Sleep(25)
Turn(r_arm, x_axis, 0, math.rad(0.5))
Move(right, z_axis, 0, math.rad(5))
Sleep(75)
Move(right, z_axis, math.rad(0.4))
Turn(r_arm, x_axis, math.rad(-5))
EmitSfx(fire, yellowmuzzelflash)
EmitSfx(fire, 2048)
Sleep(25)
Turn(r_arm, x_axis, 0, math.rad(0.5))
Move(right, z_axis, 0, math.rad(5))
Sleep(75)
Move(right, z_axis, math.rad(0.4))
Turn(r_arm, x_axis, math.rad(-5))
EmitSfx(fire, yellowmuzzelflash)
EmitSfx(fire, 2048)
Sleep(25)
Turn(r_arm, x_axis, 0, math.rad(0.5))
Move(right, z_axis, 0, math.rad(5))
Sleep(500)
end
function script.Killed(recentDamage, maxHealth)
local severity = recentDamage/maxHealth
if (severity <= 99) then
Explode(left, FALL)
Explode(right, FALL)
Explode(l_arm, FALL)
Explode(l_forearm, FALL)
Explode(r_arm, FALL)
Explode(r_forearm, FALL)
Explode(gun, FALL)
return 3
else
return 0
end
end
P.S. please don't bitch about code alignment, shit reads fine in notepad++ which is all I care about as that is my tool of choice.