Author Topic: Lagy death script  (Read 1274 times)

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #15 on: August 23, 2011, 04:59:24 am »


               So i would add that right under this?
void main()
{
object oDamager = GetLastDamager();
int nWaypoint;
object oWaypoint;
<----------------------











Current script edited by bargg with nothing new....................................


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

ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oDamager);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oDamager);

if (d100() > 50)ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eHaste, oDamager, 30.0);

}




void main()
{
object oDamager = GetLastDamager();
int nWaypoint;
object oWaypoint;

if ((GetIsPC(oDamager)) && (GetIsPossessedFamiliar(oDamager) == FALSE))
{
CreateItemOnObject("",oDamager,1); //need to add somethings resref here?
if (GetTimeHour() == 0)
{ //need to add somethings resref here?
CreateItemOnObject("",oDamager,1);
}
}

nWaypoint = 0;
oWaypoint = GetFirstObjectInArea();

while( GetIsObjectValid( oWaypoint))
{
if( GetObjectType( oWaypoint) == OBJECT_TYPE_WAYPOINT)
{
if( GetTag( oWaypoint) == GetTag( OBJECT_SELF))
{
++nWaypoint;
}
}
oWaypoint = GetNextObjectInArea();
}

/*if( nWaypoint <= 0)
{
nWaypoint = Random( nWaypoint) + 1;
}

while( GetIsObjectValid( oWaypoint))
{ if( GetObjectType( oWaypoint) == OBJECT_TYPE_WAYPOINT)
{ if( GetTag( oWaypoint) == GetTag( OBJECT_SELF))
{ if( (--nWaypoint) <= 0)
{ CreateObject( OBJECT_TYPE_CREATURE, GetResRef ( OBJECT_SELF), GetLocation( oWaypoint));
return;
}
}
}
oWaypoint = GetNextObjectInArea();*/
BuffDamager( oDamager );
//}
}
               
               

               


                     Modifié par Builder_Anthony, 23 août 2011 - 04:03 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Lagy death script
« Reply #16 on: August 23, 2011, 12:44:39 pm »


               So when one of your zombies dies you want another to spawn at a random waypoint? And, you have 8 waypoints with that tag mentioned above? Will check here when I get back from school today.
               
               

               


                     Modifié par Baragg, 23 août 2011 - 11:48 .
                     
                  


            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #17 on: August 23, 2011, 11:16:46 pm »


               Ya that sums it up right.zsa_waypoint.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Lagy death script
« Reply #18 on: August 24, 2011, 12:22:35 am »


               Could it just be done something more like so?:


//#include "i420_s_inc_pstat"
void BuffDamager(object oDamager)
{
    //SetPCKillStats(oDamager, OBJECT_SELF);
    effect eHeal = EffectHeal(1);
    effect eHaste = EffectHaste();
    effect eStr = EffectAbilityIncrease(ABILITY_STRENGTH, 1);
    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, eStr, oDamager, 30.0);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eHaste, oDamager, 30.0);
}

void main()
{
    object oDamager = GetLastDamager();
    object oWP = GetObjectByTag("ZSA_WAYPOINT", d8());

    //if you don't want the zombie to spawn at the same WP it is at, uncomment
    /*
    object oNearestWP = GetNearestObjectByTag("ZSA_WAYPOINT", oDamager, 1);
    while (oWP == oNearestWP)
    {
        oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
    }
    */

    if ((GetIsPC(oDamager)) && (GetIsPossessedFamiliar(oDamager) == FALSE))
    {
        CreateItemOnObject("",oDamager,1); //need to add somethings resref here?
        if (GetTimeHour() == 0)
        { //need to add somethings resref here?
            CreateItemOnObject("",oDamager,1);
        }
    }

    CreateObject(OBJECT_TYPE_CREATURE, GetResRef(OBJECT_SELF), GetLocation(oWP));
    BuffDamager(oDamager);
}
               
               

               


                     Modifié par GhostOfGod, 23 août 2011 - 11:55 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Lagy death script
