Bunker Gun --> HMG1 (Un-deploying Mounted Gun)

Need Help? The Day isnt going so well on the Mapping front?
Post Reply
shiftey
npc_combinegunship
npc_combinegunship
Posts: 705
Joined: Thu Oct 09, 2008 4:45 pm
Contact:

Bunker Gun --> HMG1 (Un-deploying Mounted Gun)

Post by shiftey »

Here's what I'm trying to accomplish:

A mounted gun has 512 bullets and is located in a defensive position. After the defense is over, if a player uses the gun, it will turn into the custom_hmg1.

If the player used all of the ammunition, then the hmg1 will have no ammo in it. If the player didn't deplete the ammo during the defense, they receive an hmg1 with a small amount of ammo in it.

I figured I would use a game_player_equip to equip the player with the custom_hmg1. Normally I would use map_cfg to change the default clip size to 0 and then use a point_server_command to set it higher when the player gets ammo for the gun. But I don't think I can do this with a custom weapon.

Any ideas?

Worst case scenario would be I have to set the mounted gun to have infinite ammo and then when the defense is over the player that uses the gun gets a fully loaded hmg1. However, this map is stingy on weaponry similar to tysns maps, and I don't want the player to have unlimited ammo on the mounted gun.
Ny
Phone Donator
Phone Donator
Posts: 496
Joined: Sun Oct 05, 2008 3:22 pm
Contact:

Post by Ny »

Totally new to the mapping scence but I was wondering if you could do it a similar way to the way the crowbar was handed to the player in EP1.

You have the bunker gun that acts like a normal usable turret gun with unlimited ammo. When the defence ends a trigger goes of changing the dynamics of the gun so that on next use the gun is deleted and another gun is given to the player with a finite amount of ammo

Could this work?
:nyoron:
fug4life
Beta Tester
Beta Tester
Posts: 4093
Joined: Mon Dec 11, 2006 10:35 am

Post by fug4life »

You can specify 512 bullets with the normal mounted gun right? So, Onoutofammo give logic compare 1, intial value 0. Compare (also compare at the end of the defense (trigger) or Onlostplayercontroller (func_tank)), on equal to ;game_player_equip_noammo; custom_hmg1_shiftey_empty. On less than game_player_equip_withammo; custom_hmg1_shiftey_definedammo.

And just create custom_hmg1_shiftey_empty
"clip_size" "0"
And create custom_hmg1_shiftey_withammo "clip_size" "80w/e"

Well something like that.

I Need to recall/remember logic_compares.

intial value 0
compare value 1

Oninvalue - compare or onequalto I cant remeber which (from the outofammo func_Tank) gives gun without ammo immediately
compare value
Onlessthan (from the lostplayercontrol) gives gun with specified ammo soon as player decides to nolonger use the gun.

My head is a mess but you know what I mean.
'I would probably smarten up before you meet Violet'.
'She has zero tolerance for idiots'.

fug's Obsidian files
fug's Obsidian clips
Obsidian wiki
Obsidian Map Database
shiftey
npc_combinegunship
npc_combinegunship
Posts: 705
Joined: Thu Oct 09, 2008 4:45 pm
Contact:

Post by shiftey »

Yeah Ny I left that part out but yes that is how it would work. My problem is with how to define how much ammo the gun has, which fug tried to explain but I'm confused.

@fug: are you saying I should create new custom weapons? If so, will this interfere with any other weapons? I thought I heard something about there being a limit of 7 custom weapons or something.
fug4life
Beta Tester
Beta Tester
Posts: 4093
Joined: Mon Dec 11, 2006 10:35 am

Post by fug4life »

Basically yes.

If you're ok with a 120 as the default clip (which is the exsisting custom_hmg1) then you only need to create 1 extra 'ammoempty' weapon script. If you want something other than 120 then yes you're going to need two scripts.

As for how many weapon scripts you can have, it can be infinite, as long as each is named differently. Bucket positions are the only concern. But because you are essentially using only one gun and this is for your map only then you can just use the same bucket position, as the player is only ever going to be given one of the two guns (which are the same guns using the same bucket positions anyhow).

Check the 'clip' and 'default clip'. Clip is how many in the gun, default clip is how many the gun can hold should the player find ammo else where around.

I know it may seem alot to have two scripts but end of the day they're just text files, we used to have 3 ak47 scripts, The whole reason we got scripted weapons is to customise. As long as you give the custom_hmg1_yourmapname.

Its got to be better than having point_client/server commands that pop up with yellow messages on screen.

So it works like this: You make you mounted gun along with func_tank set the ammount of ammo(512) the functank will have.
When the gun runs out of ammo an empty gun will be given to the player that ran the gun out of ammo.
If the player decides to walk away from the gun then he again automatically picks up the gun with ammo (set amount or default 120).

On both events the player has seemed to physically take the gun that was mounted, so in both cases you kill the mounted gun when they pick it up.

If you want multiple players to be able to pick up the gun then you'll need a trigger multi with an OnEndTouch or an On use on the func_tank, and leave the mounted gun in the world to symbolise where to get the hmg1 from.

Anyway this can all be done with either logic_compares or logic_cases or trigger_multis all interacting with func_tank input&outputs along with game_player_equips and players triggering Onuse or Onoutof ammo or Onendtouch, w/e else inputs/outputs etc or even math_counters. There's many ways of sending the outputs.

So the question is do you want only one player who uses the gun to get the gun? Or you want multiple players to be able to use the gun (whilst its mounted and has ammo) then you want only one player or multiple players to get the gun? <-This needs to be decided.

If you still want some help, I'll fire up hammer and look, as all this is pretty much of the top of my head. But its all possible.

P.s I cant remember if weapon scripts (just the script) can be safely packed in the map (seeing as the model is already in the mod). If so then you're not even really adding to the w/scripts folder on the clients. So its not like the whole thing is a mess. If it has to be .res then well they're just scripts they are there to do a job.

Here I've looked at the wiki for func_tank

Code: Select all

    * OnGotPlayerController 

    Fires when a Player starts to control this tank. NPCs do NOT fire this input. 

    * OnLostPlayerController 

    Fires when the Player controller of the tank stops controlling it. NPCs do NOT fire this input. 

    * OnAmmoDepleted 

    Fires when tank runs out of ammo 
Probably those and a logic_compare, logic_case or math_counter are all you need to call the game_player_equips.
'I would probably smarten up before you meet Violet'.
'She has zero tolerance for idiots'.

fug's Obsidian files
fug's Obsidian clips
Obsidian wiki
Obsidian Map Database
shiftey
npc_combinegunship
npc_combinegunship
Posts: 705
Joined: Thu Oct 09, 2008 4:45 pm
Contact:

Post by shiftey »

Alright this sounds like it will work perfectly. Thanks fug!

I'll post back here when I try it, though i won't be home again for a while.
shiftey
npc_combinegunship
npc_combinegunship
Posts: 705
Joined: Thu Oct 09, 2008 4:45 pm
Contact:

Post by shiftey »

Okay so I got it all together and it works great. However, OnAmmoDepleted is bugged and won't fire an Output but I used a simple workaround. Onfire math_counter Add 1; When the counter reaches 512 it fires.

But otherwise everything worked great. Thanks for the help fug and Ny.
Post Reply