Skip to content

Commit

Permalink
feat: pvp, simplified singles & multi logic (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerdino authored Feb 26, 2024
1 parent 7e0775a commit 807a06c
Show file tree
Hide file tree
Showing 27 changed files with 1,012 additions and 42 deletions.
14 changes: 7 additions & 7 deletions data/pack/varp.pack
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
38=lastcombat
39=magic_utility_delay
40=eat_delay
41=defending_npc_uid
41=aggressive_npc
42=varp_42
43=attackstyle
44=com_stabattack
Expand Down Expand Up @@ -76,7 +76,7 @@
75=boat_takeoff
76=scorpcatcher_progress
77=barcrawl_progress
78=varp_78
78=pk_skull
79=xplamp
80=druid_progress
81=macro_event
Expand Down Expand Up @@ -115,11 +115,11 @@
114=varp_114
115=bank_noted
116=zombiequeen_progress
117=varp_117
118=varp_118
119=varp_119
120=varp_120
121=varp_121
117=pk_prey1
118=pk_prey2
119=pk_predator1
120=pk_predator2
121=pk_predator3
122=squire_progress
123=varp_123
124=skill_anim
Expand Down
27 changes: 27 additions & 0 deletions data/src/scripts/_test/scripts/cheats/cheat_pvp.rs2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[debugproc,skull]
~pk_skull(3000);

[debugproc,clearskull]
~clear_pk_skull;

[debugproc,singles]
def_string $pk_preyname;
def_string $pk_predatorname;
if(.finduid(%pk_predator1) = true) {
$pk_predatorname = .displayname;
}
if(.finduid(%pk_prey1) = true) {
$pk_preyname = .displayname;
}
mes("Last person you attacked: <$pk_preyname>.");
mes("Last person who attacked you: <$pk_predatorname>.");
mes("Ticks ago you were in combat: <tostring(sub(map_clock, %lastcombat))>.");
if(.finduid(%pk_prey1) = true) {
mes("Ticks ago your opponent was in combat: <tostring(sub(map_clock, .%lastcombat))>.");
}
if (npc_finduid(%aggressive_npc) = true) {
mes("Aggressive NPC: <npc_name>");
if (.finduid(%npc_aggressive_player) = true) {
mes("Aggressive NPC's target: <.displayname>");
}
}
2 changes: 1 addition & 1 deletion data/src/scripts/_unpack/all.varn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[npc_attacking_uid]
type=player_uid

[npc_defending_uid]
[npc_aggressive_player]
type=player_uid

[npc_lastcombat]
Expand Down
26 changes: 19 additions & 7 deletions data/src/scripts/_unpack/all.varp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protect=no

[eat_delay]

[defending_npc_uid]
[aggressive_npc]
type=npc_uid
protect=no

Expand Down Expand Up @@ -86,7 +86,9 @@ scope=perm
[boat_takeoff]
transmit=yes

[varp_78]
[pk_skull]
protect=no
scope=perm

[xplamp]
transmit=yes
Expand Down Expand Up @@ -125,15 +127,25 @@ scope=perm
transmit=yes
scope=perm

[varp_117]
[pk_prey1]
protect=no
type=player_uid

[varp_118]
[pk_prey2]
protect=no
type=player_uid

[varp_119]
[pk_predator1]
protect=no
type=player_uid

[varp_120]
[pk_predator2]
protect=no
type=player_uid

[varp_121]
[pk_predator3]
protect=no
type=player_uid

[varp_123]

Expand Down
16 changes: 16 additions & 0 deletions data/src/scripts/engine.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
[command,strongqueue](queue $queue, int $delay)
[command,weakqueue](queue $queue, int $delay)
[command,anim](seq $anim, int $delay)
[command,.anim](seq $anim, int $delay)
[command,buffer_full]()(int)
[command,buildappearance](inv $inv)
[command,cam_lookat](coord $coord, int $unknown0, int $unknown1, int $unknown2)
Expand Down Expand Up @@ -79,13 +80,20 @@
[command,p_walk](coord $dest)
[command,.p_walk](coord $dest)
[command,say](string $text)
[command,.say](string $text)
[command,sound_synth](synth $sound, int $loops, int $delay)
[command,.sound_synth](synth $sound, int $loops, int $delay)
[command,staffmodlevel]()(int)
[command,stat](stat $stat)(int)
[command,.stat](stat $stat)(int)
[command,stat_base](stat $stat)(int)
[command,.stat_base](stat $stat)(int)
[command,stat_add](stat $stat, int $constant, int $percent)
[command,.stat_add](stat $stat, int $constant, int $percent)
[command,stat_sub](stat $stat, int $constant, int $percent)
[command,.stat_sub](stat $stat, int $constant, int $percent)
[command,stat_heal](stat $stat, int $constant, int $percent)
[command,.stat_heal](stat $stat, int $constant, int $percent)
[command,uid]()(player_uid)
[command,.uid]()(player_uid)
[command,p_logout]
Expand Down Expand Up @@ -116,6 +124,7 @@
[command,if_multizone](boolean $multizone)
[command,givexp](stat $stat, int $exp)
[command,damage](player_uid $uid, int $type, int $amount)
[command,.damage](player_uid $uid, int $type, int $amount)
[command,if_setresumebuttons](component $component1, component $component2, component $component3, component $component4, component $component5)
[command,text_gender](string $male_text, string $female_text)(string)
[command,midi_song](string $song)
Expand All @@ -126,10 +135,12 @@
[command,settimer]/*(timer $timer, int $interval, ...)*/
[command,cleartimer](timer $timer)
[command,spotanim_pl](spotanim $spotanim, int $height, int $delay)
[command,.spotanim_pl](spotanim $spotanim, int $height, int $delay)
[command,hint_stop]
[command,if_closesticky]
[command,p_exactmove](coord $startCoord, coord $endCoord, int $startCycle, int $endCycle, int $direction)
[command,queue](queue $queue, int $delay)
[command,.queue](queue $queue, int $delay)
[command,busy]()(boolean)
[command,.busy]()(boolean)
[command,getqueue](queue $queue)(int)
Expand All @@ -144,17 +155,21 @@
[command,bas_walk_r](seq $seq)
[command,bas_running](seq $seq)
[command,gender]()(int)
[command,.gender]()(int)
[command,hint_npc](npc_uid $npc)
[command,hint_player](player_uid $player)
[command,headicons_get]()(int)
[command,headicons_set](int $icons)
[command,p_opobj](int $op)
[command,p_opplayer](int $op)
[command,.p_opplayer](int $op)
[command,p_opplayert](component $spell)
[command,player_findallzone](coord $coord)
[command,player_findnext]()(boolean)
[command,allowdesign](boolean $allow)
[command,last_targetslot]()(int)
[command,setmovecheck]
[command,.setmovecheck]
[command,clearqueue](queue $queue)
[command,afk_event]()(int)
[command,lowmemory]()(boolean)
Expand Down Expand Up @@ -274,6 +289,7 @@
// Inventory ops (4300-4399)
[command,inv_allstock](inv $inv)(boolean)
[command,inv_size](inv $inv)(int)
[command,.inv_size](inv $inv)(int)
[command,inv_stockbase](inv $inv, obj $obj)(int)
[command,inv_add](inv $inv, namedobj $obj, int $count)
[command,.inv_add](inv $inv, namedobj $obj, int $count)
Expand Down
15 changes: 14 additions & 1 deletion data/src/scripts/player/scripts/combat_level.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,18 @@ def_int $melee = calc(13 * (stat_base(attack) + stat_base(strength)));
def_int $ranged = calc(13 * scale(3, 2, stat_base(ranged)));
def_int $magic = calc(13 * scale(3, 2, stat_base(magic)));

def_int $final = calc(($base + max(max($melee, $ranged), $magic))/10);
//mes("Base: <tostring($base)>, Melee: <tostring($melee)>, Ranged: <tostring($ranged)>, Magic: <tostring($magic)>");

def_int $final = calc(($base + max(max($melee, $ranged), $magic))/40);
return($final);

[proc,.player_combat_level]()(int)
def_int $base = calc(10 * (.stat_base(defence) + .stat_base(hitpoints) + .stat_base(prayer) / 2));
def_int $melee = calc(13 * (.stat_base(attack) + .stat_base(strength)));
def_int $ranged = calc(13 * scale(3, 2, .stat_base(ranged)));
def_int $magic = calc(13 * scale(3, 2, .stat_base(magic)));

//mes("Base: <tostring($base)>, Melee: <tostring($melee)>, Ranged: <tostring($ranged)>, Magic: <tostring($magic)>");

def_int $final = calc(($base + max(max($melee, $ranged), $magic))/40);
return($final);
43 changes: 42 additions & 1 deletion data/src/scripts/player/scripts/damage.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ anim(human_death, 0);
p_delay(6);

// todo: save 3 items + protect items prayer
// todo: pk skull lose all items
def_int $i = 0;
def_int $size = inv_size(inv);
def_obj $prev_wep = inv_getobj(worn, ^wearpos_rhand);
Expand Down Expand Up @@ -41,6 +42,7 @@ stat_heal(hitpoints, 99, 0);
stat_heal(prayer, 99, 0);
healenergy(10000);
~combat_clearqueue;
~clear_pk_skull;
// todo: end poison timer ~player_end_poison
~update_all($prev_wep);

Expand Down Expand Up @@ -77,4 +79,43 @@ if (gender() = 0) {
case default : $sound = female_hit;
}
}
sound_synth($sound, 0, 20);
sound_synth($sound, 0, 20);


