|
|
1.1 ! root 1: /* ! 2: ============================================================================== ! 3: ! 4: BERSERK ! 5: ! 6: ============================================================================== ! 7: */ ! 8: ! 9: #include "g_local.h" ! 10: #include "m_berserk.h" ! 11: ! 12: ! 13: static int sound_pain; ! 14: static int sound_die; ! 15: static int sound_idle; ! 16: static int sound_punch; ! 17: static int sound_sight; ! 18: static int sound_search; ! 19: ! 20: void berserk_sight (edict_t *self, edict_t *other) ! 21: { ! 22: gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0); ! 23: } ! 24: ! 25: void berserk_search (edict_t *self) ! 26: { ! 27: gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0); ! 28: } ! 29: ! 30: ! 31: void berserk_fidget (edict_t *self); ! 32: mframe_t berserk_frames_stand [] = ! 33: { ! 34: ai_stand, 0, berserk_fidget, ! 35: ai_stand, 0, NULL, ! 36: ai_stand, 0, NULL, ! 37: ai_stand, 0, NULL, ! 38: ai_stand, 0, NULL ! 39: }; ! 40: mmove_t berserk_move_stand = {FRAME_stand1, FRAME_stand5, berserk_frames_stand, NULL}; ! 41: ! 42: void berserk_stand (edict_t *self) ! 43: { ! 44: self->monsterinfo.currentmove = &berserk_move_stand; ! 45: } ! 46: ! 47: mframe_t berserk_frames_stand_fidget [] = ! 48: { ! 49: ai_stand, 0, NULL, ! 50: ai_stand, 0, NULL, ! 51: ai_stand, 0, NULL, ! 52: ai_stand, 0, NULL, ! 53: ai_stand, 0, NULL, ! 54: ai_stand, 0, NULL, ! 55: ai_stand, 0, NULL, ! 56: ai_stand, 0, NULL, ! 57: ai_stand, 0, NULL, ! 58: ai_stand, 0, NULL, ! 59: ai_stand, 0, NULL, ! 60: ai_stand, 0, NULL, ! 61: ai_stand, 0, NULL, ! 62: ai_stand, 0, NULL, ! 63: ai_stand, 0, NULL, ! 64: ai_stand, 0, NULL, ! 65: ai_stand, 0, NULL, ! 66: ai_stand, 0, NULL, ! 67: ai_stand, 0, NULL, ! 68: ai_stand, 0, NULL ! 69: }; ! 70: mmove_t berserk_move_stand_fidget = {FRAME_standb1, FRAME_standb20, berserk_frames_stand_fidget, berserk_stand}; ! 71: ! 72: void berserk_fidget (edict_t *self) ! 73: { ! 74: if (self->monsterinfo.aiflags & AI_STAND_GROUND) ! 75: return; ! 76: if (random() > 0.15) ! 77: return; ! 78: ! 79: self->monsterinfo.currentmove = &berserk_move_stand_fidget; ! 80: gi.sound (self, CHAN_WEAPON, sound_idle, 1, ATTN_IDLE, 0); ! 81: } ! 82: ! 83: ! 84: mframe_t berserk_frames_walk [] = ! 85: { ! 86: ai_walk, 9.1, NULL, ! 87: ai_walk, 6.3, NULL, ! 88: ai_walk, 4.9, NULL, ! 89: ai_walk, 6.7, NULL, ! 90: ai_walk, 6.0, NULL, ! 91: ai_walk, 8.2, NULL, ! 92: ai_walk, 7.2, NULL, ! 93: ai_walk, 6.1, NULL, ! 94: ai_walk, 4.9, NULL, ! 95: ai_walk, 4.7, NULL, ! 96: ai_walk, 4.7, NULL, ! 97: ai_walk, 4.8, NULL ! 98: }; ! 99: mmove_t berserk_move_walk = {FRAME_walkc1, FRAME_walkc11, berserk_frames_walk, NULL}; ! 100: ! 101: void berserk_walk (edict_t *self) ! 102: { ! 103: self->monsterinfo.currentmove = &berserk_move_walk; ! 104: } ! 105: ! 106: /* ! 107: ! 108: ***************************** ! 109: SKIPPED THIS FOR NOW! ! 110: ***************************** ! 111: ! 112: Running -> Arm raised in air ! 113: ! 114: void() berserk_runb1 =[ $r_att1 , berserk_runb2 ] {ai_run(21);}; ! 115: void() berserk_runb2 =[ $r_att2 , berserk_runb3 ] {ai_run(11);}; ! 116: void() berserk_runb3 =[ $r_att3 , berserk_runb4 ] {ai_run(21);}; ! 117: void() berserk_runb4 =[ $r_att4 , berserk_runb5 ] {ai_run(25);}; ! 118: void() berserk_runb5 =[ $r_att5 , berserk_runb6 ] {ai_run(18);}; ! 119: void() berserk_runb6 =[ $r_att6 , berserk_runb7 ] {ai_run(19);}; ! 120: // running with arm in air : start loop ! 121: void() berserk_runb7 =[ $r_att7 , berserk_runb8 ] {ai_run(21);}; ! 122: void() berserk_runb8 =[ $r_att8 , berserk_runb9 ] {ai_run(11);}; ! 123: void() berserk_runb9 =[ $r_att9 , berserk_runb10 ] {ai_run(21);}; ! 124: void() berserk_runb10 =[ $r_att10 , berserk_runb11 ] {ai_run(25);}; ! 125: void() berserk_runb11 =[ $r_att11 , berserk_runb12 ] {ai_run(18);}; ! 126: void() berserk_runb12 =[ $r_att12 , berserk_runb7 ] {ai_run(19);}; ! 127: // running with arm in air : end loop ! 128: */ ! 129: ! 130: ! 131: mframe_t berserk_frames_run1 [] = ! 132: { ! 133: ai_run, 21, NULL, ! 134: ai_run, 11, NULL, ! 135: ai_run, 21, NULL, ! 136: // PMM .. from NULL ! 137: ai_run, 25, monster_done_dodge, ! 138: ai_run, 18, NULL, ! 139: ai_run, 19, NULL ! 140: }; ! 141: mmove_t berserk_move_run1 = {FRAME_run1, FRAME_run6, berserk_frames_run1, NULL}; ! 142: ! 143: void berserk_run (edict_t *self) ! 144: { ! 145: monster_done_dodge (self); ! 146: if (self->monsterinfo.aiflags & AI_STAND_GROUND) ! 147: self->monsterinfo.currentmove = &berserk_move_stand; ! 148: else ! 149: self->monsterinfo.currentmove = &berserk_move_run1; ! 150: } ! 151: ! 152: ! 153: void berserk_attack_spike (edict_t *self) ! 154: { ! 155: static vec3_t aim = {MELEE_DISTANCE, 0, -24}; ! 156: fire_hit (self, aim, (15 + (rand() % 6)), 400); // Faster attack -- upwards and backwards ! 157: } ! 158: ! 159: ! 160: void berserk_swing (edict_t *self) ! 161: { ! 162: gi.sound (self, CHAN_WEAPON, sound_punch, 1, ATTN_NORM, 0); ! 163: } ! 164: ! 165: mframe_t berserk_frames_attack_spike [] = ! 166: { ! 167: ai_charge, 0, NULL, ! 168: ai_charge, 0, NULL, ! 169: ai_charge, 0, berserk_swing, ! 170: ai_charge, 0, berserk_attack_spike, ! 171: ai_charge, 0, NULL, ! 172: ai_charge, 0, NULL, ! 173: ai_charge, 0, NULL, ! 174: ai_charge, 0, NULL ! 175: }; ! 176: mmove_t berserk_move_attack_spike = {FRAME_att_c1, FRAME_att_c8, berserk_frames_attack_spike, berserk_run}; ! 177: ! 178: ! 179: void berserk_attack_club (edict_t *self) ! 180: { ! 181: vec3_t aim; ! 182: ! 183: VectorSet (aim, MELEE_DISTANCE, self->mins[0], -4); ! 184: fire_hit (self, aim, (5 + (rand() % 6)), 400); // Slower attack ! 185: } ! 186: ! 187: mframe_t berserk_frames_attack_club [] = ! 188: { ! 189: ai_charge, 0, NULL, ! 190: ai_charge, 0, NULL, ! 191: ai_charge, 0, NULL, ! 192: ai_charge, 0, NULL, ! 193: ai_charge, 0, berserk_swing, ! 194: ai_charge, 0, NULL, ! 195: ai_charge, 0, NULL, ! 196: ai_charge, 0, NULL, ! 197: ai_charge, 0, berserk_attack_club, ! 198: ai_charge, 0, NULL, ! 199: ai_charge, 0, NULL, ! 200: ai_charge, 0, NULL ! 201: }; ! 202: mmove_t berserk_move_attack_club = {FRAME_att_c9, FRAME_att_c20, berserk_frames_attack_club, berserk_run}; ! 203: ! 204: ! 205: void berserk_strike (edict_t *self) ! 206: { ! 207: //FIXME play impact sound ! 208: } ! 209: ! 210: ! 211: mframe_t berserk_frames_attack_strike [] = ! 212: { ! 213: ai_move, 0, NULL, ! 214: ai_move, 0, NULL, ! 215: ai_move, 0, NULL, ! 216: ai_move, 0, berserk_swing, ! 217: ai_move, 0, NULL, ! 218: ai_move, 0, NULL, ! 219: ai_move, 0, NULL, ! 220: ai_move, 0, berserk_strike, ! 221: ai_move, 0, NULL, ! 222: ai_move, 0, NULL, ! 223: ai_move, 0, NULL, ! 224: ai_move, 0, NULL, ! 225: ai_move, 9.7, NULL, ! 226: ai_move, 13.6, NULL ! 227: }; ! 228: ! 229: mmove_t berserk_move_attack_strike = {FRAME_att_c21, FRAME_att_c34, berserk_frames_attack_strike, berserk_run}; ! 230: ! 231: ! 232: void berserk_melee (edict_t *self) ! 233: { ! 234: monster_done_dodge (self); ! 235: ! 236: if ((rand() % 2) == 0) ! 237: self->monsterinfo.currentmove = &berserk_move_attack_spike; ! 238: else ! 239: self->monsterinfo.currentmove = &berserk_move_attack_club; ! 240: } ! 241: ! 242: ! 243: /* ! 244: void() berserk_atke1 =[ $r_attb1, berserk_atke2 ] {ai_run(9);}; ! 245: void() berserk_atke2 =[ $r_attb2, berserk_atke3 ] {ai_run(6);}; ! 246: void() berserk_atke3 =[ $r_attb3, berserk_atke4 ] {ai_run(18.4);}; ! 247: void() berserk_atke4 =[ $r_attb4, berserk_atke5 ] {ai_run(25);}; ! 248: void() berserk_atke5 =[ $r_attb5, berserk_atke6 ] {ai_run(14);}; ! 249: void() berserk_atke6 =[ $r_attb6, berserk_atke7 ] {ai_run(20);}; ! 250: void() berserk_atke7 =[ $r_attb7, berserk_atke8 ] {ai_run(8.5);}; ! 251: void() berserk_atke8 =[ $r_attb8, berserk_atke9 ] {ai_run(3);}; ! 252: void() berserk_atke9 =[ $r_attb9, berserk_atke10 ] {ai_run(17.5);}; ! 253: void() berserk_atke10 =[ $r_attb10, berserk_atke11 ] {ai_run(17);}; ! 254: void() berserk_atke11 =[ $r_attb11, berserk_atke12 ] {ai_run(9);}; ! 255: void() berserk_atke12 =[ $r_attb12, berserk_atke13 ] {ai_run(25);}; ! 256: void() berserk_atke13 =[ $r_attb13, berserk_atke14 ] {ai_run(3.7);}; ! 257: void() berserk_atke14 =[ $r_attb14, berserk_atke15 ] {ai_run(2.6);}; ! 258: void() berserk_atke15 =[ $r_attb15, berserk_atke16 ] {ai_run(19);}; ! 259: void() berserk_atke16 =[ $r_attb16, berserk_atke17 ] {ai_run(25);}; ! 260: void() berserk_atke17 =[ $r_attb17, berserk_atke18 ] {ai_run(19.6);}; ! 261: void() berserk_atke18 =[ $r_attb18, berserk_run1 ] {ai_run(7.8);}; ! 262: */ ! 263: ! 264: ! 265: mframe_t berserk_frames_pain1 [] = ! 266: { ! 267: ai_move, 0, NULL, ! 268: ai_move, 0, NULL, ! 269: ai_move, 0, NULL, ! 270: ai_move, 0, NULL ! 271: }; ! 272: mmove_t berserk_move_pain1 = {FRAME_painc1, FRAME_painc4, berserk_frames_pain1, berserk_run}; ! 273: ! 274: ! 275: mframe_t berserk_frames_pain2 [] = ! 276: { ! 277: ai_move, 0, NULL, ! 278: ai_move, 0, NULL, ! 279: ai_move, 0, NULL, ! 280: ai_move, 0, NULL, ! 281: ai_move, 0, NULL, ! 282: ai_move, 0, NULL, ! 283: ai_move, 0, NULL, ! 284: ai_move, 0, NULL, ! 285: ai_move, 0, NULL, ! 286: ai_move, 0, NULL, ! 287: ai_move, 0, NULL, ! 288: ai_move, 0, NULL, ! 289: ai_move, 0, NULL, ! 290: ai_move, 0, NULL, ! 291: ai_move, 0, NULL, ! 292: ai_move, 0, NULL, ! 293: ai_move, 0, NULL, ! 294: ai_move, 0, NULL, ! 295: ai_move, 0, NULL, ! 296: ai_move, 0, NULL ! 297: }; ! 298: mmove_t berserk_move_pain2 = {FRAME_painb1, FRAME_painb20, berserk_frames_pain2, berserk_run}; ! 299: ! 300: void berserk_pain (edict_t *self, edict_t *other, float kick, int damage) ! 301: { ! 302: if (self->health < (self->max_health / 2)) ! 303: self->s.skinnum = 1; ! 304: ! 305: if (level.time < self->pain_debounce_time) ! 306: return; ! 307: ! 308: self->pain_debounce_time = level.time + 3; ! 309: gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0); ! 310: ! 311: if (skill->value == 3) ! 312: return; // no pain anims in nightmare ! 313: ! 314: monster_done_dodge (self); ! 315: ! 316: if ((damage < 20) || (random() < 0.5)) ! 317: self->monsterinfo.currentmove = &berserk_move_pain1; ! 318: else ! 319: self->monsterinfo.currentmove = &berserk_move_pain2; ! 320: } ! 321: ! 322: ! 323: void berserk_dead (edict_t *self) ! 324: { ! 325: VectorSet (self->mins, -16, -16, -24); ! 326: VectorSet (self->maxs, 16, 16, -8); ! 327: self->movetype = MOVETYPE_TOSS; ! 328: self->svflags |= SVF_DEADMONSTER; ! 329: self->nextthink = 0; ! 330: gi.linkentity (self); ! 331: } ! 332: ! 333: ! 334: mframe_t berserk_frames_death1 [] = ! 335: { ! 336: ai_move, 0, NULL, ! 337: ai_move, 0, NULL, ! 338: ai_move, 0, NULL, ! 339: ai_move, 0, NULL, ! 340: ai_move, 0, NULL, ! 341: ai_move, 0, NULL, ! 342: ai_move, 0, NULL, ! 343: ai_move, 0, NULL, ! 344: ai_move, 0, NULL, ! 345: ai_move, 0, NULL, ! 346: ai_move, 0, NULL, ! 347: ai_move, 0, NULL, ! 348: ai_move, 0, NULL ! 349: ! 350: }; ! 351: mmove_t berserk_move_death1 = {FRAME_death1, FRAME_death13, berserk_frames_death1, berserk_dead}; ! 352: ! 353: ! 354: mframe_t berserk_frames_death2 [] = ! 355: { ! 356: ai_move, 0, NULL, ! 357: ai_move, 0, NULL, ! 358: ai_move, 0, NULL, ! 359: ai_move, 0, NULL, ! 360: ai_move, 0, NULL, ! 361: ai_move, 0, NULL, ! 362: ai_move, 0, NULL, ! 363: ai_move, 0, NULL ! 364: }; ! 365: mmove_t berserk_move_death2 = {FRAME_deathc1, FRAME_deathc8, berserk_frames_death2, berserk_dead}; ! 366: ! 367: ! 368: void berserk_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point) ! 369: { ! 370: int n; ! 371: ! 372: if (self->health <= self->gib_health) ! 373: { ! 374: gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0); ! 375: for (n= 0; n < 2; n++) ! 376: ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC); ! 377: for (n= 0; n < 4; n++) ! 378: ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC); ! 379: ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC); ! 380: self->deadflag = DEAD_DEAD; ! 381: return; ! 382: } ! 383: ! 384: if (self->deadflag == DEAD_DEAD) ! 385: return; ! 386: ! 387: gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0); ! 388: self->deadflag = DEAD_DEAD; ! 389: self->takedamage = DAMAGE_YES; ! 390: ! 391: if (damage >= 50) ! 392: self->monsterinfo.currentmove = &berserk_move_death1; ! 393: else ! 394: self->monsterinfo.currentmove = &berserk_move_death2; ! 395: } ! 396: ! 397: //=========== ! 398: //PGM ! 399: void berserk_jump_now (edict_t *self) ! 400: { ! 401: vec3_t forward,up; ! 402: ! 403: AngleVectors (self->s.angles, forward, NULL, up); ! 404: VectorMA(self->velocity, 100, forward, self->velocity); ! 405: VectorMA(self->velocity, 300, up, self->velocity); ! 406: } ! 407: ! 408: void berserk_jump2_now (edict_t *self) ! 409: { ! 410: vec3_t forward,up; ! 411: ! 412: AngleVectors (self->s.angles, forward, NULL, up); ! 413: VectorMA(self->velocity, 150, forward, self->velocity); ! 414: VectorMA(self->velocity, 400, up, self->velocity); ! 415: } ! 416: ! 417: void berserk_jump_wait_land (edict_t *self) ! 418: { ! 419: if(self->groundentity == NULL) ! 420: self->monsterinfo.nextframe = self->s.frame; ! 421: else ! 422: self->monsterinfo.nextframe = self->s.frame + 1; ! 423: } ! 424: ! 425: mframe_t berserk_frames_jump [] = ! 426: { ! 427: ai_move, 0, NULL, ! 428: ai_move, 0, NULL, ! 429: ai_move, 0, NULL, ! 430: ai_move, 0, berserk_jump_now, ! 431: ai_move, 0, NULL, ! 432: ai_move, 0, NULL, ! 433: ai_move, 0, berserk_jump_wait_land, ! 434: ai_move, 0, NULL, ! 435: ai_move, 0, NULL ! 436: }; ! 437: mmove_t berserk_move_jump = { FRAME_jump1, FRAME_jump9, berserk_frames_jump, berserk_run }; ! 438: ! 439: mframe_t berserk_frames_jump2 [] = ! 440: { ! 441: ai_move, -8, NULL, ! 442: ai_move, -4, NULL, ! 443: ai_move, -4, NULL, ! 444: ai_move, 0, berserk_jump_now, ! 445: ai_move, 0, NULL, ! 446: ai_move, 0, NULL, ! 447: ai_move, 0, berserk_jump_wait_land, ! 448: ai_move, 0, NULL, ! 449: ai_move, 0, NULL ! 450: }; ! 451: mmove_t berserk_move_jump2 = { FRAME_jump1, FRAME_jump9, berserk_frames_jump2, berserk_run }; ! 452: ! 453: void berserk_jump (edict_t *self) ! 454: { ! 455: if(!self->enemy) ! 456: return; ! 457: ! 458: monster_done_dodge (self); ! 459: ! 460: if(self->enemy->s.origin[2] > self->s.origin[2]) ! 461: self->monsterinfo.currentmove = &berserk_move_jump2; ! 462: else ! 463: self->monsterinfo.currentmove = &berserk_move_jump; ! 464: } ! 465: ! 466: qboolean berserk_blocked (edict_t *self, float dist) ! 467: { ! 468: if(blocked_checkjump (self, dist, 256, 40)) ! 469: { ! 470: berserk_jump(self); ! 471: return true; ! 472: } ! 473: ! 474: if(blocked_checkplat (self, dist)) ! 475: return true; ! 476: ! 477: return false; ! 478: } ! 479: //PGM ! 480: //=========== ! 481: ! 482: void berserk_sidestep (edict_t *self) ! 483: { ! 484: // if we're jumping, don't dodge ! 485: if ((self->monsterinfo.currentmove == &berserk_move_jump) || ! 486: (self->monsterinfo.currentmove == &berserk_move_jump2)) ! 487: { ! 488: return; ! 489: } ! 490: ! 491: // don't check for attack; the eta should suffice for melee monsters ! 492: ! 493: if (self->monsterinfo.currentmove != &berserk_move_run1) ! 494: self->monsterinfo.currentmove = &berserk_move_run1; ! 495: } ! 496: ! 497: ! 498: /*QUAKED monster_berserk (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight ! 499: */ ! 500: void SP_monster_berserk (edict_t *self) ! 501: { ! 502: if (deathmatch->value) ! 503: { ! 504: G_FreeEdict (self); ! 505: return; ! 506: } ! 507: ! 508: // pre-caches ! 509: sound_pain = gi.soundindex ("berserk/berpain2.wav"); ! 510: sound_die = gi.soundindex ("berserk/berdeth2.wav"); ! 511: sound_idle = gi.soundindex ("berserk/beridle1.wav"); ! 512: sound_punch = gi.soundindex ("berserk/attack.wav"); ! 513: sound_search = gi.soundindex ("berserk/bersrch1.wav"); ! 514: sound_sight = gi.soundindex ("berserk/sight.wav"); ! 515: ! 516: self->s.modelindex = gi.modelindex("models/monsters/berserk/tris.md2"); ! 517: VectorSet (self->mins, -16, -16, -24); ! 518: VectorSet (self->maxs, 16, 16, 32); ! 519: self->movetype = MOVETYPE_STEP; ! 520: self->solid = SOLID_BBOX; ! 521: ! 522: self->health = 240; ! 523: self->gib_health = -60; ! 524: self->mass = 250; ! 525: ! 526: self->pain = berserk_pain; ! 527: self->die = berserk_die; ! 528: ! 529: self->monsterinfo.stand = berserk_stand; ! 530: self->monsterinfo.walk = berserk_walk; ! 531: self->monsterinfo.run = berserk_run; ! 532: // pmm ! 533: // self->monsterinfo.dodge = NULL; ! 534: self->monsterinfo.dodge = M_MonsterDodge; ! 535: self->monsterinfo.sidestep = berserk_sidestep; ! 536: // pmm ! 537: self->monsterinfo.attack = NULL; ! 538: self->monsterinfo.melee = berserk_melee; ! 539: self->monsterinfo.sight = berserk_sight; ! 540: self->monsterinfo.search = berserk_search; ! 541: self->monsterinfo.blocked = berserk_blocked; //PGM ! 542: ! 543: self->monsterinfo.currentmove = &berserk_move_stand; ! 544: self->monsterinfo.scale = MODEL_SCALE; ! 545: ! 546: gi.linkentity (self); ! 547: ! 548: walkmonster_start (self); ! 549: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.