Author Topic: Adding creatures to areas  (Read 19301 times)

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Adding creatures to areas
« on: July 13, 2010, 09:55:01 AM »
Since I have not found any patches or macros that accomplish this, I would like to know what the current method is. Hopefully not INSERT_BYTES.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Adding creatures to areas
« Reply #1 on: July 13, 2010, 10:05:29 AM »
Is there any particular reason you can't do that with script files?
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 Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Adding creatures to areas
« Reply #2 on: July 13, 2010, 10:13:37 AM »
Not as such, but it seems like adding a second step to something that might be done with only one. It may also use a lot of variables. Are they unlimited?

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Adding creatures to areas
« Reply #3 on: July 13, 2010, 10:33:08 AM »
Not as such, but it seems like adding a second step to something that might be done with only one.
Every other mod in existance doesn't have a problem with it (especially since it eases the issue with old save files).

Are they unlimited?
The limit is (probably) in the billions.
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 devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Adding creatures to areas
« Reply #4 on: July 13, 2010, 12:32:44 PM »
The limit is (probably) in the billions.
Actually, I think they doubled the limit in TotSC patch from like ~1,000 to ~2,000. :-)

Don't you pretty much change every single creature in some areas? Just include those AREs with the mod.

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Adding creatures to areas
« Reply #5 on: July 13, 2010, 12:47:26 PM »
Don't you pretty much change every single creature in some areas? Just include those AREs with the mod.

I guess you mean replace the existing CREs with new ones in which case the answer is no. I mostly use the same CREs and though they have been updated, the area remains the same. Most of the area changes are items being removed, added or replaced.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Adding creatures to areas
« Reply #6 on: July 13, 2010, 01:02:56 PM »
Either way, you need a single global variable per area file that needs new creatures, and not even those if BG1/TotSC supports area-scoped variables ( Global("whaterver","AR0001",1) or Global("whaterver","MYAREA",1)).
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 Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Adding creatures to areas
« Reply #7 on: July 13, 2010, 01:22:40 PM »
It does, although MYAREA cannot be used.

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Adding creatures to areas
« Reply #8 on: July 14, 2010, 03:43:12 PM »
Do you want me to remove CREs in the same way? Patching existing scripts or making new ones to change things ingame rather than during installation is really not the most effective way of handling this.

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Adding creatures to areas
« Reply #9 on: July 14, 2010, 04:07:04 PM »
You could just add a generic DestroySelf() script to the NPCs you want to remove in their ARE headers (like the Specifics slot or something).

If you take a look at BG1UB, we delete some guy from AR1009 (should have been done from script, but I did it in TP2 anyway). We should also have some AREs where we add CREs, but this was before THIS and LONG_AT, so it's kind of fugly, and one of these nuts these days will have some solution that requires 10,000 additional lines so you could save like 10 minutes for every thousand creatures (after the initial hours wasted coming up with something so ridiculous).

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Adding creatures to areas
« Reply #10 on: July 14, 2010, 04:13:49 PM »
I know how it can be done with scripts but it turns into more work this way and I do not need that. Considering the highly similar patches and macros that WeiDU sports, I am surprised add/remove CRE is missing.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Adding creatures to areas
« Reply #11 on: July 14, 2010, 04:26:26 PM »
I am surprised add/remove CRE is missing.
That's because every modder codes those functions via BCS scripts and not via tp2.
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 Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Adding creatures to areas
« Reply #12 on: July 14, 2010, 04:36:05 PM »
That's because every modder codes those functions via BCS scripts and not via tp2.

Just because everybody uses this method does not give it a free upgrade to "highly effective". As for the savegame issue, FotD requires you to start a new game anyway. For now I will rather try my hand at macros than do it the BCS way.

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Adding creatures to areas
« Reply #13 on: July 14, 2010, 04:38:03 PM »
So I guess the part where I directed you to look at BG1UB for TP2 examples was written in farsi or something?

Sorry about that. I sometimes forget to use English.

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Adding creatures to areas
« Reply #14 on: July 14, 2010, 04:43:27 PM »
It must have been something like that because I do not know why I ignored it. Thanks. :)

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: Adding creatures to areas
« Reply #15 on: July 20, 2010, 03:21:15 AM »
So I guess the part where I directed you to look at BG1UB for TP2 examples was written in farsi or something?
Perhaps not, but the code itself might well be :P.

Yeah, I'm not slamming it, I know you didn't have fancy modern WeiFu functions back then. There is in fact one in long use in aurora/lib/fj_add_are_struct.tpa (and probably a few other mods) to do practically anything area-related that should just be added to WeiDU already. At least externally, though compressed it totals a whole 4kb which is hardly bloat, or at least is very useful bloat anyhow. It can add not only actors but just about anything else to an area - trigger region, entrance, animation, etc. And no, it's not mine, so no need to worry about crappy code :P.

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Adding creatures to areas
« Reply #16 on: July 20, 2010, 05:11:39 PM »
and one of these nuts these days will have some solution that requires 10,000 additional lines so you could save like 10 minutes for every thousand creatures (after the initial hours wasted coming up with something so ridiculous).
Now do I know my shit or do I know my shit?

Don't mess with Zoltar!
« Last Edit: July 20, 2010, 05:16:00 PM by devSin »

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: Adding creatures to areas
« Reply #17 on: July 20, 2010, 05:36:09 PM »
and one of these nuts these days will have some solution that requires 10,000 additional lines so you could save like 10 minutes for every thousand creatures (after the initial hours wasted coming up with something so ridiculous).
Now do I know my shit or do I know my shit?
Actually, I don't think you do know what you're on about :P.

