Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RadioMessage.cpp
Go to the documentation of this file.
1 /* Project Starshatter 4.5
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: RadioMessage.cpp
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Radio communication message class implementation
13 */
14 
15 #include "MemDebug.h"
16 #include "RadioMessage.h"
17 #include "Ship.h"
18 #include "Text.h"
19 
20 // +----------------------------------------------------------------------+
21 
22 RadioMessage::RadioMessage(Ship* dst, const Ship* s, int a)
23 : dst_ship(dst), dst_elem(0), sender(s), action(a), channel(0)
24 {
25  if (s)
26  channel = s->GetIFF();
27 }
28 
29 RadioMessage::RadioMessage(Element* dst, const Ship* s, int a)
30 : dst_ship(0), dst_elem(dst), sender(s), action(a), channel(0)
31 {
32  if (s)
33  channel = s->GetIFF();
34 }
35 
37 : dst_ship(rm.dst_ship), dst_elem(rm.dst_elem),
38 sender(rm.sender), action(rm.action), channel(rm.channel),
39 info(rm.info), location(rm.location)
40 {
41  if (rm.target_list.size() > 0) {
42  for (int i = 0; i < rm.target_list.size(); i++) {
43  SimObject* obj = rm.target_list.at(i);
44  target_list.append(obj);
45  }
46  }
47 }
48 
50 { }
51 
52 // +----------------------------------------------------------------------+
53 
54 const char*
56 {
57  if (a == ACK) {
58  int coin = rand();
59  if (coin < 10000) return "Acknowledged";
60  if (coin < 17000) return "Roger that";
61  if (coin < 20000) return "Understood";
62  if (coin < 22000) return "Copy that";
63  return "Affirmative";
64  }
65 
66  if (a == DISTRESS) {
67  int coin = rand();
68  if (coin < 15000) return "Mayday! Mayday!";
69  if (coin < 18000) return "She's breaking up!";
70  if (coin < 21000) return "Checking out!";
71  return "We're going down!";
72  }
73 
74  if (a == WARN_ACCIDENT) {
75  int coin = rand();
76  if (coin < 15000) return "Check your fire!";
77  if (coin < 18000) return "Watch it!";
78  if (coin < 21000) return "Hey! We're on your side!";
79  return "Confirm your targets!";
80  }
81 
82  if (a == WARN_TARGETED) {
83  int coin = rand();
84  if (coin < 15000) return "Break off immediately!";
85  if (coin < 20000) return "Buddy spike!";
86  return "Abort! Abort!";
87  }
88 
89  switch (a) {
90  case NONE: return "";
91 
92  case NACK: return "Negative, Unable";
93 
94  case ATTACK: return "Engage";
95  case ESCORT: return "Escort";
96  case BRACKET: return "Bracket";
97  case IDENTIFY: return "Identify";
98 
99  case COVER_ME: return "Cover Me";
100  case MOVE_PATROL: return "Vector";
101  case SKIP_NAVPOINT: return "Skip Navpoint";
102  case RESUME_MISSION: return "Resume Mission";
103  case RTB: return "Return to Base";
104  case DOCK_WITH: return "Dock With";
105  case QUANTUM_TO: return "Jump to";
106  case FARCAST_TO: return "Farcast to";
107 
108  case GO_DIAMOND: return "Goto Diamond Formation";
109  case GO_SPREAD: return "Goto Spread Formation";
110  case GO_BOX: return "Goto Box Formation";
111  case GO_TRAIL: return "Goto Trail Formation";
112 
113  case WEP_FREE: return "Break and Attack";
114  case WEP_HOLD: return "Hold All Weapons";
115  case FORM_UP: return "Return to Formation";
116  case SAY_POSITION: return "Say Your Position";
117 
118  case LAUNCH_PROBE: return "Launch Probe";
119  case GO_EMCON1: return "Goto EMCON 1";
120  case GO_EMCON2: return "Goto EMCON 2";
121  case GO_EMCON3: return "Goto EMCON 3";
122 
123  case REQUEST_PICTURE: return "Request Picture";
124  case REQUEST_SUPPORT: return "Request Support";
125  case PICTURE: return "Picture is clear";
126 
127  case CALL_INBOUND: return "Calling Inbound";
128  case CALL_APPROACH: return "Roger your approach";
129  case CALL_CLEARANCE: return "You have clearance";
130  case CALL_FINALS: return "On final approach";
131  case CALL_WAVE_OFF: return "Wave off - Runway is closed";
132 
133  case DECLARE_ROGUE: return "Prepare to be destroyed!";
134 
135  case CALL_ENGAGING: return "Engaging";
136  case FOX_1: return "Fox One!";
137  case FOX_2: return "Fox Two!";
138  case FOX_3: return "Fox Three!";
139  case SPLASH_1: return "Splash One!";
140  case SPLASH_2: return "Splash Two!";
141  case SPLASH_3: return "Splash Three!";
142  case SPLASH_4: return "Splash Four!";
143  case SPLASH_5: return "Target Destroyed!";
144  case SPLASH_6: return "Enemy Destroyed!";
145  case SPLASH_7: return "Confirmed Kill!";
146  case BREAK_ORBIT: return "Breaking Orbit";
147  case MAKE_ORBIT: return "Heading for Orbit";
148  case QUANTUM_JUMP: return "Going Quantum";
149 
150  default: return "Unknown";
151  }
152 }
153 
154 // +----------------------------------------------------------------------+
155 
156 void
158 {
159  if (obj && !target_list.contains(obj)) {
160  target_list.append(obj);
161  }
162 }
163 
164 
165