This file is indexed.

/usr/share/games/adanaxisgpl/ruby/AdanaxisPiecePlayer.rb is in adanaxisgpl-data 1.2.5.dfsg.1-6.

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
398
399
400
401
402
403
404
#%Header {
##############################################################################
#
# File data-adanaxis/ruby/AdanaxisPiecePlayer.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 } /CLhMQeLenBvuR33lAQjXA
# $Id: AdanaxisPiecePlayer.rb,v 1.35 2007/09/06 13:07:06 southa Exp $
# $Log: AdanaxisPiecePlayer.rb,v $
# Revision 1.35  2007/09/06 13:07:06  southa
# Backport X11 changes
#
# Revision 1.34  2007/06/27 13:18:54  southa
# Debian packaging
#
# Revision 1.33  2007/06/27 12:58:12  southa
# Debian packaging
#
# Revision 1.32  2007/06/14 18:55:10  southa
# Level and display tweaks
#
# Revision 1.31  2007/06/07 13:23:01  southa
# Level 24
#
# Revision 1.30  2007/05/23 19:14:58  southa
# Level 18
#
# Revision 1.29  2007/05/22 12:59:09  southa
# Vortex effect on player
#
# Revision 1.28  2007/05/21 13:32:52  southa
# Flush weapon
#
# Revision 1.27  2007/05/10 14:06:25  southa
# Level 16 and retina spin
#
# Revision 1.26  2007/04/18 09:21:53  southa
# Header and level fixes
#
# Revision 1.25  2007/03/27 14:01:02  southa
# Attendant AI
#
# Revision 1.24  2007/03/26 16:31:35  southa
# L2 work
#
# Revision 1.23  2007/03/24 18:07:22  southa
# Level 3 work
#
# Revision 1.22  2007/03/23 18:39:08  southa
# Carriers and spawning
#
# Revision 1.21  2007/03/21 11:56:05  southa
# Rail effects and damage icons
#
# Revision 1.20  2007/03/19 16:01:34  southa
# Damage indicators
#
# Revision 1.19  2007/03/13 21:45:08  southa
# Release process
#
# Revision 1.18  2007/03/07 16:59:43  southa
# Khazi spawning and level ends
#
# Revision 1.17  2006/12/14 15:59:22  southa
# Fire and cutscene fixes
#
# Revision 1.16  2006/12/11 18:54:13  southa
# Positional audio
#
# Revision 1.15  2006/11/21 16:13:54  southa
# Cutscene handling
#
# Revision 1.14  2006/11/17 20:08:34  southa
# Weapon change and ammo handling
#
# Revision 1.13  2006/11/17 15:47:42  southa
# Ammo remnants
#
# Revision 1.12  2006/11/14 20:28:36  southa
# Added rail gun
#
# Revision 1.11  2006/11/12 20:09:54  southa
# Missile guidance
#
# Revision 1.10  2006/11/12 14:39:49  southa
# Player weapons amd audio fix
#
# Revision 1.9  2006/11/10 20:17:11  southa
# Audio work
#
# Revision 1.8  2006/11/03 18:46:31  southa
# Damage effectors
#
# Revision 1.7  2006/11/02 09:47:32  southa
# Player weapon control
#
# Revision 1.6  2006/11/01 10:07:13  southa
# Shield handling
#
# Revision 1.5  2006/10/30 19:36:38  southa
# Item collection
#
# Revision 1.4  2006/10/30 17:03:50  southa
# Remnants creation
#
# Revision 1.3  2006/10/17 15:28:00  southa
# Player collisions
#
# Revision 1.2  2006/10/04 13:35:21  southa
# Selective targetting
#
# Revision 1.1  2006/10/02 17:25:03  southa
# Object lookup and target selection
#

require 'Mushware.rb'
require 'AdanaxisAI.rb'
require 'AdanaxisEvents.rb'