« Reply #19 on: August 24, 2011, 12:59:11 am »


               Except you need to add in a time limit for str and glow red, like you have for haste which is 30.0
Currently they are set as temporary effects with no time parameter.
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oDamager,30.0);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eStr, oDamager,30.0);
Lol.  I see you changed it as I was writing this.
               
               

               


                     Modifié par ffbj, 24 août 2011 - 12:00 .
                     
                  


            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #20 on: August 24, 2011, 01:04:25 am »


               IM in here too lol
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #21 on: August 24, 2011, 01:06:38 am »


               OK i did some editing 

Took out str bonus 

Took out the comments necause i awalys want them to spawn in a differnt location

Took out create object that didnt have a resref because that was giving a zombie kill token but the other system takes care of that in the include.







Current script
Hows this look?It compiles....




  //#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 oDamager = GetLastDamager();
    object oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
 

    object oNearestWP = GetNearestObjectByTag("ZSA_WAYPOINT", oDamager, 1);
    while (oWP == oNearestWP)
    {
        oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
    }
 
    CreateObject(OBJECT_TYPE_CREATURE, GetResRef(OBJECT_SELF), GetLocation(oWP));
    BuffDamager(oDamager);
}
               
               

               


                     Modifié par Builder_Anthony, 24 août 2011 - 01:37 .
                     
                  


            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #22 on: August 25, 2011, 02:57:05 am »


               It says in game in one of the windows.

script zsa_zombie_death OID 8000221c TAG zombie ERROR too many instructions
               
               

               
            

Legacy_GhostOfGod

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


               Not sure what the problem is Anthony. I just tested your script and it was working fine for me. I put 8 waypoints in the test area. Gave them all the same tag. Used a custom chicken with your script in the OnDeath. I also tested it with the waypoints in different areas and it worked fine.  The only thing I can think of is that both the Random waypoint and the Nearest waypoint are invalid thus making them equal. In which case the loop will keep running and cause a TMI. Are you sure you are using the correct waypoint tag in the script?

I did alter it slightly after testing. I used GetLastKiller instead of GetLastDamager. And I added a check to see if the killer was a henchman or what not. But it did work with what you had.


  //#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 oKiller = GetLastKiller();
    if (GetIsObjectValid(GetMaster(oKiller)))
    oKiller = GetMaster(oKiller);
    string sResRef = GetResRef(OBJECT_SELF);
    object oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
    object oNearestWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, 1);

    while (oWP == oNearestWP)
    {
        oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
        //test line:
        //SendMessageToPC(oKiller, "Looping for new waypoint.");
    }

    CreateObject(OBJECT_TYPE_CREATURE, sResRef, GetLocation(oWP));
    BuffDamager(oKiller);
}
               
               

               


                     Modifié par GhostOfGod, 25 août 2011 - 03:11 .
                     
                  


            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #24 on: August 25, 2011, 06:07:50 am »


               hmmm maybe its coming from the include script?Would the include script fire the error message if it was bad?
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Lagy death script
« Reply #25 on: August 25, 2011, 06:37:57 am »


               

GhostOfGod wrote...

Not sure what the problem is Anthony. I just tested your script and it was working fine for me. I put 8 waypoints in the test area. Gave them all the same tag. Used a custom chicken with your script in the OnDeath. I also tested it with the waypoints in different areas and it worked fine.  The only thing I can think of is that both the Random waypoint and the Nearest waypoint are invalid thus making them equal. In which case the loop will keep running and cause a TMI. Are you sure you are using the correct waypoint tag in the script?

I did alter it slightly after testing. I used GetLastKiller instead of GetLastDamager. And I added a check to see if the killer was a henchman or what not. But it did work with what you had.


  //#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 oKiller = GetLastKiller();
    if (GetIsObjectValid(GetMaster(oKiller)))
    oKiller = GetMaster(oKiller);
    string sResRef = GetResRef(OBJECT_SELF);
    object oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
    object oNearestWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, 1);

    while (oWP == oNearestWP)
    {
        oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
        //test line:
        //SendMessageToPC(oKiller, "Looping for new waypoint.");
    }

    CreateObject(OBJECT_TYPE_CREATURE, sResRef, GetLocation(oWP));
    BuffDamager(oKiller);
}




If there are always going to be 8 WP possibilities on a given map, then you can change this part here:

object oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
object oNearestWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, 1);

while (oWP == oNearestWP)
{
oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
//test line:
//SendMessageToPC(oKiller, "Looping for new waypoint.");
}

To:

object oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, d8() );
 
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Lagy death script
« Reply #26 on: August 25, 2011, 07:23:53 am »


               

Failed.Bard wrote...

If there are always going to be 8 WP possibilities on a given map, then you can change this part here:

object oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
object oNearestWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, 1);

while (oWP == oNearestWP)
{
oWP = GetObjectByTag("ZSA_WAYPOINT", d8());
//test line:
//SendMessageToPC(oKiller, "Looping for new waypoint.");
}

To:

object oWP = GetNearestObjectByTag("ZSA_WAYPOINT", oKiller, d8() );
 


3 reasons why I didn't do that:

1.) Waypoints might not be in the same area.
2.) We now know that using GetNearestObjectByTag is not as efficient as just using GetObjectByTag. I already did use that function to get the first closest object to compare, however I wasn't sure whether or not searching for the 5th, 6th, etc, closest object would be worse than just finding the first.
3.) And more importantantly, I don't think he wants the creature to have a chance to spawn at the same WP it was just at. Thus the loop to intentionally get a different waypoint.
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Lagy death script
« Reply #27 on: August 25, 2011, 08:05:49 am »


               I was basing my suggestion off of his original script using GetFirst/GetNextObjectInArea to find the waypoints.  It seemed as though he wanted them to respawn in the same area based on that, though without further clarification from Builder_Anthony it's hard to know for certain.

 While GNOBT is horribly inefficient in high loop testing, and every step in nNth likely magnifies it, if he wants the waypoints to be solely in the same area it's still the best function.

 If they can respawn in any area, then it would be best to establish a constant (or set a local int on the module at the first creatures death based on a run once count of all the WPs) with the full waypoint count, and use that in place of the d8().
               
               

               
            

Legacy_Builder_Anthony

  • Hero Member
  • *****
  • Posts: 786
  • Karma: +0/-0
Lagy death script
« Reply #28 on: August 26, 2011, 07:39:14 am »


               Well i have about 90 areas.Each one of them has at least 8 zsa_waypoints.

I would like the creature to spawn in the same area,but still keeping zsa_waypoint as the tag if possible.

I still get that error after testing im guessing the include script may be causeing it?

I would like a random spawnig of the creature.But i dont awalys wanting it poping up to close.The point of it is to keep zombies in the area and have a dangerous area.
               
               

               


                     Modifié par Builder_Anthony, 26 août 2011 - 06:42 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Lagy death script
« Reply #29 on: August 26, 2011, 10:19:08 am »


               

Builder_Anthony wrote...

Well i have about 90 areas.Each one of them has at least 8 zsa_waypoints.

I would like the creature to spawn in the same area,but still keeping zsa_waypoint as the tag if possible.

I still get that error after testing im guessing the include script may be causeing it?

I would like a random spawnig of the creature.But i dont awalys wanting it poping up to close.The point of it is to keep zombies in the area and have a dangerous area.


Ah. Well then that completely changes things. Bard hit the nail on the head with this one. You will definitely need to use GetNearestObject as Bard suggested. And you either have to do a loop once to count the waypoints in the area or you can set the amount of waypoints in the area as an int On the area. It'd be better if you could add the variable manually but that would be a lot of work. So we'll just loop once per area in the OnDeath script. But since it is now 2a.m. and I can't think straight. I will tackle that fix tomorrow unless someone else beats me to it.

As far as the TMI error gos, I have no idea. Try the script with the include and function that gos with the inlcude commented out and see if that fixes it.