-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Destat NPC #119
base: main
Are you sure you want to change the base?
Destat NPC #119
Changes from 9 commits
7ba0bd5
1d316ab
4d4a77a
f5ae56d
23abfd1
3647948
4cc4f73
2071755
d6957a0
61e05bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5585,6 +5585,50 @@ function init_io() { | |
resend(player, "reopen+nc+inv"); | ||
success_response({ num: num, cevent: true }); | ||
}); | ||
|
||
socket.on("destat", function (data) { | ||
var player = players[socket.id]; | ||
var item = player.items[data.item_num]; | ||
var def = G.items[item && item.name]; | ||
if (!player || player.user) { | ||
return fail_response("cant_in_bank"); | ||
} | ||
if (!player.computer && simple_distance(G.maps.desertland.ref.scrollsmith, player) > B.sell_dist) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probable use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return fail_response("distance"); | ||
} | ||
var item = player.items[data.num]; | ||
if (!item) { | ||
return fail_response("no_item"); | ||
} | ||
var def = G.items[item.name]; | ||
Comment on lines
+5597
to
+5601
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you redefine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied a lot of the code from |
||
if (item.stat_type == null) { | ||
return fail_response("scrollsmith_cant"); | ||
} | ||
var scrolltype = item.stat_type + "scroll"; | ||
if (scrolltype == "mp_costscroll") { | ||
scrolltype = "mpcostscroll"; | ||
Comment on lines
+5605
to
+5607
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you try with all scrolls to make sure they all follow the pattern except There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
} | ||
var scrolldef = G.items[scrolltype]; | ||
if (!scrolldef) { | ||
return fail_response("scrollsmith_cant"); // Just in case there isn't actually an item associated with the scroll... should never happen, though. | ||
} | ||
var needed = [1, 10, 100, 1000, 9999, 9999, 9999]; | ||
var ograde = calculate_item_grade(def, { name: item.name, level: 0 }); | ||
var cost = needed[ograde] * scrolldef.g * 10; | ||
if (player.gold < cost) { | ||
return fail_response("gold_not_enough"); | ||
} | ||
if (!can_add_items(player, list_to_pseudo_items([[needed[ograde], scrolltype]]))) { | ||
return fail_response("inv_size"); | ||
} | ||
player.gold -= cost; | ||
add_item(player, scrolltype, { q: needed[ograde] }); | ||
delete item.stat_type; | ||
socket.emit("game_response", { response: "scrollsmith_success", gold: cost }); | ||
player.citems[data.num] = cache_item(player.items[data.num]); | ||
resend(player, "reopen+nc"); | ||
success_response(); | ||
}); | ||
socket.on("locksmith", function (data) { | ||
var player = players[socket.id]; | ||
var item = player.items[data.item_num]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable was
num
in the client-side function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.