summaryrefslogtreecommitdiff
path: root/npc/craft/smith.txt
blob: d75f30d92ca06965b19a6e48f461ccef4dc1ea9a (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
// TMW2 Script
// Author:
//  Jesusalva
// Description:
//  Smith System (Player, Guild, NPC)
// Notes:
//  Base for Evol MR

// Usage: SmithSystem ({scope})
// Scopes: CRAFT_NPC, CRAFT_PLAYER, CRAFT_GUILD
// If an invalid scope is passed, .knowledge won't be set but will be required
// Returns true on success, false on failure
function	script	SmithSystem	{
    // Set .scope, .knowledge and .success
    .scope=getarg(0, CRAFT_PLAYER);
    if (.scope == CRAFT_PLAYER)
        copyarray(.knowledge,RECIPES_EQUIPMENT,getarraysize(RECIPES_EQUIPMENT));
    else if (.scope == CRAFT_GUILD)
        copyarray(.knowledge,$@RECIPES_EQUIPMENT[getcharid(2)],getarraysize($@RECIPES_EQUIPMENT[getcharid(2)]));
    .success=false;

    setskin "craft4";
    .@var$ = requestcraft(4);
    .@craft = initcraft(.@var$);
    .@entry = findcraftentry(.@craft, CRAFT_EQUIPMENT);
    if (debug || $@GM_OVERRIDE) mes "found craft entry: " + .@entry;
    if (debug || $@GM_OVERRIDE) mes "knowledge value: " + .knowledge[.@entry];
    if (.@entry < 0) {
            .success=false;
    } else {
        if (.scope == CRAFT_NPC || .knowledge[.@entry]) {
            usecraft .@craft;
            .success=true;
        } else {
            .success=false;
        }
    }
    deletecraft .@craft;
    setskin "";
    return .success;
}