Friendly AI Problem
Posted: Mon May 12, 2003 8:13 pm
Dear All
I've written a basic SP script with three objectives. It all works perfectly until the player meets up with a friendly 'prisoner' Miller. The friendly moves to the player and follows the player - no problem. But as soon as we encounter enemy AI and the firing starts the whole thing freezes and I get this error message
Script Error: Cannot cast 'NIL' to float
wait self.waittime (global/friendly.scr,1172)
Script Error: Cannot cast 'NIL' to float
while (iSalive self) (global/freindly.scr,228)
ERROR: Command overflow Possible infinite loop in thread
The full script is pasted below. Anyone got any ideas as to what I'm doing wrong?? Thanks in anticipation.
Regards
Otto
//test_sam
exec global/ai.scr
exec global/loadout.scr maps/test_sam.scr
level waittill prespawn
exec global/ambient.scr test_sam
level waittill spawn
main:
waitthread InitPlayer
waitthread InitFriends
waitthread InitObjectives
end
InitPlayer:
$player item weapons/m1_garand.tik
$player ammo rifle 24
$player useweaponclass rifle
fadein 2 0 0 0 1
wait 2
level.script = "maps/test_sam.scr"
end
InitFriends:
thread FriendWait
end
FriendWait:
$friend_trigger waittill trigger
$friendly.destination = $player
$friendly.friendtype = 1
$friendly.distance = 150
$friendly thread global/friendly.scr::friendlythink
end
InitObjectives:
waitthread global/objectives.scr::add_objectives 1 1 "Get the documents" $documents.origin
waitthread global/objectives.scr::add_objectives 2 1 "Rescue Miller" $miller.origin
waitthread global/objectives.scr::add_objectives 3 1 "Exit by back gate" $gate.origin
waitthread global/objectives.scr::add_objectives 1 2
waitthread global/objectives.scr::current_objectives 1
end
objective1:
$documents remove
goto objective
end
objective:
waitthread global/objectives.scr::add_objectives 1 3 "Get the documents" $documents.origin
waitthread global/objectives.scr::add_objectives 2 2
waitthread global/objectives.scr::current_objectives 2
end
objective2:
goto objectivenext
end
objectivenext:
waitthread global/objectives.scr::add_objectives 2 3 "Rescue Miller" $miller.origin
waitthread global/objectives.scr::add_objectives 3 2
waitthread global/objectives.scr::current_objectives 3
end
objective3:
goto levelend
end
levelend:
waitthread global/objectives.scr::add_objectives 3 3 "Exit by back gate" $gate.origin
waitthread global/objectives.scr::current_objectives 0
iprintln_noloc "Mission Complete!"
wait 1
exec global/missioncomplete.scr test_sam 1
end
I've written a basic SP script with three objectives. It all works perfectly until the player meets up with a friendly 'prisoner' Miller. The friendly moves to the player and follows the player - no problem. But as soon as we encounter enemy AI and the firing starts the whole thing freezes and I get this error message
Script Error: Cannot cast 'NIL' to float
wait self.waittime (global/friendly.scr,1172)
Script Error: Cannot cast 'NIL' to float
while (iSalive self) (global/freindly.scr,228)
ERROR: Command overflow Possible infinite loop in thread
The full script is pasted below. Anyone got any ideas as to what I'm doing wrong?? Thanks in anticipation.
Regards
Otto
//test_sam
exec global/ai.scr
exec global/loadout.scr maps/test_sam.scr
level waittill prespawn
exec global/ambient.scr test_sam
level waittill spawn
main:
waitthread InitPlayer
waitthread InitFriends
waitthread InitObjectives
end
InitPlayer:
$player item weapons/m1_garand.tik
$player ammo rifle 24
$player useweaponclass rifle
fadein 2 0 0 0 1
wait 2
level.script = "maps/test_sam.scr"
end
InitFriends:
thread FriendWait
end
FriendWait:
$friend_trigger waittill trigger
$friendly.destination = $player
$friendly.friendtype = 1
$friendly.distance = 150
$friendly thread global/friendly.scr::friendlythink
end
InitObjectives:
waitthread global/objectives.scr::add_objectives 1 1 "Get the documents" $documents.origin
waitthread global/objectives.scr::add_objectives 2 1 "Rescue Miller" $miller.origin
waitthread global/objectives.scr::add_objectives 3 1 "Exit by back gate" $gate.origin
waitthread global/objectives.scr::add_objectives 1 2
waitthread global/objectives.scr::current_objectives 1
end
objective1:
$documents remove
goto objective
end
objective:
waitthread global/objectives.scr::add_objectives 1 3 "Get the documents" $documents.origin
waitthread global/objectives.scr::add_objectives 2 2
waitthread global/objectives.scr::current_objectives 2
end
objective2:
goto objectivenext
end
objectivenext:
waitthread global/objectives.scr::add_objectives 2 3 "Rescue Miller" $miller.origin
waitthread global/objectives.scr::add_objectives 3 2
waitthread global/objectives.scr::current_objectives 3
end
objective3:
goto levelend
end
levelend:
waitthread global/objectives.scr::add_objectives 3 3 "Exit by back gate" $gate.origin
waitthread global/objectives.scr::current_objectives 0
iprintln_noloc "Mission Complete!"
wait 1
exec global/missioncomplete.scr test_sam 1
end