Author Topic: HCR2 Scripting edit help  (Read 666 times)

Legacy_grostilzirelman

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
HCR2 Scripting edit help
« on: February 06, 2011, 04:53:45 am »


                Since it appears the forums for HCR2 are closed, at least accoding to the site link I found, I figured the next best place for me to ask was here.

Here is what I'm trying to do.

I currently have HCR2 installed, and working fine. No problems at all.

What happens is that in my current system when someone bleeds out they teleport to the Fugue Plane, as per the HCR2 standard system. I have it that PC's can resurrect other players as normal, but if that option is not available there is a NPC there in the fugue that the PC can talk to to restore them to life. This happens with a basic script that takes an item from the PC's inventory (Shard of your Soul, which I set not to leave the PC's inventory except in this script) and teleports the PC to a spot in game. This of course brings you back into the game world just fine.

Here's my problem.

The Lootbag that is dropped, It still has all the players items in it and far away from the players reach wherever they originally died. Not only that, but the corpse persists and corpse item is still at the death location.

I know why this happens. It's because the HCR system is supposed to have someone or something cast Raise Dead or the equivalent on the corpse item to resurrect the character. By teleporting out of the fugue it kinda bypasses the system in that regard.

However, I would still like to do it. 

Is there a way to have the loot bag contents return to the player either once they are teleported away from the fugue by the NPC to the 'Respawn' location? Bar that, is there a way for the Loot Bag to travel with the player when they respawn? Is there a way to destroy that leftover corpse and corpse item when the player is teleported out of fugue by the NPC? Any help would be appreciated.

Also, though not as immediate a concern, is there an option to allow it to be that the Loot bag does not drop until the player dies, rather than when they are bleeding? Being forced to regather and restructure your entire inventory every time you are knocked below 0 is kind of annoying. I'd rather the players drop their loot only upon death. Alot less annoying that way.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #1 on: February 06, 2011, 10:11:01 am »


               First, Let me say that everything you hace asked can be done.

I for one do not have the time to look at it right now.  But even if I did, It would help if you at least gave a link to the HCR2 system.  Having never even used the HCR system I would not want to search for the system you are talking about, Risk finding the wrong one and giving bad advice.  

In short, If you want a better chance of finding help, Post a link so people have something to look at.

               
               

               
            

Legacy_grostilzirelman

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #2 on: February 06, 2011, 06:57:43 pm »


               Of course, my thanks ahead of time '<img'>



Here you are. It's the final version as far as I am aware available on NWVault.



http://nwvault.ign.c....Detail&id=3066
               
               

               
            

Legacy_grostilzirelman

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #3 on: February 06, 2011, 07:06:32 pm »


               And just to say, I figured it could be done. But with such a complex system I wasn't even sure where to begin. @_@
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #4 on: February 06, 2011, 10:19:24 pm »


               I've seen what your talking about, i will look into that and reply...

EDIT ADD:
Ok what things did you use from the link ie first file mod example, second erf rar. third ducumentation

i will be using the default mod of course so to set it up to get same resaults as you I need to know your settings for
HCR rules. (rest, death, corpses, bleeding and loot)    so we match.
               
               

               


                     Modifié par Greyfort, 06 février 2011 - 10:23 .
                     
                  


            

Legacy_grostilzirelman

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #5 on: February 06, 2011, 10:50:21 pm »


               I didn't use the example mod. I actually set the setting as per the documentation myself in a new module. Done as per 'HCR2_Module_Builders_Guide.pdf'. As done throughout the pdf the setup process was done exact, no difference whatsoever.

Each of the settings are located in the _c scripts, so I'll post each change from default individually


h2_core_c
const int H2_STRIP_ON_FIRST_LOGIN = TRUE;
const int H2_READ_CHECK = TRUE;

h2_pcrest_c
const int H2_MINIMUM_SPELL_RECOVERY_REST_TIME = 0;
const int H2_HP_HEALED_PER_REST_PER_LEVEL = -1;
const int H2_REQUIRE_REST_TRIGGER_OR_CAMPFIRE = TRUE;

h2_pccorpse_c
No changes from default

h2_bleedsystem_c
No changes from default


Which ERF's?

The core of course, HCR2_Core_Only

Then the 5 Main Subsystems

HCR2_loot_system
HCR2_pccorpsesys
HCR2_bleedsystem
HCR2_fuguesystem
HCR2_rest_system



Hope I gave you everything you needed.

Again, thanks in advance.



Edited for clarification.
               
               

               


                     Modifié par grostilzirelman, 06 février 2011 - 11:00 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #6 on: February 07, 2011, 12:45:27 am »


               located in “h2_pccorpse_i”

void h2_CreatePlayerCorpse(object oPC)
{
   string uniquePCID = h2_GetPlayerPersistentString(oPC, H2_UNIQUE_PC_ID);
   location loc = GetLocalLocation(oPC, H2_LOCATION_LAST_DIED);
   object oDeadPlayer = CopyObject(oPC, loc, OBJECT_INVALID, H2_CORPSE + uniquePCID);
   SetName(oDeadPlayer, H2_TEXT_CORPSE_OF + GetName(oPC));
   ChangeToStandardFaction(oDeadPlayer, STANDARD_FACTION_COMMONER);
   // remove gold, inventory & equipped items from dead player corpse copy
   h2_DestroyNonDroppableItemsInInventory(oDeadPlayer);
   h2_MovePossessorInventory(oDeadPlayer, TRUE);
   h2_MoveEquippedItems(oDeadPlayer);
   AssignCommand(oDeadPlayer, SetIsDestroyable(FALSE, FALSE));
   AssignCommand(oDeadPlayer, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oDeadPlayer));
   object oDeathCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, H2_DEATH_CORPSE, GetLocation(oDeadPlayer));
   object oCorpseToken = CreateItemOnObject(H2_PC_CORPSE_ITEM, oDeathCorpse);
   SetName(oCorpseToken, H2_TEXT_CORPSE_OF + GetName(oPC));
   SetName(oDeathCorpse, GetName(oCorpseToken));
   SetLocalLocation(oCorpseToken, H2_LAST_DROP_LOCATION, GetLocation(oDeathCorpse));
   SetLocalString(oCorpseToken, H2_DEAD_PLAYER_ID, uniquePCID);
}

