Skip to content

Commit 08ad62f

Browse files
committed
make ship weapons object orientated
1 parent cf0a35f commit 08ad62f

4 files changed

Lines changed: 86 additions & 132 deletions

File tree

objects/obj_p_ship/Draw_0.gml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ if (selected=1){
2929
}
3030

3131
draw_set_alpha(1);
32-
for (var i=0;i<array_length(weapon);i++){
33-
if ( weapon[i]!=""){
34-
draw_weapon_firing_arc(i);
35-
}
32+
for (var i=0;i<array_length(weapons);i++){
33+
var _wep = weapons[i];
34+
_wep.draw_weapon_firing_arc();
3635
}
36+
3737
if (draw_targets != false){
3838
location_target.draw(draw_targets[0],draw_targets[1]);
3939
}

objects/obj_p_ship/Step_0.gml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,6 @@ if (hp>0) and (instance_exists(target)){
257257
bull.image_xscale=2;
258258
bull.image_yscale=2;
259259
}
260-
if (wep="Plasma Cannon"){
261-
bull.sprite_index=spr_ground_plasma;
262-
bull.image_xscale=3;bull.image_yscale=3;
263-
}
264260
}
265261
if (string_count("orpedo",wep)=1) and (ok=3){
266262

scripts/scr_automated_ship_combat_functions/scr_automated_ship_combat_functions.gml

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -153,25 +153,6 @@ function point_on_circle(start_x, start_y, radius, angle){
153153
return [_final_x, _final_y];
154154
}
155155

156-
function draw_weapon_firing_arc(wep_id){
157-
var _tangent_direction = facing_weapon_angle(weapon_facing[wep_id]);
158-
var _max_distance = weapon_range[wep_id];
159-
160-
var _left = x - _max_distance;
161-
var _top = y - _max_distance;
162-
var _right = x + _max_distance;
163-
var _bottom = y + _max_distance;
164-
165-
var _start_x = x + lengthdir_x(_max_distance, _tangent_direction - 20);
166-
var _start_y = y + lengthdir_y(_max_distance, _tangent_direction - 20);
167-
var _end_x = x + lengthdir_x(_max_distance, _tangent_direction + 20);
168-
var _end_y = y + lengthdir_y(_max_distance, _tangent_direction + 20);
169-
170-
draw_arc(_left, _top, _right, _bottom, _start_x, _start_y, _end_x, _end_y);
171-
draw_line(x, y, _start_x, _start_y);
172-
draw_line(x, y, _end_x, _end_y);
173-
}
174-
175156
function is_targeted(){
176157
var bullets = array_length(bullets_for);
177158
under_fire = false;
@@ -199,98 +180,10 @@ function create_ship_projectile(wep_id){
199180
if (facing!="front"){
200181
bull.direction=point_direction(x+lengthdir_x(32,direction),y+lengthdir_y(32,direction),target.x,target.y);
201182
}
202-
if (string_count("ova",wep)=1){
203-
bull.image_xscale=2;
204-
bull.image_yscale=2;
205-
}
206-
else if (string_count("eavy Gunz",wep)=1){
207-
bull.image_xscale=1.5;
208-
bull.image_yscale=1.5;
209-
}
210-
else if (string_count("Lance",wep)=1){
211-
bull.sprite_index=spr_ground_las;
212-
bull.image_xscale=1.5;
213-
bull.image_yscale=1.5;
214-
}
215-
else if (string_count("Ion",wep)=1){
216-
bull.sprite_index=spr_pulse;
217-
bull.image_xscale=1.5;
218-
bull.image_yscale=1.5;
219-
}
220-
else if (string_count("Rail",wep)=1){
221-
bull.sprite_index=spr_railgun;
222-
bull.image_xscale=1.5;
223-
bull.image_yscale=1.5;
224-
}
225-
else if (string_count("Gravitic",wep)=1){
226-
bull.image_xscale=2;
227-
bull.image_yscale=2;
228-
}
229-
else if (string_count("Plasma",wep)=1){
230-
bull.sprite_index=spr_ground_plasma;
231-
bull.image_xscale=2;
232-
bullimage_yscale=2;
233-
bull.speed=15;
234-
}
235-
else if (string_count("Pyro-Acid",wep)=1){
236-
bull.sprite_index=spr_glob;
237-
bull.image_xscale=2;
238-
bullimage_yscale=2;
239-
}
240183

241-
if (string_count("Weapons",wep)=1) and (owner = eFACTION.Eldar){
242-
bull.sprite_index=spr_ground_las;
243-
bull.image_xscale=2;
244-
bull.image_yscale=2;
245-
}
246-
if (string_count("Pulse",wep)=1) and (owner = eFACTION.Eldar){
247-
bull.sprite_index=spr_pulse;
248-
bull.image_xscale=1.5;
249-
bull.image_yscale=1.5;
250-
}
251-
252-
}
253-
if (string_count("orpedo",wep)=1) and (owner != eFACTION.Necrons){
254-
if (class!="Ravager"){
255-
bull=instance_create(x,y+lengthdir_y(-30,direction+90),obj_en_round);
256-
bull.speed=10;
257-
bull.direction=direction;
258-
bull.sprite_index=spr_torpedo;
259-
bull.dam=dam;
260-
}
261-
bull=instance_create(x,y+lengthdir_y(-10,direction+90),obj_en_round);
262-
bull.speed=10;
263-
bull.direction=direction;
264-
bull.sprite_index=spr_torpedo;
265-
bull.dam=dam;
266-
bull=instance_create(x,y+lengthdir_y(10,direction+90),obj_en_round);
267-
bull.speed=10;
268-
bull.direction=direction;
269-
bull.sprite_index=spr_torpedo;
270-
bull.dam=dam;
271-
272-
if (class!="Ravager"){
273-
bull=instance_create(x,y+lengthdir_y(30,direction+90),obj_en_round);
274-
bull.speed=10;
275-
bull.direction=direction;
276-
bull.sprite_index=spr_torpedo;
277-
bull.dam=dam;
278-
}
279184

280185
}
281186

282-
if (wep="Lightning Arc"){lightning=10;
283-
if (target.shields>0){
284-
if (class="Cairn Class") or (class="Reaper Class") then target.shields-=20;
285-
else{target.shields-=20;
286-
}
287-
}
288-
if (target.shields<=0){
289-
if (class="Cairn Class") or (class="Reaper Class") then target.hp-=10;
290-
else{target.hp-=10;
291-
}
292-
}
293-
}
294187
if (wep="Gauss Particle Whip"){whip=15;
295188
if (target.shields>0) then target.shields-=dam;
296189
if (target.shields<=0) then target.hp-=dam;

scripts/scr_ship_combat_data/scr_ship_combat_data.gml

Lines changed: 82 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ global.ship_weapons_stats = {
33
range : 300,
44
dam : 14,
55
facing : "front",
6-
firing_arc : 12.5
6+
firing_arc : 12.5,
7+
img : spr_ground_las,
8+
}
9+
"Plasma Cannon" : {
10+
img : spr_ground_plasma,
11+
draw_scale : 3,
12+
bullet_speed : 15,
713
}
814
"Nova Cannon": {
915
range : 1500,
@@ -12,6 +18,7 @@ global.ship_weapons_stats = {
1218
minrange : 300,
1319
cooldown : 120,
1420
minrange : 300,
21+
draw_scale: 2,
1522
},
1623
"Weapons Battery" : {
1724
facing : "most",
@@ -51,6 +58,9 @@ global.ship_weapons_stats = {
5158
dam : 12,
5259
range : 450,
5360
cooldown : 90,
61+
bullet_speed : 10,
62+
barrel_count : 4,
63+
img:spr_torpedo,
5464
},
5565

5666
"Interceptor Launch Bays" : {
@@ -81,17 +91,21 @@ global.ship_weapons_stats = {
8191
facing : "most",
8292
dam : 10,
8393
weapon_cooldown : 10,
94+
img: spr_ground_las,
8495
},
8596
"Pyro-acid Battery" : {
8697
facing : "most",
8798
dam : 8,
8899
range : 300,
100+
img : spr_glob,
101+
draw_scale : 2,
89102
},
90103
"Feeder Tendrils" : {
91104
facing : "most",
92105
dam : 8,
93106
range : 100,
94107
firing_arc : 50,
108+
melee : true,
95109
},
96110
"Bio-Plasma Discharge":{
97111
range : 200,
@@ -103,41 +117,47 @@ global.ship_weapons_stats = {
103117
dam : 20,
104118
range : 64,
105119
cooldown : 60,
120+
melee : true,
106121
},
107122
"Launch Glands" : {
108123
facing : "special",
109124
weapon_range : 9999,
110-
ammo : 6,
125+
ammo : 20,
111126
cooldown , 120,
112127
},
113128
"Gravitic launcher" : {
114129
dam : 12,
115130
range : 400,
116131
minrange : 200,
117132
cooldown:30,
133+
draw_scale:2,
118134
},
119135
"Railgun Battery": {
120136
facing : "most"
121137
dam :12,
122138
range : 450,
123139
cooldown:30,
140+
img : spr_railgun,
124141
},
125142
"Ion Cannons": {
126143
facing : "most"
127144
dam :8,
128145
range : 300,
129146
cooldown:15,
147+
img : spr_pulse,
130148
},
131149
"Lightning Arc" : {
132150
facing : "most",
133-
dam : 0,
151+
dam : 20,
134152
range : 300,
135153
cooldown : 15,
154+
damage_type:"shields"
136155
},
137156
"Star Pulse Generator": {
138157
dam : 0,
139158
range : 220,
140-
cooldown : 210
159+
cooldown : 210,
160+
img : spr_pulse
141161
},
142162
"Gauss Particle Whip":{
143163
dam : 30,
@@ -146,7 +166,7 @@ global.ship_weapons_stats = {
146166
}
147167
}
148168

149-
global.ship_defualts = {
169+
global.ship_weapon_defualts = {
150170
range : 600,
151171
facing : "front",
152172
cooldown : 30,
@@ -158,6 +178,10 @@ global.ship_defualts = {
158178
bullet_speed : 20,
159179
bullet_obj : obj_en_round,
160180
img : spr_round,
181+
damage_type : "full",
182+
draw_scale : 1.5,
183+
barrel_count : 1,
184+
melee : false,
161185

162186
}
163187
function move_data_to_current_scope(struct, overide=true){
@@ -182,6 +206,9 @@ function facing_weapon_angle(facing){
182206
case "left":
183207
_direct_-=90;
184208
break;
209+
case "rear":
210+
_direct_ -= 180;
211+
break;
185212
default:
186213
break;
187214
}
@@ -194,7 +221,7 @@ function ShipWeapon(weapon_name, overide_data={}) constructor{
194221
move_data_to_current_scope(_wep_data);
195222
}
196223
move_data_to_current_scope(overide_data);
197-
move_data_to_current_scope(global.ship_defualts, false);
224+
move_data_to_current_scope(global.ship_weapon_defualts, false);
198225
name = weapon_name;
199226
cooldown_timer = 0;
200227

@@ -203,6 +230,47 @@ function ShipWeapon(weapon_name, overide_data={}) constructor{
203230
static find_target = function(){
204231

205232
}
233+
static draw_weapon_firing_arc = function{
234+
var _tangent_direction = 0;
235+
var _facing = facing
236+
if (instance_exists(ship)){
237+
with (ship){
238+
_tangent_direction = facing_weapon_angle(_facing);
239+
}
240+
}
241+
var _max_distance = range;
242+
243+
var _left = x - _max_distance;
244+
var _top = y - _max_distance;
245+
var _right = x + _max_distance;
246+
var _bottom = y + _max_distance;
247+
248+
if (facing == "most"){
249+
firing_arc = 135;
250+
}
251+
draw_set_color(38144);
252+
253+
var _start_x = x + lengthdir_x(_max_distance, _tangent_direction - firing_arc);
254+
var _start_y = y + lengthdir_y(_max_distance, _tangent_direction - firing_arc);
255+
var _end_x = x + lengthdir_x(_max_distance, _tangent_direction + firing_arc);
256+
var _end_y = y + lengthdir_y(_max_distance, _tangent_direction + firing_arc);
257+
258+
draw_arc(_left, _top, _right, _bottom, _start_x, _start_y, _end_x, _end_y);
259+
draw_line(x, y, _start_x, _start_y);
260+
draw_line(x, y, _end_x, _end_y);
261+
262+
if (minrange > 0){
263+
draw_set_color(c_red);
264+
var _start_x = x + lengthdir_x(minrange, _tangent_direction - firing_arc);
265+
var _start_y = y + lengthdir_y(minrange, _tangent_direction - firing_arc);
266+
var _end_x = x + lengthdir_x(minrange, _tangent_direction + firing_arc);
267+
var _end_y = y + lengthdir_y(minrange, _tangent_direction + firing_arc);
268+
269+
draw_arc(_left, _top, _right, _bottom, _start_x, _start_y, _end_x, _end_y);
270+
draw_line(x, y, _start_x, _start_y);
271+
draw_line(x, y, _end_x, _end_y);
272+
}
273+
}
206274
}
207275

208276
function add_weapon_to_ship(weapon_name, overide_data={}){
@@ -506,7 +574,7 @@ function assign_ship_stats(){
506574
capacity=50;
507575
carrying=0;
508576
add_weapon_to_ship("Gunz Battery");
509-
add_weapon_to_ship("Torpedoes", {range : 300, cooldown:120});
577+
add_weapon_to_ship("Torpedoes", {range : 300, cooldown:120,barrel_count:2});
510578
}
511579
// ** Tau **
512580
if (class=="Custodian"){
@@ -783,11 +851,12 @@ function assign_ship_stats(){
783851
capacity=250;
784852
carrying=0;
785853

786-
add_weapon_to_ship("Lightning Arc");
854+
add_weapon_to_ship("Lightning Arc", {dam : 10});
787855

788856
}
789857

790-
if (class="Jackal Class"){ship_size=2;
858+
if (class="Jackal Class"){
859+
ship_size=2;
791860
sprite_index=spr_ship_jackal;
792861

793862
name="";
@@ -805,11 +874,12 @@ function assign_ship_stats(){
805874
capacity=25;
806875
carrying=0;
807876

808-
add_weapon_to_ship("Lightning Arc", range :250);
877+
add_weapon_to_ship("Lightning Arc", {dam : 10,range :250});
809878

810879
}
811880

812-
if (class="Dirge Class"){ship_size=2;
881+
if (class="Dirge Class"){
882+
ship_size=2;
813883
sprite_index=spr_ship_dirge;
814884

815885
name="";
@@ -827,12 +897,7 @@ function assign_ship_stats(){
827897
capacity=25;
828898
carrying=0;
829899

830-
weapon[1]="Lightning Arc";
831-
weapon_facing[1]="most";
832-
weapon_dam[1]=0;
833-
weapon_range[1]=250;
834-
weapon_cooldown[1]=15;
835-
900+
add_weapon_to_ship("Lightning Arc", {dam : 10,range :250});
836901
}
837902

838903

0 commit comments

Comments
 (0)