auto firing cannon at player

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
LtNeil
Sergeant
Posts: 54
Joined: Sun Nov 14, 2004 8:46 pm
Location: southend on sea
Contact:

auto firing cannon at player

Post by LtNeil »

I have'nt done scripting in ages (or mapping come to that)but i thought i would try to do this tut but i just can not get it to work.

Here is the script can anyone let me know if there something missing please.(oh yeah its to make a cannon auto fire at the player)

main

exec global/loadout.scr maps/test_flak.scr

exec global/exploder.scr

exec global/friendly.scr

exec global/ai.scr

level.script = maps/test_flak.scr

level waittill prespawn

exec global/ambient.scr m3l3 // Ambient sound of the Normandy-levels.

level waittill spawn // Wait until the player has spawned into the level

fadein 2 0 0 0 1

wait 3 // A slow level fade in

$player item weapons/m1_garand.tik // The player gets the Garand-rifle

$player ammo rifle 40 // And 40 bullets for it

$player item weapons/M2frag_grenade_sp.tik // Also, the player gets hand grenades

$player ammo grenade 15 // The amount of grenades

Fire_88mm_weapon: // This script part will start as soon as the player runs through the trigger

local.gun_name = $88mm_weapon1 // Initialize the flak

local.target = $player // Defines the player as the 88?s target

local.gun_name setaimtarget local.target // Let the 88 aim at the player

wait(1) // Let the 88 wait before firing until the turning is done

local.range = 96 + randomint(128)
local.offset = 96 + randomint(128) // Defines the range and accuracy of the gun

local.gun_name anim fire_scripted // Starts the gun firing

wait(0.7 + ((randomint(6)) * .1)) // Random time from shooting til impact

local.a = local.target.origin
if((randomint(100)) < 50)
local.a[0] = local.a[0] + local.range
else

local.a[0] = local.a[0] - local.range

if((randomint(100)) < 50)

local.a[1] = local.a[1] + local.offset

else

local.a[1] = local.a[1] - local.offset // Redefines the target to make it look realistical

local.Exp1 = spawn "fx/scriptbazookaexplosion.tik"
local.Exp2 = spawn "animate/fx_mortar_dirt.tik"

local.Exp3 = spawn "animate/fx_mortar_higgins.tik" // Play the explosions

exec global/earthquake.scr .23 4 0 0 // The screen shakes each impact

local.Exp1.origin = local.a local.Exp1 anim start

local.Exp2.origin = local.a

local.Exp2 anim start

local.Exp3.origin = local.a

local.Exp3 anim start

wait(1) // Disables the animation

local.Exp1 remove
local.Exp2 remove

local.Exp3 remove // Removes the animations

local.gun_name setaimtarget $FlakBaseAim
end // This brings the 88 gun back to its starting position (needs a script_origin inside the map)
My candle burns at both ends it will not last the night but oh my foes and oh my friends it gives a lovely light.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Try this . Does the script run at all can't spot any mistakes at the moment .

$player item weapons/M2frag_grenade_sp.tik // Also, the player gets hand grenades

$player ammo grenade 15 // The amount of grenades

end

Fire_88mm_weapon: // This script part will start as soon as the player runs through the trigger

local.gun_name = $88mm_weapon1 // Initialize the flak

local.target = $player // Defines the player as the 88?s target

local.gun_name setaimtarget local.target // Let the 88 aim at the player

local.gun_name waittill ontarget //wait(1) // Let the 88 wait before firing until the turning is done

local.range = 96 + randomint(128)
local.offset = 96 + randomint(128) // Defines the range and accuracy of the gun
Image
LtNeil
Sergeant
Posts: 54
Joined: Sun Nov 14, 2004 8:46 pm
Location: southend on sea
Contact:

Post by LtNeil »

The map is not running at all apart from spawning the player but i can not choose gun or anything.All i can think of is i must have mis-typed something in the map itself :roll:
My candle burns at both ends it will not last the night but oh my foes and oh my friends it gives a lovely light.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

It looks like you forgot the : after main :P
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

and end after level waittill spawn
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

the end goes before the start of the first thread after main:
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

global/aim_and_shoot.scr

Post by tltrude »

There is a global/aim_and_shoot.scr you can use, provided that your gun is a real AI gunner.

Below is what is in that script.

// tells AI to aim and then shoot

start local.target:
self exec global/aimat.scr local.target
self waittill animdone
self exec global/shoot.scr

There is a singleplayer mission where an AI tank shoots at the player -- might be M5L0b or 6.
Tom Trude,

Image
LtNeil
Sergeant
Posts: 54
Joined: Sun Nov 14, 2004 8:46 pm
Location: southend on sea
Contact:

Post by LtNeil »

cool i'll give it a try,theres something im not doing right as i tried a script and map i know works and that did'nt work either so i may have to re-install moh (what fun!) :P :lol:
My candle burns at both ends it will not last the night but oh my foes and oh my friends it gives a lovely light.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

As long as I can remember reinstall never fixed a problem :?
Image
LtNeil
Sergeant
Posts: 54
Joined: Sun Nov 14, 2004 8:46 pm
Location: southend on sea
Contact:

Post by LtNeil »

You must be one of those lucky people then or one that never messes with the default settings of there computer. :)

I got a game called mafia and i was playing away when i realized i could'nt get into half the streets i used to be able to :? low and behold a quick re-install of the game and everything was back to normal !

Maybe i just got a screwy computer, :lol:
My candle burns at both ends it will not last the night but oh my foes and oh my friends it gives a lovely light.
LtNeil
Sergeant
Posts: 54
Joined: Sun Nov 14, 2004 8:46 pm
Location: southend on sea
Contact:

Post by LtNeil »

Ok this is getting damn freaky!

For anyone that wants a look ive included the map.script.bsp.

This is the map ive always know to work.I get the obj to come up and when i hit the trigger it goes to next obj but i can not get any weapons to work! :? Heeeeeeelp! im going crazy

http://www.merlins-lair.co.uk/map_and_script.zip
My candle burns at both ends it will not last the night but oh my foes and oh my friends it gives a lovely light.
LtNeil
Sergeant
Posts: 54
Joined: Sun Nov 14, 2004 8:46 pm
Location: southend on sea
Contact:

Post by LtNeil »

ooook i got it to work BUT only when i tried it by loading up moh BREAKTHROUGH instead of moh allied assualt :? is there a difference ?
I don't understand why its works with one and not the other ? :oops:
My candle burns at both ends it will not last the night but oh my foes and oh my friends it gives a lovely light.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

sh, bt

Post by tltrude »

Some of the models in SH/BT don't work in Mohaa. The SDK version of radient is for SH/BT.
Tom Trude,

Image
Post Reply