This file is indexed.

/usr/share/games/adanaxisgpl/ruby/AdanaxisWeapon.rb is in adanaxisgpl-data 1.2.5.dfsg.1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
#%Header {
##############################################################################
#
# File data-adanaxis/ruby/AdanaxisWeapon.rb
#
# Copyright Andy Southgate 2006-2007
#
# This file may be used and distributed under the terms of the Mushware
# Software Licence version 1.4, under the terms for 'Proprietary original
# source files'.  If not supplied with this software, a copy of the licence
# can be obtained from Mushware Limited via http://www.mushware.com/.
# One of your options under that licence is to use and distribute this file
# under the terms of the GNU General Public Licence version 2.
#
# This software carries NO WARRANTY of any kind.
#
##############################################################################
#%Header } 2tVPM89yFBzn4dSGgYG41w
# $Id: AdanaxisWeapon.rb,v 1.26 2007/06/27 13:18:55 southa Exp $
# $Log: AdanaxisWeapon.rb,v $
# Revision 1.26  2007/06/27 13:18:55  southa
# Debian packaging
#
# Revision 1.25  2007/06/27 12:58:13  southa
# Debian packaging
#
# Revision 1.24  2007/06/05 12:15:14  southa
# Level 21
#
# Revision 1.23  2007/05/29 13:25:56  southa
# Level 20
#
# Revision 1.22  2007/05/21 13:32:52  southa
# Flush weapon
#
# Revision 1.21  2007/05/09 19:24:43  southa
# Level 14
#
# Revision 1.20  2007/04/26 16:22:41  southa
# Level 9
#
# Revision 1.19  2007/04/26 13:12:39  southa
# Limescale and level 9
#
# Revision 1.18  2007/04/18 09:21:54  southa
# Header and level fixes
#
# Revision 1.17  2007/03/28 14:45:46  southa
# Level and AI standoff
#
# Revision 1.16  2007/03/27 15:34:42  southa
# L4 and carrier ammo
#
# Revision 1.15  2007/03/26 16:31:35  southa
# L2 work
#
# Revision 1.14  2007/03/24 18:07:23  southa
# Level 3 work
#
# Revision 1.13  2007/03/23 18:39:08  southa
# Carriers and spawning
#
# Revision 1.12  2007/03/21 18:05:53  southa
# Tied sound fixes
#
# Revision 1.11  2007/03/21 11:56:05  southa
# Rail effects and damage icons
#
# Revision 1.10  2007/03/13 21:45:09  southa
# Release process
#
# Revision 1.9  2006/12/11 18:54:18  southa
# Positional audio
#
# Revision 1.8  2006/11/14 20:28:36  southa
# Added rail gun
#
# Revision 1.7  2006/11/14 14:02:16  southa
# Ball projectiles
#
# Revision 1.6  2006/11/12 20:09:54  southa
# Missile guidance
#
# Revision 1.5  2006/11/12 14:39:50  southa
# Player weapons amd audio fix
#
# Revision 1.4  2006/11/03 18:46:32  southa
# Damage effectors
#
# Revision 1.3  2006/11/02 12:23:21  southa
# Weapon selection
#
# Revision 1.2  2006/11/02 09:47:32  southa
# Player weapon control
#
# Revision 1.1  2006/11/01 13:04:21  southa
# Initial weapon handling
#

