Advanced 3d AIO chapter 7 (aiGuard.cs) crash
by Nick Wilson · in Torque Game Engine · 01/21/2006 (10:47 am) · 22 replies
Has anyone been able to get this chapter's code to work? I've tried typing up my own version of aiGuard.cs and using the one on the cd in both torque 1.3 and 1.4 and it always crashes while loading. There is little to no information in console.log. It just ends after the line "Loading compiled script starter.fps/server/scripts/aiGuard.cs." Here's the last chunk of my console.log file:
Does anyone have any idea what the problem could be? I'd appreciate any tips or insight anyone could offer.
*** Load Main Menu Exporting server prefs... Starting multiplayer mode Binding server port to default IP UDP initialized on port 28000 Loading compiled script starter.fps/server/scripts/audioProfiles.cs. Loading compiled script starter.fps/server/scripts/camera.cs. Loading compiled script starter.fps/server/scripts/markers.cs. Loading compiled script starter.fps/server/scripts/triggers.cs. Loading compiled script starter.fps/server/scripts/inventory.cs. Loading compiled script starter.fps/server/scripts/shapeBase.cs. Loading compiled script starter.fps/server/scripts/item.cs. Loading compiled script starter.fps/server/scripts/health.cs. Loading compiled script starter.fps/server/scripts/staticShape.cs. Loading compiled script starter.fps/server/scripts/weapon.cs. Loading compiled script starter.fps/server/scripts/radiusDamage.cs. Loading compiled script starter.fps/server/scripts/crossbow.cs. ParticleEmitterData(CrossbowBoltEmitter) velocityVariance > ejectionVelocity Error: shape starter.fps/data/shapes/crossbow/ammo.dts-collision detail 0 (Collision-3) bounds box invalid! Loading compiled script starter.fps/server/scripts/player.cs. Loading compiled script starter.fps/data/shapes/player/player.cs. Validation required for shape: starter.fps/data/shapes/player/player.dts Loading compiled script starter.fps/server/scripts/chimneyfire.cs. Loading compiled script starter.fps/server/scripts/aiPlayer.cs. Validation required for shape: starter.fps/data/shapes/player/player.dts Compiling starter.fps/server/scripts/aiGuard.cs... Loading compiled script starter.fps/server/scripts/aiGuard.cs.
Does anyone have any idea what the problem could be? I'd appreciate any tips or insight anyone could offer.
About the author
#2
01/28/2006 (3:27 pm)
Simply replace "LightMaleHumanAvatar" with "PlayerBody". That should do it, assuming of course that you are using the default Torque demo app.
#3
02/06/2006 (7:53 pm)
Thanks Phil ;)
#4
Anyone have a clue how to fix this?
Edit to add: I'm using the aiGuard.cs from the second 3dgap1 book.
03/31/2006 (8:37 am)
Another question on this item. I have changed "LightMaleHumanAvatar" with "PlayerBody" and my guards spawn in without a problem. The guards spawn where they are supposed to, and they look around as expected. But, that's all they do. They won't shoot at me, (as they are programed to do) and they won't die when shot. They don't lose life at all.Anyone have a clue how to fix this?
Edit to add: I'm using the aiGuard.cs from the second 3dgap1 book.
#5
there's some typo in aiGuard.cs in fucntion AIPLayer::CheckArcOfSight(%this, %that)
look for this line,
%relbearing = %this.GetRelativeBearing(%this,%that)
should be
%relbearing = %this.GetRelativeBearing(%that)
and
if( (%relbearing > -($ARC_IF_SIGHT/2) && (%relbearing < -($ARC_OF_SIGHT/2) )
should be :
if( (%relbearing > -($ARC_IF_SIGHT/2) && (%relbearing < ($ARC_OF_SIGHT/2) )
2. they won't die when shot. They don't lose life at all.
You need to add the AIGuardDB::damage and AIGuardDB::onDisabled.
hint :
You can copy the function from player.cs
Armor::damage and Armor::onDisabled and change it to AIGuardDB::damage and AIGuardDB::onDisabled.
Hope that helps
04/23/2006 (5:57 am)
1. They won't shoot at me, (as they are programed to do) there's some typo in aiGuard.cs in fucntion AIPLayer::CheckArcOfSight(%this, %that)
look for this line,
%relbearing = %this.GetRelativeBearing(%this,%that)
should be
%relbearing = %this.GetRelativeBearing(%that)
and
if( (%relbearing > -($ARC_IF_SIGHT/2) && (%relbearing < -($ARC_OF_SIGHT/2) )
should be :
if( (%relbearing > -($ARC_IF_SIGHT/2) && (%relbearing < ($ARC_OF_SIGHT/2) )
2. they won't die when shot. They don't lose life at all.
You need to add the AIGuardDB::damage and AIGuardDB::onDisabled.
hint :
You can copy the function from player.cs
Armor::damage and Armor::onDisabled and change it to AIGuardDB::damage and AIGuardDB::onDisabled.
Hope that helps
#6
04/23/2006 (9:48 am)
I changed className to = Armor; and it fixed it for me, this was some time ago.
#7
04/25/2006 (8:30 pm)
I have made some of the changes above. However, my guards are still not shooting at me. I get this at setAllDebug()==>setAllDebug(); ~~~%this:122~AIGuardDB::DoScan (from:1619) ~~~%this: 122~AIGuardDB::checkForThreat (from: 1619) ~~~%this: 1619~AIPlayer::getClosestEnemy AI_Whisper~~~%this: 1619~AIPlayer::CheckArcOfSight AI_Whisper~~~%that: 1678 AI_Whisper~~~%this: 1619~AIPlayer::GetRelativeBearing AI_Whisper~~~%this: 1619~AIPlayer::GetBearing AI_Whisper~~~xHere: 237.778 yHere 252.676 AI_Whisper~~~xThere: 202.197 yThere268.211 AI_Whisper~~~slope: -0.43661 ~~~~~~~~~~~~~ AI_WhisperLoud~~~Angle in: -156.413 ~~~~~~~~~~~~~~~ AI_Whisper~~~%this: 1619~AIPlayer::GetHeading AI_Alert~~~HEADING: 181.328 AI_Alert~~~BEARING: AI_Alert~~~relbearing: AI_Alert~~~result: 1 ~~~%this: 1619~AIPlayer::GetTargetRange ~~~Actual range to target: 40.3771 ~~~no threat (from: 1619) ~~~%this:122~AIGuardDB::DoScan (from:1616) ~~~%this: 122~AIGuardDB::checkForThreat (from: 1616) ~~~%this: 1616~AIPlayer::getClosestEnemy AI_Whisper~~~%this: 1616~AIPlayer::CheckArcOfSight AI_Whisper~~~%that: 1678 AI_Whisper~~~%this: 1616~AIPlayer::GetRelativeBearing AI_Whisper~~~%this: 1616~AIPlayer::GetBearing AI_Whisper~~~xHere: 343.103 yHere 123.877 AI_Whisper~~~xThere: 202.197 yThere268.211 AI_Whisper~~~slope: -1.02433 ~~~~~~~~~~~~~ AI_WhisperLoud~~~Angle in: -134.312 ~~~~~~~~~~~~~~~ AI_Whisper~~~%this: 1616~AIPlayer::GetHeading AI_Alert~~~HEADING: 90.7348 AI_Alert~~~BEARING: AI_Alert~~~relbearing: AI_Alert~~~result: 1 ~~~%this: 1616~AIPlayer::GetTargetRange ~~~Actual range to target: 216.671 ~~~no threat (from: 1616) ~~~%this:122~AIGuardDB::DoScan (from:1613) ~~~%this: 122~AIGuardDB::checkForThreat (from: 1613) ~~~%this: 1613~AIPlayer::getClosestEnemy AI_Whisper~~~%this: 1613~AIPlayer::CheckArcOfSight AI_Whisper~~~%that: 1678Can anyone help me?
#8
05/03/2006 (9:10 am)
It seems that your AI do not detect the existence of Player. try checking the CheckArcOfSight and GetRelativeBearing functions. maybe there's some mistype you had.
#9
05/03/2006 (6:04 pm)
@Hermanto: I know it is a typo somehwere because I use CD version with above corrections and it works. I am just trying to find the error in my code. Additionally I do not get the "GUARD" label on top of my bots like I do when I use the CD version??
#10
06/05/2006 (5:36 am)
I had the same problems but everyone's useful tips oversame them - thanks.
#11
Does anyone know why this code should work in the FPS DEMO, but it does not work in the STARTER.FPS? I get an instant crash when trying this same procedure with fixes in Starter.fps using TGE 1.5.
12/13/2006 (9:20 am)
Phillip and Hermanto, thanks from me as well, this one was driving me crazy until I found this thread. Does anyone know why this code should work in the FPS DEMO, but it does not work in the STARTER.FPS? I get an instant crash when trying this same procedure with fixes in Starter.fps using TGE 1.5.
#12
I've followed your tips, but I still cant load up a mission in the starter.fps, it crashes...
I'm using Torsion to debug and this is the error i get in the output window
Im using TGE1.5 SDK and Im using the aiGuard.cs from the a3dgpai1 book.
Does anyone have a clue on whats happening?? Could it be that Im uing tge1.5 SDK??
Cheers!
01/30/2007 (6:49 pm)
Hi everyone!I've followed your tips, but I still cant load up a mission in the starter.fps, it crashes...
I'm using Torsion to debug and this is the error i get in the output window
starter.fps/server/scripts/aiGuard.cs (50): Unable to find parent object PlayerBody for PlayerData.
Im using TGE1.5 SDK and Im using the aiGuard.cs from the a3dgpai1 book.
Does anyone have a clue on whats happening?? Could it be that Im uing tge1.5 SDK??
Cheers!
#13
01/31/2007 (3:30 am)
Where are you exec'ing your aiGuard.cs at? I know it's in game.cs. Where in the list? It should be the very last cs in the list. If it's before player.cs, then torque won't know about the player yet.
#14
Thanks Mike! I left the aiGuard.cs in the bottom of those exec's, but I still get an error on the console: starter.fps/server/scripts/aiGuard.cs Line:149 - Syntax error.
I went to torison to try and fix that syntax error, but I cant find anything wrong... this is the code I have (exact same thing as the book):
tkx!
01/31/2007 (7:40 am)
Yo!Thanks Mike! I left the aiGuard.cs in the bottom of those exec's, but I still get an error on the console: starter.fps/server/scripts/aiGuard.cs Line:149 - Syntax error.
I went to torison to try and fix that syntax error, but I cant find anything wrong... this is the code I have (exact same thing as the book):
function AIGuardDB::onTargetEnterLOS(%this,%obj) {
DebugPrint( "%this:"@%this@"~AIGuardDB::onTargetEnterLOS LOS TARGET ! (from:"@%obj@")", "onTargetEnterLOS");
if(!isObject(%obj))
return;
%obj.attentionLevel = %this.attention;
%this.schedule($MIN_ITCHY_FINGER+getRandom($MAX_ITCHY_FINGER), "pauseFire", %obj);
%this.schedule($MIN_SCAN_GAP+getRandom($MAX_SCAN_GAP/%this.alertness), "doScan", %obj);
%obj.setImageTrigger(0,true);
}And by the way, the output window on torsion gives me the exact same error:Compiling starter.fps/server/scripts/aiGuard.cs...
starter.fps/server/scripts/aiGuard.cs Line: 149 - parse error
>>> Advanced script error report. Line 149.
>>> Some error context, with ## on sides of error halt:
DebugPrint( "> %obj.clearAim (from:"@%obj@")", "DoScan");
%obj.currentTarget = 0;
}
%this.nextScan = %this.schedule($MIN_SCAN_GAP+getRandom($MAX_SCAN_GAP/%this.alertness), "doScan",%obj);
}
function AIGuardDB::onTargetEnterLOS(%this,%obj) {
## ##
DebugPrint( "%this:"@%this@"~AIGuardDB::onTargetEnterLOS LOS TARGET ! (from:"@%obj@")", "onTargetEnterLOS");
if(!isObject(%obj))
return;
%obj.attentionLevel = %this.attention;
%this.schedule($MIN_ITCHY_FINGER+getRandom($MAX_ITCHY_FINGER), "pauseFire", %obj);
>>> Error report complete. Could it be the enconding of the text, like should it be UTF8 or something??tkx!
#15
Sorry guys!! my mistake... Apperently I had 2 calls for the 'aiGuard.cs' in the 'game.cs' script, and one of them was before the 'player.cs'. Obviously torque was messing it up crashing all the time. So I just deleted the 1st 'aiGuard.cs' call.
Now Im getting the same problem as Mike Rowley about the guard just standing in the same spot and not attacking me. I will follow the rest of this post tips and hope that everything works. Ill post back to ensure everyone that this post is working...
01/31/2007 (3:55 pm)
WOW!Sorry guys!! my mistake... Apperently I had 2 calls for the 'aiGuard.cs' in the 'game.cs' script, and one of them was before the 'player.cs'. Obviously torque was messing it up crashing all the time. So I just deleted the 1st 'aiGuard.cs' call.
Now Im getting the same problem as Mike Rowley about the guard just standing in the same spot and not attacking me. I will follow the rest of this post tips and hope that everything works. Ill post back to ensure everyone that this post is working...
#16
Ok guys, its working for me!
Becareful with the 1st Hermanto post, there are some syntax errors:
if( (%relbearing > -($ARC_IF_SIGHT/2) && (%relbearing < ($ARC_OF_SIGHT/2) )
should be:
if ( (%relbearing > -($ARC_OF_SIGHT/2)) && (%relbearing < ($ARC_OF_SIGHT/2)) )
As a matter of fact, hermanto warned to check out about some mistypes in his 2nd post!!
One other thing, is there any way to make the guards chase me? because they just stay on the same spot, and they only attack me if I get to their range...
anyone?
tkx!
01/31/2007 (5:05 pm)
Thats it!Ok guys, its working for me!
Becareful with the 1st Hermanto post, there are some syntax errors:
if( (%relbearing > -($ARC_IF_SIGHT/2) && (%relbearing < ($ARC_OF_SIGHT/2) )
should be:
if ( (%relbearing > -($ARC_OF_SIGHT/2)) && (%relbearing < ($ARC_OF_SIGHT/2)) )
As a matter of fact, hermanto warned to check out about some mistypes in his 2nd post!!
One other thing, is there any way to make the guards chase me? because they just stay on the same spot, and they only attack me if I get to their range...
anyone?
tkx!
#17
05/22/2007 (12:43 pm)
Is there a known problem with the AI Guard code and TGE 1.5? It doesn't seem to want to work.
#18
05/22/2007 (12:57 pm)
I am using it with TGE 1.5.2, I am having no problems. What kind problems you having?
#19
We've gone over the code many, many times but still have found no more mistakes. We did make a few at first, but the bot would not spawn at that time.
Eidt: Doh! I forgot to add, does anyone have a fix for this one? We've checked and checked and we can't find any script errors, punctuation, or grammitical errors.
Edit2: Got it fixed. The problem I had is for some reason the Dynamic Fields in the spawn sphere did not save. For some reason they kept changing. I have no idea why, but I finally got the mission saved where all those fields were correct, now the guard does attack me.
Now I just need to fix his aim a bit.
10/30/2007 (6:20 pm)
Ok, we've gotten this working somewhat. The bot will spawn, but not attack. When checking the console logs we do not get any errors but when we echo the "check threat" function, the player is not considered a threat.We've gone over the code many, many times but still have found no more mistakes. We did make a few at first, but the bot would not spawn at that time.
Eidt: Doh! I forgot to add, does anyone have a fix for this one? We've checked and checked and we can't find any script errors, punctuation, or grammitical errors.
Edit2: Got it fixed. The problem I had is for some reason the Dynamic Fields in the spawn sphere did not save. For some reason they kept changing. I have no idea why, but I finally got the mission saved where all those fields were correct, now the guard does attack me.
Now I just need to fix his aim a bit.
#20
11/17/2007 (5:24 pm)
I got it to work but the bad guy keeps shooting at me even after he's dead! how do I fix that? He seems to shoot sporadically after dying until the dead bad guy object fades away
Torque Owner Nick Wilson
I've figured out the code thats causing the crash in aiGuard.cs, but I have no idea why its doing it. The problem is in the datablock declaraction. Does anyone see anything wrong with this code?
datablock PlayerData(AIGuardDB : LightMaleHumanArmor) { className = "NPC"; maxInv[CrossbowAmmo] = 50000; };I've tried commenting out the assignments inside, so I know they're not the problem. I've also tried changing AIGuardDB to something else with no luck. I've also changed "PlayerData" to something else but when I do and I try to run CreateBots() from aiGuard.cs to spawn my bots, I get the message:
I'm sure there's some very basic error or something Ive missed since I'm so new. If anyone can has any advice on how to proceed I'd appreciate it.