~ubuntu-branches/ubuntu/precise/egoboo-data/precise

« back to all changes in this revision

Viewing changes to modules/bishopiacity.mod/objects/guard.obj/script.txt

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2010-04-25 10:20:11 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100425102011-1aosouybjkexdg9v
Tags: 1:2.7.7-1
* New Upstream Release
* Switch to debhelper

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//The different states
 
2
//0: Guard
 
3
//1: Ranged Combat: Get in position
 
4
//2: Ranged Combat: Aim
 
5
//3: Ranged Combat: Shoot
 
6
//4: Melee Combat
 
7
//5: Stand ground
 
8
//6: Attack training dolls
 
9
//7: Move towards the trouble
 
10
//8: Guard Captain
 
11
//On spawn the content equals the character state (Which AI script to run)
 
12
//After spawn the content determines the speech trigger (0 equals to speak, higher does not)
 
13
 
 
14
//-----------------------------------------------------------------------------------------
 
15
//Special for bishopia
 
16
IfSpawned
 
17
  JoinGoodTeam  //Just in case
 
18
  GetContent
 
19
  SetState
 
20
 
 
21
//-----------------------------------------------------------------------------------------
 
22
//What to do if target is dead
 
23
IfTargetKilled
 
24
  tmpargument = 7
 
25
  IfStateIsNot          //Dont stop coming for aid
 
26
    SetTargetToNearestEnemy
 
27
      tmpargument = 1
 
28
      SetTime           //Engage next target
 
29
    Else
 
30
      tmpargument = 0   //Or return to post
 
31
      SetState
 
32
      tmpx = selfspawnx
 
33
      tmpy = selfspawny
 
34
      ClearWaypoints
 
35
      AddWaypoint
 
36
      tmpargument = 400
 
37
      SetTime
 
38
 
 
39
//-----------------------------------------------------------------------------------------
 
40
//Handle death
 
41
IfKilled
 
42
  CallForHelp                   //Warn friends
 
43
 
 
44
  //Drop goodies
 
45
  tmpargument = 65535
 
46
  DropMoney
 
47
  DropItems
 
48
  DropKeys
 
49
 
 
50
  //Death sound
 
51
  tmpargument = 1
 
52
  tmpdistance = rand & 1027 + 11000
 
53
  PlaySound
 
54
 
 
55
  //Send message
 
56
  tmpargument = 0
 
57
  IfTargetIsOnSameTeam
 
58
    tmpargument = 5
 
59
    IfTargetIsSelf
 
60
      tmpargument = 4
 
61
  SendMessageNear
 
62
 
 
63
  // Make the character body
 
64
  tmpargument = 45
 
65
  SetBumpHeight
 
66
 
 
67
//-----------------------------------------------------------------------------------------
 
68
// Get mean if characters wanna be bad
 
69
IfAttacked
 
70
  tmpargument = rand & 1 + 4
 
71
  tmpdistance = rand & 6000 + 7000
 
72
  PlaySound
 
73
  SetTargetToWhoeverAttacked
 
74
    IfTargetIsOnHatedTeam
 
75
      CallForHelp               //Enemy attacked
 
76
    Else
 
77
      IfTargetIsAPlayer         //Player got into trouble
 
78
        CallForHelp
 
79
        JoinEvilTeam
 
80
     Else                       //Wops, a friendly NPC attacked
 
81
       SetTargetToOldTarget
 
82
  IfStateIs5
 
83
    CallForHelp
 
84
    JoinEvilTeam
 
85
    tmpargument = 0
 
86
    SetState
 
87
 
 
88
IfCalledForHelp
 
89
  DisableExport
 
90
  JoinEvilTeam
 
91
  IfTargetIsOnHatedTeam
 
92
    GetState
 
93
  Else
 
94
    tmpargument = 7
 
95
    SetState
 
96
 
 
97
//-----------------------------------------------------------------------------------------
 
98
IfTimeOut
 
99
  tmpargument = 0
 
100
  SetContent                    //Reset speech counter
 
101
 
 
102
  //MOVE AROUND - GUARD
 
103
  IfStateIs0
 
104
    Sneak                       //Move at 33% speed
 
105
    tmpargument = rand & 60 + 60
 
106
    SetTime
 
107
    SetTargetToNearestEnemy
 
108
      tmpargument = rand & 20 + 20
 
