Skip to content
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

fix: Secondary Pointers. HuntMode Packing. #227

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions data/src/scripts/areas/area_alkharid/scripts/border_gate.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -142,56 +142,46 @@ p_teleport($destination);
p_delay(0);

[proc,open_border_gate_toll_left_closed]()
def_loc $next_loc = loc_param(next_loc_stage);
def_int $next_angle = calc(loc_angle + 3);
def_coord $other = movecoord(loc_coord, 0, 0, 1);

loc_del(2);
loc_add(loc_coord, loc_83, loc_angle, wall_straight, 2);
.loc_add(loc_coord, loc_83, loc_angle, loc_shape, 2);

def_coord $coord = ~movecoord_loc_return(~door_left_open(loc_angle));
loc_add($coord, loc_83, loc_angle, wall_straight, 2);
loc_add($coord, $next_loc, $next_angle, wall_straight, 2);
.loc_add($coord, loc_83, loc_angle, wall_straight, 2);
loc_add($coord, loc_param(next_loc_stage), calc(loc_angle + 3), loc_shape, 2);

loc_findallzone($coord);
while (loc_findnext = true) {
if (loc_coord = $other & loc_category = border_gate_toll_right) {
def_loc $next_loc2 = loc_param(next_loc_stage);
def_int $next_angle2 = calc(loc_angle + 1);

loc_del(2);
loc_add(loc_coord, loc_83, loc_angle, wall_straight, 2);
.loc_add(loc_coord, loc_83, loc_angle, wall_straight, 2);

def_coord $coord = ~movecoord_loc_return(~door_open(loc_angle));
loc_add($coord, loc_83, loc_angle, wall_straight, 2);
loc_add($coord, $next_loc2, $next_angle2, wall_straight, 2);
.loc_add($coord, loc_83, loc_angle, wall_straight, 2);
loc_add($coord, loc_param(next_loc_stage), calc(loc_angle + 1), loc_shape, 2);
}
}

[proc,open_border_gate_toll_right_closed]()
def_loc $next_loc = loc_param(next_loc_stage);
def_int $next_angle = modulo(add(loc_angle, 1), 4);
def_coord $other = movecoord(loc_coord, 0, 0, 1);
def_coord $other = movecoord(loc_coord, 0, 0, -1);

loc_del(2);
loc_add(loc_coord, loc_83, loc_angle, wall_straight, 2);
.loc_add(loc_coord, loc_83, loc_angle, loc_shape, 2);

def_coord $coord = ~movecoord_loc_return(~door_open(loc_angle));
loc_add($coord, loc_83, loc_angle, wall_straight, 2);
loc_add($coord, $next_loc, $next_angle, wall_straight, 2);
.loc_add($coord, loc_83, loc_angle, wall_straight, 2);
loc_add($coord, loc_param(next_loc_stage), modulo(add(loc_angle, 1), 4), loc_shape, 2);