As far as I can tell, all the "creature adding" in BG1UB is done either via script or by replacing existing actors. And the code to add area regions, delete actors and the like is not any more or less extensive than the code I'm talking about (they're both a few hundred lines, which is a damn sight less than ten thousand). Maybe Ascension64 replaced some older "fuglier" code, who knows.

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Adding creatures to areas
« Reply #18 on: July 24, 2010, 02:15:23 PM »
There is in fact one in long use in aurora/lib/fj_add_are_struct.tpa (and probably a few other mods) to do practically anything area-related that should just be added to WeiDU already.

This code goes beyond my limited WeiDU knowledge but having this full range of area functionality in WeiDU would be great as I am also going to add/remove containers, entrances, and so on.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Adding creatures to areas
« Reply #19 on: July 25, 2010, 06:49:23 AM »
Yeah, I'm not slamming it, I know you didn't have fancy modern WeiFu functions back then. There is in fact one in long use in aurora/lib/fj_add_are_struct.tpa (and probably a few other mods) to do practically anything area-related that should just be added to WeiDU already.

Sure, can do. I need a description of the parameters for the docs, though. template:
Code: [Select]
\verb+tb#frimble+: frimbles your frazzle. \\
This is a PATCH function.
\begin{itemize}
\item SET \verb+foo+ to the number of foos in your frazzle;
\item SET \verb+bar+ to index of bar in your frazzle;
\item SPRINT \verb+baz+ to the resource to be frimbled;
\item returns the frimble amount as \verb+frimble+.
\end{itemize}
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 Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: Adding creatures to areas
« Reply #20 on: July 25, 2010, 01:52:21 PM »
I need a description of the parameters for the docs, though.
Ok, I'll see if I can come up with a sample for each use. I can mine Aurora and a couple other mods for most of them.

Offline temujin

  • Planewalker
  • *****
  • Posts: 78
Re: Adding creatures to areas
« Reply #21 on: July 26, 2010, 12:41:29 PM »
aurora/lib/fj_add_are_struct.tpa

I think there are still a few minor discrepancies in this code; someone might want to doublecheck this:


- "WRITE_LONG   fj_position + 0x2c fj_spawned"  should be a WRITE_SHORT according to the latest NI...

- same goes for "WRITE_LONG   fj_position + 0x34 fj_orientation"

- needs a "WRITE_SHORT   fj_position + 0x3E ..." to account for Movement Distance for Actors

- missing WRITEs for "creature duration", "wander distance", "movement distance" and "probability (day)" for Spawn Points

- "WRITE_ASCIIE fj_position + 0x9c ~%fj_travel_trigger%~ #16"  -- shouldn't this be #24?

- "WRITE_LONG   fj_position + 0xbc fj_dialogue_strref" -- i think the offset is fj_position + 0xb4 for Doors

- "WRITE_ASCIIE fj_position + 0xc0 ~%fj_dialogue_resref%~" should be fj_position + 0xb8 for Doors

- "WRITE_LONG   fj_position + 0x10 fj_level_base" should probably be split to two WRITE_SHORTs (explosion frequency & duration) for Projectiles


Also, since the code is not taking into account "CRE struct offset" & "CRE struct size" for each actor, it's probably worth mentioning that if you try to add any actors (or maybe even other structures) to areas with embedded creatures, the entire area will likely get corrupt...  I remember a mod or two in a mega install that had those types of areas.


Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: Adding creatures to areas
« Reply #22 on: July 26, 2010, 04:22:15 PM »

- "WRITE_LONG   fj_position + 0x2c fj_spawned"  should be a WRITE_SHORT according to the latest NI...

- same goes for "WRITE_LONG   fj_position + 0x34 fj_orientation"

- "WRITE_ASCIIE fj_position + 0x9c ~%fj_travel_trigger%~ #16"  -- shouldn't this be #24?

- "WRITE_LONG   fj_position + 0xbc fj_dialogue_strref" -- i think the offset is fj_position + 0xb4 for Doors

- "WRITE_ASCIIE fj_position + 0xc0 ~%fj_dialogue_resref%~" should be fj_position + 0xb8 for Doors
I'm way out of my league here (deciding if something's a word or dword etc) but according to the IESDP Nythrun's values are correct except the travel trigger is, according to the IESDP, 32 bytes.

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: Adding creatures to areas
« Reply #23 on: July 26, 2010, 05:10:41 PM »
Well if someone wants to upload (and hopefully test) a new version, fine with me. My time is going to be a bit limited over the next week or so as I'm moving. AFAIK, it works for everything we use it for (actors, regions, entrances, containers mainly) but I did notice some discrepancies when trying to add a door. Namely, it added the door but didn't associate the new vertices correctly.

Offline GeN1e

  • Planewalker
  • *****
  • Posts: 267
  • Gender: Male
Re: Adding creatures to areas
« Reply #24 on: July 26, 2010, 05:29:55 PM »
There's something that probably not everyone is aware of - area projectiles. They don't consist merely of the 0x1c long blocks, but also headerless V2 EFFs containing actual effects. These can be accessed from the projectile's 0x8 and 0xc offsets, although afaik nobody has ever tried to update them (not like there was a need so far). Regardless, vanilla areas are clean of projectiles (I think) and adding them via patching is beyond silly imo - much more so than patching in new actors. But it is something to consider if savegame area file needs to be patched, which again is unlikely anyway.

On a un-related note, there's a typo in Nythrun's macro - number of projectile's missiles is stored at 0x12, not 0xe, although for reasons abovementioned, it shouldn't cause problems.

 

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)?: