Author Topic: Lagy death script  (Read 1275 times)

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Lagy death script
« Reply #30 on: August 26, 2011, 12:45:59 pm »


               Sorry, I have been busy w/school stuff just have one class today will get you something after I get back home
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Lagy death script
« Reply #31 on: August 26, 2011, 07:30:32 pm »


               Ok so this is what I came up with. Added some sanity checks for different scenarios. Like if you are fighting said crature in an area where there are no respawn points then the script returns. If for some reason there happens to be only one respawn waypoint in the area then that will be its respawn point. Otherwise it will randomly pick one of the other respawn points but never the closest one(if I did the random math right). Should work correctly. And if anyone sees any ways to improve/correct it, feel free.


  //#include "i420_s_inc_pstat"
void BuffDamager(object oDamager)
{
 //SetPCKillStats(oDamager, OBJECT_SELF);
    effect eHeal = EffectHeal(1);
    effect eHaste = EffectHaste();
    effect eVis = EffectVisualEffect(VFX_DUR_GLOW_RED);

    ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oDamager);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oDamager, 30.0);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eHaste, oDamager, 30.0);
}

void main()
{
    object oArea = GetArea(OBJECT_SELF);
    int iCheck = GetLocalInt(oArea, "WAYPOINTS_CHECKED");
    object oKiller = GetLastKiller();
    if (GetIsObjectValid(GetMaster(oKiller)))
    oKiller = GetMaster(oKiller);
    string sResRef = GetResRef(OBJECT_SELF);
    object oWP;

    if (!iCheck)
    {
        int iInt = 1;
        oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, iInt);
        while (GetIsObjectValid(oWP))
        {
            iInt++;
            oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, iInt);
        }
        SetLocalInt(oArea, "AREA_SPAWN_WPS", iInt - 1);
        SetLocalInt(oArea, "WAYPOINTS_CHECKED", TRUE);
    }

    int iWPCount = GetLocalInt(oArea, "AREA_SPAWN_WPS");
    if (iWPCount == 0) return;
    if (iWPCount == 1) oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, 1);
    else
    {
        int iRand = (Random(iWPCount - 1)+1)+1;
        oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, iRand);
    }
    CreateObject(OBJECT_TYPE_CREATURE, sResRef, GetLocation(oWP));
    BuffDamager(oKiller);
}
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #32 on: August 27, 2011, 12:35:50 am »


               Thanks for your time doing all this its complicated but i think things are heading in the right direction.

I have some things to do over here since i just got back from work but i will do a runthrough.I am excited i think ive been tryen to nail this for oh 5-7 years lol.
               
               

               


                     Modifié par Builder_Anthony, 26 août 2011 - 11:37 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Lagy death script
« Reply #33 on: August 27, 2011, 03:43:13 am »


               

GhostOfGod wrote...
 And if anyone sees any ways to improve/correct it, feel free.


Only posting because you asked.   The only thing i really see is that two locals are not really needed.  You can do without the iChecked on simply by setting the other one to -1 if they have already been checked and no waypoints have been found.   As far a skipping the nearest WP, It is a good Idea, however the assumption that the nearest WP is the last one they spawned from, will not always be correct.  monsters wander and chase PC in combat. 

One  more things for the OP to consider however.  If monsters chase PC's into another area, they will not respawn back into the area they left from.  

@ ghost; Nice script by the way.  I think what you did is a lot faster then what I was considering posting. 

Here is the script with minor edits to remove the second local var.

 //#include "i420_s_inc_pstat"
void BuffDamager(object oDamager)
{
 //SetPCKillStats(oDamager, OBJECT_SELF);
    effect eHeal = EffectHeal(1);
    effect eHaste = EffectHaste();
    effect eVis = EffectVisualEffect(VFX_DUR_GLOW_RED);

    ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oDamager);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oDamager, 30.0);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eHaste, oDamager, 30.0);
}

void main()
{
    object oArea = GetArea(OBJECT_SELF);
    int iWPCount = GetLocalInt(oArea, "AREA_SPAWN_WPS");
    object oKiller = GetLastKiller();
    if (GetIsObjectValid(GetMaster(oKiller)))
    oKiller = GetMaster(oKiller);
    string sResRef = GetResRef(OBJECT_SELF);
    object oWP;
    if (!iWPCount)
    {

        oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller);
        while (GetIsObjectValid(oWP))
        {
            iWPCount++;
            oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, iWPCount);
        }
        if ( !iWPCount) iWPCount = -1;
        SetLocalInt(oArea, "AREA_SPAWN_WPS", iWPCount);

    }

    if (iWPCount == -1) return;
    if (iWPCount == 1) oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, 1);
    else
    {
        int iRand = Random(iWPCount - 1) +2;
        oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, iRand);
    }
    CreateObject(OBJECT_TYPE_CREATURE, sResRef, GetLocation(oWP));
    BuffDamager(oKiller);
}
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Lagy death script
« Reply #34 on: August 27, 2011, 06:13:23 am »


               I think the   BuffDamager (oKiller);   needs to be moved to above the WP sanity check, otherwise it won't happen unless the zombie respawns.  Otherwises the script(s) looks good to me.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Lagy death script
