Weapon Problems.

Weapon Problems.

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Weapon Problems.

Post by Machinesrocks »

Within my mod, I'm trying to make a unit shoot properly. (Of course.) I've gotten his attack function in, but whenever he shoots, he gets flung out of the map. I'm assuming this is because he is shooting the weapon within himself. So I wanted to ask how to tell the weapon where to shoot from. I've tried multiple things, but now I can't just get it right. I've heard some things about setting the flare, but nothing as really worked out for me. So can somebody explain what I would need to choose for the "flare" spot?

One more problem. When turret is set to "false" or "0," you shouldn't be able to separately move your head. Especially since he doesn't have a spinning head. I can still turn my head, but I can't shoot to the other areas I aim at. Can someone explain this too? Thanks. :mrgreen:
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Weapon Problems.

Post by smoth »

That sounds hilariously awesome care to post the mod so we can take a look see?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Weapon Problems.

Post by knorke »

So I wanted to ask how to tell the weapon where to shoot from.
like this, in your unit script:
function script.QueryWeapon1()
return piece_you_want_to_shot_from
end
another reason might be that your projectile is fired too slow and drops down too fast
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

I'm uploading it. I'll send you the link in a bit.

EDIT: I'll try that out, Knorke.
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

Sorry about the double post, Link is here: http://www.filedropper.com/openmachines Also try it in firstperson.
like this, in your unit script:
function script.QueryWeapon1()
return piece_you_want_to_shot_from
end
I replace "piece_you_want_to_shot_from" with the name of the object the bullet will launch from, right? And it will make sure the bullet doesn't get stuck in his hitbox?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Weapon Problems.

Post by knorke »

yes.
actually i am not sure if a bullet can even get stuck in its shooter like that. at least there are some units where it makes me wonder that it does not happen there.
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

knorke wrote:yes.
actually i am not sure if a bullet can even get stuck in its shooter like that. at least there are some units where it makes me wonder that it does not happen there.
Thanks! Still need someone to solve the problem where I can turn my camera in 1st person beyond the area I can actually shoot at.
EDIT: Should this go under the weapons part within the unitdef? Where it shoots from I mean. I can't seem to put it in correctly.
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

Well, this is my current code for the unit anyway.

Code: Select all

local unitName = "scout"

local unitDef = {
  
  --Internal settings
    name = "Bolter Scout",
	objectName = "scout.s3o",
	BuildPic = "filename.bmp",
    Category = "TANK SMALL NOTAIR NOTSUB",
    Side = "TANKS",
    TEDClass = "TANK",
    UnitName = "tank",
    script = "tankscript.lua",
    
--Unit limitations and properties
    BuildTime = 100,
    Description = "A small and fast unit.",
    MaxDamage = 800,
    RadarDistance = 0,
    SightDistance = 400,
    SoundCategory = "TANK",
    Upright = 0,
    
--Energy and metal related
    BuildCostEnergy = 100,
    BuildCostMetal = 0,
    
--Pathfinding and related
    Acceleration = 0.50,
    BrakeRate = 0.51,
    FootprintX = 2,
    FootprintZ = 2,
    MaxSlope = 15,
    MaxVelocity = 7.0,
    MaxWaterDepth = 20,
    MovementClass = "Default2x2",
    TurnRate = 900,
    
--Abilities
    Builder = 0,
    CanAttack = 1,
    CanGuard = 1,
    CanMove = 1,
    CanPatrol = 1,
    CanStop = 1,
    LeaveTracks = 0,
    Reclaimable = 0,

--Hitbox
--    collisionVolumeOffsets    =  "0 0 0",
--    collisionVolumeScales     =  "10 10 10",
--    collisionVolumeTest       =  1,
--    collisionVolumeType       =  "10 10 10",
    
--Weapons and related
    BadTargetCategory = "NOTAIR",
    ExplodeAs = "TANKDEATH",
    NoChaseCategory = "AIR",  


 weapons = {
[1]={name  = "scoutbolter",
	onlyTargetCategory = [[LAND]],
	},	
},
}


