Author Topic: ADD_AREA_ITEM? (help)  (Read 5286 times)

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
ADD_AREA_ITEM? (help)
« on: October 04, 2010, 04:33:19 PM »
Huzzah for who wrote the macros. Yet, I need an example. I have no clue what I have to write, and how.
From the WeiDU readme:
Quote
ADD_AREA_ITEM: adds an item to a container of an area. This is a PATCH macro and function.

    * SET item_to_add to the item you want to add
    * SET container_to_add_to to number of container the item should be added to.
    * SPRINT flags to flags the item should have (usual weidu syntax: STOLEN, IDENTIFIEDSTOLEN, etc). Default - no flags.
    * SET charges1 to amount in stock/number of charges of first magical ability (default 0)
    * SET charges2 to number of charges of second magical ability (default 0)
    * SET charges3 to number of charges of third magical ability (default 0)

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: ADD_AREA_ITEM? (help)
« Reply #1 on: October 04, 2010, 04:38:04 PM »
There is a typo. It should say: SPRINT item_to_add ...

An example with default flags:

Code: [Select]
SPRINT item_to_add ~rndtre02~
SET container_to_add_to = "2"
SET charges1 = "0"
SET charges2 = "0"
SET charges3 = "0"
LAUNCH_PATCH_MACRO ADD_AREA_ITEM

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: ADD_AREA_ITEM? (help)
« Reply #2 on: October 04, 2010, 04:43:41 PM »
Great, thank you!
EDIT: Wait - how do I tell which are this goes to? Should there be an "COPY_EXISTING ~%ESewers%.ARE~ ~override~" above?
« Last Edit: October 04, 2010, 04:45:55 PM by jastey »

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: ADD_AREA_ITEM? (help)
« Reply #3 on: October 04, 2010, 11:41:53 PM »
If you use them as functions, you don't need to initialise zero values. You don't need to set charges except for stackable items or items with actual charges (wands etc.).
Code: [Select]
//Add item
COPY_EXISTING ar0413.are override //Engine Room
  PATCH_IF SOURCE_SIZE > 0x28f BEGIN
    LAUNCH_PATCH_FUNCTION ADD_AREA_ITEM
      INT_VAR container_to_add_to = 1
      STR_VAR item_to_add = aggem08 //Fire Opal
    END
  END
BUT_ONLY

//Replace item
COPY_EXISTING ar0413.are override //Engine Room
  PATCH_IF SOURCE_SIZE > 0x28f BEGIN
    LAUNCH_PATCH_FUNCTION REPLACE_AREA_ITEM
      STR_VAR old_item = misc38 //Black Opal
      new_item = aggem08 //Fire Opal
    END
  END
BUT_ONLY

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: ADD_AREA_ITEM? (help)
« Reply #4 on: October 05, 2010, 01:31:38 AM »
Okay... (trying to understand)
What does "PATCH_IF SOURCE_SIZE > 0x28f BEGIN" do?

What is BUT_ONLY in comparison to BUT_ONLY_IF_IT_CHANGES?

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: ADD_AREA_ITEM? (help)
« Reply #5 on: October 05, 2010, 01:42:48 AM »
What does "PATCH_IF SOURCE_SIZE > 0x28f BEGIN" do?

It checks whether the file is larger than 655 bytes. I think it has something to do with some corrupted files in BG2.

Quote
What is BUT_ONLY in comparison to BUT_ONLY_IF_IT_CHANGES?

Miloch not wanting to type it all, I imagine.

Offline DavidW

  • Planewalker
  • *****
  • Posts: 316
Re: ADD_AREA_ITEM? (help)
« Reply #6 on: October 05, 2010, 02:04:48 AM »
What does "PATCH_IF SOURCE_SIZE > 0x28f BEGIN" do?

It checks whether the file is larger than 655 bytes. I think it has something to do with some corrupted files in BG2.

Specifically, it makes sure the code doesn't fail to install if the area files in question are drastically corrupted.

(I actually think it's a mistake to use it in this context: if those core-game areas don't exist, you want to know about it. (Though perhaps I'm missing something.) It's more commonly used when you're doing COPY_EXISTING_REGEXP)

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: ADD_AREA_ITEM? (help)
« Reply #7 on: October 05, 2010, 02:11:57 AM »
Thank you for the explanations.

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: ADD_AREA_ITEM? (help)
« Reply #8 on: October 05, 2010, 04:15:13 AM »
I actually think it's a mistake to use it in this context: if those core-game areas don't exist, you want to know about it.
I tend to agree... blame the fixpackers for that bad habit.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: ADD_AREA_ITEM? (help)
« Reply #9 on: October 05, 2010, 04:54:25 AM »
What is BUT_ONLY in comparison to BUT_ONLY_IF_IT_CHANGES?
They're synonims.

Re: SOURCE_SIZE checks, ALLOW_MISSING works by copying an empty file in stead of the missing file. If you copy a single file it doesn't matter, but in more complex cases it might. Consider a mod that makes Celestial Fury weight 100 and wants to patch Item Upgrade's copy (without using ACTION_IF). The following would fail (unless you use the SOURCE_SIZE check) because iusw1hxx.itm is missing and thus initialized to an empty string instead:

ALLOW_MISSING ~iusw1hxx.itm~ // Celestial Fury +5 from IU
<...>
COPY_EXISTING ~sw1hxx.itm~ ~override~
    ~iusw1hxx~ ~override~
  WRITE_LONG 0x4c 100
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: ADD_AREA_ITEM? (help)
« Reply #10 on: October 05, 2010, 07:57:35 AM »
So, does that mean I take the line "PATCH_IF SOURCE_SIZE > 0x28f BEGIN" out?

the bigg: If I do

COPY_EXISTING ~iusw1hxx~ ~override~
  WRITE_LONG 0x4c 100

and the file is not there, why is it initialized to an empty string? I thought COPY_EXISTING fails if the file is not there?

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: ADD_AREA_ITEM? (help)
« Reply #11 on: October 05, 2010, 08:15:00 AM »
So, does that mean I take the line "PATCH_IF SOURCE_SIZE > 0x28f BEGIN" out?
It doesn't really matter in the end - with the notable exception of iplot01k.itm, no file will ever be that badly broken. If a file was indeed so badly broken, you can be assured that the user is computer illiterate, writes in moron speak, and you'll need 30 posts of extremely detailed instructions before you can get him to upload the debug file.

Quote
COPY_EXISTING ~iusw1hxx~ ~override~
  WRITE_LONG 0x4c 100

and the file is not there, why is it initialized to an empty string? I thought COPY_EXISTING fails if the file is not there?
That's what happens if you used ALLOW_MISSING on iusw1hxx. Without ALLOW_MISSING, WeiDU will fail the installation as usual.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: ADD_AREA_ITEM? (help)
« Reply #12 on: October 05, 2010, 09:38:55 AM »
Quote
30 posts of extremely detailed instructions
Thank you, that example was very vivid.  ;D

Quote
That's what happens if you used ALLOW_MISSING on iusw1hxx. Without ALLOW_MISSING, WeiDU will fail the installation as usual.
So I am the idiot if i program this? Ah, and with the file size check it works because 0 byte / missing files are left out. Comprende. (At last). :)

Thank you all again!

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: