-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexploding_babies.txt
38 lines (28 loc) · 1.02 KB
/
exploding_babies.txt
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
@name exploding babies
# this is an example of how to do simple object-oriented programming with e2's new lambda functions
if( first() ){
# baby constructor
function entity spawnBaby(){
local Baby = propSpawn("models/props_c17/doll01.mdl", entity():toWorld( vec(0,0,20) ), 0)
# baby explode function
Baby["explode", function] = function(){
local Bomb = propSpawn("models/props_c17/oildrum001_explosive.mdl", Baby:pos(), 1)
Bomb:propBreak()
Baby:propDelete()
}
# baby can explode
Baby["canExplode",number] = 1
return Baby
}
}
event playerUse(Player:entity, Entity:entity) {
# press e on this chip to spawn a baby
if( Entity == entity() ){
local Baby = spawnBaby()
Baby:soundPlay(Baby:id(), 0.5, "ambient/creatures/teddy.wav")
}
# if the used entity can explode, explode it
if( Entity["canExplode",number] ){
Entity["explode",function]()
}
}