« Reply #35 on: August 27, 2011, 03:08:38 pm »


               Cool
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #36 on: August 28, 2011, 02:10:30 am »


               Like this?I added to like  line 30 or 40 with a comment<-----------------------------



//#include "i420_s_inc_pstat"
void BuffDamager(object oDamager)
{
//SetPCKillStats(oDamager, OBJECT_SELF);
   effect eHeal = EffectHeal(1);
   effect eHaste = EffectHaste();
   effect eVis = EffectVisualEffect(VFX_DUR_GLOW_RED);

   ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oDamager);
   ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oDamager, 30.0);
   ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eHaste, oDamager, 30.0);
}

void main()
{
   object oArea = GetArea(OBJECT_SELF);
   int iWPCount = GetLocalInt(oArea, "AREA_SPAWN_WPS");
   object oKiller = GetLastKiller();
   if (GetIsObjectValid(GetMaster(oKiller)))
   oKiller = GetMaster(oKiller);
   string sResRef = GetResRef(OBJECT_SELF);
   BuffDamager(oKiller);//<-----------------------------------------Like this?

   object oWP;
   if (!iWPCount)
   {

       oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller);
       while (GetIsObjectValid(oWP))
       {
           iWPCount++;
           oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, iWPCount);
       }
       if ( !iWPCount) iWPCount = -1;
       SetLocalInt(oArea, "AREA_SPAWN_WPS", iWPCount);

   }

   if (iWPCount == -1) return;
   if (iWPCount == 1) oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, 1);
   else
   {
       int iRand = Random(iWPCount - 1) +2;
       oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, iRand);
   }
   CreateObject(OBJECT_TYPE_CREATURE, sResRef, GetLocation(oWP));
   }
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Lagy death script
« Reply #37 on: August 28, 2011, 03:39:23 am »


               Yep. Looks good.
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #38 on: August 28, 2011, 06:15:02 pm »


               I created a new mod with a rat and added this death script to the rat.

I made 4 waypoints tagged ZSA_ZOMBIE and placed them in the area at ends of hallways.

I killed the rat and nothing respawned.

Am i souppsed to set a varible on the area or something?I seem to be missing a step.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Lagy death script
« Reply #39 on: August 28, 2011, 06:33:05 pm »


               Did you change all of the  "ZSA_WAYPOINT"  strings in the script to "ZSA_ZOMBIE" ?
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #40 on: August 28, 2011, 10:28:47 pm »


               Yes i tried the tag of the creature ZSA_ZOMBIE and in another test i tried the resref.No respawning when killed by dm.All quoatation marks were filled in.
               
               

               


                     Modifié par Builder_Anthony, 28 août 2011 - 09:30 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Lagy death script
« Reply #41 on: August 28, 2011, 10:36:42 pm »


               Ill test it out a littler later. If someone does not get to it first.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Lagy death script
« Reply #42 on: August 29, 2011, 12:34:37 am »


               Sorry,  my mess up.   I was overcounting the number of waypoints in the area.

 //#include "i420_s_inc_pstat"
void BuffDamager(object oDamager)
{
 //SetPCKillStats(oDamager, OBJECT_SELF);
    effect eHeal = EffectHeal(1);
    effect eHaste = EffectHaste();
    effect eVis = EffectVisualEffect(VFX_DUR_GLOW_RED);

    ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oDamager);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oDamager, 30.0);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eHaste, oDamager, 30.0);
}

void main()
{
    object oArea = GetArea(OBJECT_SELF);
    int iWPCount = GetLocalInt(oArea, "AREA_SPAWN_WPS");
    object oKiller = GetLastKiller();
    if (GetIsObjectValid(GetMaster(oKiller)))
    oKiller = GetMaster(oKiller);
    string sResRef = GetResRef(OBJECT_SELF);
    object oWP;
    if (!iWPCount)
    {
        do
        {
            iWPCount++;
            oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, iWPCount);
        }while (GetIsObjectValid(oWP));
        iWPCount--;
        if ( !iWPCount) iWPCount = -1;
        SetLocalInt(oArea, "AREA_SPAWN_WPS", iWPCount);
    }

    BuffDamager(oKiller);
    if (iWPCount == -1) return;
    if (iWPCount == 1) oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, 1);
    else
    {
        int iRand = Random(iWPCount - 1) +2;
        oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, iRand);
    }
    CreateObject(OBJECT_TYPE_CREATURE, sResRef, GetLocation(oWP));
    }


               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #43 on: August 29, 2011, 02:50:42 am »


               Ya im not sure i tested the last script with ZSA_ZOMBIE and ZSA_WAYPOINT will no respawns.I didnt set any varibles on anything.....I dont think im soupposed to though.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Lagy death script
« Reply #44 on: August 29, 2011, 03:11:22 am »


               I just tested it adain.  I am having no problems.  Just make sure your Waypoint tags match the waypoint name in the script.  one note here. You will not want the tag on the waypoint and the tag on the creature to be the same thing.    If they are, I guess we will have to modify the script for that.