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

Required Stats, Restricted Items, Unreleased Items, and Multiple Ammo types properly Unequip on condition failure #39

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions world/map/db/const.txt
Expand Up @@ -672,3 +672,8 @@ OPT_BANK_CLOSE 2
// Currently used by the fluffy hunt (033-1).
// starts counting with 0
MAX_HIGH_SCORES 4

// Launcher/Ammo Types
AMMO_NONE 0
AMMO_BOW 1
AMMO_SLING 2
22 changes: 12 additions & 10 deletions world/map/db/item_db.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion world/map/npc/021-1/north_shops.txt
Expand Up @@ -3,7 +3,7 @@
// More high-end stuff to satisfy the richer people in Royal Tulimshar

// Some clothing
021-1.gat,135,38,0|shop|Inar|108,CottonShirt :-1,CottonShorts :-1,CottonBoots :-1,DesertShirt :-1,SilkRobe :-5,DesertHat :-4
021-1.gat,135,38,0|shop|Inar|108,SlingShot :-1,SlingBullet :-1,CottonShirt :-1,CottonShorts :-1,CottonBoots :-1,DesertShirt :-1,SilkRobe :-5,DesertHat :-4

021-1.gat,129,40,0|script|Well|400,
{
Expand Down
2 changes: 2 additions & 0 deletions world/map/npc/042-2/sorfina.txt
Expand Up @@ -231,6 +231,8 @@ L_SkipTut:
mes "\"Alright, if you say so. But take at least this.";
callfunc "TutorialCompleted";
getitem "Knife", 1;
getitem "SlingShot", 1;
getitem "SlingBullet", 100;
getitem "CottonShirt", 1;
getitem "RaggedShorts", 1;
set Zeny, Zeny + 50;
Expand Down
12 changes: 10 additions & 2 deletions world/map/npc/042-2/tanisha.txt
Expand Up @@ -50,7 +50,7 @@ L_Maggots:

L_Fight_Again:
mes "\"Ok, listen what to do.";
mes "Equip the knife and kill the maggots.\"";
mes "Equip a weapon and kill the maggots.\"";
next;
mes "\"Press A to focus on a monster. With X you can focus and start attacking the same time.";
mes "But it also works to click on the monster with your mouse.\"";
Expand All @@ -64,7 +64,15 @@ L_Fight_Again:
// The getitem must be in the same place as set tanisha, 2;
// since it was moved to after L_Fight_Again, add it conditionally
if (tanisha == 1)
getitem "Knife", 1;
goto L_GetFightItems;
goto L_ContinueFight;

L_GetFightItems:
getitem "Knife", 1;
getitem "SlingShot", 1;
getitem "SlingBullet", 100;

L_ContinueFight:
set tanisha, 2;
set @Maggot_Kills, 0;
set @time, 0;
Expand Down
55 changes: 55 additions & 0 deletions world/map/npc/items/launcher_ammo.txt
@@ -0,0 +1,55 @@
// ------------------------------------------------------------
// Ammo Needs to know Launcher and vice versa.
//
// Behavior:
// Ammo is always unequipped
//
// Variables passed to this script:
//
// @LauncherType, @AmmoType
//
// ------------------------------------------------------------

function|script|CheckLauncher|,
{
// Need to check if this is still equipped later.
set @LauncherTypeId, @itemId;
// If no Ammo equipped Hide LauncherType Until it's Needed.
if (!(@LauncherNoAmmoType) || (@LauncherType != @LauncherNoAmmoType))
set @LauncherNoAmmoType, @LauncherType;
set @LauncherType, 0;
return;
}

function|script|CheckAmmo|,
{
// Iterates over all slots to check for equipment
// Allows Armor to effect Ammo and equip slots to move
set @EquipSlotCheck, 0;

L_EquipCheck:
if (@EquipSlotCheck == 11)
goto L_CheckAmmo;
if (@LauncherTypeId == getequipid(@EquipSlotCheck))
goto L_LauncherEquipped;

L_EquipInc:
set @EquipSlotCheck, @EquipSlotCheck + 1;
goto L_EquipCheck;

L_LauncherEquipped:
set @LauncherType, @LauncherNoAmmoType;

L_CheckAmmo:
// Check If Launcher Matches Ammo or is No Longer equipped.
if ((@LauncherType == @AmmoType) || (@LauncherType == 0))
goto L_Return;

L_Unequip:
callfunc "UnequipLater";

L_Return:
set @LauncherType, 0;
set @AmmoType, 0;
return;
}
12 changes: 9 additions & 3 deletions world/map/npc/items/require_stat.txt
Expand Up @@ -11,9 +11,15 @@
function|script|RequireStat|,
{
set @bStatVal, readparam(@bStat);
// If the requirement isn't met, then we end the script.
// Hence, subsequent item modifiers won't be applied.
// If the requirement isn't met, we set an unequip trigger.
// The item is now removed.
if (@bStatVal < @minbStatVal)
end;
goto L_Unequip;
goto L_Return;

L_Unequip:
callfunc "UnequipLater";

L_Return:
return;
}
3 changes: 1 addition & 2 deletions world/map/npc/items/restricted_item.txt
Expand Up @@ -11,11 +11,10 @@ function|script|RestrictedItem|,
if (!@minLvl) set @minLvl, 60;
if (debug || getgmlevel() >= @minLvl) goto L_Return; // If the active character is staff, do nothing.
message strcharinfo(0), "This item repells you with extreme force. It does not seem to be meant for you.";
unequipbyid @slotId;
callfunc "UnequipLater";
if (getgmlevel()) goto L_Return;
gmcommand "@wgm Restricted item '" + @itemId + "' used by character '" + strcharinfo(0) + "'.";
gmcommand "@l Restricted item '" + @itemId + "' used by character '" + strcharinfo(0) + "'.";
end;

L_Return:
return;
Expand Down
27 changes: 27 additions & 0 deletions world/map/npc/items/unequipcb.txt
@@ -0,0 +1,27 @@
// For now this has to use a real map name, but the effect happens
// on any map because of the -1s at the end.
// Note: the client (I think) has a display bug if this is called
// during the intial connection's equip hook
botcheck.gat,0,0,0|script|UnequipCB|-1,-1,-1
{

OnUnequip:
unequipbyid (@unequip_slot -1);
set @unequip_slot, 0;
end;
}

// Paired with unequipcb
function|script|UnequipLater|,
{
if(@unequip_slot)
goto L_Return;
goto L_ReturnTimer;

L_ReturnTimer:
set @unequip_slot, (@slotId + 1);
addtimer 0, "UnequipCB::OnUnequip";

L_Return:
return;
}
10 changes: 7 additions & 3 deletions world/map/npc/items/unreleased_item.txt
Expand Up @@ -5,8 +5,12 @@

function|script|UnreleasedItem|,
{
if (debug || getgmlevel()) end; // If the server allows equipping unreleased items or if the active character is staff, do nothing.
// If the server allows equipping unreleased items or if the active character is staff, do nothing.
if (debug || getgmlevel())
goto L_Return;
message strcharinfo(0), "You have difficulties equipping this item, as if it is not yet fully in this world.";
unequipbyid @slotId;
end;
callfunc "UnequipLater";

L_Return:
return;
}
2 changes: 2 additions & 0 deletions world/map/npc/scripts.conf
Expand Up @@ -29,6 +29,8 @@ npc: npc/items/unreleased_item.txt
npc: npc/items/require_stat.txt
npc: npc/items/restricted_item.txt
npc: npc/items/warpTowels.txt
npc: npc/items/unequipcb.txt
npc: npc/items/launcher_ammo.txt

import: npc/_import.txt

Expand Down