[proc,.damage_self](int $amount)
.if_close;
if ($amount > 0) {
.damage(.uid, 1, $amount);
~.human_hit_sound;
} else {
.damage(.uid, 0, 0);
}

// if (.stat(hitpoints) = 0 & .getqueue(player_death) < 1){
// .queue(player_death, 0);
// }
if (.stat(hitpoints) = 0){
.say("Pvp death is not implimented. Need support for .queue.");
}


[proc,.human_hit_sound]
def_int $rand;
def_synth $sound;
if (.gender() = 0) {
$rand = random(2);
switch_int($rand) {
case 0 : $sound = human_hit2;
case 1 : $sound = human_hit3;
case 2 : $sound = human_hit4;
case default : $sound = human_hit2;
}
} else {
$rand = random(1);
switch_int($rand) {
case 0 : $sound = female_hit;
case 1 : $sound = female_hit2;
case default : $sound = female_hit;
}
}
.sound_synth($sound, 0, 20);
39 changes: 39 additions & 0 deletions data/src/scripts/player/scripts/equip.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,45 @@ while ($i < $size) {
}
return($stabattack, $slashattack, $crushattack, $magicattack, $rangeattack, $stabdefence, $slashdefence, $crushdefence, $magicdefence, $rangedefence, $strengthbonus, $prayerbonus, $rangebonus);

