Author Topic: [Item]Holy Shield  (Read 5530 times)

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
[Item]Holy Shield
« on: November 18, 2011, 03:21:04 PM »
'sup,

I've had this lying around for a long time. This was actually the first thing I ever created for W3S, so expect no magic.
What it does is quite simple:
Remember how most people check for an Immunity_Skills block but few races actually HAVE one?

Well, a lot of races had abilities that were worth blocking and were quite annoying (ex.: an AoE-Stun).
If the race has a check for Immunity_Skills (which it should if the author took the time to do so), this blocks said ability.

Most of you coders already have this, but it's a beloved item on the server we run.
This also includes a German translation in case anyone needs it. If you have a different language you would like to see in the translation file, just PM me the content and the language-name. Ty!

Any mistakes were most-likely an accident and are eagerly awaiting a fix. Let me know if you find one.

Cheers,
Vulp


*Files appended.

Edit: 2011-11-19 (19.11.2011)
6:30 PM GMT+1
*Added language support for Russian! (All credits go to alex0310)

Edit: 2011-11-22 (22.11.2011)
8:55 AM GMT+1[/i]
    Changelog:
    • Changed money cost ($$) to 2000
    • Money and Shield can not be carried at the same time.
    • Added a ConVar that adds option to forbid necklace+shield.

[BUGTRACKING] This means: There may be bugs. The code compiles properly (but we all know that means nothing. :-D) and should (!) work correctly.
Any reported errors are greatly appreciated.


Console Variable(s):
war3_shop_shield_restriction "0" "Set this to 1 if you want to forbid necklace+shield. 0 default"[/list]
« Last Edit: November 22, 2011, 02:24:49 AM by Vulpone »
Sapere aude!

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #1 on: November 19, 2011, 11:34:22 AM »
Russian language support. Many thanks to alex0310 for that.

Updated attachment.
Sapere aude!

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: [Item]Holy Shield
« Reply #2 on: November 19, 2011, 06:54:37 PM »

commit to svn

qwerty

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Re: [Item]Holy Shield
« Reply #3 on: November 21, 2011, 10:08:58 AM »
isn't this the same as necklace of immunity?

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #4 on: November 21, 2011, 10:25:59 AM »
isn't this the same as necklace of immunity?



Necklace = Immunity_Ultimates
Shield = Immunity_Skills
Sapere aude!

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: [Item]Holy Shield
« Reply #5 on: November 21, 2011, 10:29:27 AM »

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #6 on: November 21, 2011, 10:34:18 AM »
Sapere aude!

Glider⠠⠵

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 472
  • ⠠⠵
    • View Profile
Re: [Item]Holy Shield
« Reply #7 on: November 21, 2011, 04:35:17 PM »
Let's dump the forums for a imageboard.

Also I'd like a restriction so you can either have a holy shield or necklace of immunity, but not both at the same time.

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #8 on: November 22, 2011, 12:21:30 AM »
Let's dump the forums for a imageboard.

Also I'd like a restriction so you can either have a holy shield or necklace of immunity, but not both at the same time.

haha.

It all boils down to how many max-items you can carry.  But I'll add it, I have no idea how this affects TF2 or L4D. Thanks for reminding me.

Edit:
Oh, I misread what you said.  I don't think I can do that, as I would have to edit the original War3Source_Shopitems.sp and enable a shield-check.
Should I just do that or is that your realm? I'll add it for the Shield, though.
« Last Edit: November 22, 2011, 12:24:21 AM by Vulpone »
Sapere aude!

Necavi

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
Re: [Item]Holy Shield
« Reply #9 on: November 22, 2011, 12:47:20 AM »
You wouldn't need to edit it, you just need to add a little chunk to your OnItemGain (Can't remember the precise name of the event) then see if the item being gained is necklace, and if it is and if the person also has a shield, then prevent them from getting their necklace.

Very easy :)

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #10 on: November 22, 2011, 12:55:26 AM »
You wouldn't need to edit it, you just need to add a little chunk to your OnItemGain (Can't remember the precise name of the event) then see if the item being gained is necklace, and if it is and if the person also has a shield, then prevent them from getting their necklace.

Very easy :)

Yes, but vice-versa? If I have a check when purchasing Shield, I don't have one when purchasing Necklace.

e.g. I have a necklace. I'm purchasing Shield. Boom, error! But...
I'm wearing a Shield. I'm purchasing a necklace.

Thing is, why do this inside Holy Shield?

But meh, I scrapped this together.
Code: [Select]
if(ValidPlayer(client))
{
new lace = War3_GetItemIdByShortname("lace");
if(item == thisItem && !War3_GetOwnsItem(client, lace) || item == lace && !War3_GetOwnsItem(client, thisItem))
{
War3_SetBuffItem(client,bImmunitySkills,thisItem,true);
War3_SetOwnsItem(client,item,true);
}
else if(item == thisItem && War3_GetOwnsItem(client, lace))
{
War3_SetBuffItem(client,bImmunitySkills,thisItem,false);
War3_SetOwnsItem(client,item,false);

War3_ChatMessage(client, "Error purchase Holy Shield! Cannot wear Necklace and Shield at the same time.");
}
}

