static void _water_ball_spell(int cmd, variant *res) { int l = p_ptr->lev; int dam = l*2 + l*l/25 + l*l*l/1250; switch (cmd) { case SPELL_NAME: var_set_string(res, "Water Ball"); break; case SPELL_DESC: var_set_string(res, "Fires a huge ball of water."); break; case SPELL_INFO: var_set_string(res, info_damage(0, 0, dam)); break; case SPELL_CAST: { int dir = 0; var_set_bool(res, FALSE); if (!get_aim_dir(&dir)) return; fire_ball(GF_WATER2, dir, dam, 4); var_set_bool(res, TRUE); break; } case SPELL_COST_EXTRA: var_set_int(res, dam / 10); break; default: default_spell(cmd, res); break; } }
static void _banishing_mirror_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Banishing Mirror"); break; case SPELL_DESC: if (_on_mirror) var_set_string(res, "Quickly teleport away a nearby monster."); else var_set_string(res, "Teleport away a nearby monster."); break; case SPELL_CAST: { int dir; var_set_bool(res, FALSE); if (!get_aim_dir(&dir)) return; fire_beam(GF_AWAY_ALL, dir, spell_power(p_ptr->lev)); var_set_bool(res, TRUE); break; } case SPELL_ENERGY: if (_on_mirror) { var_set_int(res, 50); break; } default: default_spell(cmd, res); break; } }
static void _excavation_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Excavation"); break; case SPELL_DESC: var_set_string(res, "You break walls on your quest for treasure! This takes a bit more time, though."); break; case SPELL_ENERGY: { int n = 200; if (equip_find_object(TV_DIGGING, SV_ANY)) n -= 120 * p_ptr->lev / 50; else n -= 80 * p_ptr->lev / 50; var_set_int(res, n); } break; case SPELL_CAST: { int dir = 5; bool b = FALSE; if ( get_rep_dir2(&dir) && dir != 5 ) { int x, y; y = py + ddy[dir]; x = px + ddx[dir]; if (!in_bounds(y, x)) { msg_print("You may excavate no further."); } else if ( cave_have_flag_bold(y, x, FF_WALL) || cave_have_flag_bold(y, x, FF_TREE) || cave_have_flag_bold(y, x, FF_CAN_DIG) ) { msg_print("You dig your way to treasure!"); cave_alter_feat(y, x, FF_TUNNEL); teleport_player_to(y, x, TELEPORT_NONMAGICAL); /*??*/ b = TRUE; } else { msg_print("There is nothing to excavate."); } } var_set_bool(res, b); } break; default: default_spell(cmd, res); break; } }
static void _shard_ball_spell(int cmd, variant *res) { int l = p_ptr->lev; int dam = l*2 + l*l/25 + l*l*l/1250; switch (cmd) { case SPELL_NAME: var_set_string(res, "Shard Ball"); break; case SPELL_DESC: var_set_string(res, "Fires a ball of shards at chosent target"); break; case SPELL_INFO: var_set_string(res, info_damage(0, 0, dam)); break; case SPELL_CAST: { int dir = 0; var_set_bool(res, FALSE); if (!get_aim_dir(&dir)) return; fire_ball(GF_SHARDS, dir, dam, 2); var_set_bool(res, TRUE); break; } case SPELL_COST_EXTRA: var_set_int(res, dam / 6); break; default: default_spell(cmd, res); break; } }
void strafing_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Strafing"); break; case SPELL_DESC: var_set_string(res, "Blink to a new location in the line of sight of your current location."); break; case SPELL_ENERGY: if (mut_present(MUT_ASTRAL_GUIDE)) var_set_int(res, 30); else default_spell(cmd, res); break; case SPELL_CAST: teleport_player(10, TELEPORT_LINE_OF_SIGHT); var_set_bool(res, TRUE); break; default: default_spell(cmd, res); break; } }
static void _mirror_of_wandering_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Mirror of Wandering"); break; case SPELL_DESC: if (_on_mirror) var_set_string(res, "Quickly teleport a long distance."); else var_set_string(res, "Teleport a long distance."); break; case SPELL_CAST: teleport_player(p_ptr->lev*5, 0); var_set_bool(res, TRUE); break; case SPELL_ENERGY: if (_on_mirror) { var_set_int(res, 50); break; } default: default_spell(cmd, res); break; } }
static void _shine_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Shine"); break; case SPELL_DESC: var_set_string(res, "Generates a large ball of sunlight."); break; case SPELL_INFO: var_set_string(res, info_damage(0, 0, p_ptr->lev * 3)); break; case SPELL_CAST: fire_ball(GF_LITE, 0, p_ptr->lev * 3 * 2, 3); var_set_bool(res, TRUE); break; case SPELL_COST_EXTRA: var_set_int(res, (p_ptr->lev - 20)/2); break; default: default_spell(cmd, res); break; } }
static void _first_aid_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "First Aid"); break; case SPELL_DESC: if (p_ptr->lev < 8) var_set_string(res, "Heals HP and Stun."); else if (p_ptr->lev < 12) var_set_string(res, "Heals HP and Stun. Cures cuts."); else if (p_ptr->lev < 16) var_set_string(res, "Heals HP and Stun. Cures cuts and slows poison."); else if (p_ptr->lev < 20) var_set_string(res, "Heals HP and Stun. Cures cuts and poison."); else if (p_ptr->lev < 30) var_set_string(res, "Heals HP and Stun. Cures cuts, poison and blindness."); else if (p_ptr->lev < 40) var_set_string(res, "Heals HP and Stun. Cures cuts, poison and blindness. Restores Con."); else if (p_ptr->lev < 45) var_set_string(res, "Heals HP and Stun. Cures cuts, poison and blindness. Restores Con and Chr."); else var_set_string(res, "Heals HP and Stun. Cures cuts, poison and blindness. Restores Con, Chr and Str."); break; case SPELL_SPOIL_DESC: var_set_string(res, "Heals HP and Stun. Slows Poison (L12). Cures cuts (L8), poison (L16) and blindness (L20). Restores Con (L30), Chr (L40) and Str (L45)."); break; case SPELL_INFO: var_set_string(res, info_heal(0, 0, spell_power(p_ptr->lev))); break; case SPELL_CAST: hp_player(spell_power(p_ptr->lev)); set_stun(0, TRUE); if (p_ptr->lev >= 8) set_cut(0, TRUE); if (p_ptr->lev >= 12 && p_ptr->lev < 16) set_poisoned(p_ptr->poisoned / 2, TRUE); if (p_ptr->lev >= 16) set_poisoned(0, TRUE); if (p_ptr->lev >= 20) set_blind(0, TRUE); if (p_ptr->lev >= 30) do_res_stat(A_CON); if (p_ptr->lev >= 40) do_res_stat(A_CHR); if (p_ptr->lev >= 45) do_res_stat(A_STR); var_set_bool(res, TRUE); break; case SPELL_COST_EXTRA: var_set_int(res, p_ptr->lev / 5); break; default: default_spell(cmd, res); break; } }
void _cyber_rocket_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Rocket"); break; case SPELL_DESC: var_set_string(res, "Launches a powerful rocket at your opponent."); break; case SPELL_INFO: var_set_string(res, info_damage(0, 0, _rocket_amount())); break; case SPELL_CAST: { int dir = 0; var_set_bool(res, FALSE); if (!get_aim_dir(&dir)) return; msg_print("You launch a rocket."); fire_rocket(GF_ROCKET, dir, _rocket_amount(), 2); var_set_bool(res, TRUE); break; } case SPELL_COST_EXTRA: var_set_int(res, p_ptr->lev*19/50 + p_ptr->lev*p_ptr->lev*19/2500); break; default: default_spell(cmd, res); break; } }
void _learning_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Learning"); break; case SPELL_DESC: var_set_string(res, ""); break; case SPELL_CAST: if (p_ptr->action == ACTION_LEARN) set_action(ACTION_NONE); else set_action(ACTION_LEARN); var_set_bool(res, TRUE); break; case SPELL_ENERGY: var_set_int(res, 0); break; default: default_spell(cmd, res); break; } }
void breathe_fire_II_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Breathe Fire"); break; case SPELL_DESC: var_set_string(res, "Breathes Fire at your opponent."); break; case SPELL_INFO: var_set_string(res, info_damage(0, 0, spell_power(p_ptr->chp*2/5))); break; case SPELL_COST_EXTRA: var_set_int(res, p_ptr->lev); break; case SPELL_CAST: { int dir = 0; var_set_bool(res, FALSE); if (get_fire_dir(&dir)) { stop_mouth(); msg_print("You breathe fire..."); fire_ball(GF_FIRE, dir, spell_power(p_ptr->chp*2/5), -1 - (p_ptr->lev / 20)); var_set_bool(res, TRUE); } break; } default: default_spell(cmd, res); break; } }
static void _warped_mirror_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Warped Mirror"); break; case SPELL_DESC: if (_on_mirror) var_set_string(res, "Quickly teleport a short distance."); else var_set_string(res, "Teleport a short distance."); break; case SPELL_CAST: teleport_player(10, 0); var_set_bool(res, TRUE); break; case SPELL_ENERGY: if (_on_mirror) { var_set_int(res, 50); break; } default: default_spell(cmd, res); break; } }
static int parse_unary(struct _asm_context *asm_context, int64_t *num, int operation) { char token[TOKENLEN]; int token_type; int64_t temp; struct _var var; var_set_int(&var, 0); token_type = tokens_get(asm_context, token, TOKENLEN); //printf("parse_unary: %s token_type=%d(%d)\n", token, token_type, TOKEN_NUMBER); if (IS_TOKEN(token,'-')) { if (parse_unary(asm_context, &temp, OPER_MINUS) == -1) { return -1; } } else if (IS_TOKEN(token,'~')) { if (parse_unary(asm_context, &temp, OPER_NOT) != 0) { return -1; } } else if (token_type == TOKEN_NUMBER) { temp = atoll(token); } else if (IS_TOKEN(token, '(')) { if (eval_expression_ex(asm_context, &var) != 0) { return -1; } if (var.type != VAR_INT) { print_error("Non-integer number in expression", asm_context); return -1; } temp = var_get_int64(&var); token_type = tokens_get(asm_context, token, TOKENLEN); if (IS_NOT_TOKEN(token,')')) { print_error_unexp(token, asm_context); return -1; } } else { print_error_unexp(token, asm_context); return -1; } if (operation == OPER_NOT) { *num = ~temp; } else if (operation == OPER_MINUS) { *num = -temp; } else { print_error_internal(NULL, __FILE__, __LINE__); return -1; } return 0; }
int main(int argc, char *argv[]) { struct _var var1,var2; printf("Testing var.h\n"); var_set_int(&var1, 1000); CHECK(var1, 1000, 1000); var_set_float(&var1, 99.32); CHECK(var1, 99, 99.32); var_set_int(&var1, 0x0122223333); CHECK_INT(var1, 0x22223333, 0x122223333); var_set_int(&var1, 0xffffffffffffffff); CHECK_INT(var1, 0xffffffff, 0xffffffffffffffff); var_set_int(&var1, 0x0fffffffffffffff); CHECK_INT(var1, 0xffffffff, 0x0fffffffffffffff); TEST_OP(add, int, -10, 20, 10, 10); TEST_OP(add, int, 10, 20, 30, 30); TEST_OP(sub, int, -10, 20, -30, -30); TEST_OP(sub, int, 10, 20, -10, -10); TEST_OP(mul, int, 10, 20, 200, 200); TEST_OP(div, int, 10, 20, 0, 0); TEST_OP(div, int, 20, -10, -2, -2); TEST_OP(add, float, -10.1, 20, 9, 9.9); TEST_OP(add, float, -10, 20.2, 10, 10.2); TEST_OP(sub, float, -10, 20.2, -30, -30.2); TEST_OP(mul, float, -10, 20.2, -202, -202); TEST_OP(mul, float, 8, 20.2, 161, 161.60); TEST_OP(div, float, 2.56, 8, 0, 0.32); TEST_OP(div, float, 32.8, 4, 8, 8.2); TEST_OP_INT(add, int, 0xffffffff, 1, 0, 0x100000000); if (errors != 0) { printf("var.h ... FAILED.\n"); return -1; } printf("var.h ... PASSED.\n"); return 0; }
int eval_expression_ex(struct _asm_context *asm_context, struct _var *var) { struct _operator operator; var_set_int(var, 0); operator.precedence = PREC_UNSET; operator.operation = OPER_UNSET; return eval_expression_go(asm_context, var, &operator); }
/**************************************************************** * Spells ****************************************************************/ static void _toggle_spell(int which, int cmd, variant *res) { switch (cmd) { case SPELL_CAST: var_set_bool(res, FALSE); if (_get_toggle() == which) _set_toggle(TOGGLE_NONE); else _set_toggle(which); var_set_bool(res, TRUE); break; case SPELL_ENERGY: if (_get_toggle() != which) var_set_int(res, 0); /* no charge for dismissing a technique */ else var_set_int(res, 100); break; default: default_spell(cmd, res); break; } }
static void _tval_menu_fn(int cmd, int which, vptr cookie, variant *res) { switch (cmd) { case MENU_KEY: var_set_int(res, _tval_choices[which].name[0]); break; case MENU_TEXT: var_set_string(res, format("%s", _tval_choices[which].name)); break; default: default_menu(cmd, which, cookie, res); } }
static void _spell_menu_fn(int cmd, int which, vptr cookie, variant *res) { _spell_menu_t *ss = (_spell_menu_t*)cookie; _spell_menu_t *s = ss + which; switch (cmd) { case MENU_TEXT: if (s->total_charges) { char buf[1024]; _kind_t k = s->spell->kind; cptr info = _do_device(s->spell->kind.tval, s->spell->kind.sval, SPELL_INFO); sprintf(buf, "%-22.22s %3d %3d %3d%% ", _kind_name(&k), s->charges, s->total_charges, s->fail); if (info) strcat(buf, info); var_set_string(res, buf); } else var_clear(res); break; case MENU_HELP: var_set_string(res, _kind_desc(&s->spell->kind)); break; case MENU_COLOR: if (!s->total_charges) var_set_int(res, TERM_DARK); else if (!s->charges) var_set_int(res, TERM_RED); else var_set_int(res, TERM_WHITE); break; default: default_menu(cmd, which, cookie, res); } }
static void _rune_default_spell(int cmd, variant *res) { switch (cmd) { case SPELL_COST_EXTRA: var_set_int(res, p_ptr->msp); break; /*case SPELL_COLOR: var_set_int(res, TERM_L_BLUE); break; */ default: default_spell(cmd, res); break; } }
static void _group_menu_fn(int cmd, int which, vptr cookie, variant *res) { _group_t *groups = (_group_t*)cookie; switch (cmd) { case MENU_KEY: var_set_int(res, groups[which].name[0]); break; case MENU_TEXT: var_set_string(res, format("%s", groups[which].name)); break; default: default_menu(cmd, which, cookie, res); } }
void monk_double_attack_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Double Attack"); break; case SPELL_DESC: var_set_string(res, "Attack twice at an adjacent enemy. This action consumes double the normal energy."); break; case SPELL_CAST: var_set_bool(res, FALSE); if (_monk_check_spell()) { int x, y, dir = 0; if (!get_rep_dir(&dir, FALSE)) return; y = py + ddy[dir]; x = px + ddx[dir]; if (cave[y][x].m_idx) { if (one_in_(2)) msg_print("Ahhhtatatatatatatatatatatatatatataatatatatattaaaaa!!!!"); else msg_print("Oraoraoraoraoraoraoraoraoraoraoraoraoraoraoraoraora!!!!"); py_attack(y, x, 0); if (cave[y][x].m_idx) { handle_stuff(); py_attack(y, x, 0); } } else { msg_print("You don't see any monster in this direction"); msg_print(NULL); } var_set_bool(res, TRUE); } break; case SPELL_ENERGY: var_set_int(res, 100 + ENERGY_NEED()); break; default: default_spell(cmd, res); break; } }
static void _spell_menu_fn(int cmd, int which, vptr cookie, variant *res) { switch (cmd) { case MENU_TEXT: var_set_string(res, _groups[which].name); break; case MENU_HELP: var_set_string(res, _groups[which].help); break; case MENU_COLOR: var_set_int(res, _groups[which].color); break; default: default_menu(cmd, which, cookie, res); } }
void _minor_displacement_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: if (p_ptr->lev >= 45) var_set_string(res, "Dimension Door"); else var_set_string(res, "Minor Displacement"); break; case SPELL_SPOIL_NAME: var_set_string(res, "Minor Displacement"); break; case SPELL_DESC: if (p_ptr->lev >= 45) var_set_string(res, "Attempt to teleport to a specific location."); else var_set_string(res, "Teleport short distance."); break; case SPELL_SPOIL_DESC: var_set_string(res, "Teleports the player (Range 10). At L45, gives dimension door instead (Range L/2 + 10)."); break; case SPELL_CAST: { if (p_ptr->lev >= 45) var_set_bool(res, dimension_door(p_ptr->lev / 2 + 10)); else { teleport_player(10, 0L); var_set_bool(res, TRUE); } break; } case SPELL_COST_EXTRA: { int n = 0; if (p_ptr->lev >= 45) n += 40; var_set_int(res, n); break; } default: default_spell(cmd, res); break; } }
static void _evasive_leap_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Evasive Leap"); break; case SPELL_ENERGY: if (p_ptr->shero) { var_set_int(res, 30); break; } default: strafing_spell(cmd, res); break; } }
void breathe_fire_I_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Breathe Fire"); break; case SPELL_DESC: var_set_string(res, "Breathes Fire at your opponent."); break; case SPELL_GAIN_MUT: msg_print("You gain the ability to breathe fire."); break; case SPELL_LOSE_MUT: msg_print("You lose the ability to breathe fire."); break; case SPELL_MUT_DESC: var_set_string(res, "You can breathe fire (dam lvl * 2)."); break; case SPELL_INFO: var_set_string(res, info_damage(0, 0, spell_power(2 * p_ptr->lev))); break; case SPELL_COST_EXTRA: var_set_int(res, (p_ptr->lev+1)/2); break; case SPELL_CAST: { int dir = 0; var_set_bool(res, FALSE); if (get_aim_dir(&dir)) { stop_mouth(); msg_print("You breathe fire..."); fire_ball(GF_FIRE, dir, spell_power(2 * p_ptr->lev), -1 - (p_ptr->lev / 20)); var_set_bool(res, TRUE); } break; } default: default_spell(cmd, res); break; } }
void hex_stop_spelling_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Stop Spelling"); break; case SPELL_DESC: var_set_string(res, ""); break; case SPELL_ENERGY: var_set_int(res, 10); break; case SPELL_CAST: var_set_bool(res, stop_hex_spell()); break; default: default_spell(cmd, res); break; } }
static void _breathe_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Breathe"); break; case SPELL_DESC: var_set_string(res, format("Breathes %s at your opponent.", _breath_desc())); break; case SPELL_INFO: var_set_string(res, info_damage(0, 0, _breath_amount())); break; case SPELL_COST_EXTRA: { int l = p_ptr->lev; int cst = l*l/100; var_set_int(res, cst); break; } case SPELL_CAST: { int dir = 0; var_set_bool(res, FALSE); if (get_aim_dir(&dir)) { int e = _breath_effect(); msg_format("You breathe %s", gf_name(e)); fire_ball(e, dir, _breath_amount(), -1 - (p_ptr->lev / 20)); var_set_bool(res, TRUE); } break; } default: default_spell(cmd, res); break; } }
void quick_walk_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, T("Quick Walk", "┬о╢юд▒")); break; case SPELL_DESC: var_set_string(res, ""); break; case SPELL_CAST: if (p_ptr->action == ACTION_HAYAGAKE) set_action(ACTION_NONE); else set_action(ACTION_HAYAGAKE); var_set_bool(res, TRUE); break; case SPELL_ENERGY: var_set_int(res, 0); break; default: default_spell(cmd, res); break; } }
void hound_stalk_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Stalk"); break; case SPELL_DESC: var_set_string(res, "By moving slowly, you will be able to sneak up on your prey very effectively."); break; case SPELL_CAST: if (p_ptr->action == ACTION_STALK) set_action(ACTION_NONE); else set_action(ACTION_STALK); var_set_bool(res, TRUE); break; case SPELL_ENERGY: var_set_int(res, 0); break; default: default_spell(cmd, res); break; } }
static void _mirror_tunnel_spell(int cmd, variant *res) { switch (cmd) { case SPELL_NAME: var_set_string(res, "Mirror Tunnel"); break; case SPELL_DESC: if (_on_mirror) var_set_string(res, "Quickly teleport to a given location."); else var_set_string(res, "Teleport to a given location."); break; case SPELL_CAST: { int x = 0, y = 0; var_set_bool(res, FALSE); msg_print("You go through the mirror world ..."); if (!tgt_pt(&x, &y, p_ptr->lev / 2 + 10)) return; if (!dimension_door_aux(x, y, p_ptr->lev / 2 + 10)) msg_print("You fail to pass into the mirror plane correctly!"); var_set_bool(res, TRUE); break; } case SPELL_ENERGY: if (_on_mirror) { var_set_int(res, 50); break; } default: default_spell(cmd, res); break; } }