109
      IfHoldingRangedWeapon     //Engage ranged attack code
 
110
        tmpargument = 1
 
111
        SetState
 
112
      IfHoldingMeleeWeapon      //Charge in melee!
 
113
        tmpargument = 4
 
114
        SetState
 
115
    Else                        //Else wander around
 
116
      SetTurnModeToVelocity
 
117
      tmpx = rand & 1024 - 512 + selfx
 
118
      tmpy = rand & 1024 - 512 + selfy
 
119
      tmpturn = rand & 512 - 256 + selfturn
 
120
      Compass
 
121
      ClearWaypoints
 
122
      AddWaypoint
 
123
 
 
124
  // RANGED COMBAT - GET IN POSITON
 
125
  IfStateIs1
 
126
    tmpargument = 50
 
127
    SetTime
 
128
    Run
 
129
    SetTurnModeToVelocity
 
130
    SetTargetToNearestEnemy
 
131
      tmpx = targetx
 
132
      tmpy = targety
 
133
      tmpturn = targetturnto + 32768
 
134
      tmpdistance = 650
 
135
      Compass
 
136
      ClearWaypoints
 
137
      AddWaypoint
 
138
      tmpargument = 2
 
139
      SetState
 
140
    Else
 
141
      tmpargument = 0           //No enemies, return to guard mode
 
142
      SetState
 
143
 
 
144
  // RANGED COMBAT - AIM
 
145
  IfStateIs2
 
146
    tmpargument = rand & 15 + 15
 
147
    SetTime
 
148
 
 
149
    //Standard movement
 
150
    SetTurnModeToVelocity
 
151
    tmpx = targetx
 
152
    tmpy = targety
 
153
 
 
154
    // Keep distance from friends
 
155
    SetTargetToNearestFriend
 
156
       tmpx = targetdistance
 
157
       tmpy = 100
 
158
       IfXIsLessThanY
 
159
 
 
160
         tmpx = targetx
 
161
         tmpy = targety
 
162
         SetTargetToOldTarget
 
163
       Else
 
164
         SetTargetToOldTarget
 
165
         tmpx = targetx
 
166
         tmpy = targety
 
167
 
 
168
     // Keep running away
 
169
     tmpturn = xyturnto + 32768
 
170
     tmpdistance = 500                  // Desired range
 
171
     Compass
 
172
     ClearWaypoints
 
173
     AddWaypoint
 
174
 
 
175
     // Check distance to target
 
176
     tmpx = targetx - selfx
 
177
     tmpy = targety - selfy
 
178
     tmpx = xydistance // Pythag thing...  targetdistance isn't as good
 
179
     tmpy = 200 // The desired range ( MIN )
 
180
     IfXIsMoreThanY
 
181
       tmpy = 1100 // The desired range ( MAX )
 
182
       IfXIsLessThanY
 
183
         // Target is in range, so switch to fire state
 
184
         tmpargument = 3
 
185
         SetState
 
186
         SetTurnModeToWatchTarget
 
187
         tmpargument = 30 // Time before shooting
 
188
         SetTime
 
189
 
 
190
  // RANGED COMBAT - SHOOT
 
191
  IfStateIs3 
 
192
    Run
 
193
    tmpargument = rand & 7 + 10
 
194
    SetTime
 
195
 
 
196
    //Is the target to far away or too close?
 
197
    tmpy = 500
 
198
    tmpx = targetdistance
 
199
    IfXIsLessThanY      //Too close
 
200
      tmpargument = 1
 
201
      SetState          //If so, go back to positioning
 
202
    Else
 
203
      tmpy = 900
 
204
      IfXIsMoreThanY    //Too far away
 
205
        tmpargument = 1 //If so, go back to positioning
 
206
        SetState
 
207
 
 
208
    // Don't shoot if friends are too close
 
209
    SetTargetToNearestFriend
 
210
      tmpx = targetdistance
 
211
      tmpy = 200
 
212
      IfXIsLessThanY
 
213
        // Keep distance from friends
 
214
        tmpx = targetx
 
215
        tmpy = targety
 
216
        tmpturn = rand & 8191 + 28000 + targetturnto
 
217
        tmpdistance = 300
 
218
        Compass
 
219
        ClearWaypoints
 
220
        AddWaypoint
 
221
      Else
 
222
        // Safe to fire
 
