Skip to content

Commit

Permalink
feat(content): pvp related fixes and additions (#557)
Browse files Browse the repository at this point in the history
* fix(content): use queue2 for pvp and add duel arena death

* feat: pvp death

* feat(content): ring of recoil

* fix(content): have damage_player queue check if player has ring of recoil

* feat(content): ring of life

* fix(content): better guess for flower power duel

* feat(content): pvp poison

* fix(content): duel arena and combat changes

* fix(content): use stakeinv for stakes and tempinv for collecting arrows during stakes

* fix(content): add some if_closes to duel arena

* refactor: combine duel arena win/loss into one queue

* feat(engine): findhero and both_heropoints commands

* fix(engine): properly reset hero points after stat regen

* feat(content): both_heropoints applied to pvp scripts

* feat(content): drop bones on death

* fix(content): move ring of recoil check to opplayer2 script

* fix(engine): check for activeplayer in findhero command

* Revert "fix(content): move ring of recoil check to opplayer2 script"

This reverts commit 6629885.

* fix(content): make recoil damage its own queue to avoid loop

---------

Co-authored-by: tannerdino <[email protected]>
  • Loading branch information
tannerdino and tannerdino authored Jun 9, 2024
1 parent 6689abe commit ae15229
Show file tree
Hide file tree
Showing 26 changed files with 511 additions and 251 deletions.
2 changes: 1 addition & 1 deletion data/src/pack/inv.pack
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
139=generalshop14
140=inv_140
141=reward
142=duel_arena_arrows
142=stakeinv
143=shrimp_and_parrot
144=crafting_rings
145=crafting_necklaces
Expand Down
10 changes: 10 additions & 0 deletions data/src/scripts/_test/scripts/cheats/cheat_pvp.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ if (npc_finduid(%aggressive_npc) = true) {
if (.finduid(%npc_aggressive_player) = true) {
mes("Aggressive NPC's target: <.displayname>");
}
}

[debugproc,pvp]
if (p_finduid(uid) = true) {
p_telejump(0_52_60_37_37);
}

[debugproc,duel]
if (p_finduid(uid) = true) {
p_telejump(0_52_51_42_4);
}
18 changes: 18 additions & 0 deletions data/src/scripts/_test/scripts/engine/debug_findhero.rs2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[debugproc,findhero]
if (findhero = true) {
mes(.displayname);
if (.findhero = true) {
mes(displayname);
}
}


[debugproc,both_heropoints]
huntall(coord, 5, 0);
while (.huntnext = true) {
if (uid ! .uid) {
both_heropoints(1);
mes("both_heropoints(1);");
}
}

1 change: 1 addition & 0 deletions data/src/scripts/_unpack/all.varp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ scope=perm
[varp_289]

[ring_of_recoil]
scope=perm

[ring_of_forging]
scope=perm
5 changes: 5 additions & 0 deletions data/src/scripts/engine.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[command,npc_huntnext]()(boolean)
[command,.npc_huntnext]()(boolean)
[command,inzone](coord $from, coord $to, coord $pos)(boolean)
[command,.inzone](coord $from, coord $to, coord $pos)(boolean)
[command,lineofwalk](coord $from, coord $to)(boolean)
[command,stat_random](int $level, int $low, int $high)(boolean)
[command,spotanim_map](spotanim $anim, coord $coord, int $height, int $delay)
Expand Down Expand Up @@ -205,9 +206,13 @@
[command,getwalktrigger]()(walktrigger)
[command,.getwalktrigger]()(walktrigger)
[command,clearqueue](queue $queue)
[command,.clearqueue](queue $queue)
[command,afk_event]()(int)
[command,lowmemory]()(boolean)
[command,setidkit](idkit $kit, int $color)
[command,findhero]()(boolean)
[command,.findhero]()(boolean)
[command,both_heropoints](int $damage)

// Npc ops (2500-2999)
[command,npc_finduid](npc_uid $uid)(boolean)
Expand Down
14 changes: 14 additions & 0 deletions data/src/scripts/general/scripts/misc/coord_procs.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ while($i < db_getfieldcount($data, coord_pair_table:coord_pair)) {
}
return (false);

[proc,.inzone_coord_pair_table](dbrow $data, coord $coord)(boolean)
def_coord $coord1;
def_coord $coord2;
def_int $i = 0;
while($i < db_getfieldcount($data, coord_pair_table:coord_pair)) {
$coord1, $coord2 = db_getfield($data, coord_pair_table:coord_pair, $i);
if(.inzone($coord1, $coord2, $coord) = true) {
return (true);
} else {
$i = add($i, 1);
}
}
return (false);

// returns ^exact_north, ^exact_east, ^exact_south, ^exact_west
[proc,coord_direction](coord $coord1, coord $coord2)(int)
def_int $x1 = coordx($coord1);
Expand Down
12 changes: 12 additions & 0 deletions data/src/scripts/interface_trade/scripts/trade.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ while ($i < $size) {
$i = add($i, 1);
}

[proc,.moveallinv](inv $src, inv $dest)
def_int $size = .inv_size($src);
def_int $i = 0;
while ($i < $size) {
def_obj $obj = .inv_getobj($src, $i);
if ($obj ! null) {
.inv_moveitem($src, $dest, $obj, .inv_total($src, $obj));
}
$i = add($i, 1);
}


// ----

[opplayer4,_]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
^north_east_camera = 4
^north_west_camera = 5
^south_east_camera = 6
^south_west_camera = 7
^south_west_camera = 7

^duelstatus_lost = 5
^duelstatus_victory = 6
^duelstatus_opponent_resigned = 7
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ allstock=no
stock1=rotten_tomato,2000,10


[duel_arena_arrows]
size=29
[stakeinv]
size=29
protect=no
40 changes: 37 additions & 3 deletions data/src/scripts/minigames/game_duelarena/scripts/duel_arena.rs2
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
[debugproc,tempinv]
def_int $i = 0;
def_int $null = 0;
while ($i < inv_size(tempinv)) {
if (inv_getobj(tempinv, $i) ! null) {
mes("<tostring($i)>: <oc_debugname(inv_getobj(tempinv, $i))>");
} else {
$null = add($null, 1);
}
$i = add($i, 1);
}
if ($null = inv_size(tempinv)) {
mes("tempinv is empty");
}

[debugproc,stakeinv]
def_int $i = 0;
def_int $null = 0;
while ($i < inv_size(stakeinv)) {
if (inv_getobj(stakeinv, $i) ! null) {
mes("<tostring($i)>: <oc_debugname(inv_getobj(stakeinv, $i))>");
} else {
$null = add($null, 1);
}
$i = add($i, 1);
}
if ($null = inv_size(stakeinv)) {
mes("stakeinv is empty");
}

[opplayer1,_]
if (.busy = true) {
mes("<.displayname> is busy at the moment."); // https://youtu.be/YkJQDvB14-U?t=26
Expand Down Expand Up @@ -260,9 +290,8 @@ if (.finduid(%duelpartner) = true) {

if_close;
.if_close;
if (p_finduid(uid) = true & .p_finduid(.uid) = true) {
@start_duel;
}
queue(duel_arena_prepare_start, 0);
queue2(duel_arena_prepare_start, 0);
} else {
.if_settext(duel_confirm:status, "Other player has accepted."); // https://youtu.be/HFp6hOkiCns?t=481
if_settext(duel_confirm:status, "Waiting for other player.");
Expand Down Expand Up @@ -354,6 +383,11 @@ if (~inzone_coord_pair_table(duel_arena_fight_zones, coord) = true | ~inzone_coo
}
return(false);

[proc,.in_duel_arena]()(boolean)
if (~.inzone_coord_pair_table(duel_arena_fight_zones, coord) = true | ~.inzone_coord_pair_table(duel_arena_obstacle_fight_zones, coord) = true) {
return(true);
}
return(false);

[proc,duel_arena_login]
if (~in_duel_arena = true) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,74 @@
[queue,duel_arena_finished](string $displayname, int $combat_level)
mes("Well done! You have defeated <$displayname>!");
if_openmainmodal(duel_win);
if_settext(duel_win:displayname, $displayname);
if_settext(duel_win:combat_level, tostring($combat_level));

// get stuff back in ur tempinv
[queue,duel_arena_finish]
if (getqueue(duel_arena_finish) > 0) {
clearqueue(duel_arena_finish);
}
if (~in_duel_arena = false) {
%duelstatus = 0;
%duelpartner = null;
return;
}
// get arrows back
def_int $i = 0;
while ($i < inv_size(tempinv)) {
if (inv_getobj(tempinv, $i) ! null) {
//mes("<oc_debugname(inv_getobj(tempinv, $i))>: <tostring(inv_getnum(tempinv, $i))>");
inv_movefromslot(tempinv, inv, $i);
}
$i = calc($i + 1);
}

$i = 0;
while ($i < inv_size(duel_arena_arrows)) {
if (inv_getobj(duel_arena_arrows, $i) ! null) {
//mes("<oc_debugname(inv_getobj(tempinv, $i))>: <tostring(inv_getnum(tempinv, $i))>");
inv_movefromslot(duel_arena_arrows, inv, $i);
}
$i = calc($i + 1);
}
p_telejump(~duel_arena_finish_coord(coord));
anim(null, 0);
p_stopaction;

inv_clear(tempinv);
~stat_reset_all;
healenergy(10000);
~combat_clearqueue;
clearqueue(player_death);
~clear_poison;
~update_all(inv_getobj(worn, ^wearpos_rhand));
hint_stop;

// take stuff from other player's tempinv
if (.finduid(%duelpartner) = true) {
.both_moveinv(tempinv, tempinv);
.%duelpartner = null;
if (.finduid(%duelpartner) = true & (%duelstatus = ^duelstatus_victory | %duelstatus = ^duelstatus_opponent_resigned)) {
if (%duelstatus = ^duelstatus_opponent_resigned) {
if_settext(duel_win:com_99, "You are victorious! Your opponent resigned!"); // 2006
mes("Well done! <.displayname> resigned!"); // 2006
} else {
if_settext(duel_win:com_99, "You are victorious!");
mes("Well done! You have defeated <.displayname>!");
}
if_openmainmodal(duel_win);
~duel_adjust_scoreboard(displayname, ~player_combat_level, .displayname, ~.player_combat_level);
if_settext(duel_win:displayname, .displayname);
if_settext(duel_win:combat_level, tostring(~.player_combat_level));

$i = 0;
while ($i < inv_size(stakeinv)) {
if (inv_getobj(stakeinv, $i) ! null) {
//mes("<oc_debugname(inv_getobj(stakeinv, $i))>: <tostring(inv_getnum(tempinv, $i))>");
inv_movefromslot(stakeinv, inv, $i);
}
$i = calc($i + 1);
}
inv_clear(stakeinv);
// take stuff from other player's stakeinv
.both_moveinv(stakeinv, stakeinv);
// .%duelpartner = null;
// display spoils
inv_transmit(tempinv, duel_win:spoils);
inv_transmit(stakeinv, duel_win:spoils);
}

%duelstatus = 0;
%duelpartner = null;

[if_close,duel_win]
// take spoils
def_int $i = 0;
while ($i < inv_size(tempinv)) {
if (inv_getobj(tempinv, $i) ! null) {
inv_movefromslot(tempinv, inv, $i);
while ($i < inv_size(stakeinv)) {
if (inv_getobj(stakeinv, $i) ! null) {
inv_movefromslot(stakeinv, inv, $i);
}
$i = calc($i + 1);
}
inv_clear(stakeinv);
inv_stoptransmit(duel_win:spoils);

// https://youtu.be/QggKGBAl_X8?t=111
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ if (~in_duel_arena = false) {
return(true);
}
if (testbit(%duel_settings, ^flower_power) = true) {
mes("You can only use flowers for this duel."); // guess
mes("This is a 'flower power' duel. You can only use flowers."); // guess based off of 2006 vid
// 2006: "This is a 'fun weapon' duel. You can only use flowers or a rubber|chicken."
return(false);
}
return(true);
Expand All @@ -216,7 +217,8 @@ if (~in_duel_arena = false) {
return(true);
}
if (testbit(%duel_settings, ^flower_power) = true) {
mes("You can only use flowers for this duel."); // guess
mes("This is a 'flower power' duel. You can only use flowers."); // guess based off of 2006 vid
// 2006: "This is a 'fun weapon' duel. You can only use flowers or a rubber|chicken."
return(false);
}
return(true);
Expand Down Expand Up @@ -253,7 +255,8 @@ if (testbit(%duel_settings, ^no_magic) = true) {
return(false);
}
if (testbit(%duel_settings, ^flower_power) = true) {
mes("You can only attack with flowers in this duel."); // guess
mes("This is a 'flower power' duel. You can only use flowers."); // guess based off of 2006 vid
// 2006: "This is a 'fun weapon' duel. You can only use flowers or a rubber|chicken."
return(false);
}
return(true);
Loading

0 comments on commit ae15229

Please sign in to comment.