class AdanaxisWeapon < MushObject
  @@c_defaultOffset = [MushVector.new(0,0,0,0)]
  @@c_defaultAngularVelocity = MushTools.cRotationInXYPlane(0.02)
  MushTools.cRotationInXZPlane(0.05).mRotate(@@c_defaultAngularVelocity)
  MushTools.cRotationInYZPlane(0.07).mRotate(@@c_defaultAngularVelocity)

  def initialize(inParams = {})
    AdanaxisUtil.cSpellCheck(inParams)
    @m_projectileMesh = inParams[:projectile_mesh]
    @m_lifetimeMsec = inParams[:lifetime_msec] || 10000
    @m_speed = inParams[:speed] || 1.0
    @m_acceleration = inParams[:acceleration] || 0.0
    @m_speedLimit = inParams[:speed_limit] || 0.0
    @m_fireRateMsec = inParams[:fire_rate_msec] || 1000
    @m_offsetSequence = inParams[:offset_sequence] || @@c_defaultOffset
    @m_offsetNumber = 0
    @m_fireSound = inParams[:fire_sound]
    @m_reloadSound = inParams[:reload_sound]
    @m_angularVelocity = inParams[:angular_velocity] || @@c_defaultAngularVelocity
    @m_hitPoints = inParams[:hit_points] || 1.0
    @m_aiParams = inParams[:ai_params]
    @m_numProjectiles = inParams[:num_projectiles] || 1
    @m_deviation = inParams[:deviation]
    @m_type = inParams[:type] || nil
    @m_itemType = inParams[:item_type] || nil
    @m_ammoCount = inParams[:ammo_count] || nil
    @m_spawnLimit = inParams[:spawn_inhibit_limit] || 20 * (1+AdanaxisRuby.cGameDifficulty)
    @m_alphaStutter = inParams[:alpha_stutter] || 0.0
    @m_isFlush = inParams[:is_flush]
    @m_jammable = inParams[:jammable]
    @m_lastFireMsec = 0
  end

  mush_accessor :m_ammoCount

  def mFireOpportunityTake
    retVal = false
    if @m_lastFireMsec + @m_fireRateMsec < MushGame.cGameMsec && @m_ammoCount != 0
      @m_lastFireMsec = MushGame.cGameMsec
      unless @m_type == :spawner && $currentGame.mSpace.mKhaziRedCount > @m_spawnLimit
        retVal = true
      end
    end
    retVal
  end

  def mCommonFire(inEvent, inPiece, inProjPost)
    @m_lastFireMsec = MushGame.cGameMsec
    @m_offsetNumber += 1
    @m_offsetNumber = 0 if @m_offsetNumber >= @m_offsetSequence.size

    MushGame.cTiedSoundPlay(@m_fireSound, inProjPost) if @m_fireSound
    MushGame.cTiedSoundPlay(@m_reloadSound, inProjPost) if @m_reloadSound

    @m_ammoCount -= 1 if @m_ammoCount

  end

  def mProjectileFire(inEvent, inPiece)
    projPost = inEvent.mPost.dup

    # Get player forward velocity but not transverse
    vel = projPost.velocity
    projPost.angular_position.mInverse.mRotate(vel)
    vel.x = 0
    vel.y = 0
    vel.z = 0
    vel.w = vel.w - @m_speed

    offset = @m_offsetSequence[@m_offsetNumber].dup

    projPost.angular_position.mRotate(offset)
    projPost.angular_position.mRotate(vel)

    projPost.position = projPost.position + offset
    projPost.velocity = vel

    # Apply the angular velocity in the object frame
    if @m_type == :rocket
      projPost.angular_velocity = MushRotation.new
    else
      angVel = projPost.angular_position.mInverse
      @m_angularVelocity.mRotate(angVel)
      projPost.angular_position.mRotate(angVel)
      projPost.angular_velocity = angVel
    end

    if @m_aiParams
      aiParams = @m_aiParams.merge(
        :target_id => inEvent.mTargetID
      )
      if @m_jammable && $currentGame.mSpace.mJamming
        aiParams[:seek_acceleration] *= -1.0
      end
    end

    baseVelocity = projPost.velocity
    lifetime = @m_lifetimeMsec
    @m_numProjectiles.times do
      projPost.velocity = baseVelocity + MushTools.cRandomUnitVector * @m_deviation if @m_deviation
      lifetime = @m_lifetimeMsec.begin + rand(@m_lifetimeMsec.end - @m_lifetimeMsec.begin) if @m_lifetimeMsec.kind_of?(Range)
      AdanaxisPieceProjectile.cCreate(
        :mesh_name => @m_projectileMesh,
        :post => projPost,
        :owner => inPiece.mId,
        :lifetime_msec => lifetime,
        :hit_points => @m_hitPoints,
        :acceleration => @m_acceleration,
        :speed_limit => @m_speedLimit,
        :ai_params => aiParams,
        :is_rocket => (@m_type == :rocket),
        :is_flush => @m_isFlush,
        :alpha_stutter => @m_alphaStutter
      )
    end

    mCommonFire(inEvent, inPiece, projPost)

    nil
  end

  def mItemFire(inEvent, inPiece)
    projPost = inEvent.mPost.dup

    vel = projPost.velocity
    projPost.angular_position.mInverse.mRotate(vel)
    vel.x = 0
    vel.y = 0
    vel.z = 0
    vel.w = vel.w - @m_speed

    offset = @m_offsetSequence[@m_offsetNumber].dup

    projPost.angular_position.mRotate(offset)
    projPost.angular_position.mRotate(vel)

    projPost.position = projPost.position + offset
    projPost.velocity = vel

    # Apply the angular velocity in the object frame

    angVel = projPost.angular_position.mInverse
    @m_angularVelocity.mRotate(angVel)
    projPost.angular_position.mRotate(angVel)
    projPost.angular_velocity = angVel

    if @m_aiParams
      aiParams = @m_aiParams.merge(
        :target_id => inEvent.mTargetID
      )
    end

    baseVelocity = projPost.velocity
    lifetime = @m_lifetimeMsec
    @m_numProjectiles.times do
      projPost.velocity = baseVelocity + MushTools.cRandomUnitVector * @m_deviation if @m_deviation
      lifetime = @m_lifetimeMsec.begin + rand(@m_lifetimeMsec.end - @m_lifetimeMsec.begin) if @m_lifetimeMsec.kind_of?(Range)
      AdanaxisPieceItem.cCreate(
        :item_type => @m_itemType,
        :mesh_name => @m_projectileMesh,
        :post => projPost,
        :owner => inPiece.mId,
        :lifetime_msec => lifetime,
        :hit_points => @m_hitPoints,
        :acceleration => @m_acceleration,
        :speed_limit => @m_speedLimit,
        :ai_params => aiParams,
        :is_rocket => (@m_type == :rocket),
        :is_flush => @m_isFlush,
        :alpha_stutter => @m_alphaStutter
      )
    end

    mCommonFire(inEvent, inPiece, projPost)

    nil
  end

  def mRailFire(inEvent, inPiece)
    projPost = inEvent.mPost.dup
    offset = @m_offsetSequence[@m_offsetNumber].dup

    # Apply the angular velocity in the object frame
    angVel = projPost.angular_position.mInverse
    @m_angularVelocity.mRotate(angVel)
    projPost.angular_position.mRotate(angVel)
    projPost.angular_velocity = angVel

    baseVelocity = projPost.velocity
    lifetime = @m_lifetimeMsec

    # Create the effector before applying the offset, so the gunsight works as expected
    AdanaxisPieceEffector.cCreate(
      :rail => true,
      :mesh_name => @m_projectileMesh,
      :post => projPost,
      :owner => inPiece.mId,
      :lifetime_msec => 0,
      :hit_points => @m_hitPoints,
      :vulnerability => 0.0
    )

    projPost.angular_position.mRotate(offset)
    projPost.position = projPost.position + offset

    AdanaxisPieceDeco.cCreate(
      :mesh_name => @m_projectileMesh,
      :post => projPost,
      :lifetime_msec => lifetime
    )

    $currentLogic.mEffects.mFlareCreate(
      :post => projPost,
      :flare_lifetime_range => 400..500,
      :flare_scale_range => 4.0..4.4
    )

    mCommonFire(inEvent, inPiece, projPost)

    nil
  end

  def mSpawnerFire(inEvent, inPiece)
    projPost = inEvent.mPost.dup

    # Get firer forward velocity but not transverse
    vel = projPost.velocity
    projPost.angular_position.mInverse.mRotate(vel)
    vel.x = 0
    vel.y = 0
    vel.z = 0
    vel.w = vel.w - @m_speed

    offset = @m_offsetSequence[@m_offsetNumber].dup

    projPost.angular_position.mRotate(offset)
    projPost.angular_position.mRotate(vel)

    projPost.position = projPost.position + offset
    projPost.velocity = vel

    # Rotate spawned object so it faces the opposite way to the spawner
    angPos = projPost.angular_position
    # This combo send (x,y,z,w) to (-x,-y,-z,-w)
    MushTools.cRotationInXYPlane(Math::PI).mRotate(angPos)
    MushTools.cRotationInZWPlane(Math::PI).mRotate(angPos)
    projPost.angular_position = angPos

    # Apply the angular velocity in the object frame
    angVel = projPost.angular_position.mInverse
    @m_angularVelocity.mRotate(angVel)
    projPost.angular_position.mRotate(angVel)
    projPost.angular_velocity = angVel

    baseVelocity = projPost.velocity
    lifetime = @m_lifetimeMsec

    case @m_projectileMesh
      when :limescale
        $currentGame.mSpace.mPieceLibrary.mLimescaleCreate(
          :colour => inPiece.mColour,
          :post => projPost,
          :spawned => true
        )
      when :harpik
        $currentGame.mSpace.mPieceLibrary.mHarpikCreate(
          :colour => inPiece.mColour,
          :post => projPost,
          :spawned => true
        )
      when :vendor
        $currentGame.mSpace.mPieceLibrary.mVendorCreate(
          :colour => inPiece.mColour,
          :post => projPost,
          :spawned => true
        )
      else
        $currentGame.mSpace.mPieceLibrary.mAttendantCreate(
          :colour => inPiece.mColour,
          :post => projPost,
          :spawned => true
        )
    end

    mCommonFire(inEvent, inPiece, projPost)

    nil
  end

  def mFire(inEvent, inPiece)
    case @m_type
      when :item : mItemFire(inEvent, inPiece)
      when :spawner : mSpawnerFire(inEvent, inPiece)
      when :rail : mRailFire(inEvent, inPiece)
      else mProjectileFire(inEvent, inPiece)
    end
  end
end