[proc,.equip_get_bonuses]()(int, int, int, int, int, int, int, int, int, int, int, int, int)
def_int $stabattack = 0;
def_int $slashattack = 0;
def_int $crushattack = 0;
def_int $magicattack = 0;
def_int $rangeattack = 0;
def_int $stabdefence = 0;
def_int $slashdefence = 0;
def_int $crushdefence = 0;
def_int $magicdefence = 0;
def_int $rangedefence = 0;
def_int $strengthbonus = 0;
def_int $prayerbonus = 0;
def_int $rangebonus = 0;

def_int $size = .inv_size(worn);
def_int $i = 0;
while ($i < $size) {
def_obj $obj = .inv_getobj(worn, $i);
if ($obj ! null) {
$stabattack = calc($stabattack + oc_param($obj, stabattack));
$slashattack = calc($slashattack + oc_param($obj, slashattack));
$crushattack = calc($crushattack + oc_param($obj, crushattack));
$magicattack = calc($magicattack + oc_param($obj, magicattack));
$rangeattack = calc($rangeattack + oc_param($obj, rangeattack));
$stabdefence = calc($stabdefence + oc_param($obj, stabdefence));
$slashdefence = calc($slashdefence + oc_param($obj, slashdefence));
$crushdefence = calc($crushdefence + oc_param($obj, crushdefence));
$magicdefence = calc($magicdefence + oc_param($obj, magicdefence));
$rangedefence = calc($rangedefence + oc_param($obj, rangedefence));
$strengthbonus = calc($strengthbonus + oc_param($obj, strengthbonus));
$prayerbonus = calc($prayerbonus + oc_param($obj, prayerbonus));
$rangebonus = calc($rangebonus + oc_param($obj, rangebonus));
}
$i = calc($i + 1);
}
return($stabattack, $slashattack, $crushattack, $magicattack, $rangeattack, $stabdefence, $slashdefence, $crushdefence, $magicdefence, $rangedefence, $strengthbonus, $prayerbonus, $rangebonus);