223
        SetTargetToOldTarget
 
224
          SetTurnModeToWatchTarget
 
225
          IfFacingTarget
 
226
            tmpargument = LATCHRIGHT
 
227
            PressLatchButton   
 
228
 
 
229
    // Safe to fire
 
230
    IfFacingTarget
 
231
      IfTargetIsOnHatedTeam
 
232
        tmpargument = LATCHRIGHT
 
233
        PressLatchButton   
 
234
      Else
 
235
        SetTargetToNearestEnemy
 
236
 
 
237
    //Reload weapon
 
238
    IfHoldingRangedWeapon
 
239
      GetState
 
240
    Else
 
241
      SetTargetToSelf
 
242
      tmpargument = ACTIONMC
 
243
      DoAction
 
244
      tmpargument = [XBOW]
 
245
      RestockTargetAmmoIDFirst
 
246
      tmpargument = [LBOW]
 
247
      RestockTargetAmmoIDFirst
 
248
      tmpargument = 1
 
249
      SendMessageNear
 
250
      tmpargument = 9
 
251
      tmpdistance = rand & 8000 + 11000
 
252
      PlaySound
 
253
      SetTargetToOldTarget
 
254
    
 
255
 
 
256
  //MELEE COMBAT - CHARGE AND FIGHT
 
257
  IfStateIs4
 
258
    Run
 
259
    tmpargument = 15
 
260
    SetTime
 
261
    SetTargetToNearestEnemy     //Move towards enemy
 
262
      tmpx = targetx
 
263
      tmpy = targety
 
264
      tmpturn = targetturnto
 
265
      tmpdistance = 850
 
266
      Compass
 
267
      ClearWaypoints
 
268
      AddWaypoint
 
269
    Else                                //No enemies in sight
 
270
      tmpargument = 0                   //begin guarding again
 
271
      SetState
 
272
    tmpx = targetdistance
 
273
    tmpy = 200                  //Can we attack?
 
274
    IfXIsLessThanY
 
275
      IfFacingTarget
 
276
        IfTargetIsAlive
 
277
          IfTargetIsOnHatedTeam
 
278
            tmpargument = LATCHRIGHT    //Yep!
 
279
            PressLatchButton
 
280
 
 
281
  //STAND GROUND - GUARD
 
282
  IfStateIs5
 
283
    tmpargument = rand & 10 + 5
 
284
    SetTime
 
285
    SetTargetToWideEnemy                //Enemy in sight
 
286
      IfHoldingMeleeWeapon              //charge in melee
 
287
        tmpargument = 3
 
288
        SetState
 
289
      Else
 
290
        tmpargument = 1                 //Keep distance with ranged
 
291
        SetState
 
292
    Else
 
293
      tmpx = selfspawnx                 //Go back to start position
 
294
      tmpy = selfspawny
 
295
      Compass
 
296
      ClearWaypoints
 
297
      AddWaypoint
 
298
 
 
299
  //MOVING AROUND - COMING FOR AID
 
300
  IfStateIs7
 
301
    tmpargument = 25
 
302
    SetTime
 
303
    SetTargetToWideEnemy        //Enemy located, attack him
 
304
      tmpargument = 0
 
305
      SetState
 
306
    Else
 
307
      SetTargetToWhoeverCalledForHelp
 
308
        tmpx = targetx          //Move towards the trouble
 
309
        tmpy = targety
 
310
        tmpturn = targetturnto
 
311
        ClearWaypoints
 
312
        AddWaypoint
 
313
 
 
314
//-----------------------------------------------------------------------------------------
 
315
//Use shield against attacking enemies
 
316
IfTargetIsAttacking             //Must be attacking
 
317
  IfTargetIsOnHatedTeam         //Must be enemy
 
318
    tmpargument = [SHIE]        //Holding shield?
 
319
    IfHoldingItemID
 
320
      IfFacingTarget
 
321
        tmpx = targetdistance
 
322
        tmpy = 300 + rand & 500
 
323
        IfXIsLessThanY
 
324
          tmpargument = LATCHLEFT
 
325
          PressLatchButton      //Yep, defend!
 
326
      Else
 
327
        GetAttackTurn           //Position from the attack
 
328
        tmpx = selfx
 
329
        tmpy = selfy
 
330
        Compass
 
331
        ClearWaypoints
 
332
        AddWaypoint
 
