Author Topic: A Mass of Questions from NineCoronas  (Read 1060 times)

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
A Mass of Questions from NineCoronas
« Reply #15 on: February 04, 2013, 06:08:08 pm »


               <floating...>

GetFirstObjectInShape is expecting a float for the distance. Change 17 to 17.0f and give it a try :-)

<...a suggestion>
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
A Mass of Questions from NineCoronas
« Reply #16 on: February 04, 2013, 06:11:46 pm »


               

Rolo Kipp wrote...

<floating...>

GetFirstObjectInShape is expecting a float for the distance. Change 17 to 17.0f and give it a try :-)

<...a suggestion>


It's at 17.0 at the moment. Compile error solved as mentioned above ^ '<img'>



Now on to the next question....

object oPlayer = GetLastPlayerDied();
location lPlayerDeath = GetLocation(oPlayer);



object oHostile = GetFirstObjectInShape(SHAPE_SPHERE, 17.0, lPlayerDeath, TRUE, OBJECT_TYPE_CREATURE);
while(GetIsObjectValid(oHostile))
{
   if(GetIsReactionTypeHostile(oHostile))
   {
   if(GetLocalInt(oHostile, "ens_noclear")) return; //If the script finds this integer in any form on the creature, it will skip deleting it.
    {
    DestroyObject(oHostile);
    }
   }
   //Select the next target within the spell shape.
   oHostile = GetNextObjectInShape(SHAPE_SPHERE, 17.0, lPlayerDeath, TRUE, OBJECT_TYPE_CREATURE);
}


Specifically, I want to know if "   if(GetLocalInt(oHostile, "ens_noclear")) return; //If the script
finds this integer in any form on the creature, it will skip deleting
it."

will do what is intended? I'm also curious why "return FALSE" and "return TRUE" wouldn't compile in that instance. O.o
               
               

               


                     Modifié par NineCoronas2021, 04 février 2013 - 06:18 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
A Mass of Questions from NineCoronas
« Reply #17 on: February 04, 2013, 07:03:02 pm »


               <stopping at the first...>

Hah! I did like a compiler and stopped at the first error I saw :-P Yeah, location...

On the next Q, the return will break out of the while loop, meaning that *no other* objects will be checked (or deleted) after it returns.  Instead say
if ( !GetLocalInt( oHostile, "en_noclear")) DestroyObject(oHostile);

If you say return (value), it has to be within a function that is supposed to return a value of that type. I.e. if the function is a "void MyFunction()" then return shouldn't return anything.
If it's "int MyFunction()" then it *has to* return an integer (or boolean).

<...bar he finds>
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
A Mass of Questions from NineCoronas
« Reply #18 on: February 04, 2013, 09:32:24 pm »


               Makes sense, thank you.

EDIT:
I seem to be getting in the habit of answering my own questions...
               
               

               


                     Modifié par NineCoronas2021, 04 février 2013 - 09:35 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
A Mass of Questions from NineCoronas
« Reply #19 on: February 04, 2013, 09:36:38 pm »


               

NineCoronas2021 wrote...

Makes sense, thank you.

Next question:

object oHench1 = GetHenchman(oPlayer, 1);
object oHench2 = GetHenchman(oPlayer, 2);
if (!GetCurrentHitPoints(oHench1) | GetCurrentHitPoints(oHench2) >= 1)
 {
//If not, remove immortality and initiate player death
 SetPlotFlag(oPlayer, FALSE);
 ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oPlayer));
 }

 


I highlighted some suspicious code in red and changed your code to

object oHench1 = GetHenchman(oPlayer, 1);
object oHench2 = GetHenchman(oPlayer, 2);
if (!GetCurrentHitPoints(oHench1) || GetCurrentHitPoints(oHench2) >= 1)
{
//If not, remove immortality and initiate player death
SetPlotFlag(oPlayer, FALSE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oPlayer);
}
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
A Mass of Questions from NineCoronas
« Reply #20 on: February 04, 2013, 09:54:59 pm »


               Thanks Henesua, I noticed the extra bracket but didn't catch the straight line thingy.

So my next question is thus:

if (GetCurrentHitPoints(oHench1) || GetCurrentHitPoints(oHench2) >= 1)
 {
 object oHostile = GetFirstObjectInShape(SHAPE_SPHERE, 17.0, lPlayerDying, TRUE, OBJECT_TYPE_CREATURE);
 while (GetIsObjectValid(oHostile))
  {
  if (!GetIsReactionTypeHostile(oHostile))
//If not, bring player to 1 HP and remove immortality, destroy bloodstain after 10 minutes
   {
   SetPlotFlag(oPlayer, FALSE);
   ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(2), oPlayer);
   CleanUpBloodSpatter(oPlayer);
   }
   oHostile = GetNextObjectInShape(SHAPE_SPHERE, 17.0, lPlayerDying, TRUE, OBJECT_TYPE_CREATURE);
  }
 }