[proc,update_bonus_text](component $com, string $name, int $bonus)
def_string $sign = "+";
if ($bonus < 0) {
Expand Down
2 changes: 2 additions & 0 deletions data/src/scripts/player/scripts/global.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ settimer(general_macro_events, 500);
~check_chest_macro_gas;
// for logout out during a general macro event, they respawn when you log back in
~macro_event_general_check;
// so pk skulls persist after logging back in
~set_pk_skull_login;


if (%tutorial_progress < ^tutorial_complete) {
Expand Down
1 change: 1 addition & 0 deletions data/src/scripts/player/scripts/logout.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ if (%tradepartner ! null) {
%tradepartner = null;
}
~reset_stall_trade_timers;
~set_pk_skull_logout;

return(true);
11 changes: 7 additions & 4 deletions data/src/scripts/skill_combat/scripts/npc/npc_combat.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// npc flinch
if (~npc_out_of_combat = true) {
%npc_action_delay = add(map_clock, divide(npc_param(attackrate), 2));
%npc_attacking_uid = %npc_defending_uid;
%npc_attacking_uid = %npc_aggressive_player;
}
if (finduid(%npc_attacking_uid) = true) {
npc_setmode(opplayer2);
Expand Down Expand Up @@ -146,16 +146,19 @@ npc_queue(1, 0, $queue_delay);
if (~inzone_coord_pair_table(multiway_zones, npc_coord) = false & %npc_attacking_uid ! uid & %npc_attacking_uid ! null) {
%npc_action_delay = add(map_clock, 8);
}
%npc_defending_uid = uid;
%npc_aggressive_player = uid;
%npc_lastcombat = map_clock;

[proc,npc_set_attack_vars]
%lastcombat = map_clock;
%npc_lastattack = map_clock;
%defending_npc_uid = npc_uid;
%aggressive_npc = npc_uid;

[proc,npc_can_attack_player]()(boolean)
if (add(%lastcombat, 8) > map_clock & %defending_npc_uid ! npc_uid & ~inzone_coord_pair_table(multiway_zones, npc_coord) = false) {
if (~inzone_coord_pair_table(multiway_zones, npc_coord) = true) {
return(true);
}
if (add(%lastcombat, 8) > map_clock & %aggressive_npc ! npc_uid) {
return(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ return(~combat_stat($effective_magic, $magicattack));

[movecheck,frozen]()(boolean)
if (map_clock < %stunned) {
mes("You're frozen!"); // guess fornow
mes("A magical force stops you from moving.");
return(false);
}

Expand Down
2 changes: 1 addition & 1 deletion data/src/scripts/skill_combat/scripts/npc/npc_death.rs2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
npc_setmode(null); // seems to give appropriate behavior: imps can continue to wander after death
if (npc_findhero = true & npc_param(death_sound) ! null){
sound_synth(npc_param(death_sound), 0, 0);
%defending_npc_uid = null;
%aggressive_npc = null;
}
npc_anim(npc_param(death_anim), 0);
npc_delay(npc_param(deathanim_delay));
Expand Down
Loading

0 comments on commit 807a06c

Please sign in to comment.