Combat Manger Object #42

Parent #1Owner #10Flags read, writeSource MurpgCore-0.4/MurpgCore-0.4.db

2 verbs · 20 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
init_orderthis none thisrwxd#4223
battlethis none thisrwxd#4272

Properties

PropertyDefinerFlagsOwnerValue
base_thac0#42rw#1020
round_length#42rw#102
hit_color#42rw#10"%Y"
crit_color#42rw#10"%R"
miss_color#42rw#10"%c"
end_per_round#42rw#104
description#1rw#10<clear>
aliases#1rw#10<clear>
home#1rw#10<clear>
short_desc#1rw#10<clear>
core#1rw#101
handedness#1rw#10<clear>
base_enc#1rw#10<clear>
base_weight#1rw#10<clear>
capacity#1rw#10<clear>
max_fit#1rw#10<clear>
pprep#1rw#10<clear>
gprep#1rw#10<clear>
generic_name#1rw#10<clear>
age#1rw#10<clear>

Ancestry

Ancestors (nearest first): #1 Root Class

Children: none

Call graph

calls n42_1 #42:battle n42_1->n42_1 n42_0 #42:init_order n42_1->n42_0

Source

init_order

Spec this none thisFlags rwxdOwner #10Definer #42

Referenced by

Source

1"$combat:init_order ( list ) this none this";
2"returns list sorted by init rolls (attack order)";
3"assumes that combatant.combat_weapon is set to something";
4{combatants} = args;
5init_order = {};
6for each in (combatants)
7each.combat_init = each:init_roll(each.combat_weapon);
8list_size = length(init_order);
9if (list_size == 0)
10init_order = {@init_order, each};
11else
12x = 1;
13while ((init_order[x].combat_init < each.combat_init) && (x < list_size))
14x = x + 1;
15endwhile
16if (each.combat_init <= init_order[x].combat_init)
17init_order = listinsert(init_order, each, x);
18elseif (x == list_size)
19init_order = {@init_order, each};
20endif
21endif
22endfor
23return init_order;

battle

Spec this none thisFlags rwxdOwner #10Definer #42

Referenced by

Source

1"$combat:battle( location ) this none this";
2"forked by _attack() and/or itself";
3"performs auto combat for animates in location";
4{loc} = args;
5combatants = loc.combatants;
6"set weapon for this round";
7for each in (combatants)
8each.combat_weapon = each:get_weapon();
9endfor
10"arrange combatants in order of initiative roll";
11combatants = $combat:init_order(combatants);
12for each in (combatants)
13each:lower_endurance($combat.end_per_round);
14each:tell("");
15endfor
16for each in (combatants)
17if (each.combat_stance == "attack")
18targ = each:get_target();
19if (targ != 0)
20each:hit(targ);
21else
22loc.combatants = setremove(loc.combatants, each);
23endif
24elseif (each.combat_stance == "passive")
25"do nothing";
26for targ in (each.targets)
27if (targ.combat_stance != "attack")
28targ.targets = setremove(targ.targets, each);
29each.targets = setremove(each.targets, targ);
30endif
31endfor
32elseif (each.combat_stance == "flee")
33for targ in (each.targets)
34if (targ.combat_stance != "attack")
35targ.targets = setremove(targ.targets, each);
36each.targets = setremove(each.targets, targ);
37endif
38endfor
39viewers = each.location:get_animates();
40viewers = setremove(viewers, each);
41for guy in (viewers)
42guy:sees(3, {each:known_to(guy)[2] + " attempts to flee, but can't escape."});
43endfor
44each:tell("You attempt to flee, but can't escape.");
45elseif (each.combat_stance == "defend")
46"do nothing";
47for targ in (each.targets)
48if (targ.combat_stance != "attack")
49targ.targets = setremove(targ.targets, each);
50each.targets = setremove(each.targets, targ);
51endif
52endfor
53endif
54if (each.targets == {})
55combatants = setremove(combatants, each);
56endif
57"if neither is attacking, take out of targets";
58endfor
59loc.combatants = combatants;
60if (loc.combatants != {})
61fork pid ($combat.round_length)
62$combat:battle(loc);
63endfork
64loc.combat_pid = pid;
65else
66loc.combat_pid = 0;
67viewers = loc:get_animates();
68for each in (viewers)
69each:sees(3, {"The fray has ended."});
70endfor
71endif
72notify(#5, "Ticks left: " + tostr(ticks_left()));