FS2_Open
Open source remastering of the Freespace 2 engine
shipspecialdamage.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 // ShipSpecialDamage.cpp : implementation file
11 //
12 
13 #include "stdafx.h"
14 #include "FRED.h"
15 #include "ShipSpecialDamage.h"
16 #include "globalincs/linklist.h"
17 #include "parse/sexp.h"
18 #include "FREDDoc.h"
19 
20 #ifdef _DEBUG
21 #undef THIS_FILE
22 static char THIS_FILE[] = __FILE__;
23 #endif
24 
26 // ShipSpecialDamage dialog
27 
28 
29 ShipSpecialDamage::ShipSpecialDamage(CWnd* pParent /*=NULL*/)
30  : CDialog(ShipSpecialDamage::IDD, pParent)
31 {
32  //{{AFX_DATA_INIT(ShipSpecialDamage)
33  //}}AFX_DATA_INIT
34 }
35 
36 
37 void ShipSpecialDamage::DoDataExchange(CDataExchange* pDX)
38 {
39  CDialog::DoDataExchange(pDX);
40  //{{AFX_DATA_MAP(ShipSpecialDamage)
41  DDX_Check(pDX, IDC_ENABLE_SHOCKWAVE, m_shock_enabled);
44  DDX_Text(pDX, IDC_SPECIAL_INNER_RAD, m_inner_rad);
45  DDV_MinMaxInt(pDX, m_inner_rad, 1, INT_MAX);
46  DDX_Text(pDX, IDC_SPECIAL_OUTER_RAD, m_outer_rad);
47  DDV_MinMaxInt(pDX, m_outer_rad, 2, INT_MAX);
48  DDX_Text(pDX, IDC_SPECIAL_DAMAGE, m_damage);
49  DDV_MinMaxInt(pDX, m_damage, 0, INT_MAX);
50  DDX_Text(pDX, IDC_SPECIAL_SHOCK_SPEED, m_shock_speed);
51  DDV_MinMaxInt(pDX, m_shock_speed, 0, INT_MAX);
52  DDX_Text(pDX, IDC_SPECIAL_DEATHROLL_TIME, m_duration);
53  DDV_MinMaxInt(pDX, m_duration, 0, INT_MAX);
54  DDX_Text(pDX, IDC_SPECIAL_BLAST, m_blast);
55  DDV_MinMaxInt(pDX, m_blast, 0, INT_MAX);
56  //}}AFX_DATA_MAP
57 }
58 
59 
60 BEGIN_MESSAGE_MAP(ShipSpecialDamage, CDialog)
61  //{{AFX_MSG_MAP(ShipSpecialDamage)
62  ON_BN_CLICKED(IDC_ENABLE_SHOCKWAVE, OnEnableShockwave)
63  ON_BN_CLICKED(IDC_ENABLE_DEATHROLL_TIME, OnEnableDeathrollTime)
64  ON_BN_CLICKED(IDC_ENABLE_SPECIAL_EXP, OnEnableSpecialExp)
65  //}}AFX_MSG_MAP
66 END_MESSAGE_MAP()
67 
69 // ShipSpecialDamage message handlers
70 
71 void ShipSpecialDamage::OnEnableShockwave()
72 {
73  // TODO: Add your control notification handler code here
74  UpdateData(TRUE);
75 
76  // enable/disable shock speed
77  DoGray();
78 }
79 
81 {
82  // TODO: Add your control notification handler code here
83  UpdateData(TRUE);
84 
85  // set delay
87  UpdateData(FALSE);
88 
89  // enable/disable deathroll time
90  DoGray();
91 }
92 
94 {
95  // TODO: Add your control notification handler code here
96  UpdateData(TRUE);
97 
98  DoGray();
99 }
100 
102 {
103 
104  // TODO: Add extra initialization here
105 
106  // get ship num
107  object *objp;
108 
109  num_selected_ships = 0;
110 
111  objp = GET_FIRST(&obj_used_list);
112  while (objp != END_OF_LIST(&obj_used_list)) {
113  if ((objp->type == OBJ_START) || (objp->type == OBJ_SHIP)) {
114  if (objp->flags & OF_MARKED) {
115  m_selected_ships[num_selected_ships] = objp->instance;
116  num_selected_ships++;
117  }
118  }
119  objp = GET_NEXT(objp);
120  }
121 
124 
125  if (!(Ships[m_ship_num].use_special_explosion)) {
126  // get default_table_values
127  ship_info *sip;
129 
131  m_outer_rad = (int)sip->shockwave.outer_rad;
132  m_damage = (int) sip->shockwave.damage;
133  m_blast = (int) sip->shockwave.blast;
135  m_shock_speed = (int) sip->shockwave.speed;
137  m_duration = 0;
139 
140  if (m_inner_rad < 1) {
141  m_inner_rad = 1;
142  }
143  if (m_outer_rad < 2) {
144  m_outer_rad = 2;
145  }
146  if (m_shock_speed < 1) {
147  m_shock_speed = 1;
148  }
149  }
150  else {
160  }
161 
162 
163  CDialog::OnInitDialog();
164 
165  // maybe gray out lots of stuff
166  DoGray();
167 
168  return TRUE; // return TRUE unless you set the focus to a control
169  // EXCEPTION: OCX Property Pages should return FALSE
170 }
171 
173 {
174  GetDlgItem(IDC_SPECIAL_DAMAGE)->EnableWindow(m_special_exp_enabled);
175  GetDlgItem(IDC_SPECIAL_BLAST)->EnableWindow(m_special_exp_enabled);
176  GetDlgItem(IDC_SPECIAL_INNER_RAD)->EnableWindow(m_special_exp_enabled);
177  GetDlgItem(IDC_SPECIAL_OUTER_RAD)->EnableWindow(m_special_exp_enabled);
178  GetDlgItem(IDC_ENABLE_SHOCKWAVE)->EnableWindow(m_special_exp_enabled);
179  GetDlgItem(IDC_ENABLE_DEATHROLL_TIME)->EnableWindow(m_special_exp_enabled);
180  GetDlgItem(IDC_SPECIAL_SHOCK_SPEED)->EnableWindow(m_special_exp_enabled && m_shock_enabled);
182 }
183 
184 
186 {
187  // TODO: Add extra cleanup here
188 
189  CDialog::OnCancel();
190 }
191 
193 {
194  UpdateData(TRUE);
195 
196  int i;
197 
198  if (m_inner_rad > m_outer_rad) {
199  MessageBox("Inner radius must be less than outer radius");
200  return;
201  }
202 
203  for ( i = 0; i < num_selected_ships; i++ ) {
204  update_ship(m_selected_ships[i]);
205  }
206 
207  CDialog::OnOK();
208 }
209 
211 {
212  ship *shipp = &Ships[shipnum];
213 
214  // set to update
215  set_modified();
216 
217  if (m_special_exp_enabled) {
218  // set em
219  shipp->use_special_explosion = true;
222  shipp->special_exp_damage = m_damage;
223  shipp->special_exp_blast = m_blast;
224  shipp->use_shockwave = (m_shock_enabled ? 1:0) ;
225  if (m_shock_speed) {
226  if (m_shock_speed < 1) {
227  m_shock_speed = 1;
228  MessageBox("Shockwave speed must be defined! Setting this to 1 now");
229  }
231  }
232  if (m_duration) {
233  if (m_duration < 2) {
234  m_duration = 2;
235  MessageBox("Death roll time must be at least 2 milliseconds!");
236  }
238  }
239  } else {
240  shipp->use_special_explosion = false;
241  shipp->special_exp_inner = -1;
242  shipp->special_exp_outer = -1;
243  shipp->special_exp_damage = -1;
244  shipp->special_exp_blast = -1;
245  shipp->use_shockwave = false;
246  shipp->special_exp_shockwave_speed = -1;
247  shipp->special_exp_deathroll_time = 0;
248  }
249 }
250 
void update_ship(int ship)
afx_msg void OnEnableDeathrollTime()
virtual void OnCancel()
int i
Definition: multi_pxo.cpp:466
shockwave_create_info shockwave
Definition: ship.h:1237
#define IDC_SPECIAL_DAMAGE
Definition: resource.h:992
Assert(pm!=NULL)
int special_exp_blast
Definition: ship.h:586
int special_exp_inner
Definition: ship.h:587
ShipSpecialDamage(CWnd *pParent=NULL)
#define TRUE
Definition: pstypes.h:399
int special_exp_outer
Definition: ship.h:588
object obj_used_list
Definition: object.cpp:53
#define IDC_ENABLE_SHOCKWAVE
Definition: resource.h:993
#define IDC_SPECIAL_INNER_RAD
Definition: resource.h:780
object * objp
Definition: lua.cpp:3105
#define IDC_ENABLE_DEATHROLL_TIME
Definition: resource.h:997
ship * shipp
Definition: lua.cpp:9162
bool use_special_explosion
Definition: ship.h:584
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
int instance
Definition: object.h:150
#define OBJ_START
Definition: object.h:35
#define IDC_SPECIAL_DEATHROLL_TIME
Definition: resource.h:814
int explosion_propagates
Definition: ship.h:1238
int special_exp_deathroll_time
Definition: ship.h:591
Definition: ship.h:534
#define IDC_SPECIAL_BLAST
Definition: resource.h:994
object Objects[MAX_OBJECTS]
Definition: object.cpp:62
#define OF_MARKED
Definition: object.h:125
bool use_shockwave
Definition: ship.h:589
#define OBJ_SHIP
Definition: object.h:32
GLbitfield flags
Definition: Glext.h:6722
#define IDC_SPECIAL_OUTER_RAD
Definition: resource.h:792
void set_modified(BOOL arg)
Definition: freddoc.cpp:676
virtual BOOL OnInitDialog()
int BOOL
Definition: config.h:80
ship Ships[MAX_SHIPS]
Definition: ship.cpp:122
#define IDC_ENABLE_SPECIAL_EXP
Definition: resource.h:991
virtual void DoDataExchange(CDataExchange *pDX)
afx_msg void OnEnableSpecialExp()
int ship_info_index
Definition: ship.h:539
SCP_vector< ship_info > Ship_info
Definition: ship.cpp:164
int MessageBox(HWND h, const char *s1, const char *s2, int i)
int cur_object_index
Definition: management.cpp:79
int special_exp_damage
Definition: ship.h:585
#define IDC_SPECIAL_SHOCK_SPEED
Definition: resource.h:806
uint flags
Definition: object.h:151
char type
Definition: object.h:146
#define FALSE
Definition: pstypes.h:400
int special_exp_shockwave_speed
Definition: ship.h:590