This script is supposed to get all the creatures in a 17 meter sphere around the player and check to see if any of them are hostile, if none are then the character is healed out of the dying state, if there are hostile creatures (and this part I haven't gotten around to coding yet), then it will simply loop back through.
I'm either going to use a series of DelayCommands, but I can see that getting extremely clunky, quickly.

My questions are
1) Will the script I have quoted work as intended or am I "doing it wrong"?
&
2) Would it be possible to create a function (Foo), that uses a single delay command and calls itself everytime it finds a hostile creature, thereby creating a loop or "pseudo-heartbeat"?


EDIT:

And a very random, left-field question... can Henchmen wear items that aren't identified?
               
               

               


                     Modifié par NineCoronas2021, 04 février 2013 - 10:11 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
A Mass of Questions from NineCoronas
« Reply #21 on: February 04, 2013, 10:22:57 pm »


               

NineCoronas2021 wrote...

And a very random, left-field question... can Henchmen wear items that aren't identified?

no on his own, but you can identify the item before you assign him to equipt them item and unidentify it again, if neccessary
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
A Mass of Questions from NineCoronas
« Reply #22 on: February 05, 2013, 02:25:10 am »


               Hrm, unfortunate.

So, I put this function in an include file:

void CheckForHostiles(location lPlayerDying);
void CheckForHostiles(location lPlayerDying)
 {
 object oHostile = GetFirstObjectInShape(SHAPE_SPHERE, 17.0, lPlayerDying, TRUE, OBJECT_TYPE_CREATURE);
 while (GetIsObjectValid(oHostile))
  {
  if (!GetIsReactionTypeHostile(oHostile)) //Checks for hostiles, if none, player heals
   {
   SetPlotFlag(oPlayer, FALSE);            //Mortalize player
   ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(2), oPlayer); //Heal him to 1hp
   CleanUpBloodSpatter(oPlayer);           //Destroy blood spatter placeables after 10 minutes
   }
  else if (GetIsReactionTypeHostile(oHostile))
  {
  DelayCommand(6.0, CheckForHostiles(lPlayerDying));
  }
  oHostile = GetNextObjectInShape(SHAPE_SPHERE, 17.0, lPlayerDying, TRUE, OBJECT_TYPE_CREATURE);
 }
}


and called it from my dying script with:

if (GetCurrentHitPoints(oHench1) || GetCurrentHitPoints(oHench2) >= 1)
 {
 CheckForHostiles(lPlayerDying); //Runs a check to see if hostiles are present,
                                 // if they aren't, raise PC, if they are, check again in a round.
 }

}


I'm off to test it, my main concern is that I put together that the script will actually check all creatures in the sphere to see if they're hostile before deciding to either run the script again in 6 seconds or raise the PC.

Any help on that would be appreciated!

-NineCoronas
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
A Mass of Questions from NineCoronas
« Reply #23 on: February 06, 2013, 01:17:03 am »


               

LoA_Tristan wrote...

As to 1, the slider is the percentage of what experience value would normally be awarded, for players of a certain level versus opponents of a certain CR, under the pen and paper rules.  (Default is 10%.  This is a video game— so resting, heals, items, and big mobs of enemies come way thicker than PnP)

For 3, the OnDisturbed event handler.  It could undo whatever the PC does to muck things up, but I don't know if it could prevent any action.

ex.


void main()
{
    object oItem = GetLastDisturbed();
    if (GetTag(oItem) == "MY_TREASURED_ITEM") ActionEquipItem(oItem, INVENTORY_SLOT_x);
}
...would instantly re-equip an item.  A conversation could also be initiated by this event.

Don't forget about tagging NPC's personal possessions as undroppable.


Just in case anyone runs across this question in the future, in fact, OnDisturbed on henchman only fires if a creature of another faction tries to pickpocket them.

To achieve what I wanted, in a somewhat sloppy manner, I had to write an OnAcquire script that 'yoinked' the item away if it went into my inventory and an NPC heartbeat that reequipped the items automatically (in case they were just dragged into the inventory).

Hope this helps someone someday.

Cheers!

-NineCoronas
               
               

               


                     Modifié par NineCoronas2021, 06 février 2013 - 01:45 .