Skip to content

Commit

Permalink
Fixed a bug where NumLock button get spammed when Elona opens in back…
Browse files Browse the repository at this point in the history
…ground

Added a tweak to disable random CNPC spawn / enable CNPC summon using a summoning crystal
  • Loading branch information
JianmengYu committed May 19, 2023
1 parent ce20d65 commit ee3f15e
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 3 deletions.
12 changes: 12 additions & 0 deletions 2.05-custom-gx/action.hsp
Original file line number Diff line number Diff line change
Expand Up @@ -13369,6 +13369,18 @@
}
if ( _switch_val == EFFECT_SUMMONING_CRYSTAL | _switch_sw ) {
_switch_sw = 0
/********** CUSTOM NPC SUMMONING - BEGINNING **********/
if ( TweakData(TWEAK_GAMEPLAY_CUSTOM_CNPC_SUMMONING, TWEAK_CATEGORY_GAMEPLAY) != 0 ) {
if ( gdata(GDATA_AREA) != AREA_SHOW_HOUSE ) {
if ( mdata(MDATA_TYPE) == MAP_TYPE_WORLD ) {
txt lang("それは鈍く輝いた。", "It glows dully.")
goto *act_use_SWEND1
}
gosub *com_userNpcExisting
goto *act_use_SWEND1
}
}
/********** CUSTOM NPC SUMMONING - ENDING **********/
if ( gdata(GDATA_AREA) != AREA_SHOW_HOUSE ) {
txt lang("それは鈍く輝いた。", "It glows dully.")
goto *act_use_SWEND1
Expand Down
333 changes: 333 additions & 0 deletions 2.05-custom-gx/command.hsp
Original file line number Diff line number Diff line change
Expand Up @@ -6839,6 +6839,339 @@
}
goto *com_tone_loop

/********** CUSTOM NPC SUMMONING - BEGINNING **********/
*com_userNpcExisting
snd SOUNDLIST_CHARA
gsel 4
repeat 8
pos cnt \ 4 * 180, cnt / 4 * 300
picload exedir + "\\graphic\\g" + (cnt + 1) + ".bmp", 1
loop
gsel 0
listmax = 0
page = 0
pagesize = 14
cs = 0
cc = CHARA_PLAYER
cs_bk = -1
repeat usernpcmax
if ( instr(userdatan(6, cnt), 0, "_tmp_") > (-1) ) {
continue
}
setCom lang(userdatan(1, cnt) + "(" + userdatan(0, cnt) + ")", userdatan(1, cnt)), userdatan(6, cnt)
loop
txt lang("どの者を召喚したいと願うか?", "Check which CNPC?")
windowshadow = 1
*com_userNpcExisting_loop_pgchk
redraw 0
page_check
*com_userNpcExisting_loop
redraw 0
s = lang("カスタムNPC一覧", "Custom NPC"), lang("決定 [召喚] ", "Enter [Details] ") + strhint2 + strhint3
display_window (windoww - 500) / 2 + inf_screenx, winposy(400), 500, 400
x = ww / 5 * 3
y = wh - 80
gmode 4, 180, 300, 50
pos wx + ww / 3 * 2, wy + wh / 2
grotate 4, cmbg / 4 \ 4 * 180, cmbg / 4 / 4 \ 2 * 300, 0, x, y
gmode 2
display_topic lang("名前", "Name"), wx + 28, wy + 36
display_topic lang("Level", "Level"), wx + 348, wy + 36
keyrange = 0
repeat pagesize
p = pagesize * page + cnt
if ( p >= listmax ) {
break
}
key_list(cnt) = key_select(cnt)
keyrange++
if ( cnt \ 2 == 0 ) {
pos wx + 70, wy + 66 + cnt * 19
gfini ww - 100, 18
gfdec2 12, 14, 16
}
display_key wx + 58, wy + 66 + cnt * 19 - 2, cnt
loop
gmode 2
font lang(cfg_font1, cfg_font2), 14 - en * 2, 0
cs_listbk
repeat pagesize
p = pagesize * page + cnt
if ( p >= listmax ) {
break
}
i = list(0, p)
s = "" + listn(0, p)
pos wx + 380, wy + 66 + cnt * 19
mes "" + userdata(2, i)
cs_list s, wx + 85, wy + 66 + cnt * 19 - 1, 19
loop
if ( keyrange != 0 ) {
cs_bk = cs
}
redraw 1
await cfg_wait1
key_check
cursor_check
p = -1
repeat keyrange
if ( key == key_select(cnt) ) {
p = list(0, pagesize * page + cnt)
cs = cnt
break
}
loop
if ( p != (-1) ) {
gosub *com_knowCNPC
if ( key == key_enter ) {
f = 0
if ( cdata(CDATA_PLATINUM, CHARA_PLAYER) >= userdata(2, knowCNPC) ) {
txtef COLOR_YELLOW
txt lang("..?", "Summon them as friendly npc? It will cost you " + userdata(2, knowCNPC) + " plantinum coins.")
promptYesNo
if ( rtval == 0 ) {
cdata(CDATA_PLATINUM, CHARA_PLAYER) -= userdata(2, knowCNPC)
f = 1
}
}
initunid = findunid(userdatan(0, knowCNPC))
txtef COLOR_GREEN
txt lang("カスタムNPCを作成した!", "A custom NPC has been successfully summoned from another world!")
if ( cdata(CDATA_X, CHARA_PLAYER) > 1 ) {
sux = cdata(CDATA_X, CHARA_PLAYER) - 1
}
flt
characreate -1, CREATURE_ID_USER, sux, cdata(CDATA_Y, CHARA_PLAYER)
repeat MAX_CHARA_TOTAL
if ( cdata(CDATA_ID, cnt) == CREATURE_ID_USER ) {
getunid cnt
}
loop
txtef COLOR_YELLOW
if ( f == 1 ) {
cdata(CDATA_RELATION, rc) = -1
cdata(CDATA_RELATION_ORG, rc) = -1
txt lang(name(rc) + "は興奮して襲い掛かってきた。", cdatan(CDATAN_NAME, rc) + " is excited!")
} else {
cdata(CDATA_RELATION, rc) = -3
cdata(CDATA_RELATION_ORG, rc) = -3
txt lang(name(rc) + "は興奮して襲い掛かってきた。", cdatan(CDATAN_NAME, rc) + " is confused and attacks you.")
}
return 1
}
key = ""
}
page_change *com_userNpcExisting_loop_pgchk
if ( key == key_cancel ) {
return -1
}
goto *com_userNpcExisting_loop

*com_knowCNPC
listmaxbk = listmax
pagesizebk = pagesize
pagemaxbk = pagemax
pagebk = page
cs_bk2 = cs
listmax = 0
pagesize = 13
page = 0
cc = tc
snd SOUNDLIST_POP2
knowCNPC = p

ww = 380
wh = 400
wx = (windoww - ww) / 2 + inf_screenx
wy = winposy(wh)
windowanime wx, wy, ww, wh, 40, 7
gsel 3
pos 960, 96
picload exedir + "graphic\\deco_mirror.bmp", 1
gsel 0
*com_knowCNPC_loop
redraw 0
s = lang("こころの中", "Image in the Crystal"), lang("Shift,Esc [戻る] 決定 [召喚] ", "Shift,Esc [Back] Enter [Summon] ")
display_window (windoww - 380) / 2 + inf_screenx, winposy(wh) - 12, ww, wh
display_topic lang("項目", "CNPC Summary"), wx + 34, wy + 36
font lang(cfg_font1, cfg_font2), 14 - en * 2, 0

if (page == 0) {
window2 wx + 234, wy + 90, 88, 120, 1, 1
i = SPRITE_SHEET_COLS_CHARA * SPRITE_SHEET_ROWS_CHARA + knowCNPC
chara_preparepic SPRITE_SHEET_COLS_CHARA * SPRITE_SHEET_ROWS_CHARA + knowCNPC, 0
pos wx + 276, wy + 149
gmode 2, chipc(CHIPC_WIDTH, i), chipc(CHIPC_HEIGHT, i)
grotate 5, 0, 960, 0, chipc(CHIPC_WIDTH, i), chipc(CHIPC_HEIGHT, i)
gmode 2
}

buff = ""
notesel buff
buff += "" + userdatan(1, knowCNPC) + "(" + userdatan(0, knowCNPC) + ")\n"
buff += "Level " + userdata(2, knowCNPC) + "\n"
if ( userdata(3, knowCNPC) == 0 ) { buff += "Male " }
if ( userdata(3, knowCNPC) == 1 ) { buff += "Female " }
buff += userdatan(2, knowCNPC) + "\n"
if ( userdata(5, knowCNPC) <= 1 ) { buff += "Common " }
if ( userdata(5, knowCNPC) == 2 ) { buff += "Skilled " }
if ( userdata(5, knowCNPC) == 3 ) { buff += "Professional " }
if ( userdata(5, knowCNPC) == 4 ) { buff += "Legendary " }
if ( userdata(5, knowCNPC) == 5 ) { buff += "Godly " }
if ( userdata(5, knowCNPC) == 6 ) { buff += "Well-Known " }
buff += userdatan(3, knowCNPC) + "\n"

buff += "Likes to: "
if ( userdata(7, knowCNPC) == 0 ) { buff += "Do Nothing.\n" }
if ( userdata(7, knowCNPC) == 1 ) { buff += "Walk Around.\n" }
if ( userdata(7, knowCNPC) == 2 ) { buff += "Walk in Circles.\n" }
if ( userdata(7, knowCNPC) == 3 ) { buff += "Do Nothing.\n" }
if ( userdata(7, knowCNPC) == 4 ) { buff += "Stalk People.\n" }
if ( userdata(7, knowCNPC) == 5 ) { buff += "Stalk Adventurers.\n" }
if ( userdata(7, knowCNPC) == 6 ) { buff += "Sing.\n" }
if ( userdata(7, knowCNPC) == 7 ) { buff += "Preach.\n" }
if ( userdata(7, knowCNPC) == 8 ) { buff += "Dance.\n" }
if ( userdata(7, knowCNPC) == 9 ) { buff += "Kill Snails.\n" }
if ( userdata(7, knowCNPC) == 10 ) { buff += "\"It's a secret\".\n" }
if ( userdata(7, knowCNPC) == 11 ) { buff += "Laze in Town.\n" }
if ( userdata(7, knowCNPC) == 12 ) { buff += "Beg for Money.\n" }

buff += "Prefered Distance: " + userdata(9, knowCNPC) + "\n"
buff += "Move Willingness: " + userdata(8, knowCNPC) + "%\n"
buff += "<title1>*Actions(" + (100 - unaiactsubfreq(knowCNPC)) + "%)<def>\n"
repeat 5
if ( userdata(15+cnt, knowCNPC) == 0 ) { buff += "Do Nothing\n" }
if ( userdata(15+cnt, knowCNPC) == (-1) ) { buff += "Melee Attack\n" }
if ( userdata(15+cnt, knowCNPC) == (-2) ) { buff += "Ranged Attack\n" }
if ( userdata(15+cnt, knowCNPC) == (-3) ) { buff += "Melee Attack\n" }
if ( userdata(15+cnt, knowCNPC) == (-4) ) { buff += "Roam Around\n" }
if ( userdata(15+cnt, knowCNPC) >= STARTING_SKILL_SPELL ) {
buff += skillname(userdata(15+cnt, knowCNPC)) + "\n"
}
loop
buff += "<title1>*Subactions(" + (unaiactsubfreq(knowCNPC)) + "%)<def>\n"
repeat 5
if ( userdata(20+cnt, knowCNPC) == 0 ) { buff += "Do Nothing\n" }
if ( userdata(20+cnt, knowCNPC) == (-1) ) { buff += "Melee Attack\n" }
if ( userdata(20+cnt, knowCNPC) == (-2) ) { buff += "Ranged Attack\n" }
if ( userdata(20+cnt, knowCNPC) == (-3) ) { buff += "Melee Attack\n" }
if ( userdata(20+cnt, knowCNPC) == (-4) ) { buff += "Roam Around\n" }
if ( userdata(20+cnt, knowCNPC) >= STARTING_SKILL_SPELL ) {
buff += skillname(userdata(20+cnt, knowCNPC)) + "\n"
}
loop
buff += "<title1>*Emergency Action<def>\n"
if ( userdata(10, knowCNPC) == 0 ) { buff += "Do Nothing\n" }
if ( userdata(10, knowCNPC) == (-1) ) { buff += "Melee Attack\n" }
if ( userdata(10, knowCNPC) == (-2) ) { buff += "Ranged Attack\n" }
if ( userdata(10, knowCNPC) == (-3) ) { buff += "Melee Attack\n" }
if ( userdata(10, knowCNPC) == (-4) ) { buff += "Roam Around\n" }
if ( userdata(10, knowCNPC) >= STARTING_SKILL_SPELL ) {
buff += skillname(userdata(10, knowCNPC)) + "\n"
}
buff += "<title1>*Resistance<def>\n"
csvstr2 unres, userdatan(5, knowCNPC)
repeat
if ( cnt > 15 | unres(cnt) == "" ) {
break
}
if ( unres(cnt * 2) == "") {
break
}
unrespower = limit( int(unres(cnt * 2 + 1)) / 2 + 4, 0, 8 )
unrestype = int(unres(cnt * 2))
if ( unrestype < 50 | unrestype > 60 ) {
continue
}
buff += _resist(unrespower) + " " + skilldesc(unrestype) + "\n"
loop
buff += "<title1>*Quirks<def>\n"
repeat 34
HMMBITCHECK userdata(40 + cnt / 32, knowCNPC), cnt \ 32
if ( stat ) {
if ( cnt == 5 ) { buff += "Can Float.\n" }
if ( cnt == 6 ) { buff += "Invisible.\n" }
if ( cnt == 7 ) { buff += "Keen Eyes.\n" }
if ( cnt == 8 ) { buff += "Immune to Confuse.\n" }
if ( cnt == 9 ) { buff += "Immune to Blind.\n" }
if ( cnt == 10 ) { buff += "Immune to Fear.\n" }
if ( cnt == 11 ) { buff += "Immune to Sleep.\n" }
if ( cnt == 12 ) { buff += "Immune to Paralyze.\n" }
if ( cnt == 13 ) { buff += "Immune to Poison.\n" }
if ( cnt == 14 ) { buff += "Iron Stomach.\n" }
if ( cnt == 15 ) { buff += "Hate Thieves.\n" }
if ( cnt == 16 ) { buff += "Stealthy.\n" }
if ( cnt == 17 ) { buff += "Loose Purse.\n" }
if ( cnt == 18 ) { buff += "Goes Kamikaze.\n" }
if ( cnt == 19 ) { buff += "Curses People.\n" }
if ( cnt == 20 ) { buff += "Master Blaster.\n" }
if ( cnt == 21 ) { buff += "Is a Defender.\n" }
if ( cnt == 22 ) { buff += "Like Carrying Others.\n" }
if ( cnt == 23 ) { buff += "Splits.\n" }
if ( cnt == 24 ) { buff += "Immune to Curse.\n" }
if ( cnt == 25 ) { buff += "Hate Carrying Others.\n" }
if ( cnt == 26 ) { buff += "Blessed by Elements.\n" }
if ( cnt == 27 ) { buff += "Splits.\n" }
if ( cnt == 28 ) { buff += "Made of Metal.\n" }
if ( cnt == 29 ) { buff += "Immune to Bleeding.\n" }
if ( cnt == 30 ) { buff += "Hate Walls.\n" }
if ( cnt == 31 ) { buff += "Think traps are okay.\n" }
if ( cnt == 32 ) { buff += "VERY ANGRY\n" }
if ( cnt == 33 ) { buff += "Was not made of flesh.\n" }
if ( cnt == 34 ) { buff += "Fastest " + userdatan(3, knowCNPC) + " in the West.\n" }
}
loop
listmax = noteinfo(0)
pagemax = (listmax / pagesize)
repeat pagesize
p = pagesize * page + cnt
if ( p >= listmax ) {
break
}
noteget s, p
gmesx = HIGHDPI_X(wx + 40)
gmesy = HIGHDPI_Y(wy + 66 + cnt * 19 + 2)
gmesw = HIGHDPI_X(600)
gmescol = 30, 30, 30
gmestype = 0
pos wx + 54, wy + 66 + cnt * 19 + 2
gmes s
loop

redraw 1
*com_knowCNPC_pgchg
redraw 0
redraw 1
await cfg_wait1
key_check
// page_change *com_knowCNPC_loop
if ( key == key_next | key == key_pageup | key == key_east | key == key_south ) {
page++
if (page > pagemax) { page = 0 }
goto *com_knowCNPC_loop
}
if ( key == key_prev | key == key_pagedown | key == key_west | key == key_north ) {
page--
if (page < 0) { page = pagemax }
goto *com_knowCNPC_loop
}
if ( key == key_cancel | key == key_enter ) {
pagesize = pagesizebk
pagemax = pagemaxbk
page = pagebk
listmax = listmaxbk
cs = cs_bk2
p = knowCNPC
if ( key == key_cancel ) {
return -1
}
if ( key == key_enter ) {
return 1
}
}
goto *com_knowCNPC_loop
/********** CUSTOM NPC SUMMONING - ENDING **********/

*com_userNpc
snd SOUNDLIST_CHARA
gsel 4
Expand Down
11 changes: 10 additions & 1 deletion 2.05-custom-gx/custom_tweaks.hsp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ TweakData(51, 4) = "Disable cicada noises."
cs = 0
page = 0
pagesize = 16
listmax = 31
listmax = 32
*GameplayTweakMenu_pgchk
redraw 0
page_check
Expand Down Expand Up @@ -518,6 +518,7 @@ TweakData(51, 4) = "Disable cicada noises."
listn(0, 28) = "Use CGX Map Layouts in Random Nefia." + GetTStatus(TWEAK_CATEGORY_GAMEPLAY, TWEAK_GAMEPLAY_USE_CUSTOM_NEFIA_TYPES) + "% Chance."
listn(0, 29) = "Use CGX Job Quests." + GetTStatus(TWEAK_CATEGORY_GAMEPLAY, TWEAK_GAMEPLAY_CUSTOM_JOB_QUESTS)
listn(0, 30) = "Use CGX Arrow/Bolt/Ball Spell Animation." + GetTStatus(TWEAK_CATEGORY_GAMEPLAY, TWEAK_GAMEPLAY_CUSTOM_SPELL_ANIMATIONS)
listn(0, 31) = "Disable random CNPC spawn." + GetTStatus(TWEAK_CATEGORY_GAMEPLAY, TWEAK_GAMEPLAY_CUSTOM_CNPC_SUMMONING)

font lang(cfg_font1, cfg_font2), 14 - en * 2, 0

Expand Down Expand Up @@ -635,6 +636,9 @@ TweakData(51, 4) = "Disable cicada noises."
s = "Use Custom Animation for Arrow/Bolt/Ball spell animations."
}
if ( p == 31 ) {
s = "Disable Random CNPC spawn in all areas except Derphy and Melkawn.\nInstead, you can use a summon crystal to summon them at will."
}
if ( p == 32 ) {
s = "Return to the previous menu."
}
pos wx + 38, wy + 343
Expand Down Expand Up @@ -814,6 +818,11 @@ TweakData(51, 4) = "Disable cicada noises."
gosub *ToggleTweak
}
if ( p == 31 ) {
tc = TWEAK_CATEGORY_GAMEPLAY
tn = TWEAK_GAMEPLAY_CUSTOM_CNPC_SUMMONING
gosub *ToggleTweak
}
if ( p == 32 ) {
snd SOUNDLIST_OK1
return
}
Expand Down
Loading

0 comments on commit ee3f15e

Please sign in to comment.