333
      
 
334
 
 
335
//-----------------------------------------------------------------------------------------
 
336
//How to react if bumped
 
337
IfBumped                                // Bumped
 
338
  SetTargetToWhoeverBumped                //
 
339
    IfTargetIsOnHatedTeam               //Enemy!
 
340
      IfHoldingRangedWeapon
 
341
        tmpargument = 1                       //Run away and get in position
 
342
        SetState
 
343
      Else
 
344
        tmpargument = 4                 //Attack melee
 
345
        SetState
 
346
    Else                                    //Friendly bumper
 
347
 
 
348
      //If its a player, find out what to say
 
349
      IfStateIs0                                        //Not in combat
 
350
        IfTargetIsAPlayer                               //Only talk to players
 
351
          tmpargument = 0                               
 
352
          IfContentIs                                   //Check speak counter
 
353
            tmpargument = 1
 
354
            SetContent                                  //Set to no more talking
 
355
            tmpx = rand % 5                             //Randomize speech
 
356
 
 
357
            //We serve and protect
 
358
            tmpy = 0
 
359
            IfXIsEqualToY
 
360
              tmpargument = 2
 
361
              SendMessageNear
 
362
              tmpargument = 8
 
363
              tmpdistance = rand & 6000 + 8000
 
364
              PlaySound
 
365
 
 
366
            //Hey! (If male) or Hey baby! (If female), Rouges get a warning instead
 
367
            tmpy = 1
 
368
            IfXIsEqualToY
 
369
              tmpargument = [DISA]
 
370
              IfTargetHasSkillID                //Obey the law or...
 
371
                tmpargument = 9
 
372
                SendMessageNear
 
373
                tmpargument = 7
 
374
                PlaySound
 
375
              Else
 
376
                IfTargetIsFemale                //Hey baby...
 
377
                  tmpargument = 3
 
378
                  SendMessageNear
 
379
                  tmpargument = 11
 
380
                  PlaySound
 
381
                Else                            //Hey!
 
382
                  tmpargument = 6
 
383
                  SendMessageNear
 
384
                  PlaySound
 
385
  
 
386
            //Stay out of trouble!
 
387
            tmpy = 2
 
388
            IfXIsEqualToY
 
389
              tmpargument = 8
 
390
              SendMessageNear
 
391
              tmpargument = 12
 
392
              PlaySound
 
393
 
 
394
            //Waddya want?
 
395
            tmpy = 3
 
396
            IfXIsEqualToY
 
397
              tmpargument = 7
 
398
              SendMessageNear
 
399
              tmpargument = 10
 
400
              PlaySound
 
401
 
 
402
            //Keep moving!
 
403
            tmpy = 4
 
404
            IfXIsEqualToY
 
405
              tmpargument = 10
 
406
              SendMessageNear
 
407
              tmpargument = 13
 
408
              PlaySound
 
409
 
 
410
          //Try to move out of the way of friendlies
 
411
          tmpx = rand & 511 + targetx - 256         
 
412
          tmpy = rand & 511 + targety - 256
 
413
          tmpturn = selfturn
 
414
          tmpdistance = rand & 250
 
415
          Compass                   
 
416
          ClearWaypoints                            
 
417
          AddWaypoint
 
418
          tmpargument = 40                           
 
419
          SetTime
 
420
 
 
421
      //Guard Captain words
 
422
      IfStateIs8
 
423
        IfTargetIsAPlayer
 
424
          tmpargument = 0                               
 
425
          IfContentIs                                   //Check speak counter
 
426
            tmpargument = 1
 
427
            SetContent                                  //Set to no more talking
 
428
            tmpargument = 80                         
 
429
            SetTime
 
430
 
 
431
            tmpx = targetlevel
 
432
            tmpy = 3
 
433
            IfXIsMoreThanY
 
434
              tmpargument = 12                  //TODO: Add Griffin Tower quest
 
435
              SendMessageNear
 
436
            Else
 
437
              tmpargument = 11                  //Sorry, too low level
 
438
              SendMessageNear
 
439
              tmpargument = 13
 
440
              PlaySound
 
441
 
 
442
 
 
443
      SetTargetToOldTarget
 
444
 
 
445
//-----------------------------------------------------------------------------------------
 
446
End                                     // All done
 
447
//-----------------------------------------------------------------------------------------