I am wondering how to get a unit to shoot from a different weapon depending on what weapon is equipped. This is what I have at the moment:
Code:
function script.QueryWeapon1()
return flare
end
function script.AimFromWeapon1()
return flare
end
function script.AimWeapon1(heading, pitch)--(weaponID, heading, pitch) --Spring.Echo("weapon ID is...",weaponID) -- Function that aims the weapon if (waterGunAllowed == true or magicWandP == true) then Spring.Echo("heyyyyy") --weaponID = 1 --Spring.Echo("in aim weapon!") Signal(SIG_AIM) SetSignalMask(SIG_AIM) -- Each time the Signal is called, all other functions with the same SignalMask will stop running. This makes sure the tank isn't trying to fire at something, and restore the turret position, at the same time. Turn(turret, y_axis, heading, math.rad(90)) --Turn(gun, x_axis, -pitch, math.rad(90)) --Turn(waterGunVal, x_axis, -pitch, math.rad(90)) Turn(torso, y_axis, heading, math.rad(90)) Turn(head, y_axis, heading, math.rad(90)) Turn(rHand, y_axis, heading, math.rad(90)) Turn(rFoot, y_axis, heading, math.rad(90)) Turn(lFoot, y_axis, heading, math.rad(90)) WaitForTurn(turret, y_axis) --WaitForTurn(waterGunVal, x_axis) --WaitForTurn(gun, x_axis) WaitForTurn(head, y_axis) WaitForTurn(rHand, y_axis) WaitForTurn(rFoot, y_axis) WaitForTurn(lFoot, y_axis) StartThread(RestoreAfterDelay) --Spring.Echo("in aim weapon2!") -- else -- -- Spring.CallCOBScript(unitID, "ChangeWeapon", 1) -- --weaponID = 2 -- Spring.Echo("weapon ID is...",weaponID) -- Signal(SIG_AIM) -- SetSignalMask(SIG_AIM) -- Move(lHand, z_axis, 15, 20) StartThread(RestoreAfterDelay) --else script.AimWeapon2(heading, pitch) return true else return false end end
function script.FireWeapon1() Spring.Echo("fire!") end
function script.QueryWeapon2() --if(waterGunAllowed ~= true) then Spring.Echo("I'm querying properly") return rHand --end end
function script.AimFromWeapon2() --if(waterGunAllowed ~= true) then Spring.Echo("aiming from proper weapon!") return rHand --end end
function script.AimWeapon2(heading, pitch) --Spring.CallCOBScript(unitID, "ChangeWeapon", 1) Spring.Echo("aim weapon 2!") if(waterGunAllowed ~= true) then Spring.Echo("Fist!") Signal(SIG_AIM) SetSignalMask(SIG_AIM) Move(rHand, z_axis, 15, 20) StartThread(RestoreAfterDelay) return true else return false end end
function script.FireWeapon2() Spring.Echo("fire2!") end
The weapons are all defined in the unitdef. Right now it sometimes performs the sounds of the first weapon when it should be actually firing the second weapon, which it never does. Thank you for any help!
//Every time the unit is moving on a slope steeper than BOOST_SLOPE_THRSHOLD the boost value is increased by one (otherwise decreased) //Once the boost goes over BOOST_THRESHOLD the unit will use its boosters //The boost will not go higher than BOOST_LIMIT so the cooldown after the end of the slope won't take long #define BOOST_SLOPE_THRESHOLD [1] #define BOOST_THRESHOLD 2 #define BOOST_LIMIT 4 #define REGULAR_SPEED 6*65536 #define BOOST_SPEED 15*65536
/*------------------------------------------------------ / run animations /-----------------------------------------------------*/ walk() { turn right_l to y-axis <0> speed <135>; turn left_l to y-axis <0> speed <130>;
turn right_l to z-axis <0> speed <135>; turn left_l to z-axis <0> speed <130>; turn foot_l to z-axis <0> speed <130>; turn foot_r to z-axis <0> speed <130>;
turn base to x-axis <25> speed <395>;
if (weaponchosen) { turn l_forearm to x-axis <0> speed <250>; turn r_forearm to x-axis <0> speed <250>; turn rlgun2 to x-axis <0> speed <350>; turn rlgun1 to x-axis <0> speed <350>; } else { turn r_forearm to x-axis <-55> speed <350>; turn l_forearm to x-axis <-55> speed <350>; }
if(ISMOVING) {
turn base to y-axis <0> speed <395>; turn right to x-axis <0> speed <150>;
turn left to x-axis <45> speed <450>;
turn left_l to x-axis <-50> speed <430>; turn shin_l to x-axis <40> speed <330>; turn foot_l to x-axis <20> speed <535>;
emit-sfx dirt from dustr;
turn foot_r to x-axis <-20> speed <535>;
turn base to y-axis <5> speed <395>;
turn right_l to x-axis <75> speed <395>; turn shin_r to x-axis <20> speed <330>; turn foot_l to x-axis <25> speed <535>; sleep 240; } if(ISMOVING) {
turn base to y-axis <0> speed <395>; turn right to x-axis <45> speed <450>; turn left to x-axis <0> speed <150>;
turn right_l to x-axis <-50> speed <430>; turn shin_r to x-axis <40> speed <435>; turn foot_r to x-axis <20> speed <535>;
emit-sfx dirt from dustl;
turn foot_l to x-axis <-20> speed <535>;
turn base to y-axis <-5> speed <395>;
turn left_l to x-axis <75> speed <395>; turn shin_l to x-axis <20> speed <330>; turn foot_r to x-axis <25> speed <535>;
sleep 240; } turn right to x-axis <0> speed <350>; turn left to x-axis <0> speed <350>; }
waterwalk() { turn right_l to y-axis <0> speed <135>; turn left_l to y-axis <0> speed <130>;
turn right_l to z-axis <0> speed <135>; turn left_l to z-axis <0> speed <130>; turn foot_l to z-axis <0> speed <130>; turn foot_r to z-axis <0> speed <130>;
turn base to x-axis <25> speed <395>;
turn r_forearm to x-axis <-35> speed <350>; turn l_forearm to x-axis <-35> speed <350>; turn rlgun2 to x-axis <15> speed <350>; turn rlgun1 to x-axis <15> speed <350>;
if(ISMOVING) { turn right to x-axis <45> speed <550>; turn left to x-axis <45> speed <550>;
turn left_l to x-axis <50> speed <430>; turn shin_l to x-axis <40> speed <330>; turn foot_l to x-axis <20> speed <535>;
turn right_l to x-axis <50> speed <430>; turn shin_r to x-axis <40> speed <330>; turn foot_r to x-axis <20> speed <535>;
emit-sfx kampfertail from thrust1; emit-sfx kampfertail from thrust2; emit-sfx kampfertail from thrust3; emit-sfx dirt from dustr; emit-sfx dirt from dustl; sleep 240; }
turn right to x-axis <0> speed <235>; turn left to x-axis <0> speed <230>; }
watershoot() { turn right_l to y-axis <0> speed <135>; turn left_l to y-axis <0> speed <130>;
turn right_l to z-axis <0> speed <135>; turn left_l to z-axis <0> speed <130>; turn foot_l to z-axis <0> speed <130>; turn foot_r to z-axis <0> speed <130>;
if (weaponchosen) { turn l_forearm to x-axis <0> speed <250>; turn r_forearm to x-axis <0> speed <250>; } else { turn r_forearm to x-axis <-90> speed <250>; }
turn rlgun2 to x-axis <0> speed <350>; turn rlgun1 to x-axis <0> speed <350>;
if(ISMOVING) {
turn left_l to x-axis <50> speed <430>; turn shin_l to x-axis <40> speed <330>; turn foot_l to x-axis <20> speed <535>;
turn right_l to x-axis <50> speed <430>; turn shin_r to x-axis <40> speed <330>; turn foot_r to x-axis <20> speed <535>;
emit-sfx dirt from dustr; emit-sfx dirt from dustl; sleep 240; } }
shootwalk() { turn right_l to y-axis <0> speed <135>; turn left_l to y-axis <0> speed <130>;
turn right_l to z-axis <0> speed <135>; turn left_l to z-axis <0> speed <130>; turn foot_l to z-axis <0> speed <130>; turn foot_r to z-axis <0> speed <130>; if (weaponchosen) { turn l_forearm to x-axis <0> speed <250>; turn r_forearm to x-axis <0> speed <250>; } else { if (baiming) { turn r_forearm to x-axis <-90> speed <350>; } else { turn r_forearm to x-axis <0> speed <250>; } }
turn rlgun2 to x-axis <0> speed <350>; turn rlgun1 to x-axis <0> speed <350>;
if(ISMOVING) { turn left_l to x-axis <-50> speed <430>; turn shin_l to x-axis <40> speed <330>; turn foot_l to x-axis <20> speed <535>;
emit-sfx dirt from dustr;
turn foot_r to x-axis <-20> speed <535>;
turn right_l to x-axis <75> speed <395>; turn shin_r to x-axis <20> speed <330>; turn foot_l to x-axis <25> speed <535>; sleep 240; } if(ISMOVING) { turn right_l to x-axis <-50> speed <430>; turn shin_r to x-axis <40> speed <435>; turn foot_r to x-axis <20> speed <535>;
emit-sfx dirt from dustl;
turn foot_l to x-axis <-20> speed <535>;
turn left_l to x-axis <75> speed <395>; turn shin_l to x-axis <20> speed <330>; turn foot_r to x-axis <25> speed <535>;
sleep 240; }
}
stopwalk () { turn base to x-axis <0> speed <395>; turn foot_l to x-axis <0> speed <395>; turn foot_r to x-axis <0> speed <395>; turn right_l to x-axis <0> speed <235>; turn left_l to x-axis <0> speed <230>; turn shin_l to x-axis <0> speed <235>; turn shin_r to x-axis <0> speed <230>;
if (weaponchosen) { turn l_forearm to x-axis <0> speed <250>; turn r_forearm to x-axis <0> speed <250>; turn rlgun2 to x-axis <0> speed <350>; turn rlgun1 to x-axis <0> speed <350>; } else { turn r_forearm to x-axis <0> speed <250>; if (baiming) { turn r_forearm to x-axis <-90> speed <350>; } else { turn r_forearm to x-axis <0> speed <250>; } }
turn right_l to y-axis <-20> speed <135>; turn left_l to y-axis <20> speed <130>;
turn right_l to z-axis <3> speed <135>; turn left_l to z-axis <-3> speed <130>; turn foot_l to z-axis <3> speed <130>; turn foot_r to z-axis <-3> speed <130>; }
stopwater() { turn base to x-axis <0> speed <395>; turn foot_l to x-axis <40> speed <395>; turn foot_r to x-axis <40> speed <395>; turn right_l to x-axis <0> speed <235>; turn left_l to x-axis <0> speed <230>; turn shin_l to x-axis <0> speed <235>; turn shin_r to x-axis <0> speed <230>;
if (weaponchosen) { turn l_forearm to x-axis <0> speed <250>; turn r_forearm to x-axis <0> speed <250>; turn rlgun2 to x-axis <0> speed <350>; turn rlgun1 to x-axis <0> speed <350>; } else { if (baiming) { turn r_forearm to x-axis <-90> speed <350>; } else { turn r_forearm to x-axis <-55> speed <350>; }
turn l_forearm to x-axis <-55> speed <350>; }
turn right_l to y-axis <-10> speed <135>; turn left_l to y-axis <10> speed <130>;
turn right_l to z-axis <5> speed <135>; turn left_l to z-axis <-5> speed <130>; turn foot_l to z-axis <5> speed <130>; turn foot_r to z-axis <-5> speed <130>;
emit-sfx dirt from dustr; emit-sfx dirt from dustl; } /*------------------------------------------------------ / motion functions /-----------------------------------------------------*/ StartMoving() { ISMOVING = TRUE; }
StopMoving() { ISMOVING = FALSE; }
Flamingass() { while(TRUE) { if (onwater || boost > BOOST_THRESHOLD) { emit-sfx kampfertail from thrust1; emit-sfx kampfertail from thrust2; emit-sfx kampfertail from thrust3; emit-sfx kampfertail from thrust4; emit-sfx kampfertail from thrust5; emit-sfx kampfertail from thrust6; emit-sfx kampfertail from thrust7; emit-sfx kampfertail from thrust8; } sleep 130; }
turn base to y-axis <0> speed <435>; turn r_arm to x-axis <0> speed <430>; turn left to x-axis <0> speed <450>; turn right to x-axis <0> speed <450>; turn l_forearm to x-axis <0> speed <450>; turn l_forearm to z-axis <0> speed <450>;
turn r_forearm to x-axis <0> speed <250>;
turn pole_l to x-axis <0> speed <450>; turn pole_r to x-axis <0> speed <450>; bAiming = FALSE; }
AimWeapon2(heading,pitch) { signal SIG_AIM; set-signal-mask SIG_AIM;
// Announce that we would like to aim, and wait until we can bAiming = TRUE; while (!bCanAim || weaponchosen) { sleep 100; }
turn r_forearm to x-axis <-90> speed <350>; turn base to y-axis heading speed <425>; turn right to x-axis (<-0>-pitch) speed <490>; turn left to x-axis <0> speed <250>; wait-for-turn r_forearm around x-axis; wait-for-turn right around x-axis; wait-for-turn head around y-axis;
start-script RestoreAfterDelay();
return (TRUE); }
FireWeapon2() { move right to z-axis [-0.5] now; //emit-sfx 2048+1 from flare1; emit-sfx shotgun from flare1; move right to z-axis [0] speed [3]; }
AimWeapon1(heading,pitch) { signal SIG_AIM_2; set-signal-mask SIG_AIM_2;
// Announce that we would like to aim, and wait until we can while (!bCanAim || !weaponchosen) { sleep 100; }
turn base to y-axis heading speed <425>; turn left to x-axis (<-90>-pitch) speed <450>; turn right to x-axis (<-90>-pitch) speed <450>;
wait-for-turn head around y-axis; wait-for-turn left around x-axis; wait-for-turn right around x-axis; start-script RestoreAfterDelay();
return(TRUE); }
FireWeapon1() { if( shooting_num == 1) { move right to z-axis [-1.0] now; emit-sfx redmuzzle from rlflare2; move right to z-axis [0] speed [3]; }
if( shooting_num == 2) { move left to z-axis [-1.0] now; emit-sfx redmuzzle from rlflare1; move left to z-axis [0] speed [3]; }
shooting_num=shooting_num+1;
if( shooting_num == 3) { shooting_num=1; }
}
AimWeapon3(heading,pitch) { signal SIG_AIM_3; set-signal-mask SIG_AIM_3;
// Announce that we would like to aim, and wait until we can while (NOT bCanAim || ISMOVING || (terraintype == 2 || terraintype == 3)) { sleep 100; }
turn pole_r to x-axis (<-45>+pitch) speed <450>; turn pole_l to x-axis (<-45>+pitch) speed <450>;
wait-for-turn pole_r around x-axis; wait-for-turn pole_l around x-axis;
Killed( severity, corpsetype ) { if (severity <= 25) { corpsetype = 1; explode base type FALL; explode cod type BITMAPONLY; explode head type FALL; return( 0 ); }
if (severity <= 50) { corpsetype = 2; explode base type FALL; explode cod type FALL; explode head type FALL; return( 0 ); }
if (severity <= 99) { corpsetype = 3; explode base type BITMAPONLY; explode cod type BITMAPONLY; explode head type BITMAPONLY; return( 0 ); }
corpsetype = 3; explode base type BITMAPONLY; explode cod type BITMAPONLY; explode head type FALL; return( 0 ); }
Weapon switch command
Code:
function gadget:GetInfo() return { name = "Kampfer weapons", desc = "Switch kampfer weapons", author = "Smoth", date = "11-20-2010", license = "Public Domain", layer = 20, --must be greater than 10 (specialability.lua's layer) enabled = true } end local EditUnitCmdDesc = Spring.EditUnitCmdDesc local FindUnitCmdDesc = Spring.FindUnitCmdDesc local GetFeatureTeam = Spring.GetFeatureTeam local InsertUnitCmdDesc = Spring.InsertUnitCmdDesc
local CMD_SET_KweaponsCMD = 458238
if (gadgetHandler:IsSyncedCode()) then
local Kweaponscmd= { id = CMD_SET_KweaponsCMD, name = "KWeapons", tooltip = "Switch Weapon", type = CMDTYPE.ICON_MODE, params = { '0', 'Switch\nto\nShotgun', 'Switch\nto\nRockets'}, texture = "bitmaps/ui/command_buttons/cmd_kampferon.png", }
function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) if ( unitDefID == UnitDefNames.kampfer.id ) then InsertUnitCmdDesc(unitID, 500, Kweaponscmd) featureplacer = unitID end end
function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions) if ( unitDefID == UnitDefNames.kampfer.id ) then if (cmdID == CMD_SET_KweaponsCMD) then
local cmdDescID = FindUnitCmdDesc(unitID, CMD_SET_KweaponsCMD)
if cmdParams[1] == 1 then Kweaponscmd.texture="bitmaps/ui/command_buttons/cmd_kampferoff.png" else Kweaponscmd.texture="bitmaps/ui/command_buttons/cmd_kampferon.png" end
Spring.CallCOBScript(unitID, "SwitchWeapon",0) return false end end return true end end
Thanks for the help. I have been trying to implement it without creating a gadget. Here is the code I have for that portion:
Code:
local function RestoreAfterDelay(unitID) -- Defines a local funtion to wait a bit, then move the turret back to how it was originally. Sleep(RESTORE_DELAY) if(waterGunAllowed == true) then Turn(turret, y_axis, 0, math.rad(90)) --Turn(gun, x_axis, 0, math.rad(90)) --rn(waterGunVal, x_axis, 0, math.rad(90)) Turn(torso, y_axis, 0, math.rad(90)) Turn(head, y_axis, 0, math.rad(90)) Turn(rHand, y_axis, 0, math.rad(90)) Turn(rFoot, y_axis, 0, math.rad(90)) Turn(lFoot, y_axis, 0, math.rad(90)) else Move(lHand, z_axis, 0, 20) end end
function script.QueryWeapon2() --if(waterGunAllowed ~= true) then --Spring.Echo("I'm querying properly") --Spring.Echo("querying le 2") return rHand --end end
function script.AimFromWeapon2() --if(waterGunAllowed ~= true) then --Spring.Echo("aiming from proper weapon!") --Spring.Echo("aiming from le 2") return rHand --end end
--if(waterGunAllowed ~= true) then Spring.Echo("I am fist!") while(weaponChosen ~= 1) do Sleep (100) end
Spring.Echo("Fist!")
Move(rHand, z_axis, 15, 20) StartThread(RestoreAfterDelay) return true -- else return false -- end end
function script.FireWeapon2() Spring.Echo("fire2!") end
function script.QueryWeapon1() -- The piece that the bullet/laser/whatever comes out of. FLARE --if (waterGunAllowed == true or magicWandP == true) then return flare -- else -- return lHand --else script.QueryWeapon2() --end end
function script.AimFromWeapon1() -- The unit looks from this piece down the QueryWeapon piece, to see whether it's aiming at anything. FLARE --if (waterGunAllowed == true or magicWandP == true) then return flare -- else -- return lHand --end --else script.AimFromWeapon2() --end end
function SwitchWeapon() if (waterGunP == true) then weaponChosen = 0 elseif (magicWandP == true) then weaponChosen = 2 else weaponChosen = 1 end end
function script.AimWeapon1(heading, pitch)--(weaponID, heading, pitch) --Spring.Echo("weapon ID is...",weaponID) -- Function that aims the weapon --if (waterGunAllowed == true or magicWandP == true) then Spring.Echo("heyyyyy") --weaponID = 1 --Spring.Echo("in aim weapon!") Signal(SIG_AIM_2) SetSignalMask(SIG_AIM_2) --while(!bCanAim || weaponchosen != 0) while(weaponChosen ~=0) do Sleep(100) end Spring.Echo("aiming when I shouldn't") -- Each time the Signal is called, all other functions with the same SignalMask will stop running. This makes sure the tank isn't trying to fire at something, and restore the turret position, at the same time. Turn(turret, y_axis, heading, math.rad(90)) --Turn(gun, x_axis, -pitch, math.rad(90)) --Turn(waterGunVal, x_axis, -pitch, math.rad(90)) Turn(torso, y_axis, heading, math.rad(90)) Turn(head, y_axis, heading, math.rad(90)) Turn(rHand, y_axis, heading, math.rad(90)) Turn(rFoot, y_axis, heading, math.rad(90)) Turn(lFoot, y_axis, heading, math.rad(90)) WaitForTurn(turret, y_axis) --WaitForTurn(waterGunVal, x_axis) --WaitForTurn(gun, x_axis) WaitForTurn(head, y_axis) WaitForTurn(rHand, y_axis) WaitForTurn(rFoot, y_axis) WaitForTurn(lFoot, y_axis) StartThread(RestoreAfterDelay) --Spring.Echo("in aim weapon2!") -- else -- -- Spring.CallCOBScript(unitID, "ChangeWeapon", 1) -- --weaponID = 2 -- Spring.Echo("weapon ID is...",weaponID) -- Signal(SIG_AIM) -- SetSignalMask(SIG_AIM) -- Move(lHand, z_axis, 15, 20) StartThread(RestoreAfterDelay) --else script.AimWeapon2(heading, pitch) return true --else -- return false -- end end
function script.FireWeapon1() Spring.Echo("fire!") end
--ename1 = UnitDefs[enemyID1].name function script.HitByWeapon(x, z, weaponDefID, damage) wname = WeaponDefs[weaponDefID].name i, j = string.find(wname, "fist") if(hulaHoopP == true) then --if(i ~= nil) then newDamage = damage - (0.75*damage) return newDamage --end end end -- Mentioned in section 4.3.1.2 of MTDF v0 function script.StartMoving() StartThread(walk) end
-- Mentioned in section 4.3.1.3 of MTDF v0 function script.StopMoving() Signal(SIG_WALK) legs_down() end
-- function script.BeginTransport(passengerID) -- end -- function script.QueryTransport(passengerID) -- return -1 -- end
function script.TransportDrop(passengerID) end
--wname = WeaponDefs[weaponDefID].name
function script.TransportPickup (passengerID) Spring.UnitScript.AttachUnit(turret, passengerID) local unitDefID = Spring.GetUnitDefID(passengerID) wID = passengerID local name = UnitDefs[unitDefID].name --Spring.Echo("carrying a ", name) if (name == "wwatergun") then waterGunAllowed = true Equip() waterGunP = true Spring.SetUnitRulesParam(unitID, "waterGun", 1, {public = true}) --waterGunVal = passengerID --wname = WeaponDefs[1].name --wname2 = WeaponDefs[2].name end if(name == "whulahoop") then hulaHoopP = true -- CHANGE THE UNIT'S HEALTH -- local _, currentMaxHealth, _, _, _= Spring.GetUnitHealth(unitID) currentMaxHealth = currentMaxHealth+20 Spring.SetUnitMaxHealth(unitID, currentMaxHealth) Spring.SetUnitHealth(unitID, currentMaxHealth)
Spring.SetUnitRulesParam(unitID, "hulaHoop", 1, {public = true}) end if(name == "wbbglove") then bbGloveP = true Spring.SetUnitRulesParam(unitID, "bbGlove", 1, {public = true}) Spring.UnitScript.SetPieceVisibility(rHand, false) end if(name == "wmagicwand") then magicWandP = true Spring.SetUnitRulesParam(unitID, "magicWand", 1, {public = true}) end if(name == "wcape") then capeP = true Spring.SetUnitRulesParam(unitID, "cape", 1, {public = true}) end if(name == "wswimTrunks") then swimTrunksP = true Spring.SetUnitRulesParam(unitID, "swimTrunks", 1, {public = true}) end if(name == "wrunningShoes") then runningShoesP = true Spring.SetUnitRulesParam(unitID, "runningShoes", 1, {public = true}) end SwitchWeapon() Spring.Echo("chosen weapon is", weaponChosen) end
Right now it is firing a weapon, but not the correct one and I'm not really even sure what one is firing. I've checked and it knows that the correct weapon is the second weapon. It prints the "heyyy" message showing it is going into AimWeapon1. Though it does not aim it. It never enters AimWeapon2 but does query it and know where to aim from for it. Is this because I do not have a gadget or am I doing something else wrong?
No I don't understand why that's necessary. If you could explain it that would be great. I did change it to a bool in the game and am having the exact same problem.
Do me a favor and post the source on pastebin(with the commented code removed), I only posted the kampfer source here on the site so that it could be around as a resource.
There's the link. Now it's firing the first weapon and I get why it's doing that. However, I want the third weapon to be the default weapon when the first two are not available. How would I do that?
I was just about to post about that. There will be a weapon 2. I just have 1 and 3 in there right now because I'd like to get them working first, but also keeping in mind the fact that there will be a weapon 2.
Yes that's what I want. I thought that was what you might be doing because of the bool but I was thrown off but the weapon 3 code you had. Do you know of a way that I can toggle between 3 weapons?
Joined: 22 Feb 2006, 01:02 Location: cheap kitchen
i think return false to prevent weapon from shooting is quite reliable. (seeing how so many mods use it) ---
Code:
local activeWeapon = 1 AimWeapon(weaponNum, heading, pitch)) if weaponNum == activeWeapon then ..animation blabla.. return true else return false end end
or if you want to allow multiple weapons to be active at the same time:
Code:
local activeWeapons = {} --enable weapon 2&4, disable 1&3 activeWeapon[1]= false, activeWeapon[2]= true, activeWeapon[3]= false, activeWeapon[4]= true, AimWeapon(weaponNum, heading, pitch)) if activeWeapon[weaponNum] then ..animation blabla.. return true else return false end end
To en/disable just do activeWeapon[i]= true/false not sure if weaponNum starts at 0 or 1 (1 i think)
Users browsing this forum: No registered users and 0 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum