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:
|
/*============================================================
BOT ZOMBIE SCRIPT
v.0.1(beta)
by Serthy
============================================================*/
init()
{
level.zombie = [];
level.zombie["model"][0] = "xmodel/zombie"; precacheModel( level.zombie["model"][0] );
level.zombie["model"][1] = "xmodel/charple"; precacheModel( level.zombie["model"][1] );
level.zombie["skill"][0] = 1;
level.zombie["skill"][1] = 1.5;
level.zombie["skill"][2] = 3;
level.zombie["damage"][0] = 15;
level.zombie["damage"][1] = 20;
level.zombie["damage"][2] = 30;
level.zombie["damage_radius"][0] = 30;
level.zombie["damage_radius"][1] = 50;
level.zombie["damage_radius"][2] = 90;
level.zombie["zombie"] = [];
for( i = 0 ; i < level.zombie["amount"] ; i++ )
{
level.zombie["zombie"][i] = "none";
level.zombie["zombie"][i].in_use = false;
}
thread zombie_WaitCvar();
}
/* bugged hier, man spawn nur zombies level 1, 2 3 4... schön der reihe nach, muss noch geändert werden */
zombie_WaitCvar()
{
zombienum = 0;
for( ; ; )
{
wait 5;
zombienum = getCvar( "zombie_amount" );
if( zombienum > 0 )
{
for( i = 0 ; i < zombienum ; i++ )
{
id = zombie_GetFreeZombie();
zombie_spawn( id );
}
}
setCvar( "zombie_amount" , 0 );
}
}
zombie_spawn( ID )
{
spawnpointname = "mp_tdm_spawn";
spawnpoints = getentarray( spawnpointname , "classname" );
spawnpoint = zombie_getSpawnpoint( spawnpoints );
zombie = spawn( "script_model" , spawnpoint.origin );
zombie.id = id;
zombie.skill = level.zombie["skill"][id];
zombie.health = level.zombie["health"] * zombie.skill;
zombie.targetname = zombie;
zombie.target = zombie;
zombie.targetteam = "allies";
zombie.team = "axis";
zombie.closestdist = 10000;
zombie.angles = spawnpoint.angles;
zombie hide();
zombie setContents( 0 );
zombie.trigger = spawn( "trigger_radius" , zombie.origin , level.zombie["damage"].range , level.zombie["damage"].range );
zombie.trigger enableLinkTo();
zombie.trigger linkto( zombie );
zombie setmodel( level.zombie["model"][id] );
zombie thread zombie_Remove();
zombie thread zombie_Handle();
zombie thread zombie_Kill();
zombie thread zombie_LookingForTarget();
zombie thread zombie_monitorDamage( zombie.trigger );
zombie thread zombie_Motion();
zombie notify( "zombie_spawn" );
}
zombie_GetFreeZombie()
{
for( i = 0 ; i < level.zombie["amount"] ; i++ )
{
if( level.zombie["zombie"][i].in_use )
continue;
return i;
}
}
zombie_Handle()
{
while( isDefined( self ) )
{
self waittill( "zombie_spawn" );
self show();
self setContents( 1 );
self waittill( "zombie_killed" , attacker );
self thread zombie_GivePoints( attacker );
self hide();
self setContents( 0 );
if( isDefined( self.trigger ) )
{
self.trigger unlink();
self.trigger delete();
}
if( isdefined( self )
{
level.zombie["zombie"][self.id].in_use = false;
level.zombie["zombie"][self.id] = "none";
self notify( "delete_zombie" );
wait 0.05;
self delete();
}
}
}
zombie_monitorDamage( trigger )
{
self endon( "delete_zombie" );
while( isDefined( self ) && isDefined( trigger ) )
{
trigger waittill( "damage" , iDamage , attacker );
if( attacker.pers["team"] != self.targetteam )
continue;
if( iDamage < 1 )
iDamage = 1;
attacker thread maps\mp\gametypes\_damagefeedback::updatedamagefeedback();
self.health -= iDamage;
if( self.health <= 0 )
self notify( "zombie_killed" , attacker );
}
}
zombie_LookingForTarget()
{
self endon( "delete_zombie" );
while( isDefined( self ) )
{
wait 1;
self thread zombie_NoHunter();
targetplayers = [];
players = getentarray( "player" , "classname" );
for( i = 0 ; i < players.size ; i++ )
{
if( players[i].sessionstate == "spectator" || players[i].sessionstate == "dead" || players[i].pers["team"] == self.team )
continue;
else
{
targetplayers[targetplayers.size] = players[i];
}
}
for( i = 0 ; i < targetplayers.size ; i++ )
{
enemyeye = targetplayers[i] getEye() + ( 0 , 0 , 15 );
dist = ( distance( self.origin , targetplayers[i].origin ) );
trace = bullettrace( self.origin + ( 0 , 0 , 50 ) , enemyeye , false , undefined );
if( dist < self.closestdist && trace["surfacetype"] == "none" )
{
self.target = targetplayers[i];
self.closestdist = dist;
}
}
}
}
zombie_Kill()
{
self endon( "delete_zombie" );
while( isDefined( self ) )
{
wait 0.05;
if( self.closestdist <= level.zombie["damage_radius"][self.id] )
if( isDefined( self.target ) && isAlive( self.target ) )
self.target [[level.callback_playerdamage]]( undefined , undefined , level.zombie["damage"][self.id] , 1 , "MOD_SUICIDE" , "mp_zombie" , self.origin , vectornormalize( self.origin , self.target.origin ) , "pelvis" , 0 );
}
zombie_Motion()
{
self endon( "delete_zombie" );
while( isDefined( self ) )
{
wait 0.05;
speed = ( self.closestdist / 50 ) * self.skill;
if( isDefined( self.target ) && self.target != self )
{
if( !isPlayer( self.target ) || !isAlive( self.target ) || self.target.pers["team"] != self.targetteam )
continue;
target_direction = vectorNormalize( ( self.target.origin[0] - self.origin[0] , self.target.origin[0] - self.origin[0] , self.target.origin[0] - self.origin[0] ) );
self rotateTo( vectorToAngles( target_direction ) , 0.5 );
self moveto( self.target.origin , speed , speed / 3 , 0 );
}
}
}
zombie_getSpawnpoint( spawnpoints )
{
if( !isdefined( spawnpoints ) )
return undefined;
spawnpoint = undefined;
for( i = 0 ; i < spawnpoints.size ; i++ )
{
j = randomInt( spawnpoints.size );
spawnpoint = spawnpoints[i];
spawnpoints[i] = spawnpoints[j];
spawnpoints[j] = spawnpoint;
}
for( i = 0 ; i < spawnpoints.size ; i++ )
{
spawnpoint = spawnpoints[i];
if( !positionWouldTelefrag( spawnpoint.origin ) )
break;
}
return spawnpoint;
}
zombie_GivePoints( attacker )
{
attacker iPrintLnBold( "You killed Zombie #" + self.id );
}
zombie_NoHunter()
{
numonteam = [];
while( isDefined( self ) )
{
wait 1;
players = getentarray( "player" , "classname" );
for( i = 0 ; i < players.size ; i++ )
{
player = players[i];
if( isDefined( player.pers["team"] ) && player.pers["team"] != "spectator" )
numonteam[player.pers["team"]]++;
}
if( numonteam[self.targetteam] <= 0 )
{
for( i = 0 ; i < level.zombie["zombie"].size ; i++ )
{
if( level.zombie["zombie"][i] != "none" )
level.zombie["zombie"][i] notify( "delete_zombie" );
}
}
}
}
zombie_Remove()
{
self waittill( "delete_zombie" );
if( isDefined( self.trigger ) )
{
self.trigger unlink();
self.trigger delete();
}
if( isdefined( self )
{
level.zombie["zombie"][self.id].in_use = false;
level.zombie["zombie"][self.id] = "none";
self notify( "delete_zombie" );
wait 0.05;
self delete();
}
} |