]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/troll.qc
312745892ff8883cb68b69be0b3266af9c6642cf
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / troll.qc
1 #include "troll.qh"
2
3 #ifdef SVQC
4 float autocvar_g_monster_troll_health = 900;
5 float autocvar_g_monster_troll_damageforcescale = 0.1;
6 float autocvar_g_monster_troll_attack_claw_damage = 90;
7 float autocvar_g_monster_troll_speed_stop = 300;
8 float autocvar_g_monster_troll_speed_run = 300;
9 float autocvar_g_monster_troll_speed_walk = 190;
10
11 /*
12 const float troll_anim_attack           = 0;
13 const float troll_anim_idle                     = 1;
14 const float troll_anim_walk                     = 2;
15 const float troll_anim_death            = 3;
16 const float troll_anim_dead         = 4;
17 const float troll_anim_run                      = 5;
18 */
19
20 void M_Troll_Attack_Swing(entity this)
21 {
22     Monster_Attack_Melee(this, this.enemy, (autocvar_g_monster_troll_attack_claw_damage), this.anim_melee1, this.attack_range, 0.5, DEATH_MONSTER_TROLL_MELEE.m_id, true);
23 }
24
25 bool M_Troll_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
26 {
27         switch(attack_type)
28         {
29                 case MONSTER_ATTACK_MELEE:
30                 {
31             actor.state = MONSTER_ATTACK_MELEE; // freeze monster
32             setanim(actor, actor.anim_melee1, false, true, true);
33                         Monster_Delay(actor, 1, 0.6, M_Troll_Attack_Swing);
34             actor.anim_finished = actor.attack_finished_single[0] = time + 0.6; // set this for the delay
35                         return true;
36                 }
37                 case MONSTER_ATTACK_RANGED:
38                 {
39                         // troll has no ranged attack
40                         return false;
41                 }
42         }
43
44         return false;
45 }
46
47 spawnfunc(monster_troll) { Monster_Spawn(this, true, MON_TROLL.monsterid); }
48 #endif // SVQC
49
50 #ifdef SVQC
51 METHOD(Troll, mr_think, bool(Troll this, entity actor))
52 {
53     TC(Troll, this);
54     return true;
55 }
56
57 METHOD(Troll, mr_pain, float(Troll this, entity actor, float damage_take, entity attacker, float deathtype))
58 {
59     TC(Troll, this);
60     actor.pain_finished = time + 0.5;
61     // no pain animation yet
62     //setanim(actor, actor.anim_pain1, true, true, false);
63     return damage_take;
64 }
65
66 METHOD(Troll, mr_death, bool(Troll this, entity actor))
67 {
68     TC(Troll, this);
69     setanim(actor, actor.anim_die1, false, true, true);
70     return true;
71 }
72 #endif
73 #ifdef GAMEQC
74 METHOD(Troll, mr_anim, bool(Troll this, entity actor))
75 {
76     TC(Troll, this);
77     vector none = '0 0 0';
78     actor.anim_die1 = animfixfps(actor, '3 1 1', none); // 2 seconds
79     actor.anim_walk = animfixfps(actor, '2 1 1', none);
80     actor.anim_idle = animfixfps(actor, '1 1 1', none);
81     actor.anim_melee1 = animfixfps(actor, '0 1 1', none); // analyze models and set framerate
82     actor.anim_run = animfixfps(actor, '5 1 1', none);
83     return true;
84 }
85 #endif
86 #ifdef SVQC
87 .float animstate_endtime;
88 METHOD(Troll, mr_setup, bool(Troll this, entity actor))
89 {
90     TC(Troll, this);
91     if(!actor.health) actor.health = (autocvar_g_monster_troll_health);
92     if(!actor.attack_range) actor.attack_range = 150;
93     if(!actor.speed) { actor.speed = (autocvar_g_monster_troll_speed_walk); }
94     if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_troll_speed_run); }
95     if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_troll_speed_stop); }
96     if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_troll_damageforcescale); }
97
98     actor.view_ofs = '0 0 35'; // we swing at a lower height than our eyes
99
100     actor.monster_loot = ITEM_ArmorBig;
101     actor.weapon = WEP_MORTAR.m_id;
102
103     setanim(actor, actor.anim_idle, false, true, true);
104     actor.spawn_time = actor.animstate_endtime;
105     actor.spawnshieldtime = actor.spawn_time;
106     actor.monster_attackfunc = M_Troll_Attack;
107
108     return true;
109 }
110 #endif