quickly I found that they simply rename the corpse not give it a new tag, and the only thing persistant so far is the uniquePCID.  I am writing a script searching for placeable to match the info in the function I will be back with results.  Unless some on else has solved this problem with HCR2.  I did not want to change the function due to upgrades etc but logicly to me giving placeable new tag along with new name would have been better.
               
               

               


                     Modifié par Greyfort, 07 février 2011 - 12:47 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #7 on: February 07, 2011, 01:52:44 am »


               You spoke of a npc that removes a item then ports you back into world...

I had a npc cast reserection on PC then port them into world, this seemed to take off the jump back to F***plane if dead...



The issue once again was ware the body lay and the item bag, it was in the location player died.  And even though im only dealing with one placeable corpse my own I could not jump it.  I will continue to try,  We may have to add a Hook as described in doc devolpers guide to work along the core with out altering core functions.



Good news you dont have to have them have a item by default they will always return to F** plane if dead until they get reserected.
               
               

               
            

Legacy_grostilzirelman

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #8 on: February 07, 2011, 02:13:56 am »


               As far as I understood it, HCR was designed so that another players would cast Raise Dead (or Rez, whatever) on the PC corpse item that was located on the corpse of the player that died while they were in the fugue plane, not the actual corpse of the dead player.



The NPC casting it on the Player inside of the Fugue Plane would technically be casting the spell on a standing PC, not the corpse item.



So I'd imagine off hand anyway, that process would be bad. Haven't tried it though. What about perhaps creating a corpse item on the PC in the Fugue in addition to the one on the corpse wherever the player died? Then you could have the NPC take the 'Soul Shard' from the player, and cast the spell targeted on the Corpse item in the PC's inventory? I'm not sure if it could be scripted to have a NPC target a specific item in a players inventory or not.



               
               

               
            

Legacy_grostilzirelman

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #9 on: February 07, 2011, 02:24:00 am »


               Also, I'd like to state just in case it may be confusing you.

The item that the PC's has that the NPC takes from them when they teleport them back to the game world from the fugue is a 'Soul Shard'. Basically, the system is supposed to be permadeath.

The player is given 10 'Soul Shards' when first logged in, and every time they die it takes one away to bring them back. No XP or GP loss. However, once all the soul shards are gone the PC is unable to get free respawns and must be raised by another players actions.

I decided to use items in the PC's inventory for three major reasons.

1. It allows a PC to keep track and know how many 'Free Respawns' they have left.
2. It allows a DM to give 'Soul Shards' to players as rewards or for bug purposes.a
3. Certain one shot quests in the game will allow players to get a 'Soul Shard' as a reward. Which is a big one in Permadeath settings.

Hope that might clarify if anyone was confused.
               
               

               


                     Modifié par grostilzirelman, 07 février 2011 - 03:34 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #10 on: February 07, 2011, 03:40:07 am »


               Also in reading the scripts, although they have persistance avalable they dont have it scripted in...IE corpse only there by local server reset Gone.  Also If I remember corectly you can’t move items, or placeables across areas or even in same area you have to destroy object then create object.  I confirmed this by using a Item that targeted placeable/item and jumpthem to pc location they did not budge.

I also discovered since just one player I had to pick up my corspe then res it to be reserected that way allthough I’m not sure what it did really.  a npc res or useing corpse on npc did nothing.

so in order to do what your asking we have to use the persistant functions to save to the data base the corpse / itembag location and then when you want your body and items it uses the persistant functions to create them at cuurent player location and destory the old ones.  This can be done by changeing the variable in module properties that denotes player death and runs the default nwn_script you just open default nwn script save as your name and then direct that accordingly.

Example  :
OnPlayerDeath2 string h2_pccorpseopd =script to run in that script we find...

#include "h2_pccorpse_i"

void main()
{
   object oPC = GetLastPlayerDied();
   object oArea = GetArea(oPC);

   //if some other death subsystem set the player state back to alive before this one, no need to continue
   if (h2_GetPlayerPersistentInt(oPC, H2_PLAYER_STATE) != H2_PLAYER_STATE_DEAD)
       return;

   if (GetLocalInt(oArea, H2_DO_NOT_CREATE_CORPSE_IN_AREA))
       return;
   if (!GetLocalInt(oPC, H2_LOGIN_DEATH))
       h2_CreatePlayerCorpse(oPC);
}

all this uses the HCR2 local var scripts I havent found any persistant death tracking other then

if (h2_GetPlayerPersistentInt(oPC, H2_PLAYER_STATE) != H2_PLAYER_STATE_DEAD)
       return;
they did put a comment in about :
//if some other death subsystem set the player state back to alive before this one, no need to continue

The big issue is when corpse created it sets persistance of corpse not just state.  This most likely can be done through a function, yet we dont want to alter core HCR2 functions even though its the final version.  If we do alter it we need to stay in there format so if any upgrade it spands across with no issue.  

The other option is useing hcr2 functs alteringthem and saving them as corp_perst_?? something like that then directing the on death script variable in module properties to your new death script that uses your corp_perst_?? functions.

so at a quick glance its not a quick job, but possible.
               
               

               


                     Modifié par Greyfort, 07 février 2011 - 03:51 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #11 on: February 07, 2011, 03:49:02 am »


               Also in reading the scripts, although they have persistance avalable they dont have it scripted in...IE corpse only there by local server reset Gone.  Also If I remember corectly you can’t move items, or placeables across areas or even in same area you have to destroy object then create object.  I confirmed this by using a Item that targeted placeable/item and jumpthem to pc location they did not budge.

I also discovered since just one player I had to pick up my corspe then res it to be reserected that way allthough I’m not sure what it did really.  a npc res or useing corpse on npc did nothing.

so in order to do what your asking we have to use the persistant functions to save to the data base the corpse / itembag location and then when you want your body and items it uses the persistant functions to create them at cuurent player location and destory the old ones.  This can be done by changeing the variable in module properties that denotes player death and runs the default nwn_script you just open default nwn script save as your name and then direct that accordingly.

Example  :
OnPlayerDeath2 string h2_pccorpseopd =script to run in that script we find...

#include "h2_pccorpse_i"

void main()
{
   object oPC = GetLastPlayerDied();
   object oArea = GetArea(oPC);

   //if some other death subsystem set the player state back to alive before this one, no need to continue
   if (h2_GetPlayerPersistentInt(oPC, H2_PLAYER_STATE) != H2_PLAYER_STATE_DEAD)
       return;

   if (GetLocalInt(oArea, H2_DO_NOT_CREATE_CORPSE_IN_AREA))
       return;
   if (!GetLocalInt(oPC, H2_LOGIN_DEATH))
       h2_CreatePlayerCorpse(oPC);
}

all this uses the HCR2 local var scripts I havent found any persistant death tracking other then

if (h2_GetPlayerPersistentInt(oPC, H2_PLAYER_STATE) != H2_PLAYER_STATE_DEAD)
       return;
they did put a comment in about :
//if some other death subsystem set the player state back to alive before this one, no need to continue

The big issue is when corpse created it sets persistance of corpse not just state.  This most likely can be done through a function, yet we dont want to alter core HCR2 functions even though its the final version.  If we do alter it we need to stay in there format so if any upgrade it spands across with no issue.  

The other option is useing hcr2 functs alteringthem and saving them as corp_perst_?? something like that then directing the on death script variable in module properties to your new death script that uses your corp_perst_?? functions.

so at a quick glance its not a quick job, but possible.

I like your idea obut the shards, that does insure a PC 2 PC raise/res Double post forgive me
               
               

               


                     Modifié par Greyfort, 07 février 2011 - 03:50 .
                     
                  


            

Legacy_grostilzirelman

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #12 on: February 07, 2011, 03:57:16 am »


               Well considering that HCR2 is in it's final version and hasn't been updated since... well it seems early 2007, it's fairly safe to say altering the system isn't too big of an issue I imagine.

However, bypassing it and creating a seperate system to handle corpses, loot bags, and respawning seems like not only alot of work, but almost pointless to hold onto the HCR system if I'm to alter how it handles nearly everything the system is designed to do. Why install Windows and then try and make it work like a Mac when you can just have a Mac, right?

Well... unless someone is willing to help me through this daunting process is there anything else out there I might want to take a look at using instead of HCR2?

Thanks for liking the idea '<img'> I enjoy permadeath environments alot but most seem to function as either 1-life and your done, or invisibly tracking how many lives you have. I thought having a tangible indication of your lives (Green mushrooms, anyone '^_^')  but watching your 1-ups diminish as you go down is a pretty good indication of your PC's mortality.
               
               

               


                     Modifié par grostilzirelman, 07 février 2011 - 04:02 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #13 on: February 07, 2011, 05:13:51 am »


               //----------------
!!!Newest findings !!!

Located in module properties variables...

ON_PLAYER_DEATH1 string h2_fuguedeathopd   **sends pc to plane
ON_PLAYER_DEATH2 string h2_pccorpseopd   **creates corpse
ON_PLAYER_DEATH3 string h2_lootsystemopd   **creates loot Bag

these are the key files for death and there includes within them...this is ware you will alter what you want done...to create corpse on player or in F*** plane

Any way you can run a small test mod in tech_support section perhaps password set then email me pass and we can send script to eachother until it works.  Due to my single player delima I cant really see what effect raise/res has on pc i loos no xp when i die heck I dont even get a option for the respawn button LOL

this is key create corpse function:

void h2_CreatePlayerCorpse(object oPC)
{
   string uniquePCID = h2_GetPlayerPersistentString(oPC, H2_UNIQUE_PC_ID);
   location loc = GetLocalLocation(oPC, H2_LOCATION_LAST_DIED);
   object oDeadPlayer = CopyObject(oPC, loc, OBJECT_INVALID, H2_CORPSE + uniquePCID);
   SetName(oDeadPlayer, H2_TEXT_CORPSE_OF + GetName(oPC));
   ChangeToStandardFaction(oDeadPlayer, STANDARD_FACTION_COMMONER);
   // remove gold, inventory & equipped items from dead player corpse copy
   h2_DestroyNonDroppableItemsInInventory(oDeadPlayer);
   h2_MovePossessorInventory(oDeadPlayer, TRUE);
   h2_MoveEquippedItems(oDeadPlayer);
   AssignCommand(oDeadPlayer, SetIsDestroyable(FALSE, FALSE));
   AssignCommand(oDeadPlayer, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oDeadPlayer));
   object oDeathCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, H2_DEATH_CORPSE, GetLocation(oDeadPlayer));
   object oCorpseToken = CreateItemOnObject(H2_PC_CORPSE_ITEM, oDeathCorpse);
   SetName(oCorpseToken, H2_TEXT_CORPSE_OF + GetName(oPC));
   SetName(oDeathCorpse, GetName(oCorpseToken));
   SetLocalLocation(oCorpseToken, H2_LAST_DROP_LOCATION, GetLocation(oDeathCorpse));
   SetLocalString(oCorpseToken, H2_DEAD_PLAYER_ID, uniquePCID);
}

you find this in “h2_pccorpse_i”

This is the key create loot bag function

object h2_CreateLootBag(object oPC)
{
   object oLootBag = GetLocalObject(oPC, H2_LOOT_BAG);
   location lLootBag = GetLocation(oLootBag);
   location lPlayer = GetLocation(oPC);
   if (!GetIsObjectValid(oLootBag) || GetDistanceBetweenLocations(lPlayer, lLootBag) > 3.0 ||
       GetAreaFromLocation(lLootBag) != GetArea(oPC))
   {
       oLootBag = CreateObject(OBJECT_TYPE_PLACEABLE, H2_LOOT_BAG, GetLocation(oPC));
       //TODO: set the name of the lootbag using 1.67 patch SetName fuction?
       SetLocalObject(oPC, H2_LOOT_BAG, oLootBag);
   }
   return oLootBag;
}

found in “h2_lootsystem_i”

Altering these two core functions will allow you to create corpse/lootbag ware you want.

You could also in the death ware you put the take away crystal free respawn have these functions fire if there are zero crystals you would alter that in....

“h2_pccorpseopd” for corpse options...

#include "h2_pccorpse_i"

void main()
{
   object oPC = GetLastPlayerDied();
   object oArea = GetArea(oPC);
if(check crystal count == 0 )
{
   //if some other death subsystem set the player state back to alive before this one, no need to continue
   if (h2_GetPlayerPersistentInt(oPC, H2_PLAYER_STATE) != H2_PLAYER_STATE_DEAD)
       return;

   if (GetLocalInt(oArea, H2_DO_NOT_CREATE_CORPSE_IN_AREA))
       return;
   if (!GetLocalInt(oPC, H2_LOGIN_DEATH)   
       h2_CreatePlayerCorpse(oPC);
}
//other wise the script is not fired hence no corpse/lootbag '<img'>   
}

So there is a lternitive we just take what you used for crystals and dont make these parts fire, but once out your out you will need PC intervention or a function that tracks and sets all pc deaths to a db and upon server reset creates corpses in some area temple etc...thats the next simplest thing I can think of...

PM me if you want to give hcr2 a shot I think its possible.
               
               

               


                     Modifié par Greyfort, 07 février 2011 - 05:23 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
HCR2 Scripting edit help
« Reply #14 on: February 19, 2011, 09:52:42 pm »


               I have found another thing we could do is when it copys the players inventory to the loot bag, we can create a nwn DB "CorpseBag" which would have the location of the corpse/item bag and the items in bag. this would then allow you to destory the placeables and recreate the placeables ware you want.  Giving you the option you spoke of having there corpse and item bag appear at temple.  You would just have to alter the include as described above.  I can try to help you if you like just send me a PM