394 lines
11 KiB
Text
394 lines
11 KiB
Text
//----------------------------------------------------------------------------
|
|
// Test_Ai.Scr
|
|
//
|
|
// This level/script provides the basics of using both enemy and friendly AI.
|
|
// In addition, this script demonstrates the use of objectives and artillery.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
exec global/auto.scr
|
|
|
|
level waittill prespawn
|
|
level waittill spawn
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
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
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------------
|
|
InitFriends:
|
|
//
|
|
// Setup our friendlies to wait until the player shows up...
|
|
//----------------------------------------------------------------------------
|
|
|
|
// rename our friendlies to something more "friendly"
|
|
level.friendly1.targetname = cappy
|
|
level.friendly2.targetname = friend2
|
|
level.friendly3.targetname = friend3
|
|
|
|
thread FriendWait
|
|
|
|
end
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
InitEnemies:
|
|
//
|
|
// Setup all the triggers to spawn in the enemy.
|
|
//----------------------------------------------------------------------------
|
|
|
|
thread SpawnSet100
|
|
thread SpawnSet200
|
|
thread SpawnSet300
|
|
|
|
end
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
InitObjectives:
|
|
//----------------------------------------------------------------------------
|
|
|
|
waitthread global/objectives.scr::add_objectives 1 1 "Rendezvous With Your Allies" $cappy.origin
|
|
waitthread global/objectives.scr::add_objectives 2 1 "Locate and Destroy Artillery Emplacements[1 remaining]" $flak88A.origin
|
|
waitthread global/objectives.scr::add_objectives 3 1 "Clear area of Nazis." $trigger300.origin
|
|
waitthread global/objectives.scr::add_objectives 4 1 "Destroy enemy tanks." $aagun.origin
|
|
|
|
// Turn on objective #1 and set it as current objective.
|
|
waitthread global/objectives.scr::add_objectives 1 2
|
|
waitthread global/objectives.scr::current_objectives 1
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------------
|
|
InitArtillery:
|
|
//
|
|
// setup various parameters for the artillery in the level.
|
|
//----------------------------------------------------------------------------
|
|
|
|
$flak88A_turret0 turnspeed 15
|
|
$flak88A_turret0 pitchspeed 7.5
|
|
$flak88A_turret0 viewjitter 7
|
|
$flak88A_turret0 firedelay 4
|
|
$flak88A_turret0 maxyawoffset 20.0
|
|
$flak88A_turret0 pitchcaps "20 10 0"
|
|
|
|
// setup collision for base of flak88
|
|
$flak88A.collisionent = $flak88A_collision
|
|
|
|
// setup collision for the turret of the flak88
|
|
$flak88A_turret0.collisionent = $flak88A_turret_collision
|
|
|
|
// aagun
|
|
$aagun_turret0 maxyawoffset 115.0
|
|
$aagun_turret0 turnspeed 25
|
|
$aagun_turret0 pitchspeed 25
|
|
$aagun_turret0 pitchcaps "-50 10 0"
|
|
$aagun_turret0 viewjitter 1
|
|
$aagun_turret0 firedelay 0.08
|
|
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------------
|
|
InitVehicles:
|
|
//
|
|
// Initialize level vehicles
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
thread TankTriggerWait
|
|
|
|
end
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
InitMG42s:
|
|
//
|
|
// Initialize MG42s in the level...
|
|
//----------------------------------------------------------------------------
|
|
|
|
if ( self==NIL )
|
|
{
|
|
println "No MG42s in level."
|
|
end
|
|
}
|
|
|
|
self maxyawoffset 70.0
|
|
self pitchcaps "-20 20 0"
|
|
self AIbulletspread 350 175
|
|
self convergetime 0.25
|
|
|
|
end
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
FriendWait:
|
|
//
|
|
// wait for player to hit our trigger..
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
$friend_trigger waittill trigger
|
|
|
|
// objective was accomplished, check it off...
|
|
waitthread global/objectives.scr::add_objectives 1 3
|
|
|
|
// set objective #2 as current...
|
|
waitthread global/objectives.scr::add_objectives 2 2
|
|
waitthread global/objectives.scr::current_objectives 2
|
|
|
|
// show our throbbing box now.
|
|
$ThrobbingBox show
|
|
|
|
// Have some sample dialog with the player.
|
|
$cappy turnto $player
|
|
$cappy lookat $player
|
|
wait 0.2
|
|
$cappy anim 11b100_BritCaptGreet
|
|
$cappy waittill animdone
|
|
|
|
$cappy anim 12C105_Dialogue03
|
|
$cappy waittill animdone
|
|
|
|
$cappy turnto NULL
|
|
$cappy lookat NULL
|
|
|
|
|
|
$cappy.destination = $player
|
|
$friend2.destination = $player
|
|
$friend3.destination = $player
|
|
|
|
$cappy.friendtype = 1
|
|
$friend2.friendtype = 1
|
|
$friend3.friendtype = 1
|
|
|
|
// stagger how far away they keep from their destinations
|
|
$cappy.distance = 175
|
|
$friend2.distance = 225
|
|
$friend3.distance = 250
|
|
|
|
// setup the friendlies to follow the player...
|
|
$cappy thread global/friendly.scr::friendlythink
|
|
$friend2 thread global/friendly.scr::friendlythink
|
|
$friend3 thread global/friendly.scr::friendlythink
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------------
|
|
SpawnSet100:
|
|
//
|
|
// Spawn AI set 100
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
$trigger100 waittill trigger
|
|
thread global/ai.scr::spawnset 100 spawn100
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------------
|
|
SpawnSet200:
|
|
//
|
|
// Spawn AI set 200
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
$trigger200 waittill trigger
|
|
waitthread global/ai.scr::spawnset 200 spawn200
|
|
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------------
|
|
SpawnSet300:
|
|
//
|
|
// Spawn AI set 300
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
$trigger300 waittill trigger
|
|
waitthread global/ai.scr::spawnset 300 spawn300
|
|
|
|
level.bad_guys_left = 0
|
|
|
|
$spawn300 thread BadGuyCheck
|
|
|
|
thread TruckGO
|
|
|
|
end
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
BadGuyCheck:
|
|
//
|
|
// Counts the bad guys that are spawned in and when they are all dead,
|
|
// updates the objective as complete.
|
|
//----------------------------------------------------------------------------
|
|
level.bad_guys_left++
|
|
self waittill death
|
|
level.bad_guys_left--
|
|
|
|
|
|
if ( level.bad_guys_left==0 )
|
|
{
|
|
// Complete objective 3!
|
|
waitthread global/objectives.scr::add_objectives 3 3
|
|
|
|
// go on to objective 4.
|
|
waitthread global/objectives.scr::add_objectives 4 2
|
|
waitthread global/objectives.scr::current_objectives 4
|
|
}
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------------
|
|
TankTriggerWait:
|
|
//----------------------------------------------------------------------------
|
|
|
|
$tank_objective waittill trigger
|
|
|
|
// start up the tanks...
|
|
|
|
level.playertanktarget = $player
|
|
|
|
$tank1 thread TankGo $tank1_path 200 panzer
|
|
$tank2 thread TankGo $tank2_path 200 empty_panzer // don't want anyone to come out of this tank
|
|
|
|
level.tank_count = 0
|
|
$tank1 thread TankObjectiveCheck
|
|
$tank2 thread TankObjectiveCheck
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------
|
|
TankObjectiveCheck:
|
|
//----------------------------------------------------------------------
|
|
level.tank_count++
|
|
self waittill death
|
|
|
|
level.tank_count--
|
|
|
|
if ( level.tank_count==0 )
|
|
{
|
|
waitthread global/objectives.scr::add_objectives 4 3
|
|
centerprint "You've completed all your objectives!"
|
|
}
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------
|
|
TankGo local.path local.speed local.type:
|
|
//----------------------------------------------------------------------
|
|
|
|
self thread global/vehicles_thinkers.scr::enemy_tank_think 0 local.type
|
|
self thread drive_path local.path local.speed
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------
|
|
drive_path local.path local.speed:
|
|
//----------------------------------------------------------------------
|
|
self.driving = 1
|
|
|
|
self drive local.path local.speed 30 200 256
|
|
self waittill drive
|
|
if (self)
|
|
{
|
|
self stop
|
|
self.driving = 0
|
|
}
|
|
|
|
end
|
|
|
|
//----------------------------------------------------------------------------
|
|
ArtilleryDestroyed:
|
|
//
|
|
// This get's called from the ThrobbingBox when the explosion happens.
|
|
//----------------------------------------------------------------------------
|
|
|
|
// complete objective #2
|
|
waitthread global/objectives.scr::add_objectives 2 3
|
|
|
|
// show objective #3
|
|
waitthread global/objectives.scr::add_objectives 3 2
|
|
|
|
// make objective #3 current
|
|
waitthread global/objectives.scr::current_objectives 3
|
|
|
|
|
|
end
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
TruckGO:
|
|
//
|
|
// Send a truck into the mix...
|
|
//----------------------------------------------------------------------------
|
|
|
|
// setup truck with 2 passengers..
|
|
$truck waitthread gags/t3l1_enemyspawn.scr::DoTruck 1800 2 0
|
|
|
|
// Set the type of guns the passengers will use...
|
|
$truck.passenger[1] gun "mp40"
|
|
$truck.passenger[2] gun "Mauser KAR 98K"
|
|
|
|
|
|
$trigger_truck waittill trigger
|
|
// $truck playsound opeltruck_snd_start
|
|
wait .5
|
|
$truck vehicleanim idlelights
|
|
// make truck go and wait till it's done moving...
|
|
$truck waitthread gags/t3l1_enemyspawn.scr::TruckDrive $truck_path 0 400 0 0 0
|
|
// turn off our lights when we get here....
|
|
wait .5
|
|
// $truck_1 playsound opeltruck_snd_stop
|
|
$truck_1 vehicleanim idlenolights
|
|
|
|
|
|
end
|