class AdanaxisPiecePlayer < AdanaxisPiece
  extend MushRegistered
  mushRegistered_install

  @@c_weaponList = [
    :player_base,
    :player_light_cannon,
    :player_flak,
    :player_quad_cannon,
    :player_rail,
    :player_heavy_cannon,
    :player_light_missile,
    :player_heavy_missile,
    :player_flush,
    :player_nuclear
  ]

  def initialize(inParams = {})
    AdanaxisUtil.cSpellCheck(inParams)
    @m_defaultType = "p"
    super
    @m_hitPoints = inParams[:hit_points] || 100.0
    @m_originalHitPoints = @m_hitPoints
    @m_shield = inParams[:shield] || 0.0
    @m_originalShield = 100.0
    @m_weaponNum = 0
    @m_weaponName = @@c_weaponList[@m_weaponNum]
    @m_weapon = $currentGame.mSpace.mWeaponLibrary.mWeapon(@m_weaponName)
    @m_magazine = AdanaxisMagazine.new
    @m_magazine.mPlayerLoadAll if $MUSHCONFIG['DEBUG']
    @m_fireState = false
    @m_numActions = 0
    @m_lastAmmoAddMsec = 0
    @m_controlReleased = false
    @m_thrustReleased = $currentGame.mSpace.mPermanentThrust

    $currentGame.mView.mDashboard.mUpdate(
      :weapon_name => @m_weaponName,
      :ammo_count => @m_magazine.mAmmoCount(@m_weaponName)
    )

    @m_callInterval = 100
  end

  mush_accessor :m_shield, :m_originalShield, :m_magazine, :m_controlReleased, :m_thrustReleased

  def mShieldRatio
    @m_shield / @m_originalShield
  end

  def mVulnerability
    vuln = ((150.0 - @m_shield) / 150.0) - 0.2
    vuln = 0.0 if vuln < 0.0
    vuln = 1.0 if vuln > 1.0 || @m_shield == 0

    return vuln
  end

  def mDamageTake(inDamage, inPiece)
    @m_shield -= inDamage
    @m_shield = 0.0 if @m_shield < 0.0
    amount = super
    if amount > 0.0
      amount = MushUtil.cClamped(amount / 20.0, 0.5, 2.0)

      if inPiece.kind_of?(AdanaxisPieceEffector)
        incomingVel = mPost.position - inPiece.mPost.position
      else
        incomingVel = inPiece.mPost.velocity - mPost.velocity
      end
      mPost.angular_position.mInverse.mRotate(incomingVel)
      $currentGame.mView.mDashboard.mDamageUpdate(amount, incomingVel)
    end
  end

  def mNewWeapon(inWeapon)
    if inWeapon.kind_of?(Symbol)
      @m_weaponNum = @@c_weaponList.index(inWeapon)
      @m_weaponNum ||= 0
    else
      @m_weaponNum = inWeapon
    end
    @m_weaponNum = 0 if @m_weaponNum >= @@c_weaponList.size
    @m_weaponNum = @@c_weaponList.size - 1 if @m_weaponNum < 0
    @m_weaponName = @@c_weaponList[@m_weaponNum]
    @m_weapon = $currentGame.mSpace.mWeaponLibrary.mWeapon(@m_weaponName)
    @m_weapon.mFireOpportunityTake # Weapon inactive for its reload time
    MushGame.cTiedSoundPlay("load#{@m_weaponNum}", mPost)
    $currentGame.mView.mDashboard.mUpdate(
      :weapon_name => @m_weaponName,
      :ammo_count => @m_magazine.mAmmoCount(@m_weaponName)
    )
  end

  def mAmmoCollect(inType, inCount)
    mMagazine.mLimitedAmmoAdd(inType, inCount)

    weaponNum = @@c_weaponList.index(inType)
    if weaponNum && weaponNum > @m_weaponNum
      mNewWeapon(weaponNum)
    end
  end

  def mFire
    if @m_magazine.mAmmoCount(@m_weaponName) <= 0
      @@c_weaponList.reverse_each do |name|
        if @m_magazine.mAmmoCount(name) > 0
          mNewWeapon(name)
          break
        end
      end
    elsif @m_hitPoints > 0.0 && @m_weapon.mFireOpportunityTake
      event = AdanaxisEventFire.new
      event.mPostSet(@m_post)
      event.mTargetIDSet(AdanaxisRuby.cPlayerTargetID)
      $currentLogic.mEventConsume(event, @m_id, @m_id)
      @m_magazine.mAmmoDecrement(@m_weaponName)
      $currentGame.mView.mDashboard.mUpdate(:ammo_count => @m_magazine.mAmmoCount(@m_weaponName))
    end
  end

  def mEventHandle(event)
    case event
      when AdanaxisEventFire: mFireHandle(event)
      when AdanaxisEventKeyState: mKeyStateHandle(event)
      else super
    end
    @m_callInterval
  end

  def mActionTimer
    callInterval = @m_callInterval

    if @m_fireState || (@m_numActions % 8) == 0
      mLoad

      if @m_fireState
        mFire
        # Short call interval for smooth rapid fire
        callInterval = 0
      end

      if @m_lastAmmoAddMsec + 1000 < MushGame.cGameMsec
        if @m_magazine.mAmmoCount(:player_base) < 100
          @m_magazine.mLimitedAmmoAdd(:player_base, 1)
          if @m_weaponName == :player_base
            $currentGame.mView.mDashboard.mUpdate(:ammo_count => @m_magazine.mAmmoCount(@m_weaponName))
          end
        end
        @m_lastAmmoAddMsec = MushGame.cGameMsec
      end
    end

    $currentGame.mView.mDashboard.mUpdate(
      :hit_point_ratio => mHitPointRatio,
      :shield_ratio => mShieldRatio
    )

    @m_numActions += 1
    callInterval
  end

  def mCollectItem(inItem)
    $currentLogic.mRemnant.mCollect(inItem, self)
    $currentGame.mView.mDashboard.mUpdate(:ammo_count => @m_magazine.mAmmoCount(@m_weaponName))
  end

  def mFatalCollisionHandle(event)
    super

    3.times do |i|
      post = event.mPiece1.post.dup
      disp = MushVector.new(0,0,0,-10 * (i+1))
      post.angular_position.mRotate(disp)
      post.position = post.position + disp

      $currentLogic.mEffects.mExplode(
        :post => post,
        :embers => 0,
        :explosions => 1,
        :explo_number => 5+i,
        :flares => 1,
        :explosion_lifetime_range => (3000..4000),
        :explosion_scale_range => (14.0..15.0),
        :flare_scale_range => (50.0..60.0),
        :flare_lifetime_range => (1000..2000)
        )
    end

    post = event.mPiece1.post.dup
    post.velocity = MushVector.new(0,0,0,0)
    disp = MushVector.new(0,0,0,-1)
    post.angular_position.mRotate(disp)
    post.position = post.position + disp

    $currentLogic.mEffects.mExplode(
        :post => post,
        :embers => 100,
        :explosions => 0,
        :flares => 0,
        :ember_speed_range => (0.05..0.1),
        :ember_lifetime_range => (40000..60000)
    )

    post = event.mPiece1.post.dup
    disp = MushVector.new(-10,0,0,0)
    post.angular_position.mRotate(disp)
    post.position = post.position + disp
    MushGame.cSoundPlay("explo5", post)
    post = event.mPiece1.post.dup
    disp = MushVector.new(10,0,0,0)
    post.angular_position.mRotate(disp)
    post.position = post.position + disp
    MushGame.cSoundPlay("explo6", post)
    MushGame.cSoundPlay("explo7", mPost)

    # Remove other object
    event.mPiece2.mExpireFlagSet(true)
  end

  def mCollisionHandle(event)
    super

    case event.mPiece2
      when AdanaxisPieceItem:
        if @m_hitPoints > 0.0
          mCollectItem(event.mPiece2)
          event.mPiece2.mExpireFlagSet(true)
        end
    end
  end

  def mFireHandle(event)
    mLoad
    if @m_weapon
      @m_weapon.mFire(event, self)
    end
  end

  def mKeyStateHandle(event)
    mLoad
    event.mState.each_with_index do |state, i|
      keyNum = event.mKeyNum[i]

      if keyNum == AdanaxisControl::KEY_FIRE
        @m_fireState = state
      end

      if state
        numWeapons = @@c_weaponList.size
        case keyNum
          when AdanaxisControl::KEY_WEAPON_PREVIOUS
            (numWeapons-1).times do |i|
              newNum = (@m_weaponNum+numWeapons-i-1) % numWeapons
              if @m_magazine.mAmmoCount(@@c_weaponList[newNum]) > 0
                mNewWeapon(newNum)
                break
              end
            end
          when AdanaxisControl::KEY_WEAPON_NEXT
            (numWeapons-1).times do |i|
              newNum = (@m_weaponNum+i+1) % numWeapons
              if @m_magazine.mAmmoCount(@@c_weaponList[newNum]) > 0
                mNewWeapon(newNum)
                break
              end
            end
          when AdanaxisControl::KEY_WEAPON_0..AdanaxisControl::KEY_WEAPON_9
            mNewWeapon(keyNum - AdanaxisControl::KEY_WEAPON_0)
        end
      end
    end
  end
end