Page 1 of 1

auto firing cannon at player

Posted: Tue May 02, 2006 9:51 am
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)

Posted: Tue May 02, 2006 2:07 pm
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

Posted: Tue May 02, 2006 6:29 pm
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:

Posted: Tue May 02, 2006 7:52 pm
by jv_map
It looks like you forgot the : after main :P

Posted: Wed May 03, 2006 2:19 am
by Green Beret
and end after level waittill spawn

Posted: Wed May 03, 2006 9:27 am
by bdbodger
the end goes before the start of the first thread after main:

global/aim_and_shoot.scr

Posted: Wed May 03, 2006 2:50 pm
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.

Posted: Wed May 03, 2006 5:31 pm
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:

Posted: Wed May 03, 2006 5:51 pm
by jv_map
As long as I can remember reinstall never fixed a problem :?

Posted: Thu May 04, 2006 9:45 am
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:

Posted: Thu May 04, 2006 10:43 am
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

Posted: Thu May 04, 2006 10:57 am
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:

sh, bt

Posted: Fri May 05, 2006 5:42 am
by tltrude
Some of the models in SH/BT don't work in Mohaa. The SDK version of radient is for SH/BT.