summaryrefslogtreecommitdiff
path: root/world/map/npc/commands/marry.txt
blob: 39efe6b80c4f1f0508eb896e86c4d02a52faab43 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-|script|special-marry|32767
{
    set .@target_id, getcharid(3, @args$);
    if (.@target_id < 1 || !(isloggedin(.@target_id)) || .@target_id == BL_ID) goto L_NotFound;
    if (PARTNER || get(PARTNER, .@target_id)) goto L_AlreadyMarried;
    if (isin("014-1",29,36,34,39) == 0 && isin("001-1",20,27,22,27) == 0) goto L_NotInArea;
    if (distance(BL_ID, .@target_id) != 1) goto L_AwayFromPartner;
    if (BaseLevel < WEDDING_MIN_LEVEL || get(BaseLevel, .@target_id) < WEDDING_MIN_LEVEL) goto L_TooYoung;
    if (getequipid(equip_shield) != 702 || getequipid(equip_shield, @args$) != 702) goto L_NoRing;

    if (get(@marriage[0], .@target_id) == BL_ID) goto L_Proceed;

    setarray @marriage[0], .@target_id, gettimetick(2);
    addtimer (.timeout * 1000), strnpcinfo(0) + "::OnTimeout";
    announce strcharinfo(0) + " is asking " + strcharinfo(0, .@target_id) + " for marriage.", 2;
    message strcharinfo(0, .@target_id), "Marriage : ##3##B" + strcharinfo(0) + " wishes to marry you. To accept, write `##1#marry "+strcharinfo(0)+"##3` within the next "+.timeout+" seconds.";
    end;

L_NotFound:
    message strcharinfo(0), "Marriage : ##3##BThe target player is either not found or yourself.";
    end;

L_TooYoung:
    message strcharinfo(0), "Marriage : ##3##BYou and your partner need to be at least level "+ WEDDING_MIN_LEVEL +".";
    end;

L_NoRing:
    message strcharinfo(0), "Marriage : ##3##BYou and your partner need to have ["+ getitemlink("WeddingRing") +"] equipped.";
    end;

L_AwayFromPartner:
    message strcharinfo(0), "Marriage : ##3##BYou and your partner need to be standing next to each other.";
    end;

L_NotInArea:
    message strcharinfo(0), "Marriage : ##3##BYou are not standing in a designated marriage area.";
    end;

L_Proceed:
    if ((gettimetick(2) - .timeout) > get(@marriage[1], .@target_id)) goto L_TooLate;
    set PARTNER, CHAR_ID, .@target_id;
    if (PARTNER == get(CHAR_ID, .@target_id)) goto L_Success;
    set PARTNER, 0, .@target_id;
    set PARTNER, 0;
    end;

L_Success:
    announce strcharinfo(0) + " and " + strcharinfo(0, .@target_id) + " are now married.", 2;
    end;

OnTimeout:
    goto L_TooLate;

L_TooLate:
    message strcharinfo(0), "Marriage : ##3##BThe proposal expired. Please try again.";
    message strcharinfo(0, @marriage[0]), "Marriage : ##3##BThe proposal expired. Please try again.";
    set @marriage[0], 0, @marriage[0];
    set @marriage[0], 0;
    end;

L_AlreadyMarried:
    message strcharinfo(0), "Marriage : ##3##BYou"+ if_then_else(PARTNER, " are", "r partner is") +" already married.";
    end;

OnInit:
    set .timeout, 30; // timeout for proposal
    registercmd "#marry", strnpcinfo(0); // we NEED to use a # before `marry` because otherwise manaplus does not strip colors
    end;
}