return lowerkeys({ [unitName] = unitDef })
The weapon loads up another script inside of a weapons folder within the directory, which is:

Code: Select all

local weaponName="scoutbolter"
local weaponDef={
name="Bullet",
weaponType=[[MissileLauncher]],

Accuracy=2000,

--Physic/flight path
range=1000,
reloadtime=3,
weaponVelocity=500,
startVelocity=500,
weaponAcceleration=50,
flightTime=2.5,
BurnBlow=0,
FixedLauncher=true,
dance=100,--200
wobble=1000,
tolerance=8000,
tracks=false,
Turnrate=0,
collideFriendly=true,
TrajectoryHeight = 2,

----APPEARANCE
model="projectiles/cubebullet.s3o",
smokeTrail=false,
explosionGenerator="custom:redsmoke",
CegTag="smoketrail",

----TARGETING
turret=false,
CylinderTargetting=false,
avoidFeature=false,
avoidFriendly=false,

----BURST
burst                   = 1,--8
burstrate               = 0.1,

--commandfire=true,

----DAMAGE
damage={
default=150,
heavyarmor=150,
},
areaOfEffect=100,
craterMult=0,

--?FIXME***
lineOfSight=true,


--sound
--soundHit=[[kanoba/SabotHitRemake.ogg]],
--soundStart=[[kanoba/RockLit1Remake.ogg]],
}

return lowerkeys ({[weaponName]=weaponDef})
So I don't really know where to add in the code you gave me.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Weapon Problems.

Post by knorke »

Machinesrocks wrote:So I don't really know where to add in the code you gave me.
in the unitscript.
That is the file that you define in the unitdef with the
script = "tankscript.lua",
should be in scripts\ and it controlls unit animation, aiming etc.
http://springrts.com/wiki/Animation-LuaScripting

But you already have a kind of working script, otherwise your unit would not shot at all.

I think it is something with the weapon.
maybe to high dance or wobble or try turret=true
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

Hmm, funny thing is that tankscript.lua doesn't exist, so it can't be loading it. I guess I should work on an animation script then. Also, I was trying not to have a turret, so that I can't turn my mouse, and I have tried that.
EDIT: Problem solved! I just need to make it faster, and make sure it doesn't hit the ground, or else I get launched away.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Weapon Problems.

Post by smoth »

fps mode is not really a supported engine feature. It is just sort of their.

HOWEVER, a unit still obeys fire arc limitations in fps mode with regards to where it can fire. you can look there, you just cannot shoot.
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

Well do I have to code inside of his unitscript to make him stop trying to turn his invisible head to shoot?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Weapon Problems.

Post by smoth »

I don't understand the head spinning thing. Can you give me some more details?
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

Well in the default spring gui, on the bottom left, there is a green pointer on top of a blue pointer. The mouse moves the green pointer which is supposed to be a tank turret or something, the blue pointer is moved by the arrow keys. I basically want to disable movement of the green pointer.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Weapon Problems.

Post by FLOZi »

Not possible afaik.
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

...So all units need to be tanks or they can't shoot? That doesn't make sense.

EDIT: btw, I meant I want to disable the blue pointer, it's the other way around.
Last edited by Machinesrocks on 11 Aug 2011, 19:01, edited 1 time in total.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Weapon Problems.

Post by FLOZi »

fps mode is not really a supported engine feature

[quote]fps mode is not really a supported engine feature[/quote]


[quote]fps mode is not really a supported engine feature[/quote]
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

Not only in fps mode. He doesn't turn around to shoot. He tries to turn his head which doesn't exist. He can't aim unless facing forward. Which is why I want him to turn his body around to shoot.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Weapon Problems.

Post by FLOZi »

Well, for that you need, indeed, a proper unit script.

If you post up your mod as an sdz or sd7 I'm sure we can get you sorted. :-)
User avatar
Machinesrocks
Posts: 37
Joined: 10 Aug 2011, 20:35

Re: Weapon Problems.

Post by Machinesrocks »

Alright. I'll be uploading then.
Post Reply

Return to “Game Development”