loc_findallzone($coord);
while (loc_findnext = true) {
if (loc_coord = $other & loc_category = border_gate_toll_left) {
def_loc $next_loc2 = loc_param(next_loc_stage);
def_int $next_angle2 = modulo(add(loc_angle, 3), 4);

loc_del(2);
loc_add(loc_coord, loc_83, loc_angle, wall_straight, 2);
.loc_add(loc_coord, loc_83, loc_angle, wall_straight, 2);

def_coord $coord = ~movecoord_loc_return(~door_left_open(loc_angle));
loc_add($coord, loc_83, loc_angle, wall_straight, 2);
loc_add($coord, $next_loc2, $next_angle2, wall_straight, 2);
.loc_add($coord, loc_83, loc_angle, wall_straight, 2);
loc_add($coord, loc_param(next_loc_stage), modulo(add(loc_angle, 3), 4), loc_shape, 2);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[oploc1,_outpost_gate]
if(%barcrawl_progress ! ^barcrawl_complete) {
if(~npc_within_distance(coord, barbarian_outpost_guard, 5) = true) {
if(npc_finduid(~npc_within_distance(coord, barbarian_outpost_guard, 5)) = true) {
@outpost_guard_talk;
}
}
Expand Down
4 changes: 2 additions & 2 deletions data/src/scripts/areas/monastery/scripts/prayer_guild.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

[oploc1,loc_2641]
if (%prayer_guild < 1) {
if (~npc_within_distance(coord, abbot_langley, 5) = true) {
if (npc_finduid(~npc_within_distance(coord, abbot_langley, 5)) = true) {
~chatnpc(quiz, "Only members of our order can go up there.");
@ask_to_join_abbot_langley2;
}
if (~npc_within_distance(coord, monk, 5) = true) {
if (npc_finduid(~npc_within_distance(coord, monk, 5)) = true) {
~chatnpc(quiz, "You'll need to talk to Abbot Langley about that. He's|usually to be found walking the halls of the monastery.");
return;
}
Expand Down
3 changes: 3 additions & 0 deletions data/src/scripts/engine.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
// Npc ops (2500-2999)
[command,npc_finduid](npc_uid $uid)(boolean)
[command,npc_add](coord $coord, npc $npc, int $duration)
[command,.npc_add](coord $coord, npc $npc, int $duration)
[command,npc_anim](seq $seq, int $delay)
[command,npc_basestat](npc_stat $stat)(int)
[command,npc_category]()(category)
Expand Down Expand Up @@ -170,6 +171,7 @@

// Loc ops (3000-3499)
[command,loc_add](coord $coord, loc $loc, int $angle, locshape $shape, int $duration)
[command,.loc_add](coord $coord, loc $loc, int $angle, locshape $shape, int $duration)
[command,loc_angle]()(int)
[command,loc_anim](seq $anim)
[command,loc_category]()(category)
Expand All @@ -186,6 +188,7 @@

// Obj ops (3500-4000)
[command,obj_add](coord $coord, obj $obj, int $count, int $duration)
[command,.obj_add](coord $coord, obj $obj, int $count, int $duration)
[command,obj_addall](coord $coord, obj $obj, int $count, int $duration)
[command,obj_param]/*(param $param)(dynamic)*/
[command,obj_name]()(string)
Expand Down
8 changes: 3 additions & 5 deletions data/src/scripts/general/scripts/misc/coord_procs.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ return($coord);

// loops zones around a specified coord.
// the main purpose of this is to grab npc pointer efficiently
[proc,npc_within_distance](coord $coord, npc $npc, int $distance)(boolean)
[proc,npc_within_distance](coord $coord, npc $npc, int $distance)(npc_uid)
// a radius of 1 will loop 9 zones
// a radius of 2 will loop 25 zones
// a radius of 3 will loop 49 zones
Expand Down Expand Up @@ -85,11 +85,9 @@ while ($maxX >= $minX) {
$maxX = sub($maxX, 1);
}
if ($closet_distance < $distance | $closest_npc ! null) {
// set the active npc
npc_finduid($closest_npc);
return(true);
return(npc_uid);
}
return(false);
return(null);

// 0_50_50_22_22 --> 0, 50, 50, 22, 22
[proc,coord_unpack](coord $coord)(int, int, int, int, int)
Expand Down
3 changes: 3 additions & 0 deletions data/src/scripts/levelup/scripts/levelup.rs2
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// https://www.youtube.com/watch?v=cz0FGYbfzzk
// https://www.youtube.com/watch?v=IC2n8t76DDY

[levelup,attack] queue(levelup, 0, enum(int, stat, stats, ^attack));
[levelup,strength] queue(levelup, 0, enum(int, stat, stats, ^strength));
[levelup,ranged] queue(levelup, 0, enum(int, stat, stats, ^ranged));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
if(~in_hemenster_comp = false) {
return;
}
if(~npc_within_distance(coord, big_dave, 5) = true) {
if(npc_finduid(~npc_within_distance(coord, big_dave, 5)) = true) {
@big_dave_dialogue;
}

[opnpc1,npc_236]
if(~in_hemenster_comp = false) {
return;
}
if(~npc_within_distance(coord, joshua, 5) = true) {
if(npc_finduid(~npc_within_distance(coord, joshua, 5)) = true) {
@joshua_dialogue;
}

Expand Down Expand Up @@ -95,7 +95,7 @@ if(~in_hemenster_comp = false) {
}
// Vampire check
if((npc_type = npc_234 & %fishingcompo_progress = ^fishingcompo_in_comp) | (npc_type = npc_233 & %fishingcompo_progress = ^fishingcompo_garlic_comp)) {
if(~npc_within_distance(coord, sinister_stranger, 8) = true) {
if(npc_finduid(~npc_within_distance(coord, sinister_stranger, 8)) = true) {
@sinister_stranger_my_spot;
}
}
Expand Down Expand Up @@ -154,27 +154,21 @@ p_opnpc(2);

[proc,in_hemenster_comp](boolean)
if (%hemenster_comp_stage = ^hemenster_comp_not_entered) { // Havn't entered the competition yet
if(~find_bonzo = true) {
if(npc_finduid(~npc_within_distance(coord, bonzo, 12)) = true) {
~chatnpc(happy, "Hey, you need to pay to enter the competition first! Only 5 gp entrance fee!");
mes("Talk to Bonzo to pay the entrance fee.");
}
return (false);
} else if (%hemenster_comp_stage >= ^hemenster_comp_paidfee & %fishingcompo_progress = ^fishingcompo_started) { // Entered comp but hasnt been assigned spot
if(~find_bonzo = true) {
if(npc_finduid(~npc_within_distance(coord, bonzo, 12)) = true) {
@bonzo_set_places;
}
return (false);
}else if (%hemenster_comp_stage = ^hemenster_comp_all_fish_caught) { // 3 fish caught
if(~find_bonzo = true) {
if(npc_finduid(~npc_within_distance(coord, bonzo, 12)) = true) {
~chatnpc(happy, "Okay folks, time's up!|Let's see who caught the biggest fish!");
@bonzo_handover_catch;
}
return (false);
}
return (true);

[proc,find_bonzo](boolean)
if(~npc_within_distance(coord, bonzo, 12) = true) {
return (true);
}
return (false);
return (true);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(%fishingcompo_progress = ^fishingcompo_complete) {
p_telejump(0_44_154_60_22);
}
return;
} else if(~npc_within_distance(coord, mountain_dwarf, 5) = true) {
} else if(npc_finduid(~npc_within_distance(coord, mountain_dwarf, 5)) = true) {
switch_int (%fishingcompo_progress) {
case ^fishingcompo_not_started: @mountain_dwarf_stairs;
case default: @mountain_dwarf_won;
Expand All @@ -25,7 +25,7 @@ if(coordx(coord) <= coordx(loc_coord)) {
// On OSRS this dialogue always happens (during the quest) when leaving from the south side of the gate, and
// on both sides during an active comp. Not sure if this is a rework thing since Bonzo is sitting on a table by the south side
// post-rework, but we'll use this behaviour for now
if(~find_bonzo = true) {
if(npc_finduid(~npc_within_distance(coord, bonzo, 12)) = true) {
@bonzo_quits;
}
}
Expand Down Expand Up @@ -92,14 +92,15 @@ if(%hemenster_comp_stage = ^hemenster_comp_paidfee) {
}

[label,move_hemenster_pipe]
if(~npc_within_distance(coord, sinister_stranger, 8) = true) {
if(npc_finduid(~npc_within_distance(coord, sinister_stranger, 8)) = true) {
~chatnpc(angry, "Arrgh! WHAT is that GHASTLY smell???|I think I will move over here instead...");
npc_tele(0_41_53_7_43); // telejumps in classic
npc_facesquare(movecoord(npc_coord, 1, 0, 0));
~find_bonzo;
%fishingcompo_progress = ^fishingcompo_garlic_comp;
~chatnpc(confused, "Hmm. You'd better go and take the area by the pipes then.");
~mesbox("Your fishing competition spot is now beside the pipes.");
if (npc_finduid(~npc_within_distance(coord, bonzo, 12)) = true) {
%fishingcompo_progress = ^fishingcompo_garlic_comp;
~chatnpc(confused, "Hmm. You'd better go and take the area by the pipes then.");
~mesbox("Your fishing competition spot is now beside the pipes.");
}
}

[queue,fishingcompo_quest_complete]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

[opheld2,dragon_med_helm] @dragon_equip_req_defence(last_slot);
[opheld2,dragon_sq_shield] @dragon_req_legends_quest(last_slot);
[opheld2,dragonfire_shield] @dragon_req_start_dragon_slayer_quest(last_slot);
// [opheld2,dragonfire_shield] @dragon_req_start_dragon_slayer_quest(last_slot); osrs has this. possibly not 2004.

[label,dragon_req_heroes_quest](int $slot)
if (%hero_progress ! ^hero_complete) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// TODO osrs and 2004 seems to have different level req messages.
// note: we have correct level up messages for 2004.
// https://youtu.be/RHwRNK4ZuOM?t=411

[label,equip_req_attack](int $level, int $slot)
if (stat_base(attack) < $level) {
mes("You are not a high enough level to use this item.");
Expand Down
32 changes: 32 additions & 0 deletions data/src/scripts/skill_thieving/scripts/stalls/stealing.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,35 @@ if ($free_space = 0) {
}

~steal_from_stall($data, $loc_coord, $loc_angle, $loc_shape);

[proc,stealing_check_for_guard]
if (npc_finduid(~stealing_guard_within_distance) = true) {
npc_say("Hey! Get your hands off there!");
npc_setmode(opplayer2);
}

[proc,stealing_guard_within_distance]()(npc_uid)
// look in our coord first
npc_findallzone(coord);
while (npc_findnext = true) {
if (npc_type = hero | npc_type = paladin | npc_type = npc_365 | npc_type = knight_of_ardougne_1 | npc_type = knight_of_ardougne_2 | npc_type = guard_ardougne) {
if (lineofsight(npc_coord, coord) = true) {
return(npc_uid);
}
}
}
// look around us if none found.
if (npc_finduid(~npc_within_distance(coord, hero, 5)) = true & lineofsight(npc_coord, coord) = true) {
return(npc_uid);
} else if (npc_finduid(~npc_within_distance(coord, paladin, 5)) = true & lineofsight(npc_coord, coord) = true) {
return(npc_uid);
} else if (npc_finduid(~npc_within_distance(coord, npc_365, 5)) = true & lineofsight(npc_coord, coord) = true) {
return(npc_uid);
} else if (npc_finduid(~npc_within_distance(coord, knight_of_ardougne_1, 5)) = true & lineofsight(npc_coord, coord) = true) {
return(npc_uid);
} else if (npc_finduid(~npc_within_distance(coord, knight_of_ardougne_2, 5)) = true & lineofsight(npc_coord, coord) = true) {
return(npc_uid);
} else if (npc_finduid(~npc_within_distance(coord, guard_ardougne, 5)) = true & lineofsight(npc_coord, coord) = true) {
return(npc_uid);
}
return(null);
1 change: 1 addition & 0 deletions data/src/scripts/skill_thieving/scripts/thieving.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def_int $experience = db_getfield($data, stealing:experience, 0);
def_int $respawn_ticks = db_getfield($data, stealing:respawn_ticks, 0);
anim(human_pickuptable, 0);
sound_synth(pick, 0, 0);
gosub(stealing_check_for_guard);
p_delay(0);
~stealing_check_for_reward($data);
givexp(thieving, $experience);
Expand Down
4 changes: 4 additions & 0 deletions src/lostcity/cache/NpcType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import MoveRestrict from '#lostcity/entity/MoveRestrict.js';
import NpcMode from '#lostcity/entity/NpcMode.js';
import {ParamHelper, ParamMap} from '#lostcity/cache/ParamHelper.js';
import BlockWalk from '#lostcity/entity/BlockWalk.js';
import HuntMode from '#lostcity/engine/hunt/HuntMode.js';

export default class NpcType extends ConfigType {
static configNames = new Map();
Expand Down Expand Up @@ -85,6 +86,7 @@ export default class NpcType extends ConfigType {
stats = [1, 1, 1, 1, 1, 1];
moverestrict = MoveRestrict.NORMAL;
attackrange = 7;
huntmode = HuntMode.NONE;
defaultmode = NpcMode.WANDER;
blockwalk = BlockWalk.NPC;
params: ParamMap = new Map();
Expand Down Expand Up @@ -164,6 +166,8 @@ export default class NpcType extends ConfigType {
this.attackrange = packet.g1();
} else if (opcode === 208) {
this.blockwalk = packet.g1();
} else if (opcode === 209) {
this.huntmode = packet.g1();
} else if (opcode === 210) {
this.defaultmode = packet.g1();
} else if (opcode === 249) {
Expand Down
7 changes: 5 additions & 2 deletions src/lostcity/engine/hunt/HuntMode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum HuntMode {
enum HuntMode {
NONE,
RANGED,
CONSTANT_MELEE,
CONSTANT_RANGED,
Expand All @@ -21,4 +22,6 @@ export enum HuntMode {
QUEUE11_TRIGGER,
BIGMONSTER_MELEE,
BIGMONSTER_RANGED
}
}

export default HuntMode;
4 changes: 2 additions & 2 deletions src/lostcity/engine/script/handlers/LocOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const LocOps: CommandHandlers = {
shape,
angle
);
World.addLoc(loc, duration);

World.addLoc(loc, duration);
state.activeLoc = loc;
state.pointerAdd(ScriptPointer.ActiveLoc);
state.pointerAdd(ActiveLoc[state.intOperand]);
},

[ScriptOpcode.LOC_ANGLE]: checkedHandler(ActiveLoc, (state) => {
Expand Down
Loading
Loading