Blog update - Client-side scripting and weapons (continued)
Max
Technical Director, Unknown Worlds Entertainment Join Date: 2002-03-15 Member: 318Super Administrators, Retired Developer, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, Subnautica Developer, Pistachionauts, Future Perfect Developer
Comments
Secondary fire for the pistol: Full auto fire. Hold it down and the pistol empties as fast as it can.
Nice entry btw.
Thanks again and keep at it!
Typo? Fifth paragraph, second sentence:
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Since our pistol script code informed the engine that the ammo variable should be networked, the networking system will periodically transmit its current <b>value the from the</b> server to the client.<!--QuoteEnd--></div><!--QuoteEEnd-->
Also, shouldn't minimum time between firings be a balance variable too?
<img src="style_emoticons/<#EMO_DIR#>/smile-fix.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile-fix.gif" />
This is showing suprising forethought into methods to compensate for things we will see that many development teams ignore: lag. So for that you get major kudos Max. *thumbs up*
I was wondering if u guys thought about weapon jamming at all? Keep the updates coming, it's great hearing what's going on!
Full-auto pistol is a bit too unbalancing as it would replace the roll of the lmg. In fact, why use lmg if you have 10 (or so) uber-bullets? I guess you could do this if it drastically reduced the accuracy of the bullets in full-auto.
<!--QuoteEnd--></div><!--QuoteEEnd-->
If people can create custom scripts or macros that can fire the pistol really fast, I don't see the problem with a secondary fire mode to the pistol that spits out bullets really fast... People script it already in NS in NA. It doesn't reduce skill of aiming b/c you still have to aim while holding down the button (or you risk having an empty pistol and a live skulk [which has happened to MANY a cal marine]).
I think a secondary full-auto fire for the pistol would be uber. It'd have to be balanced, but...I dont see a problem with it. Maybe lower the pistol firing speed overall or damage or spread, so that people dont start running around with their pistol everywhere. It is a pistol...not a cannon lol.
I think the light machine gun should have a small HE nade launcher or pod scanning nade launcher. The nade is sorta like the slow-fluffy hand nade, and the pod scanning nade scans a VERY small area like..behind a box! Two nades are supplied of whatever type you choose. You can't choose 1 and 1..b/c...that might be a bit unbalanced? maybe..I dunno. It'd add too much complexity lol.
Heavy machine gun--or heavy caliber machine gun--or BFG...should have an alternate fire of uber nades, uber ping, shotgun underneath, or scout-droid.
Nade Launcher can feed off of a belt of bouncy-rubber-coated 'pipebombs' or a belt of 'sticky-nades' whoz advanced stickiness is triggered by firing them. IE, alternate fire would be the sticky nades. Sticky nades can explode when you trigger them (press 'e' or spacebar or somethign) and the bouncy-rubber-coated pipebombs go off after 2 seconds. Sticky nades have a minimum explosion timer of 1.5 seconds.
Knife secondary attack is 'swing with all your might attack' and it essentially stuns you (you swing so hard that you fall over//are dizzy//you cut yourself//whatever) for two seconds after you use it.
Flamethrower's secondary is a spray unlit napalm (or whatever) onto the floor. The delay for spraying is 2 seconds in order to put out the flame. The delay to light the flame is 1 second. So in order to douse some napalm down...it delays lighting or 'flaming' for like 3 seonds (I hate Eternal Silence's Flamethrower--which has napalm coating hallways...for what seems to be eternity [i've seen a hall on fire for like a minute b/f...totally ridiculous]).
excellent :-)
sticky bombing skulks
i really like this scripting addition
it will let you guys try out ideas and balance easier between builds.
and i like the spread on the pistol idea.
It'll make the pistol a more solid secondary.
BTW Feel free to post any polls to vote on stuff.
you guys are already attracting people to these updates.
I'm not sure I like the OnIdle code. I'm one of those control freaks who like to maintain total control, including reloads. With code like this, reloads always occur when you least want them to - say when you're at the armory picking up ammo OR when you just emptied your clip, the alien is still alive, and you'd rather change weapons. So, you end up fighting with the GUI as it tries to play the reload animation, while you try to either continue picking up more ammo or desperately switch to a different weapon.
I have the same problem with the else statement in the OnPrimaryAttack. If I'm trying to fire my weapon and I have no bullets, I'd rather get a "click" sound so I can quickly change to another weapon. I'd rather not reload in the middle of a battle. And I'd rather not have to fight with the GUI in order to switch weapons.
Good post overall. It's interesting how seemingly simple code has complex behavior when you include a client-server network environment with multiple clients interacting with and dependent on each other.
i noticed in your pistol reload code you didnt add in the code for the case when the ammo==0
<!--QuoteEnd--></div><!--QuoteEEnd-->
The ammo is the first thing checked in the reload method at the bottom of the page, so it's not necessary to duplicate the code in other methods. In fact, that duplication would be a bad coding practice.
Regarding the initialization of the ammo variable; that's really just ugly coding on my part. I should have used a balance variable instead of hard coding it to 2 extra clips. The reason I hard coded it was because I hadn't yet if it made more sense to specify the starting ammo as a certain number of clips or as a fixed number of bullets. Now that I know the answer to that I'll go back and change it.
Oops! There's a bug in the code, but nobody has noticed it yet.
<!--QuoteEnd--></div><!--QuoteEEnd-->
I think I got it. (although I could be wrong simply because you might have covered it somewhere else in the code)
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
function Pistol:Reload()
<!--c2--></div><!--ec2-->
should read
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
function self:Reload()
<!--c2--></div><!--ec2-->
It makes me think, what else can be changed live? Lets take an example:
We are play testing a new build, and quickly we discover there is a bug in the client and server pistol code that stops the gun reloading. Oops. What would have to happen to fix this bug?
Could you quickly hack the code to fix it before the pt session is over?
Would you be able to transmit a patch to the client side from the server?
The ammo is the first thing checked in the reload method at the bottom of the page, so it's not necessary to duplicate the code in other methods. In fact, that duplication would be a bad coding practice.
<!--QuoteEnd--></div><!--QuoteEEnd-->
check again, it checks to see if the ammo is >0 and covers the case for if you reload when there is still ammo in your clip. there is no else statement or if/then statement about ammo==0. from looking at this code, if you were to fire off your complete clip then you would not be able to reload.
there are 2 places where the reload method is automatically called, and its in the idle sequence, where if ammo is 0 then self:reload and in the primary fire sequence where theres an else self:reload, but in the pistole:reload method there is only
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->pistole:reload()
if(ammo>0) then
do stuff that covers this case
end
end
<!--c2--></div><!--ec2-->
when there needs to be something like
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->pistole:reload()
if(ammo>0) then
do stuff that covers this case
else
//check to see if theres enough ammo to fill the clip
if(ammo>clipsize)then
clip = clipsize
ammo = ammo-clipsize
else
//if theres not enough ammo to fill the clip
clip=ammo
ammo = 0
end
end
end
<!--c2--></div><!--ec2-->
check again, it checks to see if the ammo is >0 and covers the case for if you reload when there is still ammo in your clip. there is no else statement or if/then statement about ammo==0. from looking at this code, if you were to fire off your complete clip then you would not be able to reload.
there are 2 places where the reload method is automatically called, and its in the idle sequence, where if ammo is 0 then self:reload and in the primary fire sequence where theres an else self:reload, but in the pistole:reload method there is only
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->pistole:reload()
if(ammo>0) then
do stuff that covers this case
end
end
<!--c2--></div><!--ec2-->
when there needs to be something like
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->pistole:reload()
if(ammo>0) then
do stuff that covers this case
else
//check to see if theres enough ammo to fill the clip
if(ammo>clipsize)then
clip = clipsize
ammo = ammo-clipsize
else
//if theres not enough ammo to fill the clip
clip=ammo
ammo = 0
end
end
end
<!--c2--></div><!--ec2--> <!--QuoteEnd--></div><!--QuoteEEnd-->
Im not that into codeing, but may i ask what happins, if you got lets say 3 bullets left, code dosnt seems to count the bullets just telling if ther anything ther... would you get a full clip,even you only got 3 bullets left?
Semi-auto -- fairly accurate, pull trigger each shot
Full-auto -- poor accuracy, holding trigger will empty magazine quickly sending a quick, deadly at close range, burst of bullets
use the secondary fire to switch between the modes.
What I <!--coloro:red--><span style="color:red"><!--/coloro-->DO NOT<!--colorc--></span><!--/colorc--> want for the pistol is for it to stay as a perfect shot sniper weapon. It's a pistol for crying out loud, I don't care how futuristic that is, it's physically not possible. The NS1 developers of the weapons were clearly are not Mythbusters fans. <img src="style_emoticons/<#EMO_DIR#>/tounge.gif" style="vertical-align:middle" emoid=":p" border="0" alt="tounge.gif" /> (or was that show not around back then?)
check again, it checks to see if the ammo is >0 and covers the case for if you reload when there is still ammo in your clip. there is no else statement or if/then statement about ammo==0. from looking at this code, if you were to fire off your complete clip then you would not be able to reload.
there are 2 places where the reload method is automatically called, and its in the idle sequence, where if ammo is 0 then self:reload and in the primary fire sequence where theres an else self:reload, but in the pistole:reload method there is only
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->original code<!--c2--></div><!--ec2-->
when there needs to be something like
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->ammo == 0 case<!--c2--></div><!--ec2-->
<!--QuoteEnd--></div><!--QuoteEEnd-->
I think you're confusing some of the variables. self.clip is how much ammo is in the current clip, and self.ammo is the amount of extra ammo on hand. When self.ammo == 0, there's nothing to reload, and so there is no case to handle.
Also, the code you proposed doesn't make sense anyway. You're subtracting clipsize from ammo, even though that case would only occur when ammo is 0 already, thus making ammo negative (<img src="style_emoticons/<#EMO_DIR#>/confused-fix.gif" style="vertical-align:middle" emoid="???" border="0" alt="confused-fix.gif" />).
Semi-auto -- fairly accurate, pull trigger each shot
Full-auto -- poor accuracy, holding trigger will empty magazine quickly sending a quick, deadly at close range, burst of bullets
use the secondary fire to switch between the modes.
What I <!--coloro:red--><span style="color:red"><!--/coloro-->DO NOT<!--colorc--></span><!--/colorc--> want for the pistol is for it to stay as a perfect shot sniper weapon. It's a pistol for crying out loud, I don't care how futuristic that is, it's physically not possible. The NS1 developers of the weapons were clearly are not Mythbusters fans. <img src="style_emoticons/<#EMO_DIR#>/tounge.gif" style="vertical-align:middle" emoid=":p" border="0" alt="tounge.gif" /> (or was that show not around back then?) <!--QuoteEnd--></div><!--QuoteEEnd-->
Actualy, the new kinds handheld weapons is electrical whit no moveing parts and no recoil, fireing 2-3 times as fast, unbeleavable accurate and vary far. So the only thing that should be changed is the looks, to something more futureristic. ( according to "weapons of the future" @ NGC or discovery ( cant remember wher i saw the program )
Edit.
@ some post about haveing funk fails, the weapon above cant posible get it ( or so they claimed )
The tecnolegy is allready here folks <img src="style_emoticons/<#EMO_DIR#>/smile-fix.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile-fix.gif" />
I can already hear the first trumpet...
Time to lure Max into this thread in order to clear things up:
[lure]
Titan Quest had an awesome engine, although it's netcode had quite a number of quirks. I wonder who wrote that great piece of code.
[/lure]
Should we be talking about the source code only or can we open the discussion to talking about what we all want from in NS2 guns in general? I was under the impression Max wanted this to be fairly open-ended
Some ideas for secondary fire/upgrades/different weapon ideas:
<b><u>Pistol</u></b>:
<b>Full-auto</b>; would be cool. But you may waste all your ammo.
<b>Pistol whip</b>; for those moments when a skulk is way to close for comfort and all ammo is shot. Admittedly it probably wouldn’t save you. But I assume you would only use a secondary fire like this if you had used all your other ammo on the skulk and didn’t have time to change to your knife, so the skulk would (hopefully) only need one hit :s
<b><u>Light Machine Gun</u></b>:
<b>Single shot with scope</b>; probably not necessary in NS, but could be useful in larger rooms, or down long corridors.
<b>Different clip on “Pods” that go under the machine gun barrel</b>; these could be part of the upgrades (you start with a better secondary fire pod each time the commander gets better upgrade) and could include things like a single shot grenade launcher, a short shotgun (much like a sawn off shotgun, with a wider field of fire, but shorter range and less accurate). A bayonet for close quarters actions (this could be the starting “pod”) or a chainsaw <img src="style_emoticons/<#EMO_DIR#>/tounge.gif" style="vertical-align:middle" emoid=":p" border="0" alt="tounge.gif" />. Some kind of ball mine that just rolls out from a pod, but doesn’t explode until an alien comes near it. A mini flame thrower. I dunno, just a crazy idea.
<b><u>Shotgun</u></b>:
<b>Melee attack</b>; for a smack down, could be quite a hard hit.
<b>Double shot</b>; shoots of two shells instead of one.
<b>Different ammo</b>; this could apply to all the guns really, but I think it would be best in a shot gun as a second barrel. Say a Slug for example; for more damage on one small piece, could be useful for carving holes in Fades heads. Or flammable/explosive shots, that burst into flames on contact, might be useful for taking down hives.
<b><u>Heavy Machine Gun</u></b>:
<b>Melee attack</b>, I think it would be a bit stupid, but it depends on how big the gun is in the game, but it could be a slow movement with plenty of damage.
<b>Different ammo, see shotgun.</b>
<b>Single shot grenade launcher</b>.
<b>Built in motion tracking </b> or some kind of short ranged revealing device, that shows aliens/structures in cloak, might only work for a short amount of time.
<b>“Pods” again</b>; could have the same idea as the LMG of having small devises that clip onto the bottom of the gun and do something different.
<u><b>Grenade Launcher</b></u>:
<b>Burst fire</b>; shoots off your whole clip at once across a small area.
<b>Gas grenade</b>; could cause damage to aliens in it or just provide some kind of cover like a smoke grenade. Could even do something similar to Umbra.
<b>Bouncing/Moving/Rolling grenade</b>; just because it’s such a silly idea it would be fun. Bounces off walls and around corners, keeps bouncing until it explodes, or could just move along the floor, maybe it has wheels or something.
<b>Remote grenades</b>; the grenade launcher has a remote on it to detonate them, but they could have a small chance of going off when they land because of the impact. Good for holding an area from incoming alien hordes.
<b>Incendiary grenades</b>; leaves fire on the ground/walls around a target, useful for taking out a hive and stopping gorges getting close enough to heal it.
<u><b>Hand Grenade</b></u>:
See above for grenade ideas.
<u><b>Mine</b></u>:
I think the N64s Goldeneye has always been the standard for mines in any game: <b>Timed</b>, <b>Remote</b> and <b>Proximity</b>. What more do you want?
<b>Flare mine</b>, sends off a warning to the commander that there are in coming aliens, but stay in the area until an alien destroys them.
<b><u>Knife</u></b>:
<b>Throw</b>; could be chucked, it probably isn’t a good idea unless you have a way of getting it back.
<b>Imbed/heavy slash</b>; jams the knife in the alien, takes longer to do but could do double or triple damage.
<b><u>Welder</u></b>:
<b>Electric burst</b>, fires a burst of electricity at a target, much like a taser, but might take some time to build up the charge and may only travel a short distance.
^^There are some ideas for the marines, but I was wondering weather the Kharaa would have secondary fire as well?
Also, will the Kharaa players view be sorted out; I don’t understand why when you are a Skulk your view is clearly from inside the mouth when the model clearly shows the Skulk has eyes above the mouth? Also why Heavy Armour always seems to be the same size as every other player, where as an Onos seems to grow in height?
Did I miss something in the back story or history behind the Kharaa, are those even their eyes?
I should probably save this idea for another place, but as I am on the subject of ideas for changes, I would really like to see the commander being able to move up and down through floors (or just to get a close up view of the action) in commander view, maybe using the mouse wheel or page up and down. I don’t know if this is possible. Have only just started playing NS again after a gap of a few years and have never really played commander. But it would allow for more realistic and interesting designs in maps, where multiple floors could be used more effectively, and layered on top of one another, just like you find in real buildings. Maybe there might need to be a limit on how many floors you had because commanders may end up getting lost. The mini map could have buttons that go to different floors.
Am I wrong, is this possible now (if so why can’t I work it out, am I just a n00b? <img src="style_emoticons/<#EMO_DIR#>/confused-fix.gif" style="vertical-align:middle" emoid="???" border="0" alt="confused-fix.gif" /> ), would it be possible in NS2?
Love reading the blog and everyone’s ideas on here, can’t wait for NS2 and the NS2TR! (Sorry I wrote so much <img src="style_emoticons/<#EMO_DIR#>/wink-fix.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink-fix.gif" /> )
<!--QuoteEnd--></div><!--QuoteEEnd-->
Thanks for saying the engine was awesome. The network system however was the one aspect of the engine I had nothing to do with.
In reality I haven't really been writing any networking code for NS2 either. All the stuff I described in the blogs is how Valve's system works. I'm really just creating a bridge between our scripting system and the low-level Source networking system.
Oh and the bug I mentioned before is that when you reload the pistol it discards the bullets currently in the clip. You could say that's by design (which of course I would have done if anyone had spotted it before me!) but it wasn't my intent when writing the code.
Reading through this topic I can't help but think of how a system like this could be used to support dynamic balance.<!--QuoteEnd--></div><!--QuoteEEnd-->
That's exactly what I was thinking when I read the post.
You could even use this like the global weapon pricing that is used in CSS. If done well, this could be a big help to balance the public games.
(Reading the other posts I realise that this idea for the pistol has already been forwarded... but i guess my post explains it better....)