Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
jmgBearHunter.h
1
2#pragma once
3#include "jmgUtility.h"
4#include "direct.h"
5NewObjectiveSystem NewObjectiveSystemControl = NewObjectiveSystem(1);
6#define PI 3.14159265f
7#define PI180 PI/180
8class TempPlayerData
9{
10public:
11 struct TempPlayerDataNode
12 {
13 bool hasGotIntro;
14 int killsWithoutGettingHurt;
15 bool hasAnnounced10;
16 int totalKills;
17 time_t friendlyFireTime;
18 time_t talkToPrezTime;
19 int friendlyFireCount;
20 char playerName[128];
21 bool firstJoin;
22 time_t destroyTime;
23 struct TempPlayerDataNode *next;
24 unsigned int deaths;
25 int binocularTime;
26 int sentryTurretId;
27 bool portablePumpjackBeingPlaced;
28 int portablePumpjackId;
29 bool displayedKillMessage;
30 TempPlayerDataNode(const char *playerName)
31 {
32 hasGotIntro = false;
33 displayedKillMessage = false;
34 killsWithoutGettingHurt = 0;
35 totalKills = 0;
36 talkToPrezTime = NULL;
37 friendlyFireTime = clock();
38 friendlyFireCount = 0;
39 firstJoin = true;
40 destroyTime = NULL;
41 deaths = 0;
42 binocularTime = 100;
43 sentryTurretId = 0;
44 portablePumpjackId = 0;
45 if (playerName)
46 sprintf(this->playerName,"%s",playerName);
47 else
48 sprintf(this->playerName,"");
49 next = NULL;
50 }
51 void clearData()
52 {
53 }
54 };
55 struct TempPlayerDataNode *players[128];
56private:
57 struct TempPlayerDataNode *inactivePlayerData;
58 struct TempPlayerDataNode *dummyNode;
59 TempPlayerDataNode *FindPlayerNode(const char *playerName)
60 {
61 TempPlayerDataNode *Current = inactivePlayerData;
62 if (!inactivePlayerData)
63 return (inactivePlayerData = new TempPlayerDataNode(playerName));
64 while (Current)
65 {
66 if (!_stricmp(Current->playerName,playerName))
67 return Current;
68 if (!Current->next)
69 return (Current->next = new TempPlayerDataNode(playerName));
70 Current = Current->next;
71 }
72 return NULL;
73 }
74public:
75 TempPlayerData()
76 {
77 dummyNode = new TempPlayerDataNode("");
78 for (int x = 0;x < 128;x++)
79 players[x] = NULL;
80 players[0] = dummyNode;
81 inactivePlayerData = NULL;
82 }
83 void getPlayerNode(GameObject *player)
84 {
85 if (!player)
86 return;
87 int playerId = JmgUtility::JMG_Get_Player_ID(player);
88 if (!playerId)
89 return;
90 if (!players[playerId] || _stricmp(players[playerId]->playerName,Get_Player_Name(player)))
91 players[playerId] = FindPlayerNode(Get_Player_Name(player));
92 }
93 void Cleanup()
94 {
95 TempPlayerDataNode *temp = inactivePlayerData,*die;
96 while (temp)
97 {
98 die = temp;
99 die->clearData();
100 temp = temp->next;
101 delete die;
102 }
103 inactivePlayerData = NULL;
104 for (int x = 1;x < 128;x++)
105 players[x] = NULL;
106 }
107};
108TempPlayerData PlayerData;
109struct PCTDataObject
110{
111 int id;
112 char animation[32];
113 PCTDataObject(int id,const char *animation)
114 {
115 this->id = id;
116 sprintf(this->animation,"%s",animation);
117 }
118 PCTDataObject()
119 {
120 this->PCTDataObject::PCTDataObject(0,"");
121 }
122};
123PCTDataObject pctObjectArray[20] = {PCTDataObject()};
124class PowerupLimiterSystem
125{
126 struct PowerupNode
127 {
128 int id;
129 GameObject *obj;
130 struct PowerupNode *next;
131 PowerupNode(GameObject *obj)
132 {
133 id = Commands->Get_ID(obj);
134 this->obj = obj;
135 next = NULL;
136 }
137 };
138 PowerupNode *powerupNodeList;
139 int powerupCount;
140public:
141 PowerupLimiterSystem()
142 {
143 powerupCount = 0;
144 powerupNodeList = NULL;
145 }
146 PowerupLimiterSystem &operator += (GameObject *obj)
147 {
148 PowerupNode *current = powerupNodeList;
149 if (!powerupNodeList)
150 powerupNodeList = new PowerupNode(obj);
151 while (current)
152 {
153 if (!current->next)
154 {
155 current->next = new PowerupNode(obj);
156 break;
157 }
158 current = current->next;
159 }
160 powerupCount++;
161 if (powerupCount > 30)
162 Commands->Destroy_Object(powerupNodeList->obj);
163 return *this;
164 }
165 PowerupLimiterSystem &operator -= (GameObject *obj)
166 {
167 PowerupNode *current = powerupNodeList,*prev = NULL;
168 while (current)
169 {
170 if (current->obj == obj)
171 {
172 if (!prev)
173 {
174 powerupNodeList = powerupNodeList->next;
175 delete(current);
176 }
177 else
178 {
179 prev->next = current->next;
180 delete(current);
181 }
182 powerupCount--;
183 break;
184 }
185 prev = current;
186 current = current->next;
187 }
188 return *this;
189 }
190};
191class BearHunterVoiceSystem
192{
193public:
194 static int voiceId[128];
195 static void PlayVoice(GameObject *obj,const char *soundFile,const char *text)
196 {
197 JmgUtility::DisplayChatMessage(obj,127,127,255,text);
198 int playerId = JmgUtility::JMG_Get_Player_ID(obj);
199 Stop_Sound_Player(obj,voiceId[playerId],true);
200 voiceId[playerId] = Create_2D_Wave_Sound_Dialog_Player(obj,soundFile);
201 }
202 static void PlayVoice(const char *soundFile,const char *text)
203 {
204 JmgUtility::MessageAllPlayers(127,127,255,text);
205 for (int x = 1;x < 128;x++)
206 {
207 GameObject *player = Get_GameObj(x);
208 if (!player)
209 continue;
210 Stop_Sound_Player(player,voiceId[x],true);
211 voiceId[x] = Create_2D_Wave_Sound_Dialog_Player(player,soundFile);
212 }
213 }
214};
215Rp2SimplePositionSystem::SimplePositionNode *Rp2SimplePositionSystem::GetSpotNotVisibileFromSpot(Vector3 pos)
216{
217 pos.Z += 2;
218 SimplePositionNode *current = SimplePositionNodeList;
219 int random = Commands->Get_Random_Int(0,ObjectCount*2)+1;
220 int originalRandom = random;
221 while (current)
222 {
223 Vector3 targetpos = current->position;
224 targetpos.Z += 2.0f;
225 CastResultStruct res;
226 LineSegClass ray(pos,targetpos);
227 PhysRayCollisionTestClass coltest(ray, &res, SOLDIER_GHOST_COLLISION_GROUP);
228 PhysicsSceneClass::Get_Instance()->Cast_Ray(coltest,false);
229 if (JmgUtility::SimpleDistance(pos,current->position) > 5625 && coltest.CollidedRenderObj)
230 {
231 if (random)
232 random--;
233 if (!random)
234 return current;
235 }
236 current = current->next;
237 if (!current && originalRandom != random)
238 current = SimplePositionNodeList;
239 }
240 return NULL;
241}
242Rp2SimplePositionSystem::SimplePositionNode *Rp2SimplePositionSystem::GetNonVisibleSpotFromPlayers(int value)
243{
244 SimplePositionNode *current = SimplePositionNodeList;
245 int random = Commands->Get_Random_Int(0,ObjectCount*2)+1;
246 int originalRandom = random;
247 while (current)
248 {
249 if (current->value == value)
250 {
251 bool visibile = false;
252 for (int x = 1;x < 128;x++)
253 {
254 GameObject *player = Get_GameObj(x);
255 if (!player)
256 continue;
257 Vector3 pos = Commands->Get_Position(player);
258 Vector3 targetpos = current->position;
259 targetpos.Z += 1.0f;
260 pos.Z += 1.0;
261 CastResultStruct res;
262 LineSegClass ray(pos,targetpos);
263 PhysRayCollisionTestClass coltest(ray, &res, SOLDIER_GHOST_COLLISION_GROUP);
264 PhysicsSceneClass::Get_Instance()->Cast_Ray(coltest,false);
265 if (!coltest.CollidedRenderObj)
266 visibile = true;
267 }
268 if (!visibile)
269 {
270 if (random)
271 random--;
272 if (!random)
273 return current;
274 }
275 }
276 current = current->next;
277 if (!current && originalRandom != random)
278 current = SimplePositionNodeList;
279 }
280 return GetFurthestSpotFromPlayers(value);
281}
282PowerupLimiterSystem PowerupLimiterSystemControl = PowerupLimiterSystem();
283Rp2SimplePositionSystem randomSelectableSpawnPoints[7] = {Rp2SimplePositionSystem()};
284Rp2SimplePositionSystem aiDefensePoints[6] = {Rp2SimplePositionSystem()};
285Rp2SimplePositionSystem randomWeaponContainerSpawnPositions[6] = {Rp2SimplePositionSystem()};
286Rp2SimplePositionSystem ComancheDefensePoints[6] = {Rp2SimplePositionSystem()};
287Rp2SimplePositionSystem aiPtLocations = Rp2SimplePositionSystem();
288Rp2SimplePositionSystem bossSpawnProtectionPoints = Rp2SimplePositionSystem();
289class Rp2SimpleObjectList
290{
291public:
292 struct SimpleObjectNode
293 {
294 int ID;
295 int enemyId;
296 GameObject *obj;
297 struct SimpleObjectNode *next;
298 SimpleObjectNode(GameObject *_obj)
299 {
300 obj = _obj;
301 enemyId = 0;
302 ID = Commands->Get_ID(_obj);
303 next = NULL;
304 }
305 };
306private:
307 SimpleObjectNode *SimpleObjectNodeList;
308public:
309 int objectCount;
310 Rp2SimpleObjectList()
311 {
312 objectCount = 0;
313 SimpleObjectNodeList = NULL;
314 }
315 Rp2SimpleObjectList &operator += (GameObject *obj)
316 {
317 SimpleObjectNode *Current = SimpleObjectNodeList;
318 if (!SimpleObjectNodeList)
319 SimpleObjectNodeList = new SimpleObjectNode(obj);
320 while (Current)
321 {
322 if (!Current->obj)
323 {
324 Current->ID = Commands->Get_ID(obj);
325 Current->obj = obj;
326 break;
327 }
328 if (Current->obj == obj)
329 return *this;
330 if (!Current->next)
331 {
332 Current->next = new SimpleObjectNode(obj);
333 break;
334 }
335 Current = Current->next;
336 }
337 objectCount++;
338 return *this;
339 };
340 Rp2SimpleObjectList &operator -= (GameObject *obj)
341 {
342 SimpleObjectNode *Current = SimpleObjectNodeList;
343 while (Current)
344 {
345 if (Current->obj == obj)
346 {
347 Current->ID = 0;
348 Current->obj = NULL;
349 if (objectCount)
350 objectCount--;
351 }
352 Current = Current->next;
353 }
354 return *this;
355 };
356 bool IsInList(GameObject *obj)
357 {
358 SimpleObjectNode *Current = SimpleObjectNodeList;
359 while (Current)
360 {
361 if (Current->obj == obj)
362 return true;
363 Current = Current->next;
364 }
365 return false;
366 }
367 SimpleObjectNode *find(GameObject *obj)
368 {
369 SimpleObjectNode *Current = SimpleObjectNodeList;
370 while (Current)
371 {
372 if (Current->obj == obj)
373 return Current;
374 Current = Current->next;
375 }
376 return SimpleObjectNodeList;
377 }
378 void Empty_List()
379 {
380 objectCount = 0;
381 SimpleObjectNode *temp,*die;
382 temp = SimpleObjectNodeList;
383 while (temp)
384 {
385 die = temp;
386 temp = temp->next;
387 delete die;
388 }
389 SimpleObjectNodeList = NULL;
390 }
391 void Kill_All()
392 {
393 SimpleObjectNode *temp = SimpleObjectNodeList,*die;
394 while (temp)
395 {
396 die = temp;
397 temp = temp->next;
398 if (die->obj)
399 Commands->Apply_Damage(die->obj,9999.9f,"BlamoKiller",0);
400 }
401 }
402 int Recount()
403 {
404 int Count = 0;
405 SimpleObjectNode *Current = SimpleObjectNodeList;
406 while (Current)
407 {
408 if (Commands->Find_Object(Current->ID))
409 Count++;
410 Current = Current->next;
411 }
412 return Count;
413 }
414 void DestroyLeastSignificant()
415 {
416 float LongestDistance = 0;
417 GameObject *TempObject = NULL;
418 SimpleObjectNode *Current = SimpleObjectNodeList;
419 while (Current)
420 {
421 GameObject *Object = Commands->Find_Object(Current->ID);
422 if (Object)
423 {
424 GameObject *Star = Commands->Get_A_Star(Commands->Get_Position(Object));
425 if (Star)
426 {
427 float Temp = JmgUtility::SimpleDistance(Commands->Get_Position(Object),Commands->Get_Position(Star));
428 if (Temp > LongestDistance)
429 {
430 TempObject = Object;
431 LongestDistance = Temp;
432 }
433 }
434 }
435 Current = Current->next;
436 }
437 if (TempObject)
438 Commands->Destroy_Object(TempObject);
439 }
440 void DestroyOutsideOfRange(float range,Vector3 pos)
441 {
442 SimpleObjectNode *Current = SimpleObjectNodeList;
443 while (Current)
444 {
445 GameObject *Object = Commands->Find_Object(Current->ID);
446 if (Object && JmgUtility::SimpleFlatDistance(Commands->Get_Position(Object),pos) > range)
447 Commands->Destroy_Object(Object);
448 Current = Current->next;
449 }
450 }
451 GameObject *GetRandom()
452 {
453 if (!objectCount)
454 {
455 Console_Input("msg SimpleObjectNodeList GetRandom ERROR: List is empty!");
456 return NULL;
457 }
458 int random = Commands->Get_Random_Int(0,objectCount*2);
459 SimpleObjectNode *Current = SimpleObjectNodeList;
460 while (Current)
461 {
462 GameObject *Object = Commands->Find_Object(Current->ID);
463 if (Object)
464 {
465 if (random)
466 random--;
467 if (!random)
468 return Current->obj;
469 }
470 Current = Current->next;
471 if (!Current)
472 Current = SimpleObjectNodeList;
473 }
474 return NULL;
475 }
476 int GetAndRemoveListHeadObject()
477 {
478 while (SimpleObjectNodeList)
479 {
480 SimpleObjectNode *Current = SimpleObjectNodeList;
481 int id = Current->ID;
482 SimpleObjectNodeList = SimpleObjectNodeList->next;
483 delete Current;
484 if (Commands->Find_Object(id))
485 return id;
486 }
487 return 0;
488 }
489 int countInRangeTargetingId(Vector3 pos,float range,int targetId)
490 {
491 int inRangeCount = 0;
492 range = range*range;
493 SimpleObjectNode *current = SimpleObjectNodeList;
494 while (current)
495 {
496 if (current->ID && current->enemyId == targetId && current->obj && JmgUtility::SimpleFlatDistance(Commands->Get_Position(current->obj),pos) <= range && Commands->Get_Health(current->obj))
497 inRangeCount++;
498 current = current->next;
499 }
500 return inRangeCount;
501 }
502 GameObject *GetNearest(Vector3 pos)
503 {
504 float LongestDistance = 0;
505 GameObject *TempObject = NULL;
506 SimpleObjectNode *Current = SimpleObjectNodeList;
507 while (Current)
508 {
509 GameObject *Object = Commands->Find_Object(Current->ID);
510 if (Object)
511 {
512 float Temp = JmgUtility::SimpleDistance(Commands->Get_Position(Current->obj),pos);
513 if (!TempObject || Temp < LongestDistance)
514 {
515 TempObject = Current->obj;
516 LongestDistance = Temp;
517 }
518 }
519 Current = Current->next;
520 }
521 if (TempObject)
522 return TempObject;
523 return NULL;
524 }
525 Vector3 GetNearestPosition(Vector3 pos)
526 {
527 float LongestDistance = 0;
528 GameObject *TempObject = NULL;
529 SimpleObjectNode *Current = SimpleObjectNodeList;
530 while (Current)
531 {
532 GameObject *Object = Commands->Find_Object(Current->ID);
533 if (Object)
534 {
535 float Temp = JmgUtility::SimpleDistance(Commands->Get_Position(Current->obj),pos);
536 if (!TempObject || Temp < LongestDistance)
537 {
538 TempObject = Current->obj;
539 LongestDistance = Temp;
540 }
541 }
542 Current = Current->next;
543 }
544 if (TempObject)
545 return Commands->Get_Position(TempObject);
546 return Vector3(0.0f,0.0f,0.0f);
547 }
548};
549Rp2SimpleObjectList bearObjectListControl = Rp2SimpleObjectList();
550Rp2SimpleObjectList mutantObjectListControl = Rp2SimpleObjectList();
551class JMG_Bear_Hunter_Player_Soldier : public ScriptImpClass {
552 int playerId;
553 time_t LastTime;
554 Vector3 LastPosition;
555 int clipBullets;
556 int bullets;
557 void Created(GameObject *obj);
558 void Custom(GameObject *obj,int message,int param,GameObject *sender);
559 void Timer_Expired(GameObject *obj,int number);
560 void Damaged(GameObject *obj,GameObject *damager,float damage);
561 void Killed(GameObject *obj,GameObject *killer);
562 void Destroyed(GameObject *obj);
563 void CreateExplosion(GameObject *obj,const char *explosion,Vector3 pos,float *distance,int *explosives);
564 bool LifeSystem(GameObject *obj);
565 void GrantUnlockedWeapons(GameObject *obj);
566 void GrantSpecialUnlocks(GameObject *obj);
567public:
568 struct ArmoredCarWeapon
569 {
570 char weaponName[256];
571 int lastFireTime;
572 int lastammo;
573 double calculatedGrant;
574 double addedGrant;
575 ArmoredCarWeapon()
576 {
577 sprintf(this->weaponName,"");
578 this->lastFireTime = 0;
579 this->lastammo = 0;
580 this->calculatedGrant = 0.0;
581 this->addedGrant = 0.0;
582 }
583 void Reset()
584 {
585 this->addedGrant = 0.0;
586 this->lastFireTime = 75;
587 }
588 };
589 JMG_Bear_Hunter_Player_Soldier()
590 {
591 playerId = 0;
592 lastDamaged = 0;
593 armoredCarWeapon = ArmoredCarWeapon();
594 }
595 static double speed[128];
596 static char primaryWeapon[128][256];
597 static bool hasGrenadeVest[128];
598 int lastDamaged;
599 ArmoredCarWeapon armoredCarWeapon;
600};
601double JMG_Bear_Hunter_Player_Soldier::speed[128] = {0.0};
602char JMG_Bear_Hunter_Player_Soldier::primaryWeapon[128][256] = {""};
603bool JMG_Bear_Hunter_Player_Soldier::hasGrenadeVest[128] = {false};
604struct PlayerEmulatedSound
605{
606 enum logicalSoundType{stNone = 0,stOldWeapon = 1,stFootsteps = 2,stVehicle = 3,stGunshot = 4,stBulletHit = 5,stNoticeMe = 6};
607 float Range;
608 logicalSoundType SoundType;
609 PlayerEmulatedSound()
610 {
611 Range = 0;
612 SoundType = stNone;
613 }
614 void SetPlayerEmulatedSound(float range,logicalSoundType soundType)
615 {
616 Range = range;
617 SoundType = soundType;
618 }
619};
620PlayerEmulatedSound PlayerEmulatedSoundList[128] = {PlayerEmulatedSound()};
621
622#define EmulatedSoundCustom 450040
623class JMG_Rp2_Dedicated_Server_Sound_Emulator : public ScriptImpClass {
624 int vehicleId;
625 int vehicleRounds;
626 int SoundOverrideTime;
627 int LastWeaponID;
628 float weaponSoundRange;
629 int LastBullets;
630 int PlayerID;
631 void Created(GameObject *obj);
632 void Custom(GameObject *obj,int message,int param,GameObject *sender);
633 void Timer_Expired(GameObject *obj,int number);
634 void Killed(GameObject *obj,GameObject *killer);
635 void Destroyed(GameObject *obj);
636};
637
638class BearHunterGameControl
639{
640public:
641 struct BearHunterBearPositionNode
642 {
643 int id;
644 Vector3 pos;
645 int badCount;
646 struct BearHunterBearPositionNode *xNodes;
647 struct BearHunterBearPositionNode *yNodes;
648 struct BearHunterBearPositionNode *next;
649 BearHunterBearPositionNode(int id,Vector3 pos)
650 {
651 this->id = id;
652 this->pos = pos;
653 this->badCount = 0;
654 this->yNodes = NULL;
655 this->xNodes = NULL;
656 this->next = NULL;
657 }
658 };
659private:
660 bool builtNetwork;
661 int NodeCount;
662 BearHunterBearPositionNode *BearHunterBearPositionNodeList;
663 Vector2 MiddleValues;
664 BearHunterBearPositionNode *BearHunterBearPositionNodeGrouping;
665 void AddListNode(int id,const Vector3 &pos)
666 {
667 BearHunterBearPositionNode *Current = BearHunterBearPositionNodeList;
668 if (!BearHunterBearPositionNodeList)
669 BearHunterBearPositionNodeList = new BearHunterBearPositionNode(id,pos);
670 while (Current)
671 {
672 if (!Current->next)
673 {
674 Current->next = new BearHunterBearPositionNode(id,pos);
675 break;
676 }
677 Current = Current->next;
678 }
679 }
680 void AddNodesToLookupTable(BearHunterBearPositionNode *currentNode)
681 {
682 BearHunterBearPositionNode *Current = BearHunterBearPositionNodeGrouping,*Prev = NULL;
683 if (!BearHunterBearPositionNodeGrouping)
684 BearHunterBearPositionNodeGrouping = currentNode;
685 while (Current)
686 {
687 if (currentNode->pos.X < Current->pos.X && (!Prev || currentNode->pos.X > Prev->pos.X))
688 {// Add an xNode before
689 if (!Prev)
690 BearHunterBearPositionNodeGrouping = currentNode;
691 else
692 Prev->xNodes = currentNode;
693 currentNode->xNodes = Current;
694 return;
695 }
696 if (currentNode->pos.X > Current->pos.X && (!Current->xNodes || currentNode->pos.X < Current->xNodes->pos.X))
697 {// Add an xNode after
698 currentNode->xNodes = Current->xNodes;
699 Current->xNodes = currentNode;
700 return;
701 }
702 if (Current->pos.X == currentNode->pos.X)
703 {//add a Y node
704 BearHunterBearPositionNode *YNode = Current->yNodes,*yPrev = NULL;
705 if (!Current->yNodes)
706 {
707 Current->yNodes = currentNode;
708 return;
709 }
710 while (YNode)
711 {
712 if (currentNode->pos.Y < YNode->pos.Y && (!yPrev || currentNode->pos.Y > yPrev->pos.Y))
713 {// add node before
714 if (!yPrev)
715 Current->yNodes = currentNode;
716 else
717 yPrev->yNodes = currentNode;
718 currentNode->yNodes = YNode;
719 return;
720 }
721 if (currentNode->pos.Y > YNode->pos.Y && (!YNode->yNodes || currentNode->pos.Y < YNode->yNodes->pos.Y))
722 {// add node after
723 currentNode->yNodes = YNode->yNodes;
724 YNode->yNodes = currentNode;
725 return;
726 }
727 yPrev = YNode;
728 YNode = YNode->yNodes;
729 }
730 return;
731 }
732 Prev = Current;
733 Current = Current->xNodes;
734 }
735 }
736 void BuildLookupTable()
737 {
738 BearHunterBearPositionNode *Current = BearHunterBearPositionNodeList;
739 while (Current)
740 {
741 AddNodesToLookupTable(Current);
742 Current = Current->next;
743 }
744 }
745 void PrintNodeTable()
746 {
747 int count = 0;
748 BearHunterBearPositionNode *Current = BearHunterBearPositionNodeList;
749 while (Current)
750 {
751 count++;
752 Current = Current->next;
753 }
754 char debugTxt[220];
755 sprintf(debugTxt,"msg Total Nodes In List:%d",count);
756 Console_Input(debugTxt);
757 BearHunterBearPositionNode *table = BearHunterBearPositionNodeGrouping;
758 while (table)
759 {
760 BearHunterBearPositionNode *y = table->yNodes;
761 sprintf(debugTxt,"\nX");
762 while (y)
763 {
764 sprintf(debugTxt,"X");
765 y = y->yNodes;
766 }
767 table = table->xNodes;
768 }
769 }
770public:
771 BearHunterGameControl()
772 {
773 builtNetwork = false;
774 NodeCount = 0;
775 BearHunterBearPositionNodeList = NULL;
776 BearHunterBearPositionNodeGrouping = NULL;
777 }
778 void AddNodeObject(GameObject *obj)
779 {
780 AddListNode(Commands->Get_ID(obj),Commands->Get_Position(obj));
781 NodeCount++;
782 Commands->Destroy_Object(obj);
783 }
784 void Load(const char *fileName)
785 {
786 int File = Commands->Text_File_Open(fileName);
787 if (!File)
788 {
789 char errorMsg[220];
790 sprintf(errorMsg,"msg BearHunterGameControl ERROR: File %s not found!",fileName);
791 Console_Input(errorMsg);
792 return;
793 }
794 char TextString[1024];
795 while (Commands->Text_File_Get_String(File,TextString,1024))
796 {
797 int id;
798 float x,y,z;
799 sscanf(TextString,"%d %f %f %f",&id,&x,&y,&z);
800 AddListNode(id,Vector3(x,y,z));
801 NodeCount++;
802 }
803 BuildLookupTable();
804 Commands->Text_File_Close(File);
805 }
806 Vector3 LookupNearestPosition(Vector2 pos)
807 {
808 if (BearHunterBearPositionNodeGrouping)
809 {
810 BearHunterBearPositionNode *table = BearHunterBearPositionNodeGrouping;
811 while (table)
812 {
813 if (pos.X < table->pos.X || (pos.X >= table->pos.X && (!table->xNodes || pos.X < table->xNodes->pos.X)))
814 {
815 BearHunterBearPositionNode *y = table->yNodes;
816 while (y)
817 {
818 if (pos.Y < y->pos.Y || (pos.Y >= y->pos.Y && (!y->yNodes || pos.Y < y->yNodes->pos.Y)))
819 return y->pos;
820 y = y->yNodes;
821 }
822 }
823 table = table->xNodes;
824 }
825 char debugmsg[220];
826 sprintf(debugmsg,"msg BearHunterGameControl::LookupNearestPosition ERROR: Could not find pos for location <%.2f,%.2f>",pos.X,pos.Y);
827 Console_Input(debugmsg);
828 }
829 Vector3 StarPos = Vector3(pos.X,pos.Y,0.0f);
830 float bestDist = -1;
831 BearHunterBearPositionNode *Current = BearHunterBearPositionNodeList,*BestNode = NULL;
832 while (Current)
833 {
834 float dist = JmgUtility::SimpleFlatDistance(StarPos,Current->pos);
835 if (!BestNode || dist < bestDist)
836 {
837 dist = bestDist;
838 BestNode = Current;
839 }
840 Current = Current->next;
841 }
842 if (BestNode)
843 return BestNode->pos;
844 return Vector3(0.0f,0.0f,0.0f);
845 }
846 bool getRandomPosition(Vector3 *pos,float minRange,float range)
847 {
848 if (BearHunterBearPositionNodeGrouping)
849 {
850 int Random = Commands->Get_Random_Int(0,(NodeCount ? NodeCount : 1)+1);
851 int original = Random;
852 BearHunterBearPositionNode *table = BearHunterBearPositionNodeGrouping;
853 while (table)
854 {
855 BearHunterBearPositionNode *y = table->yNodes;
856 while (y)
857 {
858 float tempDist = JmgUtility::SimpleDistance(y->pos,*pos);
859 if (tempDist <= range && tempDist >= minRange)
860 {
861 Random--;
862 if (!Random)
863 {
864 *pos = y->pos;
865 return true;
866 }
867 }
868 y = y->yNodes;
869 }
870 table = table->xNodes;
871 if (!table && Random != original)
872 {
873 original = Random;
874 table = BearHunterBearPositionNodeGrouping;
875 }
876 }
877 }
878 return false;
879 }
880 void emptyList()
881 {
882 builtNetwork = false;
883 NodeCount = 0;
884 BearHunterBearPositionNodeGrouping = NULL;
885 BearHunterBearPositionNode *temp,*die;
886 temp = BearHunterBearPositionNodeList;
887 while (temp)
888 {
889 die = temp;
890 temp = temp->next;
891 delete die;
892 }
893 BearHunterBearPositionNodeList = NULL;
894 }
895 void TestGrid();
896 BearHunterBearPositionNode *FindNodeByID(int id)
897 {
898 BearHunterBearPositionNode *Current = BearHunterBearPositionNodeList;
899 while (Current)
900 {
901 if (Current->id == id)
902 return Current;
903 Current = Current->next;
904 }
905 return NULL;
906 }
907 void SaveCleanedTestGrid()
908 {
909 BearHunterBearPositionNode *Current = BearHunterBearPositionNodeList;
910 while (Current)
911 {
912 if (Current->badCount)
913 {
914 char badNodes[220];
915 sprintf(badNodes,"msg %d was marked as bad",Current->id);
916 Console_Input(badNodes);
917 }
918 Current = Current->next;
919 }
920 }
921};
922BearHunterGameControl BearHunterGameControlSystem = BearHunterGameControl();
923struct EASTowerNode
924{
925 int id;
926 Vector3 position;
927 int activeTime;
928 EASTowerNode()
929 {
930 this->id = 0;
931 this->position = Vector3();
932 this->activeTime = 0;
933 }
934 EASTowerNode(GameObject *obj)
935 {
936 this->id = Commands->Get_ID(obj);
937 this->position = Commands->Get_Position(obj);
938 this->activeTime = 0;
939 }
940 bool operator == (const int value)
941 {
942 if (id == value)
943 return true;
944 return false;
945 }
946 bool operator != (const int value)
947 {
948 if (id == value)
949 return false;
950 return false;
951 }
952};
953class JMG_Bear_Hunter_Game_Control : public ScriptImpClass {
954 bool smoothFade;
955 bool needsCleanUp;
956 EASTowerNode easTowers[2];
957 bool alarmSwitchActive;
958 bool atCabin;
959 bool starGold;
960 int maxBears;
961 bool musicOn;
962 unsigned long meteoriteTime;
963 int maxPlayerCount;
964 static GameObject *myObject;
965 double bearChance;
966 double deerChance;
967 double gcatChance;
968 double bcatChance;
969 double ccatChance;
970 int blackBearId;
971 bool cleanUpNeeded;
972 bool engineerSpawnedOnce[5];
973 int engineerScanTime;
974 int lastUpdateEngineersDead;
975 int wildMountainLionIds[8];
976 int wildMountainLionRespawn[8];
977 int wildMountainLionsPet;
978 int cowId;
979 int cowWanderId;
980 int playerReturnedTurkeys[128];
981 int playerReturnedTurkeysDelay[128];
982 bool turkeysExist;
983 bool hasReturnedTurkeys;
984 void Created(GameObject *obj);
985 void Timer_Expired(GameObject *obj,int number);
986 void Custom(GameObject *obj,int message,int param,GameObject *sender);
987 void Destroyed(GameObject *obj);
988 bool CheckIfPlayerInRange(Vector3 pos,float distance);
989 void EndGameDataCleanup(GameObject *obj,bool saveData);
990 void CreateMouse();
991 void CreateNormalAnimals(int normalBears);
992 void CreateBears(int normalBears);
993 void SpawnAngryTinyDeer();
994 void CreateCow();
995 void TriggerCowObjective();
996 static GameObject *MutantSpawn();
997public:
998 JMG_Bear_Hunter_Game_Control();
999 static void ObjectiveCompleteReward(float credits);
1000 static enum GameState{LeaveBase = 0,HuntBears = 1,MutationStart = 2,FallBack = 3,DefendPrez = 4,SecureBase = 5,BossArrive = 6} gameState;
1001 static int mutantTargetId;
1002 static bool gameOver;
1003 static int gameTime;
1004 static int spawnGroup;
1005 static char currentSong[256];
1006 static int objective;
1007 static int bearTransition;
1008 static bool hasGotTurrets;
1009 static int aiIgnorePlayers[128];
1010 static int remainingLives[128];
1011 static bool playerAlive[128];
1012 static int bossRabitDead;
1013 static unsigned int earthWarheadId;
1014 static unsigned int deathWarheadId;
1015 static int turretsDestroyed;
1016 static Vector3 engineerSpawnLocations[5];
1017 static int entineersReturned;
1018 static bool weaponsFound[6];
1019 static bool weaponsReturned[6];
1020 static bool weaponsUnlocked[7];
1021 static float soundAttentionWhoreNotify;
1022 static bool diedInWater[128];
1023 static bool hasActivatedTower;
1024 static int winWait;
1025 static bool playersDead;
1026 static int medicineDropInTime;
1027 static float attackSubstationChance;
1028 static int mutantBears;
1029 static float mutantRespawnTime;
1030 static float CreatePositionZ;
1031 static float GamePercent;
1032 static Vector3 centerOfBase;
1033 static bool truckTimeExtended;
1034 static int spawnKarma;
1035 static bool hasBeenInjured;
1036 static int karmaDeerIds[6];
1037 static int friendlyTinyDeerIds[5];
1038 static int friendlyTinyDeerRespawnTime[5];
1039 static int wanderingAiIgnorePlayers[128];
1040 static void IncreaseBonusObjectiveCount(int objectiveId);
1041 static int bonusObjectiveCount;
1042 static int pumpJackIds[7];
1043 static int damagedPumpJackIds[3];
1044 static Vector3 pumpJackPos[7];
1045 static Vector3 damagedPumpJackPos[3];
1046};
1047GameObject *JMG_Bear_Hunter_Game_Control::myObject = NULL;
1048int JMG_Bear_Hunter_Game_Control::mutantTargetId = 600172;
1049JMG_Bear_Hunter_Game_Control::GameState JMG_Bear_Hunter_Game_Control::gameState = LeaveBase;
1050bool JMG_Bear_Hunter_Game_Control::gameOver = false;
1051int JMG_Bear_Hunter_Game_Control::gameTime = 0;
1052int JMG_Bear_Hunter_Game_Control::spawnGroup = 0;
1053char JMG_Bear_Hunter_Game_Control::currentSong[256] = {"SpecForce_Sneak_01.mp3"};
1054int JMG_Bear_Hunter_Game_Control::objective = 0;
1055int JMG_Bear_Hunter_Game_Control::bearTransition = 0;
1056bool JMG_Bear_Hunter_Game_Control::hasGotTurrets = false;
1057int JMG_Bear_Hunter_Game_Control::aiIgnorePlayers[128] = {0};
1058int JMG_Bear_Hunter_Game_Control::remainingLives[128] = {0};
1059bool JMG_Bear_Hunter_Game_Control::playerAlive[128] = {true};
1060int JMG_Bear_Hunter_Game_Control::bossRabitDead = 0;
1061unsigned int JMG_Bear_Hunter_Game_Control::earthWarheadId = 22;
1062unsigned int JMG_Bear_Hunter_Game_Control::deathWarheadId = 22;
1063int JMG_Bear_Hunter_Game_Control::turretsDestroyed = 0;
1064Vector3 JMG_Bear_Hunter_Game_Control::engineerSpawnLocations[5] = {Vector3(-263.045f,150.827f,0.839f),Vector3(-266.169f,150.874f,0.839f),Vector3(-198.472f,-262.617f,0.251f),Vector3(-198.408f,-259.017f,0.259f),Vector3(-203.714f,-260.658f,0.216f)};
1065int JMG_Bear_Hunter_Game_Control::entineersReturned = 0;
1066bool JMG_Bear_Hunter_Game_Control::weaponsFound[6] = {false};
1067bool JMG_Bear_Hunter_Game_Control::weaponsReturned[6] = {false};
1068bool JMG_Bear_Hunter_Game_Control::weaponsUnlocked[7] = {false};
1069float JMG_Bear_Hunter_Game_Control::soundAttentionWhoreNotify = 0.0025f;
1070bool JMG_Bear_Hunter_Game_Control::diedInWater[128] = {false};
1071bool JMG_Bear_Hunter_Game_Control::hasActivatedTower = false;
1072int JMG_Bear_Hunter_Game_Control::winWait = 0;
1073bool JMG_Bear_Hunter_Game_Control::playersDead = false;
1074int JMG_Bear_Hunter_Game_Control::medicineDropInTime = 0;
1075float JMG_Bear_Hunter_Game_Control::attackSubstationChance = 1.0f;
1076int JMG_Bear_Hunter_Game_Control::mutantBears = 0;
1077float JMG_Bear_Hunter_Game_Control::mutantRespawnTime = 0.0f;
1078float JMG_Bear_Hunter_Game_Control::CreatePositionZ = 0.0f;
1079float JMG_Bear_Hunter_Game_Control::GamePercent = 0.0f;
1080Vector3 JMG_Bear_Hunter_Game_Control::centerOfBase = Vector3(45.146f,-689.362f,-0.166f);
1081bool JMG_Bear_Hunter_Game_Control::truckTimeExtended = false;
1082int JMG_Bear_Hunter_Game_Control::spawnKarma = 0;
1083bool JMG_Bear_Hunter_Game_Control::hasBeenInjured = false;
1084int JMG_Bear_Hunter_Game_Control::karmaDeerIds[6] = {0};
1085int JMG_Bear_Hunter_Game_Control::friendlyTinyDeerIds[5] = {0};
1086int JMG_Bear_Hunter_Game_Control::friendlyTinyDeerRespawnTime[5] = {0};
1087int JMG_Bear_Hunter_Game_Control::wanderingAiIgnorePlayers[128] = {0};
1088int JMG_Bear_Hunter_Game_Control::bonusObjectiveCount = 0;
1089int JMG_Bear_Hunter_Game_Control::pumpJackIds[7] = {601041,601038,601044,601040,601045,601039,601043};
1090int JMG_Bear_Hunter_Game_Control::damagedPumpJackIds[3] = {601061,601062,601063};
1091Vector3 JMG_Bear_Hunter_Game_Control::pumpJackPos[7];
1092Vector3 JMG_Bear_Hunter_Game_Control::damagedPumpJackPos[3];
1093
1094struct BearHunterScoreSystem
1095{
1096public:
1097 #define BHHighScoreListCount 124
1098 struct BHScoreNode
1099 {
1100 char PlayerName[256];
1101 unsigned long PlayTime;
1102 unsigned long PreGameTime;
1103 unsigned long IdleTime;
1104 unsigned long RoundsPlayed;
1105 unsigned long RoundsCompleted;
1106 unsigned long RoundsQuit;
1107 unsigned long RoundsWon;
1108 unsigned long RoundsLost;
1109 unsigned long MostKillsInARound;
1110 unsigned long MostDeathsInARound;
1111 unsigned long MostBonusObjectivesCompletedInARound;
1112 unsigned long Deaths;
1113 unsigned long Kills;
1114 unsigned long VehicleKills;
1115 unsigned long KilledSelf;
1116 unsigned long KilledPlayers;
1117 unsigned long KilledPresident;
1118 unsigned long KilledTurrets;
1119 unsigned long KilledBears;
1120 unsigned long KilledBlackBears;
1121 unsigned long KilledMutantBears;
1122 unsigned long KilledMutantDeer;
1123 unsigned long KilledMutantCats;
1124 unsigned long KilledMutantCatsB;
1125 unsigned long KilledMutantCatsR;
1126 unsigned long KilledMutantRabbits;
1127 unsigned long ObjectiveActivatedAlarm;
1128 unsigned long ObjectiveTurretTruck;
1129 unsigned long ObjectiveTurretTruckAlarm;
1130 unsigned long ObjectiveOilRigsActivated;
1131 unsigned long ObjectiveOilRigsRepaired;
1132 unsigned long ObjectiveEngineersSaved;
1133 unsigned long ObjectiveWeaponsFound;
1134 unsigned long ObjectiveWeaponsReturned;
1135 unsigned long ObjectivePlasmaRifleReturned;
1136 unsigned long BonusObjectivesCompleted;
1137 unsigned long PickedupHealthPowerups;
1138 unsigned long PickedupArmorPowerups;
1139 unsigned long PickedupCashPowerups;
1140 unsigned long PickedupAmmoPowerups;
1141 unsigned long PickedupHealthTotal;
1142 unsigned long PickedupArmorTotal;
1143 unsigned long PickedupCashTotal;
1144 unsigned long PickedupAmmoTotal;
1145 unsigned long PickedupTotalPowerups;
1146 unsigned long PickedupTotalPowerupsInARound;
1147 unsigned long KilledHumanAi;
1148 unsigned long VehiclesDestroyed;
1149 unsigned long VehiclesLost;
1150 unsigned long JazzsLost;
1151 unsigned long CleasansLost;
1152 unsigned long TrucksLost;
1153 unsigned long TanksLost;
1154 unsigned long TurretTruckLost;
1155 unsigned long C4VestPowerups;
1156 unsigned long ActivatedCommTower;
1157 unsigned long PlayedGamesWithDefenseTurrets;
1158 unsigned long PlayedGamesWithGuardianHelicopter;
1159 unsigned long TimesDrown;
1160 unsigned long TimesFallen;
1161 unsigned long KillsWithSentryTurret;
1162 unsigned long KilledSentryTurrets;
1163 unsigned long SentryTurretsPlaced;
1164 unsigned long SentryTurretsLost;
1165 unsigned long PickedUpMedicalNeedle;
1166 unsigned long ReturnedMedicalNeedle;
1167 unsigned long RepairedSubstation;
1168 unsigned long SubstationOnLineAtEnd;
1169 unsigned long SubstationNotDamaged;
1170 unsigned long GiantDeerKilled;
1171 unsigned long WolfKilled;
1172 unsigned long MutantDogKilled;
1173 unsigned long BlueDeerKilled;
1174 unsigned long SurvivedAlarm;
1175 unsigned long CheatedRounds;
1176 unsigned long NeverInjured;
1177 unsigned long MooseKilled;
1178 unsigned long EatenByRabbit;
1179 unsigned long PickedUpDeerStatue;
1180 unsigned long DroppedDeerStatue;
1181 unsigned long ReturnedDeerStatue;
1182 unsigned long TinyDeerKilled;
1183 unsigned long MutantSquirrelsKilled;
1184 unsigned long WildDeerKilled;
1185 unsigned long WildSquirrelsKilled;
1186 unsigned long ArmoredCarsLost;
1187 unsigned long WarriorsLost;
1188 unsigned long TimeOnFoot;
1189 unsigned long TimeInAJazzs;
1190 unsigned long TimeInACleasans;
1191 unsigned long TimeInASecurityTruck;
1192 unsigned long TimeInArmoredCars;
1193 unsigned long TimeInAUDVs;
1194 unsigned long TimeInGatlingTanks;
1195 unsigned long TimeInIFVs;
1196 unsigned long FriendlyTinyDeerKilled;
1197 unsigned long SupportReceivedInfantryHp;
1198 unsigned long SupportReceivedVehicleHp;
1199 unsigned long SupportReceivedAmmo;
1200 unsigned long SupportGrantedHpInfantry;
1201 unsigned long SupportGrantedHpVehicle;
1202 unsigned long SupportGrantedAmmo;
1203 unsigned long SupportReceivedHpInfantrySelf;
1204 unsigned long SupportReceivedHpVehicleSelf;
1205 unsigned long SupportReceivedAmmoSelf;
1206 unsigned long PettedCougars;
1207 unsigned long KilledCougars;
1208 unsigned long KilledMutantCougars;
1209 unsigned long FailedPettingCougars;
1210 unsigned long KilledFriendlyCougars;
1211 unsigned long DiedTryingToEscapeBase;
1212 JmgUtility::GenericDateTime LastPlayTime;
1213 unsigned long RescuedCows;
1214 unsigned long KilledCows;
1215 unsigned long LostCows;
1216 unsigned long CompletedCowObjective;
1217 unsigned long KilledMice;
1218 unsigned long CompledMiceObjective;
1219 unsigned long KilledPortablePumpJacks;
1220 unsigned long PortablePumpJacksPlaced;
1221 unsigned long PortablePumpJacksLost;
1222 unsigned long PumpJackMoney;
1223 unsigned long MobilePumpJackMoney;
1224 unsigned long Rank;
1225 unsigned long KilledTurkey;
1226 unsigned long ReturnedTurkey;
1227
1228 bool startedRound;
1229 unsigned long totalObjectivesCompleted;
1230 unsigned long totalPowerupsPickedup;
1231 float lastFacing;
1232 Vector3 lastPos;
1233 bool isMoving;
1234 bool isTurning;
1235 unsigned int idleDelay;
1236 unsigned long tmpPlayTime;
1237 float tmpSupportReceivedInfantryHp;
1238 float tmpSupportReceivedVehicleHp;
1239 float tmpSupportGrantedHpInfantry;
1240 float tmpSupportGrantedHpVehicle;
1241 float tmpSupportReceivedHpInfantrySelf;
1242 float tmpSupportReceivedHpVehicleSelf;
1243 int tmpPettedCougars;
1244 double weightedRank;
1245 BHScoreNode *next;
1246 BHScoreNode(const char *PlayerName)
1247 {
1248 sprintf(this->PlayerName,"%s",PlayerName);
1249 PlayTime = 0;
1250 PreGameTime = 0;
1251 IdleTime = 0;
1252 RoundsPlayed = 0;
1253 RoundsCompleted = 0;
1254 RoundsQuit = 0;
1255 RoundsWon = 0;
1256 RoundsLost = 0;
1257 MostKillsInARound = 0;
1258 MostDeathsInARound = 0;
1259 MostBonusObjectivesCompletedInARound = 0;
1260 Deaths = 0;
1261 Kills = 0;
1262 VehicleKills = 0;
1263 KilledSelf = 0;
1264 KilledPlayers = 0;
1265 KilledPresident = 0;
1266 KilledTurrets = 0;
1267 KilledBears = 0;
1268 KilledBlackBears = 0;
1269 KilledMutantBears = 0;
1270 KilledMutantDeer = 0;
1271 KilledMutantCats = 0;
1272 KilledMutantCatsB = 0;
1273 KilledMutantCatsR = 0;
1274 KilledMutantRabbits = 0;
1275 ObjectiveActivatedAlarm = 0;
1276 ObjectiveTurretTruck = 0;
1277 ObjectiveTurretTruckAlarm = 0;
1278 ObjectiveOilRigsActivated = 0;
1279 ObjectiveOilRigsRepaired = 0;
1280 ObjectiveEngineersSaved = 0;
1281 ObjectiveWeaponsFound = 0;
1282 ObjectiveWeaponsReturned = 0;
1283 ObjectivePlasmaRifleReturned = 0;
1284 BonusObjectivesCompleted = 0;
1285 PickedupHealthPowerups = 0;
1286 PickedupArmorPowerups = 0;
1287 PickedupCashPowerups = 0;
1288 PickedupAmmoPowerups = 0;
1289 PickedupHealthTotal = 0;
1290 PickedupArmorTotal = 0;
1291 PickedupCashTotal = 0;
1292 PickedupAmmoTotal = 0;
1293 PickedupTotalPowerups = 0;
1294 PickedupTotalPowerupsInARound = 0;
1295 KilledHumanAi = 0;
1296 VehiclesDestroyed = 0;
1297 VehiclesLost = 0;
1298 JazzsLost = 0;
1299 CleasansLost = 0;
1300 TrucksLost = 0;
1301 TanksLost = 0;
1302 TurretTruckLost = 0;
1303 C4VestPowerups = 0;
1304 ActivatedCommTower = 0;
1305 PlayedGamesWithDefenseTurrets = 0;
1306 PlayedGamesWithGuardianHelicopter = 0;
1307 TimesDrown = 0;
1308 TimesFallen = 0;
1309 KillsWithSentryTurret = 0;
1310 KilledSentryTurrets = 0;
1311 SentryTurretsPlaced = 0;
1312 SentryTurretsLost = 0;
1313 PickedUpMedicalNeedle = 0;
1314 ReturnedMedicalNeedle = 0;
1315 RepairedSubstation = 0;
1316 SubstationOnLineAtEnd = 0;
1317 SubstationNotDamaged = 0;
1318 GiantDeerKilled = 0;
1319 WolfKilled = 0;
1320 MutantDogKilled = 0;
1321 BlueDeerKilled = 0;
1322 SurvivedAlarm = 0;
1323 CheatedRounds = 0;
1324 NeverInjured = 0;
1325 MooseKilled = 0;
1326 EatenByRabbit = 0;
1327 PickedUpDeerStatue = 0;
1328 DroppedDeerStatue = 0;
1329 ReturnedDeerStatue = 0;
1330 TinyDeerKilled = 0;
1331 MutantSquirrelsKilled = 0;
1332 WildDeerKilled = 0;
1333 WildSquirrelsKilled = 0;
1334 ArmoredCarsLost = 0;
1335 WarriorsLost = 0;
1336 TimeOnFoot = 0;
1337 TimeInAJazzs = 0;
1338 TimeInACleasans = 0;
1339 TimeInASecurityTruck = 0;
1340 TimeInArmoredCars = 0;
1341 TimeInAUDVs = 0;
1342 TimeInGatlingTanks = 0;
1343 TimeInIFVs = 0;
1344 FriendlyTinyDeerKilled = 0;
1345 SupportReceivedInfantryHp = 0;
1346 SupportReceivedVehicleHp = 0;
1347 SupportReceivedAmmo = 0;
1348 SupportGrantedHpInfantry = 0;
1349 SupportGrantedHpVehicle = 0;
1350 SupportGrantedAmmo = 0;
1351 SupportReceivedHpInfantrySelf = 0;
1352 SupportReceivedHpVehicleSelf = 0;
1353 SupportReceivedAmmoSelf = 0;
1354 PettedCougars = 0;
1355 KilledCougars = 0;
1356 KilledMutantCougars = 0;
1357 FailedPettingCougars = 0;
1358 KilledFriendlyCougars = 0;
1359 DiedTryingToEscapeBase = 0;
1360 JmgUtility::GenericDateTime LastPlayTime = JmgUtility::GenericDateTime();
1361 RescuedCows = 0;
1362 KilledCows = 0;
1363 LostCows = 0;
1364 CompletedCowObjective = 0;
1365 KilledMice = 0;
1366 CompledMiceObjective = 0;
1367 KilledPortablePumpJacks = 0;
1368 PortablePumpJacksPlaced = 0;
1369 PortablePumpJacksLost = 0;
1370 PumpJackMoney = 0;
1371 MobilePumpJackMoney = 0;
1372 Rank = 0;
1373 KilledTurkey = 0;
1374 ReturnedTurkey = 0;
1375
1376 startedRound = JMG_Bear_Hunter_Game_Control::gameState >= JMG_Bear_Hunter_Game_Control::HuntBears ? true : false;
1377 totalObjectivesCompleted = 0;
1378 totalPowerupsPickedup = 0;
1379 lastFacing = 0;
1380 lastPos = Vector3(0.0f,0.0f,0.0f);
1381 idleDelay = 0;
1382 tmpPlayTime = 0;
1383 isMoving = false;
1384 isTurning = false;
1385 tmpSupportReceivedInfantryHp = 0.0f;
1386 tmpSupportReceivedVehicleHp = 0.0f;
1387 tmpSupportGrantedHpInfantry = 0.0f;
1388 tmpSupportGrantedHpVehicle = 0.0f;
1389 tmpSupportReceivedHpInfantrySelf = 0.0f;
1390 tmpSupportReceivedHpVehicleSelf = 0.0f;
1391 tmpPettedCougars = 0;
1392 next = NULL;
1393 }
1394 };
1395private:
1396 char savePath[256];
1397 bool hasLoaded;
1398 int selectRandomMatchingScore;
1399 BHScoreNode *BHScoreNodeList;
1400 BHScoreNode *BHScoreNodeEmptyNode;
1401 BHScoreNode *BHPlayerHighScoreNodes[128];
1402 BHScoreNode *FindOrAddPlayerBHHighScoreNode(const char *PlayerName)
1403 {
1404 if (!BHScoreNodeList)
1405 {
1406 BHScoreNodeList = new BHScoreNode(PlayerName);
1407 return BHScoreNodeList;
1408 }
1409 BHScoreNode *Current = BHScoreNodeList;
1410 while (Current)
1411 {
1412 if (!_stricmp(Current->PlayerName,PlayerName))
1413 return Current;
1414 if (!Current->next)
1415 {
1416 Current->next = new BHScoreNode(PlayerName);
1417 return Current->next;
1418 }
1419 Current = Current->next;
1420 }
1421 return NULL;
1422 }
1423 int lastDispalyedHighScore;
1424 BHScoreNode *mergeList(BHScoreNode *split1,BHScoreNode *split2)
1425 {
1426 if(split1 == NULL)
1427 return split2;
1428 if(split2 == NULL)
1429 return split1;
1430 BHScoreNode *newhead = NULL;
1431 if(split1->weightedRank >= split2->weightedRank)
1432 {
1433 newhead = split1;
1434 newhead->next = mergeList(split1->next,split2);
1435 }
1436 else
1437 {
1438 newhead = split2;
1439 newhead->next = mergeList(split1,split2->next);
1440 }
1441 return newhead;
1442 }
1443 void splitList(BHScoreNode *head,BHScoreNode **split1,BHScoreNode **split2)
1444 {
1445 BHScoreNode *slow = head;
1446 BHScoreNode *fast = head->next;
1447 while(fast != NULL)
1448 {
1449 fast = fast->next;
1450 if(fast != NULL)
1451 {
1452 slow = slow->next;
1453 fast = fast->next;
1454 }
1455 }
1456 *split1 = head;
1457 *split2 = slow->next;
1458 slow->next = NULL;
1459 }
1460 void mergeSort(BHScoreNode **refToHead)
1461 {
1462 BHScoreNode *head = *refToHead;
1463 BHScoreNode *split1,*split2;
1464 if(head == NULL || head->next == NULL)
1465 return;
1466 splitList(head,&split1,&split2);
1467 mergeSort(&split1);
1468 mergeSort(&split2);
1469 *refToHead = mergeList(split1,split2);
1470 return;
1471 }
1472 void CalculateRank()
1473 {
1474 BHScoreNode *current = BHScoreNodeList;
1475 unsigned long maxRoundsWon = 0,maxKills = 0,maxBonusObjectivesCompleted = 0,maxPlayTime = 0;
1476 while (current)
1477 {
1478 if (current->RoundsWon > maxRoundsWon)
1479 maxRoundsWon = current->RoundsWon;
1480 if (current->Kills > maxKills)
1481 maxKills = current->Kills;
1482 if (current->BonusObjectivesCompleted > maxBonusObjectivesCompleted)
1483 maxBonusObjectivesCompleted = current->BonusObjectivesCompleted;
1484 if (current->PlayTime > maxPlayTime)
1485 maxPlayTime = current->PlayTime;
1486 current = current->next;
1487 }
1488 current = BHScoreNodeList;
1489 while (current)
1490 {
1491 current->weightedRank = current->RoundsWon/(double)maxRoundsWon*1.0+
1492 current->Kills/(double)maxKills*0.5+
1493 current->BonusObjectivesCompleted/(double)maxBonusObjectivesCompleted*0.5+
1494 current->PlayTime/(double)maxPlayTime*0.1;
1495 current = current->next;
1496 }
1497 mergeSort(&BHScoreNodeList);
1498 }
1499public:
1500 BearHunterScoreSystem()
1501 {
1502 hasLoaded = false;
1503 lastDispalyedHighScore = -1;
1504 BHScoreNodeList = NULL;
1505 BHScoreNodeEmptyNode = new BHScoreNode("\0");
1506 if (Exe != EXE_LEVELEDIT)
1507 {
1508 sprintf(savePath, "%s\\Save\\", Get_File_Path());
1509 }
1510 for (int x = 0;x < 128;x++)
1511 BHPlayerHighScoreNodes[x] = BHScoreNodeEmptyNode;
1512 };
1513 BHScoreNode *Get_Current_Player_Score_Node(int PlayerID)
1514 {
1515 if (!PlayerID)
1516 return BHScoreNodeEmptyNode;
1517 const char *PlayerName = Get_Player_Name_By_ID(PlayerID);
1518 if (!PlayerName)
1519 return BHScoreNodeEmptyNode;
1520 if (!BHPlayerHighScoreNodes[PlayerID])
1521 BHPlayerHighScoreNodes[PlayerID] = FindOrAddPlayerBHHighScoreNode(PlayerName);
1522 else if (_stricmp(BHPlayerHighScoreNodes[PlayerID]->PlayerName,PlayerName))
1523 BHPlayerHighScoreNodes[PlayerID] = FindOrAddPlayerBHHighScoreNode(PlayerName);
1524 return BHPlayerHighScoreNodes[PlayerID];
1525 }
1526 void Cleanup()
1527 {
1528 hasLoaded = false;
1529 lastDispalyedHighScore = -1;
1530 for (int x = 0;x < 128;x++)
1531 {
1532 if (BHPlayerHighScoreNodes[x])
1533 BHPlayerHighScoreNodes[x] = BHScoreNodeEmptyNode;
1534 }
1535 if (BHScoreNodeList)
1536 {
1537 BHScoreNode *temp,*die;
1538 temp = BHScoreNodeList;
1539 while (temp != NULL)
1540 {
1541 die = temp;
1542 temp = temp->next;
1543 delete die;
1544 }
1545 BHScoreNodeList = NULL;
1546 }
1547 }
1548 void SaveData()
1549 {
1550 if (!hasLoaded)
1551 {
1552 Console_Input("msg ERROR: Could not save high scores, no successful load detected!");
1553 return;
1554 }
1555 FILE *SaveScores;
1556 FILE *SaveScores2;
1557 char tempPath[512],textTmpPath[512],realPath[512],textPath[512];
1558 _mkdir(savePath);
1559 sprintf(tempPath,"%sBearHunterPlayerRecords.tmp",savePath);
1560 sprintf(realPath,"%sBearHunterPlayerRecords.dat",savePath);
1561 sprintf(textTmpPath,"%sBearHunterPlayerRecordsTmp.txt",savePath);
1562 sprintf(textPath,"%sBearHunterPlayerRecords.txt",savePath);
1563 SaveScores = fopen(tempPath,"w");
1564 SaveScores2 = fopen(textTmpPath,"w");
1565 CalculateRank();
1566 int currentRank = 0;
1567 BHScoreNode *Current = BHScoreNodeList;
1568 while (Current)
1569 {
1570 if (Current->tmpPlayTime >= 60)
1571 {
1572 if (JMG_Bear_Hunter_Game_Control::spawnKarma > 3)
1573 Current->CheatedRounds++;
1574 if (!JMG_Bear_Hunter_Game_Control::hasBeenInjured)
1575 Current->NeverInjured++;
1576 }
1577 Current->SupportReceivedInfantryHp += (unsigned long)Current->tmpSupportReceivedInfantryHp;
1578 Current->SupportReceivedVehicleHp += (unsigned long)Current->tmpSupportReceivedVehicleHp;
1579 Current->SupportGrantedHpInfantry += (unsigned long)Current->tmpSupportGrantedHpInfantry;
1580 Current->SupportGrantedHpVehicle += (unsigned long)Current->tmpSupportGrantedHpVehicle;
1581 Current->SupportReceivedHpInfantrySelf += (unsigned long)Current->tmpSupportReceivedHpInfantrySelf;
1582 Current->SupportReceivedHpVehicleSelf += (unsigned long)Current->tmpSupportReceivedHpVehicleSelf;
1583 Current->Rank = ++currentRank;
1584 char EncryptString[2048];
1585 sprintf(EncryptString,"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu 0",
1586 Current->PlayTime,Current->PreGameTime,Current->IdleTime,Current->RoundsPlayed,Current->RoundsCompleted,Current->RoundsQuit,Current->RoundsWon,Current->RoundsLost,Current->MostKillsInARound,Current->MostDeathsInARound,Current->MostBonusObjectivesCompletedInARound,Current->Deaths,Current->Kills,Current->VehicleKills,Current->KilledSelf,Current->KilledPlayers,Current->KilledPresident,Current->KilledTurrets,Current->KilledBears,Current->KilledBlackBears,Current->KilledMutantBears,Current->KilledMutantDeer,Current->KilledMutantCats,Current->KilledMutantCatsB,
1587 Current->KilledMutantCatsR,Current->KilledMutantRabbits,Current->ObjectiveActivatedAlarm,Current->ObjectiveTurretTruck,Current->ObjectiveTurretTruckAlarm,Current->ObjectiveOilRigsActivated,Current->ObjectiveOilRigsRepaired,Current->ObjectiveEngineersSaved,Current->ObjectiveWeaponsFound,Current->ObjectiveWeaponsReturned,Current->ObjectivePlasmaRifleReturned,Current->BonusObjectivesCompleted,Current->PickedupHealthPowerups,Current->PickedupArmorPowerups,Current->PickedupCashPowerups,Current->PickedupAmmoPowerups,Current->PickedupHealthTotal,Current->PickedupArmorTotal,
1588 Current->PickedupCashTotal,Current->PickedupAmmoTotal,Current->PickedupTotalPowerups,Current->PickedupTotalPowerupsInARound,Current->KilledHumanAi,Current->VehiclesDestroyed,Current->VehiclesLost,Current->JazzsLost,Current->CleasansLost,Current->TrucksLost,Current->TanksLost,Current->TurretTruckLost,Current->C4VestPowerups,Current->ActivatedCommTower,Current->PlayedGamesWithDefenseTurrets,Current->PlayedGamesWithGuardianHelicopter,Current->TimesDrown,Current->TimesFallen,Current->KillsWithSentryTurret,Current->KilledSentryTurrets,Current->SentryTurretsPlaced,
1589 Current->SentryTurretsLost,Current->PickedUpMedicalNeedle,Current->ReturnedMedicalNeedle,Current->RepairedSubstation,Current->SubstationOnLineAtEnd,Current->SubstationNotDamaged,Current->GiantDeerKilled,Current->SurvivedAlarm,Current->WolfKilled,Current->MutantDogKilled,Current->BlueDeerKilled,Current->CheatedRounds,Current->NeverInjured,Current->MooseKilled,Current->MooseKilled,Current->EatenByRabbit,Current->EatenByRabbit,Current->PickedUpDeerStatue,Current->DroppedDeerStatue,Current->ReturnedDeerStatue,Current->TinyDeerKilled,Current->MutantSquirrelsKilled,
1590 Current->WildDeerKilled,Current->WildSquirrelsKilled,Current->ArmoredCarsLost,Current->WarriorsLost,Current->TimeOnFoot,Current->TimeInAJazzs,Current->TimeInACleasans,Current->TimeInASecurityTruck,Current->TimeInArmoredCars,Current->TimeInAUDVs,Current->TimeInGatlingTanks,Current->TimeInIFVs,Current->FriendlyTinyDeerKilled,Current->LastPlayTime.day,Current->LastPlayTime.month,Current->LastPlayTime.year,Current->LastPlayTime.second,Current->LastPlayTime.minute,Current->LastPlayTime.hour,Current->LastPlayTime.lTime,Current->SupportReceivedInfantryHp,
1591 Current->SupportReceivedVehicleHp,Current->SupportReceivedAmmo,Current->SupportGrantedHpInfantry,Current->SupportGrantedHpVehicle,Current->SupportGrantedAmmo,Current->SupportReceivedHpInfantrySelf,Current->SupportReceivedHpVehicleSelf,Current->SupportReceivedAmmoSelf,Current->PettedCougars,Current->KilledCougars,Current->KilledMutantCougars,Current->FailedPettingCougars,Current->KilledFriendlyCougars,Current->DiedTryingToEscapeBase,Current->RescuedCows,Current->KilledCows,Current->LostCows,Current->CompletedCowObjective,Current->KilledMice,
1592 Current->CompledMiceObjective,Current->KilledPortablePumpJacks,Current->PortablePumpJacksPlaced,Current->PortablePumpJacksLost,Current->PumpJackMoney,Current->MobilePumpJackMoney,Current->Rank,Current->KilledTurkey,Current->ReturnedTurkey);
1593 fprintf(SaveScores2,"%s\n%s\n",Current->PlayerName,EncryptString);
1594 fprintf(SaveScores,"%s\n%s",JmgUtility::Rp2Encrypt(Current->PlayerName,25,5),JmgUtility::Rp2Encrypt2(EncryptString,Current->PlayerName[0],Current->PlayerName[1]));
1595 fprintf(SaveScores,"\n%s",JmgUtility::Rp2Encrypt(EncryptString,Current->PlayerName[1],Current->PlayerName[0]));
1596 if (Current->next)
1597 fprintf(SaveScores,"\n");
1598 Current = Current->next;
1599 }
1600 fclose(SaveScores);
1601 fclose(SaveScores2);
1602 remove(realPath);
1603 rename(tempPath,realPath);
1604 remove(textPath);
1605 rename(textTmpPath,textPath);
1606 }
1607 void LoadData()
1608 {
1609 hasLoaded = true;
1610 char PlayerName[256];
1611 FILE *LoadScores;
1612 char realPath[512];
1613 sprintf(realPath,"%sBearHunterPlayerRecords.dat",savePath);
1614 LoadScores = fopen(realPath,"r");
1615 if (LoadScores)
1616 {
1617 while (!feof(LoadScores))
1618 {
1619 fgets(PlayerName,256,LoadScores);
1620 int Length = strlen(PlayerName);
1621 if (Length <= 0)
1622 {
1623 Console_Input("msg MutantAssaultHighScoreSystem::LoadData ERROR: Length is less than 1");
1624 continue;
1625 }
1626 PlayerName[Length-1] = '\0';
1627 BHScoreNode *Current = FindOrAddPlayerBHHighScoreNode(JmgUtility::Rp2Decrypt(PlayerName,25,5));
1628 char DecryptString[2048],DecryptString2[2048],decryptedString[2048],decryptedString2[2048];
1629 fgets(DecryptString,2048,LoadScores);
1630 fgets(DecryptString2,2048,LoadScores);
1631 sprintf(decryptedString,"%s",JmgUtility::Rp2Decrypt(DecryptString,Current->PlayerName[0],Current->PlayerName[1]));
1632 sprintf(decryptedString2,"%s",JmgUtility::Rp2Decrypt(DecryptString2,Current->PlayerName[1],Current->PlayerName[0]));
1633 bool match = true;
1634 unsigned int stringLength = strlen(decryptedString);
1635 if (stringLength == strlen(decryptedString2))
1636 for (unsigned int x = 0;x < stringLength;x++)
1637 if (decryptedString[x] != decryptedString2[x])
1638 {
1639 match = false;
1640 char noMatchMsg[220];
1641 sprintf(noMatchMsg,"msg Error: Cou%s%syp%say%st%sr %s","ld ","Not Decr","t Pl","er Da","a Fo",Current->PlayerName);
1642 Console_Input(noMatchMsg);
1643 break;
1644 }
1645 if (match)
1646 sscanf(decryptedString,"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
1647 &Current->PlayTime,&Current->PreGameTime,&Current->IdleTime,&Current->RoundsPlayed,&Current->RoundsCompleted,&Current->RoundsQuit,&Current->RoundsWon,&Current->RoundsLost,&Current->MostKillsInARound,&Current->MostDeathsInARound,&Current->MostBonusObjectivesCompletedInARound,&Current->Deaths,&Current->Kills,&Current->VehicleKills,&Current->KilledSelf,&Current->KilledPlayers,&Current->KilledPresident,&Current->KilledTurrets,&Current->KilledBears,&Current->KilledBlackBears,&Current->KilledMutantBears,&Current->KilledMutantDeer,&Current->KilledMutantCats,&Current->KilledMutantCatsB,
1648 &Current->KilledMutantCatsR,&Current->KilledMutantRabbits,&Current->ObjectiveActivatedAlarm,&Current->ObjectiveTurretTruck,&Current->ObjectiveTurretTruckAlarm,&Current->ObjectiveOilRigsActivated,&Current->ObjectiveOilRigsRepaired,&Current->ObjectiveEngineersSaved,&Current->ObjectiveWeaponsFound,&Current->ObjectiveWeaponsReturned,&Current->ObjectivePlasmaRifleReturned,&Current->BonusObjectivesCompleted,&Current->PickedupHealthPowerups,&Current->PickedupArmorPowerups,&Current->PickedupCashPowerups,&Current->PickedupAmmoPowerups,&Current->PickedupHealthTotal,&Current->PickedupArmorTotal,
1649 &Current->PickedupCashTotal,&Current->PickedupAmmoTotal,&Current->PickedupTotalPowerups,&Current->PickedupTotalPowerupsInARound,&Current->KilledHumanAi,&Current->VehiclesDestroyed,&Current->VehiclesLost,&Current->JazzsLost,&Current->CleasansLost,&Current->TrucksLost,&Current->TanksLost,&Current->TurretTruckLost,&Current->C4VestPowerups,&Current->ActivatedCommTower,&Current->PlayedGamesWithDefenseTurrets,&Current->PlayedGamesWithGuardianHelicopter,&Current->TimesDrown,&Current->TimesFallen,&Current->KillsWithSentryTurret,&Current->KilledSentryTurrets,&Current->SentryTurretsPlaced,
1650 &Current->SentryTurretsLost,&Current->PickedUpMedicalNeedle,&Current->ReturnedMedicalNeedle,&Current->RepairedSubstation,&Current->SubstationOnLineAtEnd,&Current->SubstationNotDamaged,&Current->GiantDeerKilled,&Current->SurvivedAlarm,&Current->WolfKilled,&Current->MutantDogKilled,&Current->BlueDeerKilled,&Current->CheatedRounds,&Current->NeverInjured,&Current->MooseKilled,&Current->MooseKilled,&Current->EatenByRabbit,&Current->EatenByRabbit,&Current->PickedUpDeerStatue,&Current->DroppedDeerStatue,&Current->ReturnedDeerStatue,&Current->TinyDeerKilled,&Current->MutantSquirrelsKilled,
1651 &Current->WildDeerKilled,&Current->WildSquirrelsKilled,&Current->ArmoredCarsLost,&Current->WarriorsLost,&Current->TimeOnFoot,&Current->TimeInAJazzs,&Current->TimeInACleasans,&Current->TimeInASecurityTruck,&Current->TimeInArmoredCars,&Current->TimeInAUDVs,&Current->TimeInGatlingTanks,&Current->TimeInIFVs,&Current->FriendlyTinyDeerKilled,&Current->LastPlayTime.day,&Current->LastPlayTime.month,&Current->LastPlayTime.year,&Current->LastPlayTime.second,&Current->LastPlayTime.minute,&Current->LastPlayTime.hour,&Current->LastPlayTime.lTime,&Current->SupportReceivedInfantryHp,
1652 &Current->SupportReceivedVehicleHp,&Current->SupportReceivedAmmo,&Current->SupportGrantedHpInfantry,&Current->SupportGrantedHpVehicle,&Current->SupportGrantedAmmo,&Current->SupportReceivedHpInfantrySelf,&Current->SupportReceivedHpVehicleSelf,&Current->SupportReceivedAmmoSelf,&Current->PettedCougars,&Current->KilledCougars,&Current->KilledMutantCougars,&Current->FailedPettingCougars,&Current->KilledFriendlyCougars,&Current->DiedTryingToEscapeBase,&Current->RescuedCows,&Current->KilledCows,&Current->LostCows,&Current->CompletedCowObjective,&Current->KilledMice,&Current->CompledMiceObjective,
1653 &Current->KilledPortablePumpJacks,&Current->PortablePumpJacksPlaced,&Current->PortablePumpJacksLost,&Current->PumpJackMoney,&Current->MobilePumpJackMoney,&Current->Rank,&Current->KilledTurkey,&Current->ReturnedTurkey);
1654 }
1655 fclose(LoadScores);
1656 }
1657 }
1658 inline BHScoreNode *EveluateHighestScore(unsigned long highValue,unsigned long currentValue,BHScoreNode *High,BHScoreNode *Current)
1659 {
1660 if (highValue == currentValue)
1661 {
1662 selectRandomMatchingScore++;
1663 if (Commands->Get_Random(0.0f,(float)selectRandomMatchingScore) < 0.5)
1664 return Current;
1665 }
1666 else if (highValue < currentValue)
1667 selectRandomMatchingScore = 0;
1668 return (highValue >= currentValue ? High : Current);
1669 }
1670 BHScoreNode *CompareHighScoreNodes(BHScoreNode *High,BHScoreNode *Current,int CompVal)
1671 {
1672 if (!High)
1673 return Current;
1674 switch (CompVal)
1675 {
1676 case 0: return EveluateHighestScore(High->PlayTime,Current->PlayTime,High,Current);
1677 case 1: return EveluateHighestScore(High->PreGameTime,Current->PreGameTime,High,Current);
1678 case 2: return EveluateHighestScore(High->IdleTime,Current->IdleTime,High,Current);
1679 case 3: return EveluateHighestScore(High->RoundsPlayed,Current->RoundsPlayed,High,Current);
1680 case 4: return EveluateHighestScore(High->RoundsCompleted,Current->RoundsCompleted,High,Current);
1681 case 5: return EveluateHighestScore(High->RoundsQuit,Current->RoundsQuit,High,Current);
1682 case 6: return EveluateHighestScore(High->RoundsWon,Current->RoundsWon,High,Current);
1683 case 7: return EveluateHighestScore(High->RoundsLost,Current->RoundsLost,High,Current);
1684 case 8: return EveluateHighestScore(High->MostKillsInARound,Current->MostKillsInARound,High,Current);
1685 case 9: return EveluateHighestScore(High->MostDeathsInARound,Current->MostDeathsInARound,High,Current);
1686 case 10: return EveluateHighestScore(High->MostBonusObjectivesCompletedInARound,Current->MostBonusObjectivesCompletedInARound,High,Current);
1687 case 11: return EveluateHighestScore(High->Deaths,Current->Deaths,High,Current);
1688 case 12: return EveluateHighestScore(High->Kills,Current->Kills,High,Current);
1689 case 13: return EveluateHighestScore(High->VehicleKills,Current->VehicleKills,High,Current);
1690 case 14: return EveluateHighestScore(High->KilledSelf,Current->KilledSelf,High,Current);
1691 case 15: return EveluateHighestScore(High->KilledPlayers,Current->KilledPlayers,High,Current);
1692 case 16: return EveluateHighestScore(High->KilledPresident,Current->KilledPresident,High,Current);
1693 case 17: return EveluateHighestScore(High->KilledTurrets,Current->KilledTurrets,High,Current);
1694 case 18: return EveluateHighestScore(High->KilledBears,Current->KilledBears,High,Current);
1695 case 19: return EveluateHighestScore(High->KilledBlackBears,Current->KilledBlackBears,High,Current);
1696 case 20: return EveluateHighestScore(High->KilledMutantBears,Current->KilledMutantBears,High,Current);
1697 case 21: return EveluateHighestScore(High->KilledMutantDeer,Current->KilledMutantDeer,High,Current);
1698 case 22: return EveluateHighestScore(High->KilledMutantCats,Current->KilledMutantCats,High,Current);
1699 case 23: return EveluateHighestScore(High->KilledMutantCatsB,Current->KilledMutantCatsB,High,Current);
1700 case 24: return EveluateHighestScore(High->KilledMutantCatsR,Current->KilledMutantCatsR,High,Current);
1701 case 25: return EveluateHighestScore(High->KilledMutantRabbits,Current->KilledMutantRabbits,High,Current);
1702 case 26: return EveluateHighestScore(High->ObjectiveActivatedAlarm,Current->ObjectiveActivatedAlarm,High,Current);
1703 case 27: return EveluateHighestScore(High->ObjectiveTurretTruck,Current->ObjectiveTurretTruck,High,Current);
1704 case 28: return EveluateHighestScore(High->ObjectiveTurretTruckAlarm,Current->ObjectiveTurretTruckAlarm,High,Current);
1705 case 29: return EveluateHighestScore(High->ObjectiveOilRigsActivated,Current->ObjectiveOilRigsActivated,High,Current);
1706 case 30: return EveluateHighestScore(High->ObjectiveOilRigsRepaired,Current->ObjectiveOilRigsRepaired,High,Current);
1707 case 31: return EveluateHighestScore(High->ObjectiveEngineersSaved,Current->ObjectiveEngineersSaved,High,Current);
1708 case 32: return EveluateHighestScore(High->ObjectiveWeaponsFound,Current->ObjectiveWeaponsFound,High,Current);
1709 case 33: return EveluateHighestScore(High->ObjectiveWeaponsReturned,Current->ObjectiveWeaponsReturned,High,Current);
1710 case 34: return EveluateHighestScore(High->ObjectivePlasmaRifleReturned,Current->ObjectivePlasmaRifleReturned,High,Current);
1711 case 35: return EveluateHighestScore(High->BonusObjectivesCompleted,Current->BonusObjectivesCompleted,High,Current);
1712 case 36: return EveluateHighestScore(High->PickedupHealthPowerups,Current->PickedupHealthPowerups,High,Current);
1713 case 37: return EveluateHighestScore(High->PickedupArmorPowerups,Current->PickedupArmorPowerups,High,Current);
1714 case 38: return EveluateHighestScore(High->PickedupCashPowerups,Current->PickedupCashPowerups,High,Current);
1715 case 39: return EveluateHighestScore(High->PickedupAmmoPowerups,Current->PickedupAmmoPowerups,High,Current);
1716 case 40: return EveluateHighestScore(High->PickedupHealthTotal,Current->PickedupHealthTotal,High,Current);
1717 case 41: return EveluateHighestScore(High->PickedupArmorTotal,Current->PickedupArmorTotal,High,Current);
1718 case 42: return EveluateHighestScore(High->PickedupCashTotal,Current->PickedupCashTotal,High,Current);
1719 case 43: return EveluateHighestScore(High->PickedupAmmoTotal,Current->PickedupAmmoTotal,High,Current);
1720 case 44: return EveluateHighestScore(High->PickedupTotalPowerups,Current->PickedupTotalPowerups,High,Current);
1721 case 45: return EveluateHighestScore(High->PickedupTotalPowerupsInARound,Current->PickedupTotalPowerupsInARound,High,Current);
1722 case 46: return EveluateHighestScore(High->KilledHumanAi,Current->KilledHumanAi,High,Current);
1723 case 47: return EveluateHighestScore(High->VehiclesDestroyed,Current->VehiclesDestroyed,High,Current);
1724 case 48: return EveluateHighestScore(High->VehiclesLost,Current->VehiclesLost,High,Current);
1725 case 49: return EveluateHighestScore(High->JazzsLost,Current->JazzsLost,High,Current);
1726 case 50: return EveluateHighestScore(High->CleasansLost,Current->CleasansLost,High,Current);
1727 case 51: return EveluateHighestScore(High->TrucksLost,Current->TrucksLost,High,Current);
1728 case 52: return EveluateHighestScore(High->TanksLost,Current->TanksLost,High,Current);
1729 case 53: return EveluateHighestScore(High->TurretTruckLost,Current->TurretTruckLost,High,Current);
1730 case 54: return EveluateHighestScore(High->C4VestPowerups,Current->C4VestPowerups,High,Current);
1731 case 55: return EveluateHighestScore(High->ActivatedCommTower,Current->ActivatedCommTower,High,Current);
1732 case 56: return EveluateHighestScore(High->PlayedGamesWithDefenseTurrets,Current->PlayedGamesWithDefenseTurrets,High,Current);
1733 case 57: return EveluateHighestScore(High->PlayedGamesWithGuardianHelicopter,Current->PlayedGamesWithGuardianHelicopter,High,Current);
1734 case 58: return EveluateHighestScore(High->TimesDrown,Current->TimesDrown,High,Current);
1735 case 59: return EveluateHighestScore(High->TimesFallen,Current->TimesFallen,High,Current);
1736 case 60: return EveluateHighestScore(High->KillsWithSentryTurret,Current->KillsWithSentryTurret,High,Current);
1737 case 61: return EveluateHighestScore(High->KilledSentryTurrets,Current->KilledSentryTurrets,High,Current);
1738 case 62: return EveluateHighestScore(High->SentryTurretsPlaced,Current->SentryTurretsPlaced,High,Current);
1739 case 63: return EveluateHighestScore(High->SentryTurretsLost,Current->SentryTurretsLost,High,Current);
1740 case 64: return EveluateHighestScore(High->PickedUpMedicalNeedle,Current->PickedUpMedicalNeedle,High,Current);
1741 case 65: return EveluateHighestScore(High->ReturnedMedicalNeedle,Current->ReturnedMedicalNeedle,High,Current);
1742 case 66: return EveluateHighestScore(High->RepairedSubstation,Current->RepairedSubstation,High,Current);
1743 case 67: return EveluateHighestScore(High->SubstationOnLineAtEnd,Current->SubstationOnLineAtEnd,High,Current);
1744 case 68: return EveluateHighestScore(High->SubstationNotDamaged,Current->SubstationNotDamaged,High,Current);
1745 case 69: return EveluateHighestScore(High->GiantDeerKilled,Current->GiantDeerKilled,High,Current);
1746 case 70: return EveluateHighestScore(High->SurvivedAlarm,Current->SurvivedAlarm,High,Current);
1747 case 71: return EveluateHighestScore(High->WolfKilled,Current->WolfKilled,High,Current);
1748 case 72: return EveluateHighestScore(High->MutantDogKilled,Current->MutantDogKilled,High,Current);
1749 case 73: return EveluateHighestScore(High->BlueDeerKilled,Current->BlueDeerKilled,High,Current);
1750 case 74: return EveluateHighestScore(High->CheatedRounds,Current->CheatedRounds,High,Current);
1751 case 75: return EveluateHighestScore(High->NeverInjured,Current->NeverInjured,High,Current);
1752 case 76: return EveluateHighestScore(High->MooseKilled,Current->MooseKilled,High,Current);
1753 case 77: return EveluateHighestScore(High->EatenByRabbit,Current->EatenByRabbit,High,Current);
1754 case 78: return EveluateHighestScore(High->PickedUpDeerStatue,Current->PickedUpDeerStatue,High,Current);
1755 case 79: return EveluateHighestScore(High->DroppedDeerStatue,Current->DroppedDeerStatue,High,Current);
1756 case 80: return EveluateHighestScore(High->ReturnedDeerStatue,Current->ReturnedDeerStatue,High,Current);
1757 case 81: return EveluateHighestScore(High->TinyDeerKilled,Current->TinyDeerKilled,High,Current);
1758 case 82: return EveluateHighestScore(High->MutantSquirrelsKilled,Current->MutantSquirrelsKilled,High,Current);
1759 case 83: return EveluateHighestScore(High->WildDeerKilled,Current->WildDeerKilled,High,Current);
1760 case 84: return EveluateHighestScore(High->WildSquirrelsKilled,Current->WildSquirrelsKilled,High,Current);
1761 case 85: return EveluateHighestScore(High->ArmoredCarsLost,Current->ArmoredCarsLost,High,Current);
1762 case 86: return EveluateHighestScore(High->WarriorsLost,Current->WarriorsLost,High,Current);
1763 case 87: return EveluateHighestScore(High->TimeOnFoot,Current->TimeOnFoot,High,Current);
1764 case 88: return EveluateHighestScore(High->TimeInAJazzs,Current->TimeInAJazzs,High,Current);
1765 case 89: return EveluateHighestScore(High->TimeInACleasans,Current->TimeInACleasans,High,Current);
1766 case 90: return EveluateHighestScore(High->TimeInASecurityTruck,Current->TimeInASecurityTruck,High,Current);
1767 case 91: return EveluateHighestScore(High->TimeInArmoredCars,Current->TimeInArmoredCars,High,Current);
1768 case 92: return EveluateHighestScore(High->TimeInAUDVs,Current->TimeInAUDVs,High,Current);
1769 case 93: return EveluateHighestScore(High->TimeInGatlingTanks,Current->TimeInGatlingTanks,High,Current);
1770 case 94: return EveluateHighestScore(High->TimeInIFVs,Current->TimeInIFVs,High,Current);
1771 case 95: return EveluateHighestScore(High->FriendlyTinyDeerKilled,Current->FriendlyTinyDeerKilled,High,Current);
1772 case 96: return EveluateHighestScore(High->SupportReceivedInfantryHp,Current->SupportReceivedInfantryHp,High,Current);
1773 case 97: return EveluateHighestScore(High->SupportReceivedVehicleHp,Current->SupportReceivedVehicleHp,High,Current);
1774 case 98: return EveluateHighestScore(High->SupportReceivedAmmo,Current->SupportReceivedAmmo,High,Current);
1775 case 99: return EveluateHighestScore(High->SupportGrantedHpInfantry,Current->SupportGrantedHpInfantry,High,Current);
1776 case 100: return EveluateHighestScore(High->SupportGrantedHpVehicle,Current->SupportGrantedHpVehicle,High,Current);
1777 case 101: return EveluateHighestScore(High->SupportGrantedAmmo,Current->SupportGrantedAmmo,High,Current);
1778 case 102: return EveluateHighestScore(High->SupportReceivedHpInfantrySelf,Current->SupportReceivedHpInfantrySelf,High,Current);
1779 case 103: return EveluateHighestScore(High->SupportReceivedHpVehicleSelf,Current->SupportReceivedHpVehicleSelf,High,Current);
1780 case 104: return EveluateHighestScore(High->SupportReceivedAmmoSelf,Current->SupportReceivedAmmoSelf,High,Current);
1781 case 105: return EveluateHighestScore(High->PettedCougars,Current->PettedCougars,High,Current);
1782 case 106: return EveluateHighestScore(High->KilledCougars,Current->KilledCougars,High,Current);
1783 case 107: return EveluateHighestScore(High->KilledMutantCougars,Current->KilledMutantCougars,High,Current);
1784 case 108: return EveluateHighestScore(High->FailedPettingCougars,Current->FailedPettingCougars,High,Current);
1785 case 109: return EveluateHighestScore(High->KilledFriendlyCougars,Current->KilledFriendlyCougars,High,Current);
1786 case 110: return EveluateHighestScore(High->DiedTryingToEscapeBase,Current->DiedTryingToEscapeBase,High,Current);
1787 case 111: return EveluateHighestScore(High->RescuedCows,Current->RescuedCows,High,Current);
1788 case 112: return EveluateHighestScore(High->KilledCows,Current->KilledCows,High,Current);
1789 case 113: return EveluateHighestScore(High->LostCows,Current->LostCows,High,Current);
1790 case 114: return EveluateHighestScore(High->CompletedCowObjective,Current->CompletedCowObjective,High,Current);
1791 case 115: return EveluateHighestScore(High->KilledMice,Current->KilledMice,High,Current);
1792 case 116: return EveluateHighestScore(High->CompledMiceObjective,Current->CompledMiceObjective,High,Current);
1793 case 117: return EveluateHighestScore(High->KilledPortablePumpJacks,Current->KilledPortablePumpJacks,High,Current);
1794 case 118: return EveluateHighestScore(High->PortablePumpJacksPlaced,Current->PortablePumpJacksPlaced,High,Current);
1795 case 119: return EveluateHighestScore(High->PortablePumpJacksLost,Current->PortablePumpJacksLost,High,Current);
1796 case 120: return EveluateHighestScore(High->PumpJackMoney,Current->PumpJackMoney,High,Current);
1797 case 121: return EveluateHighestScore(High->MobilePumpJackMoney,Current->MobilePumpJackMoney,High,Current);
1798 case 122: return EveluateHighestScore(High->KilledTurkey,Current->KilledTurkey,High,Current);
1799 case 123: return EveluateHighestScore(High->ReturnedTurkey,Current->ReturnedTurkey,High,Current);
1800 default: return High;
1801 }
1802 }
1803 bool ReturnHighScoreNodeValue(BHScoreNode *Node,int CompVal)
1804 {
1805 if (!Node)
1806 return false;
1807 switch (CompVal)
1808 {
1809 case 0: return Node->PlayTime ? true : false;
1810 case 1: return Node->PreGameTime ? true : false;
1811 case 2: return Node->IdleTime ? true : false;
1812 case 3: return Node->RoundsPlayed ? true : false;
1813 case 4: return Node->RoundsCompleted ? true : false;
1814 case 5: return Node->RoundsQuit ? true : false;
1815 case 6: return Node->RoundsWon ? true : false;
1816 case 7: return Node->RoundsLost ? true : false;
1817 case 8: return Node->MostKillsInARound ? true : false;
1818 case 9: return Node->MostDeathsInARound ? true : false;
1819 case 10: return Node->MostBonusObjectivesCompletedInARound ? true : false;
1820 case 11: return Node->Deaths ? true : false;
1821 case 12: return Node->Kills ? true : false;
1822 case 13: return Node->VehicleKills ? true : false;
1823 case 14: return Node->KilledSelf ? true : false;
1824 case 15: return Node->KilledPlayers ? true : false;
1825 case 16: return Node->KilledPresident ? true : false;
1826 case 17: return Node->KilledTurrets ? true : false;
1827 case 18: return Node->KilledBears ? true : false;
1828 case 19: return Node->KilledBlackBears ? true : false;
1829 case 20: return Node->KilledMutantBears ? true : false;
1830 case 21: return Node->KilledMutantDeer ? true : false;
1831 case 22: return Node->KilledMutantCats ? true : false;
1832 case 23: return Node->KilledMutantCatsB ? true : false;
1833 case 24: return Node->KilledMutantCatsR ? true : false;
1834 case 25: return Node->KilledMutantRabbits ? true : false;
1835 case 26: return Node->ObjectiveActivatedAlarm ? true : false;
1836 case 27: return Node->ObjectiveTurretTruck ? true : false;
1837 case 28: return Node->ObjectiveTurretTruckAlarm ? true : false;
1838 case 29: return Node->ObjectiveOilRigsActivated ? true : false;
1839 case 30: return Node->ObjectiveOilRigsRepaired ? true : false;
1840 case 31: return Node->ObjectiveEngineersSaved ? true : false;
1841 case 32: return Node->ObjectiveWeaponsFound ? true : false;
1842 case 33: return Node->ObjectiveWeaponsReturned ? true : false;
1843 case 34: return Node->ObjectivePlasmaRifleReturned ? true : false;
1844 case 35: return Node->BonusObjectivesCompleted ? true : false;
1845 case 36: return Node->PickedupHealthPowerups ? true : false;
1846 case 37: return Node->PickedupArmorPowerups ? true : false;
1847 case 38: return Node->PickedupCashPowerups ? true : false;
1848 case 39: return Node->PickedupAmmoPowerups ? true : false;
1849 case 40: return Node->PickedupHealthTotal ? true : false;
1850 case 41: return Node->PickedupArmorTotal ? true : false;
1851 case 42: return Node->PickedupCashTotal ? true : false;
1852 case 43: return Node->PickedupAmmoTotal ? true : false;
1853 case 44: return Node->PickedupTotalPowerups ? true : false;
1854 case 45: return Node->PickedupTotalPowerupsInARound ? true : false;
1855 case 46: return Node->KilledHumanAi ? true : false;
1856 case 47: return Node->VehiclesDestroyed ? true : false;
1857 case 48: return Node->VehiclesLost ? true : false;
1858 case 49: return Node->JazzsLost ? true : false;
1859 case 50: return Node->CleasansLost ? true : false;
1860 case 51: return Node->TrucksLost ? true : false;
1861 case 52: return Node->TanksLost ? true : false;
1862 case 53: return Node->TurretTruckLost ? true : false;
1863 case 54: return Node->C4VestPowerups ? true : false;
1864 case 55: return Node->ActivatedCommTower ? true : false;
1865 case 56: return Node->PlayedGamesWithDefenseTurrets ? true : false;
1866 case 57: return Node->PlayedGamesWithGuardianHelicopter ? true : false;
1867 case 58: return Node->TimesDrown ? true : false;
1868 case 59: return Node->TimesFallen ? true : false;
1869 case 60: return Node->KillsWithSentryTurret ? true : false;
1870 case 61: return Node->KilledSentryTurrets ? true : false;
1871 case 62: return Node->SentryTurretsPlaced ? true : false;
1872 case 63: return Node->SentryTurretsLost ? true : false;
1873 case 64: return Node->PickedUpMedicalNeedle ? true : false;
1874 case 65: return Node->ReturnedMedicalNeedle ? true : false;
1875 case 66: return Node->RepairedSubstation ? true : false;
1876 case 67: return Node->SubstationOnLineAtEnd ? true : false;
1877 case 68: return Node->RepairedSubstation ? true : false;
1878 case 69: return Node->GiantDeerKilled ? true : false;
1879 case 70: return Node->SurvivedAlarm ? true : false;
1880 case 71: return Node->WolfKilled ? true : false;
1881 case 72: return Node->MutantDogKilled ? true : false;
1882 case 73: return Node->BlueDeerKilled ? true : false;
1883 case 74: return Node->CheatedRounds ? true : false;
1884 case 75: return Node->NeverInjured ? true : false;
1885 case 76: return Node->MooseKilled ? true : false;
1886 case 77: return Node->EatenByRabbit ? true : false;
1887 case 78: return Node->PickedUpDeerStatue ? true : false;
1888 case 79: return Node->DroppedDeerStatue ? true : false;
1889 case 80: return Node->ReturnedDeerStatue ? true : false;
1890 case 81: return Node->TinyDeerKilled ? true : false;
1891 case 82: return Node->MutantSquirrelsKilled ? true : false;
1892 case 83: return Node->WildDeerKilled ? true : false;
1893 case 84: return Node->WildSquirrelsKilled ? true : false;
1894 case 85: return Node->ArmoredCarsLost ? true : false;
1895 case 86: return Node->WarriorsLost ? true : false;
1896 case 87: return Node->TimeOnFoot ? true : false;
1897 case 88: return Node->TimeInAJazzs ? true : false;
1898 case 89: return Node->TimeInACleasans ? true : false;
1899 case 90: return Node->TimeInASecurityTruck ? true : false;
1900 case 91: return Node->TimeInArmoredCars ? true : false;
1901 case 92: return Node->TimeInAUDVs ? true : false;
1902 case 93: return Node->TimeInGatlingTanks ? true : false;
1903 case 94: return Node->TimeInIFVs ? true : false;
1904 case 95: return Node->FriendlyTinyDeerKilled ? true : false;
1905 case 96: return Node->SupportReceivedInfantryHp ? true : false;
1906 case 97: return Node->SupportReceivedVehicleHp ? true : false;
1907 case 98: return Node->SupportReceivedAmmo ? true : false;
1908 case 99: return Node->SupportGrantedHpInfantry ? true : false;
1909 case 100: return Node->SupportGrantedHpVehicle ? true : false;
1910 case 101: return Node->SupportGrantedAmmo ? true : false;
1911 case 102: return Node->SupportReceivedHpInfantrySelf ? true : false;
1912 case 103: return Node->SupportReceivedHpVehicleSelf ? true : false;
1913 case 104: return Node->SupportReceivedAmmoSelf ? true : false;
1914 case 105: return Node->PettedCougars ? true : false;
1915 case 106: return Node->KilledCougars ? true : false;
1916 case 107: return Node->KilledMutantCougars ? true : false;
1917 case 108: return Node->FailedPettingCougars ? true : false;
1918 case 109: return Node->KilledFriendlyCougars ? true : false;
1919 case 110: return Node->DiedTryingToEscapeBase ? true : false;
1920 case 111: return Node->RescuedCows ? true : false;
1921 case 112: return Node->KilledCows ? true : false;
1922 case 113: return Node->LostCows ? true : false;
1923 case 114: return Node->CompletedCowObjective ? true : false;
1924 case 115: return Node->KilledMice ? true : false;
1925 case 116: return Node->CompledMiceObjective ? true : false;
1926 case 117: return Node->KilledPortablePumpJacks ? true : false;
1927 case 118: return Node->PortablePumpJacksPlaced ? true : false;
1928 case 119: return Node->PortablePumpJacksLost ? true : false;
1929 case 120: return Node->PumpJackMoney ? true : false;
1930 case 121: return Node->MobilePumpJackMoney ? true : false;
1931 case 122: return Node->KilledTurkey ? true : false;
1932 case 123: return Node->ReturnedTurkey ? true : false;
1933 default: Console_Input("msg SCORE SYSTEM ERROR: Out of bounds!");return false;
1934 }
1935 }
1936 char *ReturnScore(BHScoreNode *High,int CompVal)
1937 {
1938 static char RetChar[200];
1939 if (!High)
1940 return " ";
1941 switch (CompVal)
1942 {
1943 case 0: sprintf(RetChar,"Server Record: %s has played bear hunter for %s mintues.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PlayTime/60.0f));return RetChar;
1944 case 1: sprintf(RetChar,"Server Record: %s has dicked around for %s minutes before finally leaving the base to go hunting.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PreGameTime/60.0f));return RetChar;
1945 case 2: sprintf(RetChar,"Server Record: %s has been idle for %s minutes.",High->PlayerName,JmgUtility::formatDigitGrouping(High->IdleTime/60.0f));return RetChar;
1946 case 3: sprintf(RetChar,"Server Record: %s has joined %s rounds of bear hunter.",High->PlayerName,JmgUtility::formatDigitGrouping(High->RoundsPlayed));return RetChar;
1947 case 4: sprintf(RetChar,"Server Record: %s has completed %s rounds of bear hunter.",High->PlayerName,JmgUtility::formatDigitGrouping(High->RoundsCompleted));return RetChar;
1948 case 5: sprintf(RetChar,"Server Record: %s has quit %s rounds of bear hunter.",High->PlayerName,JmgUtility::formatDigitGrouping(High->RoundsQuit));return RetChar;
1949 case 6: sprintf(RetChar,"Server Record: %s has won %s rounds of bear hunter.",High->PlayerName,JmgUtility::formatDigitGrouping(High->RoundsWon));return RetChar;
1950 case 7: sprintf(RetChar,"Server Record: %s has lost %s rounds of bear hunter.",High->PlayerName,JmgUtility::formatDigitGrouping(High->RoundsLost));return RetChar;
1951 case 8: sprintf(RetChar,"Server Record: %s has the most kills in a round: %s.",High->PlayerName,JmgUtility::formatDigitGrouping(High->MostKillsInARound));return RetChar;
1952 case 9: sprintf(RetChar,"Server Record: %s has the most deaths in a round: %s.",High->PlayerName,JmgUtility::formatDigitGrouping(High->MostDeathsInARound));return RetChar;
1953 case 10: sprintf(RetChar,"Server Record: %s has completed the most objectives in a round: %s.",High->PlayerName,JmgUtility::formatDigitGrouping(High->MostBonusObjectivesCompletedInARound));return RetChar;
1954 case 11: sprintf(RetChar,"Server Record: %s has %s deaths.",High->PlayerName,JmgUtility::formatDigitGrouping(High->Deaths));return RetChar;
1955 case 12: sprintf(RetChar,"Server Record: %s has %s kills.",High->PlayerName,JmgUtility::formatDigitGrouping(High->Kills));return RetChar;
1956 case 13: sprintf(RetChar,"Server Record: %s has %s vehicle kills.",High->PlayerName,JmgUtility::formatDigitGrouping(High->VehicleKills));return RetChar;
1957 case 14: sprintf(RetChar,"Server Record: %s has comitted suicide %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledSelf));return RetChar;
1958 case 15: sprintf(RetChar,"Server Record: %s has killed %s other players.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledPlayers));return RetChar;
1959 case 16: sprintf(RetChar,"Server Record: %s has killed the President of Corporate America %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledPresident));return RetChar;
1960 case 17: sprintf(RetChar,"Server Record: %s has killed %s shredder turrets.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledTurrets));return RetChar;
1961 case 18: sprintf(RetChar,"Server Record: %s has killed %s brown bears.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledBears));return RetChar;
1962 case 19: sprintf(RetChar,"Server Record: %s has killed %s black bears.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledBlackBears));return RetChar;
1963 case 20: sprintf(RetChar,"Server Record: %s has killed %s mutant bears.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledMutantBears));return RetChar;
1964 case 21: sprintf(RetChar,"Server Record: %s has killed %s mutant deer.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledMutantDeer));return RetChar;
1965 case 22: sprintf(RetChar,"Server Record: %s has killed %s mutant cats.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledMutantCats));return RetChar;
1966 case 23: sprintf(RetChar,"Server Record: %s has killed %s mutant ion cats.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledMutantCatsB));return RetChar;
1967 case 24: sprintf(RetChar,"Server Record: %s has killed %s mutant nuclear cats.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledMutantCatsR));return RetChar;
1968 case 25: sprintf(RetChar,"Server Record: %s has killed the boss rabbit %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledMutantRabbits));return RetChar;
1969 case 26: sprintf(RetChar,"Server Record: %s has activated the alarm %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ObjectiveActivatedAlarm));return RetChar;
1970 case 27: sprintf(RetChar,"Server Record: %s has returned the security truck %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ObjectiveTurretTruck));return RetChar;
1971 case 28: sprintf(RetChar,"Server Record: %s has deactivated the security alarm %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ObjectiveTurretTruckAlarm));return RetChar;
1972 case 29: sprintf(RetChar,"Server Record: %s has activated %s pump jacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ObjectiveOilRigsActivated));return RetChar;
1973 case 30: sprintf(RetChar,"Server Record: %s has repaired %s pump jacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ObjectiveOilRigsRepaired));return RetChar;
1974 case 31: sprintf(RetChar,"Server Record: %s has saved %s engineers.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ObjectiveEngineersSaved));return RetChar;
1975 case 32: sprintf(RetChar,"Server Record: %s has found %s weapon containers.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ObjectiveWeaponsFound));return RetChar;
1976 case 33: sprintf(RetChar,"Server Record: %s has returned %s weapon containers.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ObjectiveWeaponsReturned));return RetChar;
1977 case 34: sprintf(RetChar,"Server Record: %s has retrived the plasma rifle weapon container %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ObjectivePlasmaRifleReturned));return RetChar;
1978 case 35: sprintf(RetChar,"Server Record: %s has completed %s bonus objectives.",High->PlayerName,JmgUtility::formatDigitGrouping(High->BonusObjectivesCompleted));return RetChar;
1979 case 36: sprintf(RetChar,"Server Record: %s has acquired %s health powerups.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupHealthPowerups));return RetChar;
1980 case 37: sprintf(RetChar,"Server Record: %s has acquired %s armor powerups.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupArmorPowerups));return RetChar;
1981 case 38: sprintf(RetChar,"Server Record: %s has acquired %s cash powerups.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupCashPowerups));return RetChar;
1982 case 39: sprintf(RetChar,"Server Record: %s has acquired %s ammo powerups.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupAmmoPowerups));return RetChar;
1983 case 40: sprintf(RetChar,"Server Record: %s has acquired %s health from health powerups.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupHealthTotal));return RetChar;
1984 case 41: sprintf(RetChar,"Server Record: %s has acquired %s armor from armor powerups.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupArmorTotal));return RetChar;
1985 case 42: sprintf(RetChar,"Server Record: %s has acquired $%s.00 dollars from cash powerups.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupCashTotal));return RetChar;
1986 case 43: sprintf(RetChar,"Server Record: %s has acquired %s clips of ammo from ammo powerups.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupAmmoTotal));return RetChar;
1987 case 44: sprintf(RetChar,"Server Record: %s has acquired %s powerups.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupTotalPowerups));return RetChar;
1988 case 45: sprintf(RetChar,"Server Record: %s has acquired %s powerups in a round.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedupTotalPowerupsInARound));return RetChar;
1989 case 46: sprintf(RetChar,"Server Record: %s has killed %s friendly AI.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledHumanAi));return RetChar;
1990 case 47: sprintf(RetChar,"Server Record: %s has destroyed %s vehicles.",High->PlayerName,JmgUtility::formatDigitGrouping(High->VehiclesDestroyed));return RetChar;
1991 case 48: sprintf(RetChar,"Server Record: %s has lost %s vehicles.",High->PlayerName,JmgUtility::formatDigitGrouping(High->VehiclesLost));return RetChar;
1992 case 49: sprintf(RetChar,"Server Record: %s has lost %s Punda Jazzs.",High->PlayerName,JmgUtility::formatDigitGrouping(High->JazzsLost));return RetChar;
1993 case 50: sprintf(RetChar,"Server Record: %s has lost %s Cleasan Primera.",High->PlayerName,JmgUtility::formatDigitGrouping(High->CleasansLost));return RetChar;
1994 case 51: sprintf(RetChar,"Server Record: %s has lost %s Urban Defense Vehicles.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TrucksLost));return RetChar;
1995 case 52: sprintf(RetChar,"Server Record: %s has lost %s Gattling Tanks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TanksLost));return RetChar;
1996 case 53: sprintf(RetChar,"Server Record: %s has lost %s Cargo Trucks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TurretTruckLost));return RetChar;
1997 case 54: sprintf(RetChar,"Server Record: %s has acquired %s C4 Vests.",High->PlayerName,JmgUtility::formatDigitGrouping(High->C4VestPowerups));return RetChar;
1998 case 55: sprintf(RetChar,"Server Record: %s activated the transmitter %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ActivatedCommTower));return RetChar;
1999 case 56: sprintf(RetChar,"Server Record: %s played in %s games where the security truck has been returned to base.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PlayedGamesWithDefenseTurrets));return RetChar;
2000 case 57: sprintf(RetChar,"Server Record: %s has played %s games with assistance from Comanche 4573.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PlayedGamesWithGuardianHelicopter));return RetChar;
2001 case 58: sprintf(RetChar,"Server Record: %s has gone too far from the shore %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimesDrown));return RetChar;
2002 case 59: sprintf(RetChar,"Server Record: %s has fell to their death %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimesFallen));return RetChar;
2003 case 60: sprintf(RetChar,"Server Record: %s has got %s kills with a sentry turret.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KillsWithSentryTurret));return RetChar;
2004 case 61: sprintf(RetChar,"Server Record: %s has destroyed %s sentry turrets.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledSentryTurrets));return RetChar;
2005 case 62: sprintf(RetChar,"Server Record: %s has placed %s sentry turrets.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SentryTurretsPlaced));return RetChar;
2006 case 63: sprintf(RetChar,"Server Record: %s has lost %s sentry turrets.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SentryTurretsLost));return RetChar;
2007 case 64: sprintf(RetChar,"Server Record: %s has picked up the medical needle %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedUpMedicalNeedle));return RetChar;
2008 case 65: sprintf(RetChar,"Server Record: %s has returned the medical needle %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ReturnedMedicalNeedle));return RetChar;
2009 case 66: sprintf(RetChar,"Server Record: %s has repaired the Power Substation %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->RepairedSubstation));return RetChar;
2010 case 67: sprintf(RetChar,"Server Record: %s has finished %s rounds with the substation online.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SubstationOnLineAtEnd));return RetChar;
2011 case 68: sprintf(RetChar,"Server Record: %s has played %s rounds in which the substation was never damaged.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SubstationNotDamaged));return RetChar;
2012 case 69: sprintf(RetChar,"Server Record: %s has killed %s Genitically Enhanced Deer.",High->PlayerName,JmgUtility::formatDigitGrouping(High->GiantDeerKilled));return RetChar;
2013 case 70: sprintf(RetChar,"Server Record: %s has successfully held the cabin %s times for the duration of the EAS.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SurvivedAlarm));return RetChar;
2014 case 71: sprintf(RetChar,"Server Record: %s has killed %s Wolfs.",High->PlayerName,JmgUtility::formatDigitGrouping(High->WolfKilled));return RetChar;
2015 case 72: sprintf(RetChar,"Server Record: %s has killed %s Mutant Dogs.",High->PlayerName,JmgUtility::formatDigitGrouping(High->MutantDogKilled));return RetChar;
2016 case 73: sprintf(RetChar,"Server Record: %s has killed %s Karma Deer.",High->PlayerName,JmgUtility::formatDigitGrouping(High->BlueDeerKilled));return RetChar;
2017 case 74: sprintf(RetChar,"Server Record: %s has been in %s games that were won unbelievably well.",High->PlayerName,JmgUtility::formatDigitGrouping(High->CheatedRounds));return RetChar;
2018 case 75: sprintf(RetChar,"Server Record: %s has been in %s games without the president getting hurt by mutants.",High->PlayerName,JmgUtility::formatDigitGrouping(High->NeverInjured));return RetChar;
2019 case 76: sprintf(RetChar,"Server Record: %s has killed %s Moose.",High->PlayerName,JmgUtility::formatDigitGrouping(High->MooseKilled));return RetChar;
2020 case 77: sprintf(RetChar,"Server Record: %s has been eaten by the rabbit %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->EatenByRabbit));return RetChar;
2021 case 78: sprintf(RetChar,"Server Record: %s has picked up the golden deer statue %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PickedUpDeerStatue));return RetChar;
2022 case 79: sprintf(RetChar,"Server Record: %s has dropped up the golden deer statue %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->DroppedDeerStatue));return RetChar;
2023 case 80: sprintf(RetChar,"Server Record: %s has returned up the golden deer statue %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ReturnedDeerStatue));return RetChar;
2024 case 81: sprintf(RetChar,"Server Record: %s has killed %s tiny deer.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TinyDeerKilled));return RetChar;
2025 case 82: sprintf(RetChar,"Server Record: %s has killed %s mutant squirrels.",High->PlayerName,JmgUtility::formatDigitGrouping(High->MutantSquirrelsKilled));return RetChar;
2026 case 83: sprintf(RetChar,"Server Record: %s has killed %s wild deer.",High->PlayerName,JmgUtility::formatDigitGrouping(High->WildDeerKilled));return RetChar;
2027 case 84: sprintf(RetChar,"Server Record: %s has killed %s wild squirrels.",High->PlayerName,JmgUtility::formatDigitGrouping(High->WildSquirrelsKilled));return RetChar;
2028 case 85: sprintf(RetChar,"Server Record: %s has lost %s Armored Cars.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ArmoredCarsLost));return RetChar;
2029 case 86: sprintf(RetChar,"Server Record: %s has lost %s Warrior Infantry Fighting Vehicles.",High->PlayerName,JmgUtility::formatDigitGrouping(High->WarriorsLost));return RetChar;
2030 case 87: sprintf(RetChar,"Server Record: %s has spent %s minutes on foot.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimeOnFoot/60.0f));return RetChar;
2031 case 88: sprintf(RetChar,"Server Record: %s has spent %s minutes in Punda Jazzes.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimeInAJazzs/60.0f));return RetChar;
2032 case 89: sprintf(RetChar,"Server Record: %s has spent %s minutes in Cleasan Primeras.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimeInACleasans/60.0f));return RetChar;
2033 case 90: sprintf(RetChar,"Server Record: %s has spent %s minutes in Turret Trucks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimeInASecurityTruck/60.0f));return RetChar;
2034 case 91: sprintf(RetChar,"Server Record: %s has spent %s minutes in Armored Cars.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimeInArmoredCars/60.0f));return RetChar;
2035 case 92: sprintf(RetChar,"Server Record: %s has spent %s minutes in Urban Defense Vehicles.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimeInAUDVs/60.0f));return RetChar;
2036 case 93: sprintf(RetChar,"Server Record: %s has spent %s minutes in Gatling Tanks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimeInGatlingTanks/60.0f));return RetChar;
2037 case 94: sprintf(RetChar,"Server Record: %s has spent %s minutes in Warrior Infantry Fighting Vehicles.",High->PlayerName,JmgUtility::formatDigitGrouping(High->TimeInIFVs/60.0f));return RetChar;
2038 case 95: sprintf(RetChar,"Server Record: %s has killed %s friendly tiny deer.",High->PlayerName,JmgUtility::formatDigitGrouping(High->FriendlyTinyDeerKilled));return RetChar;
2039 case 96: sprintf(RetChar,"Server Record: %s has received %s points of HP to infantry from Armored Supply Trucks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SupportReceivedInfantryHp));return RetChar;
2040 case 97: sprintf(RetChar,"Server Record: %s has received %s points of HP to vehicles from Armored Supply Trucks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SupportReceivedVehicleHp));return RetChar;
2041 case 98: sprintf(RetChar,"Server Record: %s has received %s points of ammo from Armored Supply Trucks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SupportReceivedAmmo));return RetChar;
2042 case 99: sprintf(RetChar,"Server Record: %s has given %s points of HP to infantry from Armored Supply Trucks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SupportGrantedHpInfantry));return RetChar;
2043 case 100: sprintf(RetChar,"Server Record: %s has given %s points of HP to vehicles from Armored Supply Trucks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SupportGrantedHpVehicle));return RetChar;
2044 case 101: sprintf(RetChar,"Server Record: %s has given %s points of ammo from Armored Supply Trucks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SupportGrantedAmmo));return RetChar;
2045 case 102: sprintf(RetChar,"Server Record: %s has given %s points of HP to infantry from Armored Supply Trucks to theirself.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SupportReceivedHpInfantrySelf));return RetChar;
2046 case 103: sprintf(RetChar,"Server Record: %s has given %s points of HP to vehicles from Armored Supply Trucks to theirself.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SupportReceivedHpVehicleSelf));return RetChar;
2047 case 104: sprintf(RetChar,"Server Record: %s has given %s points of ammo from Armored Supply Trucks to theirself.",High->PlayerName,JmgUtility::formatDigitGrouping(High->SupportReceivedAmmoSelf));return RetChar;
2048 case 105: sprintf(RetChar,"Server Record: %s has petted %s cougars.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PettedCougars));return RetChar;
2049 case 106: sprintf(RetChar,"Server Record: %s has killed %s wild cougars.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledCougars));return RetChar;
2050 case 107: sprintf(RetChar,"Server Record: %s has killed %s mutant cougars.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledMutantCougars));return RetChar;
2051 case 108: sprintf(RetChar,"Server Record: %s has killed %s cougars instead of petting them.",High->PlayerName,JmgUtility::formatDigitGrouping(High->FailedPettingCougars));return RetChar;
2052 case 109: sprintf(RetChar,"Server Record: %s has killed %s friendly cougars.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledFriendlyCougars));return RetChar;
2053 case 110: sprintf(RetChar,"Server Record: %s has died trying to escape the base %s times when the boss was lurking about.",High->PlayerName,JmgUtility::formatDigitGrouping(High->DiedTryingToEscapeBase));return RetChar;
2054 case 111: sprintf(RetChar,"Server Record: %s has rescued %s cows.",High->PlayerName,JmgUtility::formatDigitGrouping(High->RescuedCows));return RetChar;
2055 case 112: sprintf(RetChar,"Server Record: %s has killed %s cows.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledCows));return RetChar;
2056 case 113: sprintf(RetChar,"Server Record: %s has lost %s cows.",High->PlayerName,JmgUtility::formatDigitGrouping(High->LostCows));return RetChar;
2057 case 114: sprintf(RetChar,"Server Record: %s has completed the cow objective %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->CompletedCowObjective));return RetChar;
2058 case 115: sprintf(RetChar,"Server Record: %s has killed %s mice.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledMice));return RetChar;
2059 case 116: sprintf(RetChar,"Server Record: %s has completed the pest objective %s times.",High->PlayerName,JmgUtility::formatDigitGrouping(High->CompledMiceObjective));return RetChar;
2060 case 117: sprintf(RetChar,"Server Record: %s has destroyed %s Portable Pumpjacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledPortablePumpJacks));return RetChar;
2061 case 118: sprintf(RetChar,"Server Record: %s has placed %s Portable Pumpjacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PortablePumpJacksPlaced));return RetChar;
2062 case 119: sprintf(RetChar,"Server Record: %s has lost %s Portable Pumpjacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PortablePumpJacksLost));return RetChar;
2063 case 120: sprintf(RetChar,"Server Record: %s has made $%s.00 from Pumpjacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->PumpJackMoney));return RetChar;
2064 case 121: sprintf(RetChar,"Server Record: %s has made $%s.00 from Portable Pumpjacks.",High->PlayerName,JmgUtility::formatDigitGrouping(High->MobilePumpJackMoney));return RetChar;
2065 case 122: sprintf(RetChar,"Server Record: %s has killed %s turkeys.",High->PlayerName,JmgUtility::formatDigitGrouping(High->KilledTurkey));return RetChar;
2066 case 123: sprintf(RetChar,"Server Record: %s has made $%s.00 from bringing turkeys back to base.",High->PlayerName,JmgUtility::formatDigitGrouping(High->ReturnedTurkey));return RetChar;
2067 default: sprintf(RetChar,"Server Record ERROR: Record index out of bounds!"); return RetChar;
2068 }
2069 }
2070 void StateHighScore()
2071 {
2072 int LastHighScoreList = 1;
2073 int Random = Commands->Get_Random_Int(0,BHHighScoreListCount);
2074 while (Random == lastDispalyedHighScore)
2075 Random = Commands->Get_Random_Int(0,BHHighScoreListCount);
2076BHStartOfHighScoreSelectProcess:
2077 selectRandomMatchingScore = 0;
2078 BHScoreNode *Current = BHScoreNodeList,*Best = NULL;
2079 while (Current)
2080 {
2081 Best = CompareHighScoreNodes(Best,Current,Random);
2082 Current = Current->next;
2083 }
2084 if (!ReturnHighScoreNodeValue(Best,Random))
2085 {
2086 if (LastHighScoreList < BHHighScoreListCount)
2087 {
2088 LastHighScoreList++;
2089 if (Random+1 < BHHighScoreListCount)
2090 {
2091 Random++;
2092 if (Random == lastDispalyedHighScore)
2093 Random++;
2094 if (Random >= BHHighScoreListCount)
2095 Random = 0;
2096 }
2097 else
2098 Random = lastDispalyedHighScore ? 0 : 1;
2099 goto BHStartOfHighScoreSelectProcess;
2100 }
2101 if (LastHighScoreList == BHHighScoreListCount)
2102 LastHighScoreList = 1;
2103 }
2104 lastDispalyedHighScore = Random;
2105 char DisplayMessage[128];
2106 sprintf(DisplayMessage,"%s",ReturnScore(Best,Random));
2107 for (int x = 1;x < 128;x++)
2108 {
2109 GameObject *Player = Get_GameObj(x);
2110 if (Player)
2111 JmgUtility::DisplayChatMessage(Player,6,145,148,DisplayMessage);
2112 }
2113 }
2114 void EndGameUpdatePlayerStats(bool won)
2115 {
2116 for (SLNode<cPlayer>* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next())
2117 {
2118 cPlayer *p = PlayerIter->Data();
2119 BHScoreNode *node = FindOrAddPlayerBHHighScoreNode(WideCharToChar(p->Get_Name()));
2120 if (node->startedRound)
2121 if (!p->Is_Active())
2122 node->RoundsQuit++;
2123 else
2124 node->RoundsCompleted++;
2125 if (won)
2126 node->RoundsWon++;
2127 else
2128 node->RoundsLost++;
2129 node->RoundsPlayed++;
2130 if (JMG_Bear_Hunter_Game_Control::hasGotTurrets)
2131 node->PlayedGamesWithDefenseTurrets++;
2132 if (JMG_Bear_Hunter_Game_Control::hasActivatedTower)
2133 node->PlayedGamesWithGuardianHelicopter++;
2134 if ((unsigned long)p->Get_Kills() > node->MostKillsInARound)
2135 node->MostKillsInARound = (unsigned long)p->Get_Kills();
2136 if ((unsigned long)p->Get_Deaths() > node->MostDeathsInARound)
2137 node->MostDeathsInARound = (unsigned long)p->Get_Deaths();
2138 if (node->MostBonusObjectivesCompletedInARound < node->totalObjectivesCompleted)
2139 node->MostBonusObjectivesCompletedInARound = node->totalObjectivesCompleted;
2140 if (node->PickedupTotalPowerupsInARound < node->totalPowerupsPickedup)
2141 node->PickedupTotalPowerupsInARound = node->totalPowerupsPickedup;
2142 }
2143 }
2144 void IncreasePlayerTimeScores()
2145 {
2146 JmgUtility::GenericDateTime currentTime = JmgUtility::GenericDateTime();
2147 for (int y = 1;y < 128;y++)
2148 {
2149 GameObject *Player = Get_GameObj(y);
2150 if (!Player)
2151 continue;
2152 BearHunterScoreSystem::BHScoreNode *pobj = BHPlayerHighScoreNodes[y];
2153 if (!pobj)
2154 continue;
2155 Vector3 Pos = Commands->Get_Position(Player);
2156 float Facing = Commands->Get_Facing(Player);
2157 bool IsMoving = true,IsTurning = true;
2158 if (!JmgUtility::SimpleDistance(Pos,pobj->lastPos))
2159 IsMoving = false;
2160 pobj->lastPos = Pos;
2161 if (abs(Facing - pobj->lastFacing) < 1.0f)
2162 IsTurning = false;
2163 pobj->lastFacing = Facing;
2164 pobj->LastPlayTime = currentTime;
2165 if (pobj->isMoving == IsMoving && pobj->isTurning == IsTurning)
2166 if (pobj->idleDelay > 60)
2167 {
2168 pobj->IdleTime++;
2169 continue;
2170 }
2171 else
2172 {
2173 pobj->idleDelay++;
2174 GameObject *pVehicle = Get_Vehicle(Player);
2175 if (pVehicle)
2176 {
2177 switch (Commands->Get_Preset_ID(pVehicle))
2178 {
2179 case 1000001144:case 1000001158:case 1000001162:case 1000001160:
2180 pobj->TimeInAJazzs++;break;
2181 case 1000001321:case 1000001323:case 1000001327:case 1000001325:
2182 pobj->TimeInACleasans++;break;
2183 case 1000001310:
2184 pobj->TimeInAUDVs++;break;
2185 case 1000001306:
2186 pobj->TimeInGatlingTanks++;break;
2187 case 1000001174:
2188 pobj->TimeInASecurityTruck++;break;
2189 case 1000001811:
2190 pobj->TimeInArmoredCars++;break;
2191 case 1000003594:
2192 pobj->TimeInIFVs++;break;
2193 }
2194 }
2195 else
2196 pobj->TimeOnFoot++;
2197 }
2198 else
2199 pobj->idleDelay = 0;
2200 pobj->isMoving = IsMoving;
2201 pobj->isTurning = IsTurning;
2202 if (pobj->startedRound)
2203 {
2204 pobj->PlayTime++;
2205 pobj->tmpPlayTime++;
2206 }
2207 else
2208 pobj->PreGameTime++;
2209 }
2210 }
2211 void GameStarted()
2212 {
2213 BHScoreNode *Current = BHScoreNodeList;
2214 while (Current)
2215 {
2216 Current->startedRound = true;
2217 Current = Current->next;
2218 }
2219 }
2220};
2221BearHunterScoreSystem bearHunterScoreSystem;
2222
2223class JMG_Rp2_Hostile_Mutant_AI : public ScriptImpClass {
2224 Rp2SimpleObjectList::SimpleObjectNode *myNode;
2225 bool damaged;
2226 int returnHome;
2227 Vector3 lastPos;
2228 int PlayerCount;
2229 int CanHearDelay;
2230 int LastSeen;
2231 int currentTargetID;
2232 int secondaryEnemyId;
2233 int lastSeenSecondary;
2234 int waitcount;
2235 Vector3 homelocation;
2236 float speed;
2237 bool huntEnemy;
2238 int returnHomeDelay;
2239 int vehicleChaseTime;
2240 int vehicleChaseTimeReset;
2241 int maxVehicleChaseTime;
2242 void Created(GameObject *obj);
2243 void Timer_Expired(GameObject *obj,int number);
2244 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2245 void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason);
2246 void Enemy_Seen(GameObject *obj,GameObject *seen);
2247 void Damaged(GameObject *obj,GameObject *damager,float damage);
2248 void SoundDHeard(GameObject *obj,const CombatSound &sound);
2249public:
2250 JMG_Rp2_Hostile_Mutant_AI()
2251 {
2252 myNode = NULL;
2253 }
2254 static Vector3 AllowedSoundPos;
2255 static bool CanInvestigateSound;
2256};
2257Vector3 JMG_Rp2_Hostile_Mutant_AI::AllowedSoundPos = Vector3(0.0f,0.0f,0.0f);
2258bool JMG_Rp2_Hostile_Mutant_AI::CanInvestigateSound = true;
2259
2260class JMG_Bear_Hunt_Mutant_Attacker : public ScriptImpClass {
2261 Rp2SimpleObjectList::SimpleObjectNode *myNode;
2262 int LastSeen;
2263 int secondaryEnemyId;
2264 int lastSeenSecondary;
2265 int targetedId;
2266 float targetDistance;
2267 int targetUpdate;
2268 bool ignoreEnemies;
2269 float weaponRange;
2270 float attackRange;
2271 int stuckCount;
2272 Vector3 lastPos;
2273 bool ignoreDamage;
2274 void Created(GameObject *obj);
2275 void Enemy_Seen(GameObject *obj,GameObject *seen);
2276 void Timer_Expired(GameObject *obj,int number);
2277 void AttackTarget(GameObject *obj,GameObject *target,float distance);
2278 void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason);
2279 void Damaged(GameObject *obj,GameObject *damager,float damage);
2280public:
2281 JMG_Bear_Hunt_Mutant_Attacker()
2282 {
2283 myNode = NULL;
2284 }
2285};
2286
2287class JMG_Bear_Hunter_Animal_Control : public ScriptImpClass {
2288 void Killed(GameObject *obj,GameObject *killer);
2289 void Create_Powerup(GameObject *powerup,GameObject *obj,float random,const char *powerup1,const char *powerup2,const char *powerup3);
2290};
2291
2297class JMG_Security_Camera_Behavior : public ScriptImpClass {
2298 float scanAngle;
2299 float updateRateMultiplier;
2300 float zHeight;
2301 int originalTeam;
2302 bool enabled;
2303 int floodLightId;
2304 int EnemyID;
2305 int CameraFacingCount;
2306 int IncreaseOrDecreaseCount;
2307 int SeenTime;
2308 int stealthModeOverride;
2309 float cameraAngles[5];
2310 float CameraFacingUpdateTime;
2311 float idleZAimAngleModifier;
2312 float minDistanceSquared;
2313 bool canOnlySeeTargetScript;
2314 void Created(GameObject *obj);
2315 void Enemy_Seen(GameObject *obj,GameObject *seen);
2316 void Timer_Expired(GameObject *obj,int number);
2317 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2318 void Destroyed(GameObject *obj);
2319};
2320
2321class JMG_Bear_Hunt_Mutant_Cat_Explosion : public ScriptImpClass {
2322 void Killed(GameObject *obj,GameObject *killer);
2323};
2324
2325class JMG_Bear_Hunter_President_Controller : public ScriptImpClass {
2326 int regenTime;
2327 bool injuredAnimation;
2328 time_t lastTime;
2329 int lastDisplayHealth;
2330 int hurtRecently;
2331 void Created(GameObject *obj);
2332 void Poked(GameObject *obj, GameObject *poker);
2333 void Timer_Expired(GameObject *obj,int number);
2334 void Animation_Complete(GameObject* obj,const char *anim);
2335 void Damaged(GameObject *obj,GameObject *damager,float damage);
2336 void Killed(GameObject *obj,GameObject *killer);
2337 inline void damagedEvent(GameObject *obj,bool announce,bool palyinjured);
2338 void Greeting(GameObject *obj);
2339 void InPain(GameObject *obj);
2340 void Critical(GameObject *obj);
2341 void Congrats(GameObject *obj);
2342 void Rabbit(GameObject *obj);
2343public:
2344 static double lastHPRecorded;
2345};
2346double JMG_Bear_Hunter_President_Controller::lastHPRecorded = 500.0;
2347
2348class JMG_Bear_Hunter_Turret_Death_Alert : public ScriptImpClass {
2349 void Killed(GameObject *obj,GameObject *killer);
2350};
2351
2352class JMG_Powerup_Grant_Cash : public ScriptImpClass {
2353 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2354};
2355
2356class JMG_Bear_Hunter_Powerup_Tracker : public ScriptImpClass {
2357 void Created(GameObject *obj);
2358 void Destroyed(GameObject *obj);
2359};
2360
2361class JMG_Bear_Hunter_Grenade_Vest_Powerup : public ScriptImpClass {
2362 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2363};
2364
2365class JMG_Powerup_Grant_Weapon_Clips : public ScriptImpClass {
2366 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2367};
2368
2369class JMG_Bear_Hunter_SpawnPoint : public ScriptImpClass {
2370 void Created(GameObject *obj);
2371};
2372
2373class JMG_Bear_Hunter_Player_Spawn : public ScriptImpClass {
2374 void Created(GameObject *obj);
2375 void Timer_Expired(GameObject *obj,int number);
2376 Rp2SimplePositionSystem::SimplePositionNode *JMG_Bear_Hunter_Player_Spawn::GetSpotNotVisibileFromSpots(int points,Vector3 pos[],float ranges[]);
2377 Rp2SimplePositionSystem::SimplePositionNode *JMG_Bear_Hunter_Player_Spawn::GetFurthestSpotFromSpots(int points,Vector3 pos[],float weight[]);
2378 bool TestRay(Vector3 pos,Vector3 targetPos);
2379};
2380
2381class JMG_Bear_Hunter_Player_Vehicle : public ScriptImpClass {
2382 void Created(GameObject *obj);
2383 void Timer_Expired(GameObject *obj,int number);
2384 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2385 void Damaged(GameObject *obj,GameObject *damager,float damage);
2386 void Killed(GameObject *obj,GameObject *killer);
2387public:
2388 int lastDamaged;
2389};
2390
2391class JMG_Bear_Hunter_Bear_Tracker : public ScriptImpClass {
2392 void Destroyed(GameObject *obj);
2393};
2394
2395class JMG_Bear_Hunter_Mutant_Tracker : public ScriptImpClass {
2396 void Destroyed(GameObject *obj);
2397};
2398
2399class JMG_AI_Ignore_Object : public ScriptImpClass {
2400 void Created(GameObject *obj);
2401};
2402
2403class JMG_Bear_Hunter_Security_Turret_Truck : public ScriptImpClass {
2404 GameObject *driver;
2405 bool firstTime;
2406 void Created(GameObject *obj);
2407 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2408 void Destroyed(GameObject *obj);
2409public:
2410 static int id;
2411};
2412int JMG_Bear_Hunter_Security_Turret_Truck::id = 0;
2413class JMG_Bear_Hunter_Security_Turret_Truck_Zone : public ScriptImpClass {
2414 void Entered(GameObject *obj,GameObject *enterer);
2415};
2416class JMG_Bear_Hunt_Final_Boss : public ScriptImpClass {
2417 float moveSpeed;
2418 float rabbitSize;
2419 int actionUpdate;
2420 int enemyId;
2421 int jumperId;
2422 int targetedId;
2423 float targetDistance;
2424 int targetUpdate;
2425 int stuckCount;
2426 Vector3 lastPos;
2427 float lastHealth;
2428 float lastArmor;
2429 bool attackingPlayer;
2430 bool targetIsMine;
2431 void Created(GameObject *obj);
2432 void Enemy_Seen(GameObject *obj,GameObject *seen);
2433 void Timer_Expired(GameObject *obj,int number);
2434 void AttackTarget(GameObject *obj,GameObject *target,float distance);
2435 void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason);
2436 void Damaged(GameObject *obj,GameObject *damager,float damage);
2437 void Killed(GameObject *obj,GameObject *killer);
2438 void Respawn(GameObject *obj);
2439 void ChooseTarget(GameObject *obj,Vector3 pos,GameObject *target);
2440 bool inRange(GameObject *obj);
2441 void SnackTime(GameObject *obj,GameObject *target);
2442 void MineHunt(GameObject *obj,Vector3 myPos,GameObject *enemy);
2443public:
2444 static Vector3 bossPos;
2445 static int bossChoose;
2446};
2447Vector3 JMG_Bear_Hunt_Final_Boss::bossPos = Vector3();
2448int JMG_Bear_Hunt_Final_Boss::bossChoose = 7;
2449
2450class JMG_Bear_Hunter_Spectator : public ScriptImpClass {
2451 int playerId;
2452 void Created(GameObject *obj);
2453 void Destroyed(GameObject *obj);
2454};
2455
2456class JMG_Bear_Hunter_Dummy_Script : public ScriptImpClass {
2457 void Created(GameObject *obj);
2458};
2459
2460class JMG_Set_Player_Type_On_Create : public ScriptImpClass {
2461 void Created(GameObject *obj);
2462};
2463
2464class AIPurchaseSystem
2465{
2466 struct AICharacterNode
2467 {
2468 int cost;
2469 char name[127];
2470 int requiredPurchaseState;
2471 double rating;
2472 struct AICharacterNode *next;
2473 AICharacterNode(const char *name,int cost,int requiredPurchaseState,double rating)
2474 {
2475 this->cost = cost;
2476 sprintf(this->name,"%s",name);
2477 this->requiredPurchaseState = requiredPurchaseState;
2478 this->rating = rating;
2479 next = NULL;
2480 }
2481 };
2482 AICharacterNode *AICharacterNodeList;
2483 int presetCount;
2484 void add(const char *name,int cost,int requiredPurchaseState,double rating)
2485 {
2486 AICharacterNode *current = AICharacterNodeList;
2487 if (!current)
2488 AICharacterNodeList = new AICharacterNode(name,cost,requiredPurchaseState,rating);
2489 while (current)
2490 {
2491 if (!current->next)
2492 {
2493 current->next = new AICharacterNode(name,cost,requiredPurchaseState,rating);
2494 break;
2495 }
2496 current = current->next;
2497 }
2498 presetCount++;
2499 };
2500public:
2501 AIPurchaseSystem()
2502 {
2503 AICharacterNodeList = NULL;
2504 presetCount = 0;
2505 add("CnC_Nod_Shotgunner",0,-1,0.1);
2506 add("CnC_GDI_Grenadier",0,-1,0.0);
2507 add("CnC_Nod_Flamethrower",0,-1,0.1);
2508 add("CnC_GDI_Sydney",150,1,0.2);
2509 add("CnC_Nod_Petrova",150,1,0.15);
2510 add("CnC_GDI_Officer",175,-1,0.25);
2511 add("CnC_Nod_Officer",175,-1,0.25);
2512 add("CnC_Nod_Rocket_Officer",225,-1,0.33);
2513 add("CnC_GDI_Rocket_Soldier_Officer",225,-1,0.33);
2514 add("CnC_GDI_Gunner",400,-1,0.4);
2515 add("CnC_Nod_Stealth_Blackhand",400,-1,0.45);
2516 add("CnC_Nod_Chaingunner",450,-1,0.5);
2517 add("CnC_GDI_Patch",450,1,0.45);
2518 add("CnC_Nod_Raveshaw",1000,-1,0.8);
2519 add("CnC_Nod_Raveshaw_Alt",1000,-1,0.7);
2520 add("CnC_GDI_Sydney_Ion",1000,-1,0.65);
2521 add("CnC_GDI_Sydney_Ion_ALT",1000,-1,0.6);
2522 add("CnC_GDI_Ignatio_Mobius",1000,-1,0.65);
2523 add("CnC_GDI_Ignatio_Mobius_ALT",1000,-1,0.6);
2524 add("CnC_Nod_Mendoza",1000,-1,0.8);
2525 add("CnC_Nod_Mendoza_ALT",1000,-1,0.7);
2526 add("CnC_GDI_Patch",500,-1,0.5);
2527 add("CnC_Nod_Blackhand_Sniper",500,-1,0.5);
2528 add("CnC_Nod_Sakura",1000,-1,0.65);
2529 add("CnC_Nod_Sakura_ALT",1000,-1,0.6);
2530 add("CnC_GDI_Havoc",1000,-1,0.65);
2531 add("CnC_GDI_Havoc_ALT",1000,-1,0.6);
2532 }
2533 void Empty_List()
2534 {
2535 presetCount = 0;
2536 AICharacterNode *temp = AICharacterNodeList,*die;
2537 while (temp)
2538 {
2539 die = temp;
2540 temp = temp->next;
2541 delete die;
2542 }
2543 AICharacterNodeList = NULL;
2544 }
2545 void PurchaseSoldier(GameObject *obj,float *cash)
2546 {
2547 AICharacterNode *current = AICharacterNodeList,*best = NULL;
2548 if (*cash > 1250)
2549 while (current)
2550 {
2551 if (current->requiredPurchaseState == -1 || current->requiredPurchaseState == JMG_Bear_Hunter_Game_Control::gameState)
2552 if (*cash >= current->cost && (!best || (current->rating > best->rating || (current->rating == best->rating && Commands->Get_Random(0.0f,1.0f) < 0.5f))))
2553 best = current;
2554 current = current->next;
2555 }
2556 else
2557 {
2558 int random = Commands->Get_Random_Int(0,presetCount*2);
2559 while (current)
2560 {
2561 if ((current->requiredPurchaseState == -1 || current->requiredPurchaseState == JMG_Bear_Hunter_Game_Control::gameState) && *cash >= current->cost)
2562 {
2563 random--;
2564 if (!random)
2565 {
2566 best = current;
2567 break;
2568 }
2569 }
2570 current = current->next;
2571 }
2572 }
2573 if (!best)
2574 return;
2575 *cash = *cash-best->cost;
2576 Change_Character(obj,best->name);
2577 }
2578};
2579AIPurchaseSystem AIPurchaseSystemControl;
2580
2581class JMG_Bear_Hunter_Player_Assist_AI : public ScriptImpClass {
2582 Rp2SimplePositionSystem::SimplePositionNode *currentDefensePoint;
2583 enum AIStates{NoAction = 0,AccessPT = 4,PTReload = 5,GoHome = 3,WaitForGroup = 1,FollowPlayer = 3,MoveToCabin = 2,HoldCabin = 2,DefendGate = 2,DefendPres = 2};
2584 AIStates aiState,lastAiState;
2585 JMG_Bear_Hunter_Game_Control::GameState lastGameState;
2586 float lastArmor;
2587 float lastHealth;
2588 int enemyId;
2589 float enemyDistance;
2590 int lastSeen;
2591 int actionRefresh;
2592 Vector3 targetDestination;
2593 float requiredDestinationRange;
2594 float requiredDestinationRangeSquared;
2595 float moveSpeed;
2596 char primaryWeapon[256];
2597 int ptRefillBlock;
2598 bool respawning;
2599 void Created(GameObject *obj);
2600 void Enemy_Seen(GameObject *obj,GameObject *seen);
2601 void Timer_Expired(GameObject *obj,int number);
2602 void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason);
2603 void Damaged(GameObject *obj,GameObject *damager,float damage);
2604 void Killed(GameObject *obj,GameObject *killer);
2605 void Destroyed(GameObject *obj);
2606 void GotoLocation(GameObject *obj,GameObject *player);
2607 void SetAIState(GameObject *obj,AIStates newState,Vector3 pos,float distance,float speed,Rp2SimplePositionSystem::SimplePositionNode *newNode = NULL);
2608 void Respawn(GameObject *obj);
2609 void PurchaseCharacter(GameObject *obj);
2610 void ChooseAction(GameObject *obj);
2611public:
2612 #define maxTotalBearHunterPlayerAssistAI 5
2613 static int aiIds[maxTotalBearHunterPlayerAssistAI];
2614 static int maxWait;
2615 static float cash[maxTotalBearHunterPlayerAssistAI];
2616 static unsigned int aiDeaths[maxTotalBearHunterPlayerAssistAI];
2617};
2618int JMG_Bear_Hunter_Player_Assist_AI::aiIds[maxTotalBearHunterPlayerAssistAI] = {0};
2619int JMG_Bear_Hunter_Player_Assist_AI::maxWait = 15;
2620float JMG_Bear_Hunter_Player_Assist_AI::cash[maxTotalBearHunterPlayerAssistAI] = {0};
2621unsigned int JMG_Bear_Hunter_Player_Assist_AI::aiDeaths[maxTotalBearHunterPlayerAssistAI] = {0};
2622
2623void JMG_Bear_Hunter_Game_Control::ObjectiveCompleteReward(float credits)
2624{
2625 for (int x = 0;x < maxTotalBearHunterPlayerAssistAI;x++)
2626 JMG_Bear_Hunter_Player_Assist_AI::cash[x] += credits;
2627 for (int x = 1;x < 128;x++)
2628 {
2629 GameObject *player = Get_GameObj(x);
2630 if (!player)
2631 continue;
2632 Commands->Give_Money(player,credits,0);
2633 }
2634}
2635
2636class JMG_Bear_Hunter_AI_PT_Location : public ScriptImpClass {
2637 void Created(GameObject *obj);
2638 void Timer_Expired(GameObject *obj,int number);
2639};
2640
2641class JMG_Bear_Hunter_AI_Defense_Point : public ScriptImpClass {
2642 void Created(GameObject *obj);
2643};
2644
2645class JMG_Bear_Hunter_Warning_Light_Zone : public ScriptImpClass {
2646 bool lightOn;
2647 char ModelName[16];
2648 int LightEffectIDs[2];
2649 int warnTimeCountdown;
2650 void Created(GameObject *obj);
2651 void Timer_Expired(GameObject *obj,int number);
2652 void Entered(GameObject *obj,GameObject *enterer);
2653};
2654
2655class JMG_Bear_Hunter_Vehicle_Purchase_System : public ScriptImpClass {
2656 void Created(GameObject *obj);
2657 void Timer_Expired(GameObject *obj,int number);
2658 void AirDropFunction(GameObject *obj,Vector3 pos,float facing,int deathZoneId,int waypath1,int waypath2,int waypath3);
2659};
2660
2661class JMG_Airdrop_Attached_Object_On_Create : public ScriptImpClass {
2662 char skinType[256];
2663 char armorType[256];
2664 bool entered;
2665 bool timeUp;
2666 Vector3 origPos;
2667 float origFacing;
2668 int flareId;
2669 void Created(GameObject *obj);
2670 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2671 GameObject *CreateAObject(GameObject *obj,GameObject *Object,const char *Preset,const char *Model,const char *Animation,const Vector3 &Pos,float Facing,GameObject *GAttachTo,const char *Bone,float DeathFrame,float LastFrame);
2672};
2673
2674class JMG_Animate_While_Firing : public ScriptImpClass {
2675 unsigned int spinDown;
2676 bool firing;
2677 int bulletCount;
2678 char animation[32];
2679 void Created(GameObject *obj);
2680 void Timer_Expired(GameObject *obj,int number);
2681};
2682
2683class JMG_Bear_Hunter_Alarm_Switch : public ScriptImpClass {
2684 bool waitingToDeactivate;
2685 int switchPosition;
2686 void Created(GameObject *obj);
2687 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2688 void Poked(GameObject *obj, GameObject *poker);
2689 void ActivateSwitch(GameObject *obj,int position);
2690 void UpdateTower(int position);
2691};
2692
2693class JMG_Pickup_Display_Message : public ScriptImpClass {
2694 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2695};
2696class JMG_AI_Follow_Player_When_Near : public ScriptImpClass {
2697 int targetId;
2698 int lastSeenTime;
2699 float targetDistance;
2700 float weaponRange;
2701 float attackUpdate;
2702 int playerId;
2703 float followDistance;
2704 float followMaxDistance;
2705 float lastMoveSpeed;
2706 Vector3 createLocation;
2707 void Created(GameObject *obj);
2708 void Enemy_Seen(GameObject *obj,GameObject *seen);
2709 void Timer_Expired(GameObject *obj,int number);
2710 void Destroyed(GameObject *obj);
2711 inline float GetSpeed(GameObject *player,float distance);
2712};
2713
2714class JMG_Bear_Hunter_Engineer_Follow_Player_When_Near : public ScriptImpClass {
2715 int targetId;
2716 int lastSeenTime;
2717 float targetDistance;
2718 float weaponRange;
2719 float attackUpdate;
2720 float followDistance;
2721 float followMaxDistance;
2722 float lastMoveSpeed;
2723 Vector3 createLocation;
2724 void Created(GameObject *obj);
2725 void Enemy_Seen(GameObject *obj,GameObject *seen);
2726 void Timer_Expired(GameObject *obj,int number);
2727 void Killed(GameObject *obj,GameObject *killer);
2728 inline float GetSpeed(GameObject *player,float distance);
2729public:
2730 static int followPlayerId[5];
2731};
2732int JMG_Bear_Hunter_Engineer_Follow_Player_When_Near::followPlayerId[5] = {0};
2733
2734class JMG_Bear_Hunter_Engineer_AI : public ScriptImpClass {
2735 Vector3 repairSoldierVehicleTurret;
2736 float repairGunRange;
2737 float weaponRange;
2738 bool repairGun;
2739 int actionUpdate;
2740 int targetId;
2741 float targetDistance;
2742 int targetUpdate;
2743 int samePosition;
2744 int repairTargetId;
2745 Vector3 lastPos;
2746 Vector3 moveLocation;
2747 int lastRepairTargetId;
2748 GameObject *lastTarget;
2749 GameObject *lastSecondaryTarget;
2750 bool lastRepairTarget;
2751 bool lastUseRepairGun;
2752 void Created(GameObject *obj);
2753 void Enemy_Seen(GameObject *obj,GameObject *seen);
2754 void Timer_Expired(GameObject *obj,int number);
2755 void AttackTarget(GameObject *obj,GameObject *target,GameObject *secondaryTarget,bool repairTarget,bool useRepairGun);
2756 void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason);
2757 void Damaged(GameObject *obj,GameObject *damager,float damage);
2758 void Killed(GameObject *obj,GameObject *killer);
2759 bool inRange(GameObject *obj);
2760 inline bool Valid_Repair_Target(GameObject *obj,GameObject *target,int playerType);
2761public:
2762 static int scanAgainForEngineerDeaths;
2763 static int engineersDead;
2764 static int engineerIds[5];
2765 static bool engineerMode[5];
2766};
2767int JMG_Bear_Hunter_Engineer_AI::engineerIds[5] = {0};
2768int JMG_Bear_Hunter_Engineer_AI::engineersDead = 0;
2769int JMG_Bear_Hunter_Engineer_AI::scanAgainForEngineerDeaths = 0;
2770bool JMG_Bear_Hunter_Engineer_AI::engineerMode[5] = {false};
2771
2772class JMG_Bear_Hunter_Oil_Rig : public ScriptImpClass {
2773public:
2774 struct PumpjackNode
2775 {
2776 int pumpId;
2777 bool active;
2778 PumpjackNode()
2779 {
2780 this->pumpId = 0;
2781 this->active = false;
2782 }
2783 PumpjackNode(int pumpId)
2784 {
2785 this->pumpId = pumpId;
2786 this->active = false;
2787 }
2788 };
2789private:
2790 float intPayout;
2791 bool active;
2792 void Created(GameObject *obj);
2793 void Timer_Expired(GameObject *obj,int number);
2794 void Poked(GameObject *obj, GameObject *poker);
2795 void Killed(GameObject *obj,GameObject *killer);
2796public:
2797 static int oilRigCount;
2798 static PumpjackNode pumpJacks[7];
2799
2800};
2801int JMG_Bear_Hunter_Oil_Rig::oilRigCount = 0;
2802JMG_Bear_Hunter_Oil_Rig::PumpjackNode JMG_Bear_Hunter_Oil_Rig::pumpJacks[7] = {JMG_Bear_Hunter_Oil_Rig::PumpjackNode(0)};
2803
2804class JMG_Bear_Hunter_Damaged_Oil_Rig : public ScriptImpClass {
2805 bool repaired;
2806 void Created(GameObject *obj);
2807 void Damaged(GameObject *obj,GameObject *damager,float damage);
2808 void Killed(GameObject *obj,GameObject *killer);
2809public:
2810 static int rigCount;
2811};
2812int JMG_Bear_Hunter_Damaged_Oil_Rig::rigCount = 0;
2813
2814class JMG_Complete_Objective_On_Poke : public ScriptImpClass {
2815 void Poked(GameObject *obj, GameObject *poker);
2816};
2817class JMG_Bear_Hunter_Weapons_Container_Spawn_Point : public ScriptImpClass {
2818 void Created(GameObject *obj);
2819};
2820
2821class JMG_Bear_Hunter_Weapons_Container : public ScriptImpClass {
2822 Vector3 createLocation;
2823 void Created(GameObject *obj);
2824 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2825};
2826
2827class JMG_Bear_Hunter_Weapons_Container_Attached : public ScriptImpClass {
2828 bool drop;
2829 void Created(GameObject *obj);
2830 void Timer_Expired(GameObject *obj,int number);
2831 void Destroyed(GameObject *obj);
2832public:
2833 JMG_Bear_Hunter_Weapons_Container_Attached()
2834 {
2835 drop = true;
2836 }
2837};
2838
2839class JMG_Bear_Hunter_Giant_Deer_Boss : public ScriptImpClass {
2840 bool damaged;
2841 int returnHome;
2842 Vector3 lastPos;
2843 int PlayerCount;
2844 int CanHearDelay;
2845 int LastSeen;
2846 int currentTargetID;
2847 int waitcount;
2848 Vector3 homelocation;
2849 float speed;
2850 void Created(GameObject *obj);
2851 void Timer_Expired(GameObject *obj,int number);
2852 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2853 void Enemy_Seen(GameObject *obj,GameObject *seen);
2854 void Damaged(GameObject *obj,GameObject *damager,float damage);
2855 void Killed(GameObject *obj,GameObject *killer);
2856 void ReturnHome(GameObject *obj);
2857};
2858
2859class JMG_Bear_Hunter_Kill_Score_Tracker : public ScriptImpClass {
2860 void Killed(GameObject *obj,GameObject *killer);
2861};
2862
2863class JMG_Bear_Hunter_Powerup_Score_Control : public ScriptImpClass {
2864 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2865};
2866
2867class JMG_Bear_Hunter_Increase_Score_On_Poke : public ScriptImpClass {
2868 void Poked(GameObject *obj, GameObject *poker);
2869};
2870
2871class JMG_Bear_Hunter_Radio_Tower_Control : public ScriptImpClass {
2872 void Created(GameObject *obj);
2873 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2874public:
2875 static int radioTowerId;
2876 static bool destroyed;
2877};
2878int JMG_Bear_Hunter_Radio_Tower_Control::radioTowerId = 0;
2879bool JMG_Bear_Hunter_Radio_Tower_Control::destroyed = false;
2880
2881class JMG_Bear_Hunter_Radio_Tower_Switch : public ScriptImpClass {
2882 bool activated;
2883 void Created(GameObject *obj);
2884 void Poked(GameObject *obj, GameObject *poker);
2885public:
2886 static int supportId;
2887};
2888int JMG_Bear_Hunter_Radio_Tower_Switch::supportId = 0;
2889
2890class JMG_Bear_Hunter_Radio_Tower_Support : public ScriptImpClass {
2891 void Killed(GameObject *obj,GameObject *killer);
2892};
2893
2894class JMG_Bear_Hunter_Death_Water_Zone : public ScriptImpClass {
2895 void Entered(GameObject *obj,GameObject *enterer);
2896};
2897
2898class JMG_Bear_Hunter_Guardian_Aircraft : public ScriptImpClass {
2899 enum{SECONDARY_RELOADING,SECONDARY_READY,SECONDARY_SWITCHING,SECONDARY_ACTIVE} secondaryState;
2900 Rp2SimplePositionSystem::SimplePositionNode *DPNode;
2901 char primaryWeapon[256];
2902 bool hasSecondaryWeapon;
2903 int enemyID;
2904 int enemyTimeOutTime;
2905 int newPosTime;
2906 int putAwayTime;
2907 Vector3 lastPos;
2908 Vector3 movePos;
2909 bool usePrimary;
2910 float altReloadTime;
2911 float enemyDistance;
2912 bool secondaryReady;
2913 bool reloadingSecondary;
2914 int firstMove;
2915 void Created(GameObject *obj);
2916 void Timer_Expired(GameObject *obj,int number);
2917 void Enemy_Seen(GameObject *obj,GameObject *seen);
2918 void Animation_Complete(GameObject* obj,const char *anim);
2919 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2920 void Select_New_Location(GameObject *obj);
2921 void Attack_Move_Update(GameObject *obj);
2922 void Switch_Weapon(GameObject *obj,bool primary);
2923public:
2924 JMG_Bear_Hunter_Guardian_Aircraft()
2925 {
2926 DPNode = NULL;
2927 }
2928};
2929
2930class JMG_Bear_Hunter_Comanche : public ScriptImpClass {
2931 void Created(GameObject *obj);
2932 void Killed(GameObject *obj,GameObject *killer);
2933 void Destroyed(GameObject *obj);
2934public:
2935 static int id;
2936};
2937int JMG_Bear_Hunter_Comanche::id = 0;
2938
2939class JMG_Bear_Hunter_Comanche_Defense_Point : public ScriptImpClass {
2940 void Created(GameObject *obj);
2941};
2942
2943class JMG_Bear_Hunter_Defense_Gun_Beacon : public ScriptImpClass {
2944 void Created(GameObject *obj);
2945};
2946
2947class JMG_Bear_Hunter_Defense_Gun_Powerup : public ScriptImpClass {
2948 int Count;
2949 void Created(GameObject *obj);
2950 void Timer_Expired(GameObject *obj,int number);
2951 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2952 void Destroyed(GameObject *obj);
2953};
2954
2955class JMG_Bear_Hunter_Camera_Behavior : public ScriptImpClass {
2956 BearHunterScoreSystem::BHScoreNode *playerScoreNode;
2957 bool enabled;
2958 bool cameraActive;
2959 int EnemyID;
2960 int CameraFacingCount;
2961 int IncreaseOrDecreaseCount;
2962 int SeenTime;
2963 Vector3 CameraFacingLocation[5];
2964 float CameraFacingUpdateTime;
2965 void Created(GameObject *obj);
2966 void Enemy_Seen(GameObject *obj,GameObject *seen);
2967 void Timer_Expired(GameObject *obj,int number);
2968 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2969 void Poked(GameObject *obj,GameObject *poker);
2970 void Killed(GameObject *obj,GameObject *killer);
2971public:
2972 JMG_Bear_Hunter_Camera_Behavior()
2973 {
2974 playerScoreNode = NULL;
2975 }
2976};
2977
2978class JMG_Bear_Hunter_Sentry_Turret_Placement_Tester : public ScriptImpClass {
2979 void Created(GameObject *obj);
2980 void Timer_Expired(GameObject *obj,int number);
2981 void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason);
2982};
2983
2984class JMG_Powerup_Prez_Medical_Needle : public ScriptImpClass {
2985 void Created(GameObject *obj);
2986 void Custom(GameObject *obj,int message,int param,GameObject *sender);
2987};
2988
2989class JMG_Prez_Medical_Needle_Player_Control : public ScriptImpClass {
2990 Vector3 pickupLocation;
2991 void Created(GameObject *obj);
2992 void Killed(GameObject *obj,GameObject *killer);
2993 void Destroyed(GameObject *obj);
2994};
2995
2996class JMG_Prez_Cinematic_C130 : public ScriptImpClass {
2997 void Created(GameObject *obj);
2998};
2999
3000class JMG_Bear_Hunter_Power_Transformer : public ScriptImpClass {
3001 int lastHealthPercent;
3002 bool objectiveActive;
3003 time_t announceTime;
3004 void Created(GameObject *obj);
3005 void Damaged(GameObject *obj,GameObject *damager,float damage);
3006 void ToggleTurrets(bool enabled);
3007 void UpdateHealthDisplays(float shieldStrength);
3008 void UpdateMCTs(int team);
3009public:
3010 static bool online;
3011 static int mctIds[2];
3012};
3013bool JMG_Bear_Hunter_Power_Transformer::online = true;
3014int JMG_Bear_Hunter_Power_Transformer::mctIds[2] = {0};
3015
3016class JMG_Bear_Hunter_Power_Transformer_MCT : public ScriptImpClass {
3017 void Damaged(GameObject *obj,GameObject *damager,float damage);
3018};
3019
3020class AiPlayerRespawnController
3021{
3022private:
3023 struct AiPlayerRespawnNode
3024 {
3025 int id;
3026 float spawnTime;
3027 bool spawning;
3028 AiPlayerRespawnNode *next;
3029 };
3030 AiPlayerRespawnNode *newRespawnNode(AiPlayerRespawnNode *Node,int id)
3031 {
3032 playerCount++;
3033 Node->id = id;
3034 Node->spawnTime = 0.0f;
3035 Node->spawning = false;
3036 Node->next = NULL;
3037 return Node;
3038 }
3039 void AddAPlayer(int id)
3040 {
3041 if (!AiPlayerRespawnNodeList)
3042 {
3043 AiPlayerRespawnNodeList = newRespawnNode(new AiPlayerRespawnNode(),id);
3044 return;
3045 }
3046 AiPlayerRespawnNode *Current = AiPlayerRespawnNodeList;
3047 while (Current)
3048 {
3049 if (Current->id == id)
3050 return;
3051 Current = Current->next;
3052 }
3053 Current = AiPlayerRespawnNodeList;
3054 while (Current)
3055 {
3056 if (!Current->id)
3057 {
3058 playerCount++;
3059 Current->id = id;
3060 Current->spawnTime = 0.0f;
3061 Current->spawning = false;
3062 return;
3063 }
3064 if (!Current->next)
3065 {
3066 Current->next = newRespawnNode(new AiPlayerRespawnNode(),id);
3067 return;
3068 }
3069 Current = Current->next;
3070 }
3071 return;
3072 }
3073 void RemoveAPlayer(int id)
3074 {
3075 if (!AiPlayerRespawnNodeList || !id)
3076 return;
3077 AiPlayerRespawnNode *Current = AiPlayerRespawnNodeList;
3078 while (Current)
3079 {
3080 if (Current->id == id)
3081 {
3082 Current->spawning = false;
3083 Current->id = 0;
3084 playerCount--;
3085 return;
3086 }
3087 Current = Current->next;
3088 }
3089 }
3090 AiPlayerRespawnNode *FindAPlayer(int id)
3091 {
3092 if (!AiPlayerRespawnNodeList)
3093 return NULL;
3094 AiPlayerRespawnNode *Current = AiPlayerRespawnNodeList;
3095 while (Current)
3096 {
3097 if (Current->id == id)
3098 return Current;
3099 Current = Current->next;
3100 }
3101 return NULL;
3102 }
3103 void UpdatePlayerSpawnList()
3104 {
3105 AiPlayerRespawnNode *Current = AiPlayerRespawnNodeList;
3106 while (Current)
3107 {
3108 if (Current->spawning)
3109 {
3110 Current->spawnTime -= 0.1f;
3111 if (Current->spawnTime <= 0.0f)
3112 RemoveAPlayer(Current->id);
3113 }
3114 Current = Current->next;
3115 }
3116 }
3117public:
3118 AiPlayerRespawnNode *AiPlayerRespawnNodeList;
3119 int playerCount;
3120 AiPlayerRespawnController()
3121 {
3122 AiPlayerRespawnNodeList = NULL;
3123 ClearList();
3124 }
3125 void ClearList()
3126 {
3127 if (!AiPlayerRespawnNodeList)
3128 return;
3129 playerCount = 0;
3130 AiPlayerRespawnNode *temp,*die;
3131 temp = AiPlayerRespawnNodeList;
3132 while (temp != NULL)
3133 {
3134 die = temp;
3135 temp = temp->next;
3136 delete die;
3137 }
3138 AiPlayerRespawnNodeList = NULL;
3139 }
3140 void PlayerCreate(int id)
3141 {
3142 AddAPlayer(id);
3143 }
3144 void PlayerDeath(int id,int EnemyTeamPlayerCount,float RespawnTime)
3145 {
3146 if (!AiPlayerRespawnNodeList)
3147 return;
3148 if (EnemyTeamPlayerCount >= playerCount)
3149 {
3150 AiPlayerRespawnNode *Node = FindAPlayer(id);
3151 if (!Node)
3152 return;
3153 Node->spawnTime = RespawnTime;
3154 Node->spawning = true;
3155 }
3156 else
3157 RemoveAPlayer(id);
3158 }
3159 void KillAll()
3160 {
3161 playerCount = 0;
3162 if (!AiPlayerRespawnNodeList)
3163 return;
3164 AiPlayerRespawnNode *Current = AiPlayerRespawnNodeList;
3165 while (Current)
3166 {
3167 GameObject *Bot = Commands->Find_Object(Current->id);
3168 if (Bot)
3169 Commands->Destroy_Object(Bot);
3170 Current = Current->next;
3171 }
3172 }
3173 void UpdateTeamAndSpawnCount(int enemyCount,GameObject *(SpawnObject)())
3174 {
3175 UpdatePlayerSpawnList();
3176 for (int x = playerCount;x < enemyCount;x++)
3177 AddAPlayer(Commands->Get_ID(SpawnObject()));
3178 }
3179 int TotalSpawnedPlayers()
3180 {
3181 int Count = 0;
3182 AiPlayerRespawnNode *Current = AiPlayerRespawnNodeList;
3183 while (Current)
3184 {
3185 GameObject *Bot = Commands->Find_Object(Current->id);
3186 if (Bot)
3187 Count++;
3188 Current = Current->next;
3189 }
3190 return Count;
3191 }
3192 void SendCustomToAllMembers(int message,int param,float delay,GameObject *sender = NULL)
3193 {
3194 AiPlayerRespawnNode *Current = AiPlayerRespawnNodeList;
3195 while (Current)
3196 {
3197 GameObject *Bot = Commands->Find_Object(Current->id);
3198 if (Bot)
3199 Commands->Send_Custom_Event(sender ? sender : Bot,Bot,message,param,delay);
3200 Current = Current->next;
3201 }
3202 }
3203};
3204AiPlayerRespawnController AiMutantRespawnSystem = AiPlayerRespawnController();
3205
3206class JMG_Bear_Hunter_Mutant_Respawn_Tracker : public ScriptImpClass {
3207 void Killed(GameObject *obj,GameObject *killer);
3208 void Destroyed(GameObject *obj);
3209};
3210class JMG_Wandering_AI : public ScriptImpClass {
3211 bool damaged;
3212 int returnHome;
3213 Vector3 lastPos;
3214 Vector3 homelocation;
3215 int PlayerCount;
3216 int CanHearDelay;
3217 int LastSeen;
3218 int currentTargetID;
3219 int secondaryEnemyId;
3220 int lastSeenSecondary;
3221 int waitcount;
3222 float speed;
3223 bool huntEnemy;
3224 int vehicleChaseTime;
3225 int vehicleChaseTimeReset;
3226 int maxVehicleChaseTime;
3227 int wanderDelay;
3228 void Created(GameObject *obj);
3229 void Timer_Expired(GameObject *obj,int number);
3230 void Custom(GameObject *obj,int message,int param,GameObject *sender);
3231 void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason);
3232 void Enemy_Seen(GameObject *obj,GameObject *seen);
3233 void Damaged(GameObject *obj,GameObject *damager,float damage);
3234 void SoundDHeard(GameObject *obj,const CombatSound &sound);
3235 Vector3 GetRandomPosition();
3236public:
3237 static Vector3 AllowedSoundPos;
3238 static bool CanInvestigateSound;
3239};
3240Vector3 JMG_Wandering_AI::AllowedSoundPos = Vector3(0.0f,0.0f,0.0f);
3241bool JMG_Wandering_AI::CanInvestigateSound = true;
3242
3243class JMG_Wandering_AI_Controller : public ScriptImpClass {
3244 void Destroyed(GameObject *obj);
3245 void Detach(GameObject *obj);
3246public:
3247 static Rp2SimplePositionSystem wanderPoints;
3248 static bool setup;
3249 JMG_Wandering_AI_Controller()
3250 {
3251 wanderPoints = Rp2SimplePositionSystem();
3252 JMG_Wandering_AI_Controller::setup = true;
3253 }
3254};
3255Rp2SimplePositionSystem JMG_Wandering_AI_Controller::wanderPoints;
3256bool JMG_Wandering_AI_Controller::setup = false;
3257
3258class JMG_Wandering_AI_Wander_Point : public ScriptImpClass {
3259 void Created(GameObject *obj);
3260};
3261class JMG_Wandering_AI_Wander_Point_Dont_Remove : public ScriptImpClass {
3262 void Created(GameObject *obj);
3263};
3264class JMG_Wandering_AI_Wander_Point_Mobile : public ScriptImpClass {
3265 Rp2SimplePositionSystem::SimplePositionNode *node;
3266 int faceObjectId;
3267 void Created(GameObject *obj);
3268 void Timer_Expired(GameObject *obj,int number);
3269};
3270class JMG_Utility_Custom_Spawn_System_Controller : public ScriptImpClass {
3271 void Destroyed(GameObject *obj);
3272public:
3273 static Rp2SimplePositionSystem spawnPoints;
3274 static bool setup;
3275 JMG_Utility_Custom_Spawn_System_Controller()
3276 {
3277 JMG_Utility_Custom_Spawn_System_Controller::setup = true;
3278 spawnPoints = Rp2SimplePositionSystem();
3279 }
3280};
3281Rp2SimplePositionSystem JMG_Utility_Custom_Spawn_System_Controller::spawnPoints;
3282bool JMG_Utility_Custom_Spawn_System_Controller::setup = false;
3283
3289class JMG_Utility_Custom_Spawn_System_Point : public ScriptImpClass {
3290 void Created(GameObject *obj);
3291};
3292
3298class JMG_Utility_Custom_Spawn_System : public ScriptImpClass {
3299 bool enabled;
3300 int totalChance;
3301 int eachChance[10];
3302 bool available[10];
3303 int avaliableToSpawn;
3304 int spawnLimit;
3305 void Created(GameObject *obj);
3306 void Timer_Expired(GameObject *obj,int number);
3307 void Custom(GameObject *obj,int message,int param,GameObject *sender);
3308 GameObject *Create_Preset(Vector3 location);
3309};
3310
3311class JMG_Utility_Custom_Spawn_System_Attached : public ScriptImpClass {
3312 void Destroyed(GameObject *obj);
3313};
3314
3315class JMG_Bear_Hunter_Player_Count_Scaled_Object_Health : public ScriptImpClass {
3316 float originalMaxHealth;
3317 float originalPoints;
3318 bool damaged;
3319 int PlayerCount;
3320 void Created(GameObject *obj);
3321 void Timer_Expired(GameObject *obj,int number);
3322 void Damaged(GameObject *obj,GameObject *damager,float damage);
3323};
3324class BearHunterWolfHivemindSystem
3325{
3326public:
3327 int controllerId;
3328 struct BearHunterWolfHivemindNode
3329 {
3330 int id;
3331 char presetName[256];
3332 Vector3 territoryCenterSpot;
3333 float territoryRange;
3334 int maxPackSize;
3335 int secondaryTargetId;
3336 Vector3 targetWanderPosition;
3337 bool huntEnemy;
3338 int currentPackSize;
3339 int livingCount;
3340 int lastSeenSecondary;
3341 bool heardSound;
3342 Vector3 soundHeardPos;
3343 int soundId;
3344 int wanderTime;
3345 int randomWanderTime;
3346 int currentWanderTime;
3347 float respawnTime;
3348 float respawnTimeRandom;
3349 float listenerScale;
3350 bool hearsGlobalSounds;
3351 Rp2SimplePositionSystem wanderPositionNodes;
3352 struct BearHunterWolfHivemindNode *next;
3353 BearHunterWolfHivemindNode(int id,const char *presetName,int maxPackSize,Vector3 territoryCenterSpot,float territoryRange,int wanderTime,int randomWanderTime,float respawnTime,float respawnTimeRandom,float listenerScale,bool hearsGlobalSounds)
3354 {
3355 this->id = id;
3356 sprintf(this->presetName,"%s",presetName);
3357 this->territoryCenterSpot = territoryCenterSpot;
3358 this->territoryRange = territoryRange;
3359 this->maxPackSize = maxPackSize;
3360 this->targetWanderPosition = territoryCenterSpot;
3361 this->wanderTime = wanderTime;
3362 this->randomWanderTime = randomWanderTime;
3363 currentWanderTime = wanderTime + (randomWanderTime ? Commands->Get_Random_Int(-randomWanderTime,randomWanderTime) : 0);
3364 this->secondaryTargetId = 0;
3365 this->lastSeenSecondary = 0;
3366 this->heardSound = false;
3367 this->soundHeardPos = Vector3();
3368 this->soundId = 0;
3369 this->huntEnemy = false;
3370 this->currentPackSize = 0;
3371 this->livingCount = 0;
3372 this->respawnTime = respawnTime;
3373 this->respawnTimeRandom = respawnTimeRandom;
3374 this->listenerScale = listenerScale;
3375 this->hearsGlobalSounds = hearsGlobalSounds;
3376 this->wanderPositionNodes = Rp2SimplePositionSystem();
3377 this->next = NULL;
3378 }
3379 };
3380private:
3381 BearHunterWolfHivemindNode *BearHunterWolfHivemindNodeList;
3382public:
3383 BearHunterWolfHivemindSystem()
3384 {
3385 BearHunterWolfHivemindNodeList = NULL;
3386 }
3387 bool addNode(int id,const char *presetName,int maxPackSize,Vector3 territoryCenterSpot,float territoryRange,int wanderTime,int randomWanderTime,float respawnTime,float respawnTimeRandom,float listenerScale,bool hearsGlobalSounds)
3388 {
3389 BearHunterWolfHivemindNode *current = BearHunterWolfHivemindNodeList;
3390 if (!BearHunterWolfHivemindNodeList)
3391 {
3392 BearHunterWolfHivemindNodeList = new BearHunterWolfHivemindNode(id,presetName,maxPackSize,territoryCenterSpot,territoryRange,wanderTime,randomWanderTime,respawnTime,respawnTimeRandom,listenerScale,hearsGlobalSounds);
3393 return true;
3394 }
3395 while (current)
3396 {
3397 if (current->id == id)
3398 return false;
3399 if (!current->next)
3400 {
3401 current->next = new BearHunterWolfHivemindNode(id,presetName,maxPackSize,territoryCenterSpot,territoryRange,wanderTime,randomWanderTime,respawnTime,respawnTimeRandom,listenerScale,hearsGlobalSounds);
3402 return true;
3403 }
3404 current = current->next;
3405 }
3406 return false;
3407 };
3408 BearHunterWolfHivemindNode *find(int id)
3409 {
3410 BearHunterWolfHivemindNode *Current = BearHunterWolfHivemindNodeList;
3411 while (Current)
3412 {
3413 if (Current->id == id)
3414 return Current;
3415 Current = Current->next;
3416 }
3417 return BearHunterWolfHivemindNodeList;
3418 }
3419 bool update()
3420 {
3421 BearHunterWolfHivemindNode *current = BearHunterWolfHivemindNodeList;
3422 while (current)
3423 {
3424 if (!current->livingCount)
3425 {
3426 current->secondaryTargetId = 0;
3427 current->heardSound = false;
3428 }
3429 if (current->lastSeenSecondary)
3430 {
3431 current->lastSeenSecondary--;
3432 if (!current->lastSeenSecondary)
3433 current->secondaryTargetId = 0;
3434 }
3435 if (current->currentWanderTime)
3436 {
3437 current->currentWanderTime--;
3438 if (!current->currentWanderTime)
3439 {
3440 Vector3 pos = Vector3();
3441 Rp2SimplePositionSystem::SimplePositionNode *spn = current->wanderPositionNodes.GetRandom();
3442 current->targetWanderPosition = (spn ? spn->position : current->territoryCenterSpot);
3443 current->currentWanderTime = current->wanderTime + (current->randomWanderTime ? Commands->Get_Random_Int(-current->randomWanderTime,current->randomWanderTime) : 0);
3444 }
3445 }
3446 if (current->currentPackSize < current->maxPackSize)
3447 {
3448 Vector3 createLocation = current->targetWanderPosition;
3449 if (Get_Random_Pathfind_Spot(createLocation,25.0f,&createLocation))
3450 {
3451 GameObject *packMember = Commands->Create_Object(current->presetName,createLocation);
3452 char params[512];
3453 sprintf(params,"%d,%d",current->id,controllerId);
3454 Commands->Attach_Script(packMember,"JMG_Bear_Hunter_Wolf",params);
3455 Commands->Attach_Script(packMember,"JMG_Bear_Hunter_Give_AI_Cash_For_Kills","");
3456 MoveablePhysClass *mphys = packMember->As_PhysicalGameObj() ? packMember->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass() : NULL;
3457 if (mphys && !mphys->Can_Teleport(Matrix3D(createLocation)))
3458 {
3459 mphys->Find_Teleport_Location(createLocation,2.5f,&createLocation);
3460 Commands->Set_Position(packMember,createLocation);
3461 }
3462 }
3463 }
3464 current = current->next;
3465 }
3466 return false;
3467 };
3468 void Empty_List()
3469 {
3470 BearHunterWolfHivemindNode *temp,*die;
3471 temp = BearHunterWolfHivemindNodeList;
3472 while (temp)
3473 {
3474 die = temp;
3475 temp = temp->next;
3476 die->wanderPositionNodes.Empty_List();
3477 delete die;
3478 }
3479 BearHunterWolfHivemindNodeList = NULL;
3480 }
3481};
3482BearHunterWolfHivemindSystem bearHunterWolfHivemindControl = BearHunterWolfHivemindSystem();
3483class JMG_Bear_Hunter_Wolf_Pack_Definition : public ScriptImpClass {
3484 void Created(GameObject *obj);
3485};
3486class JMG_Bear_Hunter_Wolf_Pack_Controller : public ScriptImpClass {
3487 void Created(GameObject *obj);
3488 void Timer_Expired(GameObject *obj,int number);
3489 void Custom(GameObject *obj,int message,int param,GameObject *sender);
3490 void Destroyed(GameObject *obj);
3491};
3492class JMG_Bear_Hunter_Wolf : public ScriptImpClass {
3493 BearHunterWolfHivemindSystem::BearHunterWolfHivemindNode *controller;
3494 bool damaged;
3495 int returnHome;
3496 Vector3 lastPos;
3497 int PlayerCount;
3498 int CanHearDelay;
3499 int waitcount;
3500 float speed;
3501 int returnHomeDelay;
3502 int vehicleChaseTime;
3503 int vehicleChaseTimeReset;
3504 int maxVehicleChaseTime;
3505 int soundUpdate;
3506 int currentTargetId;
3507 int lastSeen;
3508 Vector3 targetPosition;
3509 void Created(GameObject *obj);
3510 void Timer_Expired(GameObject *obj,int number);
3511 void Custom(GameObject *obj,int message,int param,GameObject *sender);
3512 void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason);
3513 void Enemy_Seen(GameObject *obj,GameObject *seen);
3514 void Damaged(GameObject *obj,GameObject *damager,float damage);
3515 void SoundDHeard(GameObject *obj,const CombatSound &sound);
3516 void Destroyed(GameObject *obj);
3517public:
3518 JMG_Bear_Hunter_Wolf()
3519 {
3520 controller = NULL;
3521 }
3522};
3523class JMG_Bear_Hunter_Wolf_Wander_Point : public ScriptImpClass {
3524 void Created(GameObject *obj);
3525 void Timer_Expired(GameObject *obj,int number);
3526};
3527
3528class JMG_Bear_Hunter_Armored_Car : public ScriptImpClass {
3529 void Created(GameObject *obj);
3530 void Timer_Expired(GameObject *obj,int number);
3531 void Custom(GameObject *obj,int message,int param,GameObject *sender);
3532 void Destroyed(GameObject *obj);
3533public:
3534 JMG_Bear_Hunter_Armored_Car()
3535 {
3536 ownerNode = NULL;
3537 }
3538 bool lightsOn;
3539 int effectRangeId;
3540 BearHunterScoreSystem::BHScoreNode *ownerNode;
3541};
3542
3543class JMG_Bear_Hunter_Armored_Car_Controller : public ScriptImpClass {
3544 void Created(GameObject *obj);
3545 void Timer_Expired(GameObject *obj,int number);
3546 void ArmoredCarSupport(GameObject *obj,BearHunterScoreSystem::BHScoreNode *ownerNode);
3547 void RegenHp(GameObject *obj,BearHunterScoreSystem::BHScoreNode *ownerNode);
3548 void GrantScore(const char *playerName,float score);
3549 void DecideScoreVehicleOrInfantry(GameObject *obj,GameObject *owner,BearHunterScoreSystem::BHScoreNode *ownerNode,float grantHp);
3550 void GrantVehicleRepairScore(GameObject *obj,GameObject *owner,BearHunterScoreSystem::BHScoreNode *ownerNode,float grantHp);
3551 void GrantInfantryRepairScore(GameObject *obj,GameObject *owner,BearHunterScoreSystem::BHScoreNode *ownerNode,float grantHp);
3552};
3553
3554class JMG_Bear_Hunt_Final_Boss_Support : public ScriptImpClass {
3555 float lastHealth;
3556 float lastArmor;
3557 int jumperId;
3558 void Created(GameObject *obj);
3559 void Timer_Expired(GameObject *obj,int number);
3560 void Damaged(GameObject *obj,GameObject *damager,float damage);
3561};
3562
3563class JMG_Bear_Hunter_Golden_Deer_Statue : public ScriptImpClass {
3564 void Created(GameObject *obj);
3565 void Custom(GameObject *obj,int message,int param,GameObject *sender);
3566public:
3567 static int playerWithTheStatue;
3568 static int tinyDeerIds[25];
3569 static int statueId;
3570};
3571
3572class JMG_Bear_Hunter_Golden_Deer_Statue_Standin : public ScriptImpClass {
3573 void Created(GameObject *obj);
3574 void Timer_Expired(GameObject *obj,int number);
3575};
3576
3577class JMG_Bear_Hunter_Golden_Deer_Statue_Attached : public ScriptImpClass {
3578 void Created(GameObject *obj);
3579 void Timer_Expired(GameObject *obj,int number);
3580 void Destroyed(GameObject *obj);
3581};
3582
3583class JMG_Bear_Hunter_AI_Avoid_Enemies : public ScriptImpClass {
3584 int closestEnemyId;
3585 float enemyDist;
3586 int seenTime;
3587 Vector3 movePosition;
3588 void Created(GameObject *obj);
3589 void Enemy_Seen(GameObject *obj,GameObject *seen);
3590 void Timer_Expired(GameObject *obj,int number);
3591 void Damaged(GameObject *obj,GameObject *damager,float damage);
3592 void Killed(GameObject *obj,GameObject *killer);
3593 void Destroyed(GameObject *obj);
3594 void GotoLocation(GameObject *obj,const Vector3 &pos,GameObject *Enemy,float speed);
3595 void setRetreatLocation(GameObject *obj,GameObject *enemy);
3596 void getRandomLocation(GameObject *obj);
3597public:
3598 bool mouse;
3599 static int wildAnimalCount;
3600 static int mouseAnimalCount;
3601};
3602
3603class JMG_Security_Camera_Behavior_Ignore : public ScriptImpClass {
3604 void Created(GameObject *obj);
3605};
3606
3607class JMG_Bear_Hunter_Friendly_Cougar : public ScriptImpClass {
3608 int gotoId;
3609 float noPathfindRange;
3610 int LastSeen;
3611 int lastSeenSecondary;
3612 int currentTargetID;
3613 int secondaryTargetId;
3614 int huntorattack;
3615 int waitcount;
3616 Vector3 homelocation;
3617 float speed;
3618 int minVisibilityTime;
3619 int maxVisibilityTime;
3620 float maxHuntDistance;
3621 Vector3 lastPos;
3622 int stuckTime;
3623 bool movingSlow;
3624 void Created(GameObject *obj);
3625 void Timer_Expired(GameObject *obj,int number);
3626 void Enemy_Seen(GameObject *obj,GameObject *seen);
3627 void Damaged(GameObject *obj,GameObject *damager,float damage);
3628 bool chooseTarget(GameObject *obj,GameObject *damager,int *compareId,int *seenTimer);
3629 void FollowPlayer(GameObject *obj,bool moveSlow);
3630};
3631
3632class JMG_Bear_Hunter_SpawnPoint_Final_Boss_Line_Of_Sight : public ScriptImpClass {
3633 void Created(GameObject *obj);
3634};
3635
3636class JMG_Bear_Hunter_SpawnPoint_Final_Boss : public ScriptImpClass {
3637 void Created(GameObject *obj);
3638};
3639
3640class JMG_Bear_Hunter_PumpJack_Beacon : public ScriptImpClass {
3641 void Created(GameObject *obj);
3642};
3643
3644class JMG_Bear_Hunter_PumpJack_Powerup : public ScriptImpClass {
3645 int Count;
3646 void Created(GameObject *obj);
3647 void Timer_Expired(GameObject *obj,int number);
3648 void Custom(GameObject *obj,int message,int param,GameObject *sender);
3649 void Destroyed(GameObject *obj);
3650};
3651
3652class JMG_Bear_Hunter_Portable_Pumpjack : public ScriptImpClass {
3653 BearHunterScoreSystem::BHScoreNode *playerScoreNode;
3654 float intPayout;
3655 float giveMoney;
3656 void Created(GameObject *obj);
3657 void Timer_Expired(GameObject *obj,int number);
3658 void Killed(GameObject *obj,GameObject *killer);
3659};
3660
3661class JMG_Bear_Hunter_PumpJack_Detect_Oil : public ScriptImpClass {
3662 int playerId;
3663 void Created(GameObject *obj);
3664 void Timer_Expired(GameObject *obj,int number);
3665 static float FindClosestPumpjack(GameObject *obj);
3666public:
3667 static float CalculateEffectiveness(GameObject *obj);
3668};
3669
3670class JMG_Bear_Hunter_Milk_Drink : public ScriptImpClass {
3671 void Created(GameObject *obj);
3672};
3673
3674class JMG_Bear_Hunter_AI_Guardian_Generic : public ScriptImpClass {
3675 float fireRange;
3676 float flightHeight;
3677 float arriveDistance;
3678 float arriveDistanceSq;
3679 Vector3 dpPosition;
3680 int EnemyID;
3681 int EnemyTimeOutTime;
3682 Vector3 LastPos;
3683 bool primaryFire;
3684 int stealthModeOverride;
3685 void Created(GameObject *obj);
3686 void Timer_Expired(GameObject *obj,int number);
3687 void Enemy_Seen(GameObject *obj,GameObject *seen);
3688 void Damaged(GameObject *obj,GameObject *damager,float damage);
3689 void Goto_Location(GameObject *obj);
3690 bool Get_A_Defense_Point(Vector3 *position);
3691};
3692
3693class JMG_Bear_Hunter_Give_AI_Cash_For_Kills : public ScriptImpClass {
3694 void Killed(GameObject *obj,GameObject *killer);
3695};
3696
3706 Rp2SimplePositionSystem::SimplePositionNode *node;
3707 int followObjectId;
3708 char presetName[128];
3709 char weaponName[128];
3710 void Created(GameObject *obj);
3711 void Timer_Expired(GameObject *obj,int number);
3712 GameObject *FindTargetObject(GameObject *obj);
3713};
3714
3715class JMG_Bear_Hunter_Turkey : public ScriptImpClass {
3716 void Killed(GameObject *obj,GameObject *killer);
3717};
3718
3724class JMG_Security_Camera_Behavior_Target : public ScriptImpClass {
3725 void Created(GameObject *obj);
3726};
Definition jmgBearHunter.h:3724
Remake of RMV_Camera_Behavior with more settings and more user control.
Definition jmgBearHunter.h:2297
This defines a spawn point for JMG_Utility_Custom_Spawn_System, each group id defines what group the ...
Definition jmgBearHunter.h:3289
A more complicated spawn system, this allows for defining presets you wish to use with precent chance...
Definition jmgBearHunter.h:3298
Makes a wander point follow an object on the map \GroupId - ID of the group the point belongs to \Pre...
Definition jmgBearHunter.h:3705