![]() |
#1
|
|||
|
|||
![]()
Hi guys,
Time to break open the code. I am seeing an error on the server and I can not pinpoint what the issue is. Below is the code I am using (the voice sounds work and get no error with that) Any Idea? Code:
public override void OnAircraftDamaged(int missionNumber, string shortName, AiAircraft aircraft, AiDamageInitiator initiator, part.NamedDamageTypes damageType) { base.OnAircraftDamaged(missionNumber, shortName, aircraft, initiator, damageType); // speech // GetDamageVictims() AiAircraft initiator_aircraft = initiator.Actor as AiAircraft; if (speechTimer.Elapsed.Milliseconds > 1 && speechTimer.Elapsed.Seconds < 20) { // timer is running & less than 20 seconds since last speech return; // speech no more fequently than 20 secs apart. } else { speechTimer.Restart(); } if (aircraft.Army() != initiator_aircraft.Army()) { // shooting at enemy aircraft Timeout(3, () => // wait 3 seconds { switch (random.Next(1, 6 + 1)) { case 1: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Nice_shot"); break; case 2: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Good_shot_sir"); break; case 3: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Good_shooting"); break; case 4: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Good_show"); break; case 5: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Bullseye"); break; case 6: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Good_hits"); break; default: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Direct_hit"); break; } }); } else { // shooting at a friendly aircraft // first verse if (random.Next(1, 100 + 1) < 75) // 33% chance of first verse { switch (random.Next(1, 2 + 1)) { case 1: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Friendlies"); break; case 2: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Damn_what_are_you_doing"); break; default: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Damn1"); break; } } //second verse Timeout(2, () => // wait 2 seconds { switch (random.Next(1, 3 + 1)) { case 1: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Cease_fire_shooting_at_friendly"); initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Return_to_base_immediately_or_you_will_be_shot_down_"); break; case 2: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Watch_it_You_re_shooting_at_one_of_ours"); break; case 3: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Stop_fire"); break; default: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Oh_my_God_Stop_Please_stop_Ooooaaaaahhh"); break; } }); // third verse Timeout(4, () => // wait 4 seconds { if (random.Next(1, 100 + 1) < 75) // 30% chance of third verse { switch (random.Next(1, 2 + 1)) { case 1: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "That_is_without_a_doubt_the_worst_flying_I_have_ever_seen"); break; case 2: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Return_to_base_immediately_or_you_will_be_shot_down_"); break; default: initiator_aircraft.SayToGroup(initiator_aircraft.AirGroup(), "Cannot_do_anything_right_today_can_you"); break; } } }); } } [23:01:42] System.NullReferenceException: Object reference not set to an instance of an object. [23:01:42] [23:01:42] Server stack trace: [23:01:42] at Mission.OnAircraftDamaged(Int32 missionNumber, String shortName, AiAircraft aircraft, AiDamageInitiator initiator, NamedDamageTypes damageType) [23:01:42] at maddox.game.ABattle.OnAircraftDamaged(Int32 missionNumber, String shortName, AiAircraft aircraft, AiDamageInitiator initiator, NamedDamageTypes damageType) [23:01:42] at maddox.game.world.Strategy.OnAircraftDamaged(Int32 missionNumber, String shortName, AiAircraft aircraft, AiDamageInitiator initiator, NamedDamageTypes damageType) [23:01:42] at maddox.game.ABattle.OnEventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt) [23:01:42] at maddox.game.world.Strategy.OnEventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt) [23:01:42] at System.Runtime.Remoting.Messaging.StackBuilderSink ._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) [23:01:42] at System.Runtime.Remoting.Messaging.StackBuilderSink .SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) [23:01:42] [23:01:42] Exception rethrown at [0]: [23:01:42] at System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage reqMsg, IMessage retMsg) [23:01:42] at System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData& msgData, Int32 type) [23:01:42] at maddox.game.IBattle.OnEventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt) [23:01:42] at maddox.game.GameDef.eventGame(GameEventId eventId, Object eventArg0, Object eventArg1, Int32 eventArgInt) [23:01:42] at WoroaxENpmii8VryBS1.l72U2qEZkgauhd5ThjE.naGW165wRS kRFDpn8qAt(Object , GameEventId , Object , Object , Int32 ) [23:01:42] at WoroaxENpmii8VryBS1.l72U2qEZkgauhd5ThjE.eventGame( GameEventId , Object , Object , Int32 ) [23:01:42] at QTJWCZav3I4dK5Rv9Zd.soVedrakcuHYXN8uYhv.V15uBXPplU M(GameEventId , Object , Object , Int32 ) [23:01:42] =================================================
__________________
__________________ Win7, 64bit Ultra Asus P8P67Pro MB Intel i7-2600K Coursair 16GB (4x 4GB), DDR3-1600MHz Gainward Nvidia 580GTX 3GB DDR5 850-Watt Modular Power Supply WIN7 and COD on Gskill SSD 240GB 40" Panasonic LCD TrackIR5 + Thrustmaster Warthog stick, throttle & pedals |
#2
|
|||
|
|||
![]()
Test initiator_aircraft for null value
Code:
if (initiator_aircraft == null) return; Last edited by FG28_Kodiak; 08-01-2012 at 04:32 AM. |
#3
|
|||
|
|||
![]()
Looks suspiciusly like some of my old code, ya bastard!
![]() Code:
public override void OnAircraftDamaged(int missionNumber, string shortName, AiAircraft aircraft, AiDamageInitiator initiator, part.NamedDamageTypes damageType) { base.OnAircraftDamaged(missionNumber, shortName, aircraft, initiator, damageType); // speech // GetDamageVictims() AiAircraft initiator_aircraft = initiator.Actor as AiAircraft; if (initiator_aircraft != null) { if (speechTimer.Elapsed.Milliseconds > 1 && speechTimer.Elapsed.Seconds < 20) { // timer is running & less than 20 seconds since last speech return; // speech no more fequently than 20 secs apart. } else { speechTimer.Restart(); } if (aircraft.Army() != initiator_aircraft.Army()) { // shooting at enemy aircraft Timeout(3, () => // wait 3 seconds { // shooting at enemy aircraft speech string[] HitEnemyACSpeech = { "Nice_shot", "Good_shot_sir", "Good_shooting", "Good_show", "Bullseye", "Good_hits", "Direct_hit" }; sayToGroup(initiator_aircraft.AirGroup(), HitEnemyACSpeech[random.Next(HitEnemyACSpeech.GetLowerBound(0), HitEnemyACSpeech.GetUpperBound(0))]); }); } else { // shooting at a friendly aircraft // first verse if (random.Next(1, 100 + 1) < 75) // 25% chance of first verse { // shooting at friendly aircraft speech string[] HitFriendlyACSpeech = { "Friendlies", "Damn_what_are_you_doing", "Damn1" }; sayToGroup(initiator_aircraft.AirGroup(), HitFriendlyACSpeech[random.Next(HitFriendlyACSpeech.GetLowerBound(0), HitEnemyACSpeech.GetUpperBound(0))]); } //second verse Timeout(2, () => // wait 2 seconds { // shooting at friendly aircraft speech 2 string[] HitFriendlyACSpeech2 = { "Cease_fire_shooting_at_friendly", "Return_to_base_immediately_or_you_will_be_shot_down_", "Watch_it_You_re_shooting_at_one_of_ours", "Stop_fire", "Oh_my_God_Stop_Please_stop_Ooooaaaaahhh" }; sayToGroup(initiator_aircraft.AirGroup(), HitFriendlyACSpeech2[random.Next(HitFriendlyACSpeech2.GetLowerBound(0), HitFriendlyACSpeech2.GetUpperBound(0))]); }); // third verse Timeout(4, () => // wait 4 seconds { if (random.Next(1, 100 + 1) < 75) // 25% chance of third verse { // shooting at friendly aircraft speech 3 string[] HitFriendlyACSpeech3 = { "That_is_without_a_doubt_the_worst_flying_I_have_ever_seen", "Return_to_base_immediately_or_you_will_be_shot_down_", "Cannot_do_anything_right_today_can_you" }; sayToGroup(initiator_aircraft.AirGroup(), HitFriendlyACSpeech3[random.Next(HitFriendlyACSpeech3.GetLowerBound(0), HitFriendlyACSpeech3.GetUpperBound(0))]); } }); } } }
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash. Get the latest COD Team Fusion patch info HERE Last edited by salmo; 08-01-2012 at 04:59 AM. |
#4
|
|||
|
|||
![]()
Thanks Salmo!
Also, "Looks suspiciusly like some of my old code, ya bastard! " That would explain why I have your name in my "Special Thanks" list next to Kodiak and others. Would you like your name further up the list? ![]() Below is in the Briefing of Mission. "(Thanks also to SNAFU, KODIAK, Salmo & Bliss) "
__________________
__________________ Win7, 64bit Ultra Asus P8P67Pro MB Intel i7-2600K Coursair 16GB (4x 4GB), DDR3-1600MHz Gainward Nvidia 580GTX 3GB DDR5 850-Watt Modular Power Supply WIN7 and COD on Gskill SSD 240GB 40" Panasonic LCD TrackIR5 + Thrustmaster Warthog stick, throttle & pedals |
#5
|
|||
|
|||
![]() Quote:
![]() ![]()
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash. Get the latest COD Team Fusion patch info HERE |
#6
|
|||
|
|||
![]()
Salmo,
Since you are reading here and not your email... Must take a while to travel from Melbourne to Tassie. You must be on the NBN...hahahaha FYI I sent you the mission to your email ![]()
__________________
__________________ Win7, 64bit Ultra Asus P8P67Pro MB Intel i7-2600K Coursair 16GB (4x 4GB), DDR3-1600MHz Gainward Nvidia 580GTX 3GB DDR5 850-Watt Modular Power Supply WIN7 and COD on Gskill SSD 240GB 40" Panasonic LCD TrackIR5 + Thrustmaster Warthog stick, throttle & pedals |
![]() |
|
|