Solution: Multiple MG42s

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
cufarmer
Private
Posts: 1
Joined: Wed Aug 15, 2007 5:32 pm

Solution: Multiple MG42s

Post by cufarmer »

I was stumped on how to get multiple MG42s to work in a single player map. every solution known to man (at least posted here) would not work for me.
but...browsing through level scripts, I stumble on this.

First, set up one mg42 and mg42_gunner using the values from this post... https://map.moh-central.net/forum/viewtopi ... 265fbd19df
This is what i have done to get 1 mg 42 running:
I made a siple room(so I can Learn it first)

Put a wall 48 units high in to but he mg42 on

placed the bipod and gun in

then I read a couple of tutuarls and went with them

gave the gun a targetname/mg42


Then added a AI/german/wehrmact/soldier

Gave him key/values

targetname/mg42_gunner

target/mg42

turret/mg42

type_idle/machinegunner

type_attack/turret
DONT copy paste script info from that post.
Now, copy the mg42 and enemy to another location where you'd like to place an mg42.
select the mg42, press "n" and change $targetname to mg42_2. also, change target to mg42_2_gunner.
deselect mg42 and select enemy ai next to mg42 and press "n".
Change $targetname to mg42_2_gunner, and change turret to mg42_2 ....you can continue this at least 3 times ...i have not tested on more than 3 guns.
......now the script.....i'm going to include the top portion of the script for my map...for reference. section in red is related to mg42's.

exec global/auto.scr
level waittill prespawn

level waittill spawn
//$mg42 thread global/mg42_active.scr::mg42 // <--ignor this line. dont place in your script

//----------------------------------------------------------------------------
main:
//----------------------------------------------------------------------------

waitthread InitPlayer
waitthread InitFriends
waitthread InitEnemies
waitthread InitObjectives
waitthread InitArtillery
waitthread InitVehicles
$mg42 waitthread InitMG42s

// Hide our throbbing box for objective #2 until player completes objective #1
$ThrobbingBox hide


end

//----------------------------------------------------------------------------
InitPlayer:
//----------------------------------------------------------------------------
// setup our player with weapons.
$player takeall
$player item weapons/Webley_Revolver.tik
$player item weapons/enfield.tik
$player item weapons/sten.tik
$player item weapons/mills_grenade.tik
$player item weapons/M18_smoke_grenade.tik

// give him some ammo
$player ammo pistol 32
$player ammo smg 128
$player ammo rifle 50
$player ammo smokegrenade 3
$player ammo grenade 3

// start out using the smg
$player useweaponclass smg

// give him binoculars and the explosive icon...
$player item items/binoculars.tik
waitthread global/items.scr::add_item "binoculars" noprint // Show binoculars inventory icon
waitthread global/items.scr::add_item "explosive" noprint // Show explosive inventory icon
//added mg42 crap...CDF
$mg42.max_range = 1024
$mg42.pitchcaps = ( -35 35 0)
$mg42 thread global/mg42_active.scr::mg42
$mg42_2.max_range = 1024
$mg42_2.pitchcaps = ( -35 35 0)
$mg42_2 thread global/mg42_active.scr::mg42
$mg42_3.max_range = 1024
$mg42_3.pitchcaps = ( -35 35 0)
$mg42_3 thread global/mg42_active.scr::mg42

end
This is what did the trick for my map, I see a lot of script tutorials for mg42's with ai and they should work, but if they dont, try this.
Post Reply