summaryrefslogtreecommitdiff
path: root/npc/functions/shake.txt
blob: e3e5268c679686ef6c8d59f46432342869699ec9 (plain) (blame)
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
// Author: Jesusalva

// Shake player screen
// Usage:
// set @max_shake then call OnShake

// sshake( {max_shake} )
function	script	sshake	{
    @max_shake=abs(getarg(0, rand2(6,10)));
    for (.@s=0; .@s < @max_shake; .@s++) {
        movecam rand(-20,20), rand(-20,20);
        sleep2(50);
    }
    return;
}

-	script	shake	32767,{
    end;

// Loops until @shake is @max_shake
OnShake:
    @shake+=1;
    movecam rand(-20,20), rand(-20,20);
    //closeclientdialog;

    if (@shake < @max_shake) {
        addtimer(50, "shake::OnShake");
    } else {
        @shake=0;
        restorecam;
        closedialog;
    }
    end;

// Called by GM Command
OnGM:
    @shake=0;
    @max_shake=rand2(6,10);
    addtimer(50, "shake::OnShake");
    end;

OnCall:
    getmapxy(.@m$,.@x,.@y,0);
    areatimer(.@m$, .@x-15, .@y-15, .@x+15, .@y+15, 10, "shake::OnGM");
    end;

OnInit:
    bindatcmd "shake", "shake::OnCall", 80, 80, 1;
    end;
}