Probably got a few error, and I have at LEAST one case not written out (the one behind the logical OR).
But I gotta run. See ya.
Sapere aude!

Necavi

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
Re: [Item]Holy Shield
« Reply #11 on: November 22, 2011, 01:01:22 AM »
Code: [Select]
if(ValidPlayer(client))
{
new lace = War3_GetItemIdByShortname("lace");
if(item == thisItem && !War3_GetOwnsItem(client, lace) || item == lace && !War3_GetOwnsItem(client, thisItem))
{
War3_SetBuffItem(client,bImmunitySkills,thisItem,true);
War3_SetOwnsItem(client,item,true);
}
else if(item == thisItem && War3_GetOwnsItem(client, lace))
{
War3_SetBuffItem(client,bImmunitySkills,thisItem,false);
War3_SetOwnsItem(client,item,false);

War3_ChatMessage(client, "Error purchase Holy Shield! Cannot wear Necklace and Shield at the same time.");
}
else if(item == lace && War3_GetOwnsItem(client, thisItem))
{
War3_SetOwnsItem(client, item, false);
War3_ChatMessage(client, "Error purchasing Necklace of Immunity! Cannot wear Necklace and Shield at the same time.");
//blahblah refund their junk
}
}

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #12 on: November 22, 2011, 01:06:30 AM »
help help.. help help.. help help. :d

Hah! Thanks. I don't have to go,so I'm free. Thanks a bunch for that.

I'll take care of refunding their gold. lol.

Edit:
I also have to remove their ultimate immunity 8^D.
Sapere aude!

Necavi

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
Re: [Item]Holy Shield
« Reply #13 on: November 22, 2011, 01:09:32 AM »
Happy to help XD But yeah, thanks to how much is broadcast as events, that kind of thing is easy without modification :3

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #14 on: November 22, 2011, 01:18:14 AM »
Happy to help XD But yeah, thanks to how much is broadcast as events, that kind of thing is easy without modification :3

True!
The API really makes things easy...

Is W3GetItemCost(itemid,bool:csmoney) safe? If I set the bool false, does it return the value ACTUALLY used? Sadly, I have no way of checking what it returns.. (no server and no comments)
Sapere aude!

Necavi

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
Re: [Item]Holy Shield
« Reply #15 on: November 22, 2011, 01:23:01 AM »
No reason it shouldn't return the cvar-set value (so if they changed it it should revert) although you should probably check that one cvar/command that returns whether its actually money or credits :P

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #16 on: November 22, 2011, 01:25:27 AM »
No reason it shouldn't return the cvar-set value (so if they changed it it should revert) although you should probably check that one cvar/command that returns whether its actually money or credits :P

What about this one?  bool:W3BuyUseCSMoney()
I should really comment out some of the Interface APIs to make sure. lol.

I'm on it, though.
Sapere aude!

Necavi

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
Re: [Item]Holy Shield
« Reply #17 on: November 22, 2011, 01:41:28 AM »
That should get it, I would assume that true = csmoney, false = credits.

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #18 on: November 22, 2011, 02:01:01 AM »
That should get it, I would assume that true = csmoney, false = credits.

First post updated! Get it while it's hot. :d
Sapere aude!

Necavi

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
Re: [Item]Holy Shield
« Reply #19 on: November 22, 2011, 02:03:01 AM »
Should probably set that to a choice :3 some people like allowing both necklace and shield (possibly default to allowing both?)

Vulpone

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #20 on: November 22, 2011, 02:21:29 AM »
Should probably set that to a choice :3 some people like allowing both necklace and shield (possibly default to allowing both?)


I've allowed both on my server, but Glider requested this.
We have a max. of two items, though..

**done.

Added to main post!
Sapere aude!

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: [Item]Holy Shield
« Reply #21 on: November 22, 2011, 10:00:37 AM »
note this event:

W3SetVar(EventArg1,item);
W3SetVar(EventArg2,1);
W3CreateEvent(CanBuyItem,client);

Arturius

  • Full Member
  • ***
  • Posts: 155
    • View Profile
    • Email
Re: [Item]Holy Shield
« Reply #22 on: November 22, 2011, 04:10:49 PM »
AntiWard already has Immunity_Skills.
Code: [Select]
bImmunitySkills, //is immune to skills
bImmunityUltimates, // is immune to ultimates
bImmunityWards, // is immune to wards, skill immunity includes ward immunity

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: [Item]Holy Shield
« Reply #23 on: November 22, 2011, 07:03:49 PM »
antiward gives ward immunity
holyshield gives skill immunity which along gives ward immunity

Glider⠠⠵

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 472
  • ⠠⠵
    • View Profile
Re: [Item]Holy Shield
« Reply #24 on: November 23, 2011, 12:56:50 PM »
[BUGTRACKING] This means: There may be bugs. The code compiles properly (but we all know that means nothing. :-D) and should (!) work correctly.
Any reported errors are greatly appreciated.

Quote from: Donald Knuth
Beware of bugs in the above code; I have only proved it correct, not tried it.

 ;D