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