Aller au contenu

Photo

Lagy death script


  • Veuillez vous connecter pour répondre
44 réponses à ce sujet

#1
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
This is what 99 percent of my creatures use as a death script and it is laggy.




This is the first script that fires

Then the execute script fires the 2nd script listed on this page

I think the script fireing order is messed up.In the creatures scripts the first script listed here fires first.

Maybe the bottom script should fire first.

Also i dont see anything that kills this creature........ since it is a death script maybe thats where the lag is coming from.

Does a number need to be set for the random waypoints in the script cause its at 0











void main()
{
    object oDamager = GetLastDamager();
    if ((GetIsPC(oDamager)) && (GetIsPossessedFamiliar(oDamager) == FALSE))
    {
        CreateItemOnObject("",oDamager,1);
        if (GetTimeHour() == 0)
        {
            CreateItemOnObject("",oDamager,1);
        }
    }
  int    nWaypoint = 0;
  object oWaypoint = GetFirstObjectInArea();
  while( GetIsObjectValid( oWaypoint))
  { if( GetObjectType( oWaypoint) == OBJECT_TYPE_WAYPOINT)
    { if( GetTag( oWaypoint) == GetTag( OBJECT_SELF))
      { ++nWaypoint;
      }
    }
    oWaypoint = GetNextObjectInArea();
  }
  if( nWaypoint <= 0) return;
  nWaypoint = Random( nWaypoint) + 1;
  oWaypoint = GetFirstObjectInArea();
  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();
    ExecuteScript("ondeatheffect",OBJECT_SELF);
  }
}














//ondeatheffect this is the 2nd script
#include "i420_s_inc_pstat"
void main()
{
  SetPCKillStats(GetLastKiller(), OBJECT_SELF);
  object oPC = GetLastKiller();
  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, oPC);
      ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oPC);
      if (d100() > 50)ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eHaste, oPC, 30.0);

}

Modifié par Builder_Anthony, 21 août 2011 - 12:45 .


#2
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
The ExecuteScript portion should be executed on the killer, instead of the creature killed. While cutting out the one unneeded check won't improve performance in any noticeable way, it would be more reliable.

One thing you could do to increase performance, is after it does the waypoint count of that waypoint tag type the first time, you could write the count to the area as an int to be retrieved on the next OnDeath event for that tagged creature. Then only the first death of each tagged creature per area needs the full object check.

#3
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
I look at the execute script and it does seem to do it from the killer.

Eliminating any unused checks is my goal.

As for the last comment about the waypoints .......well im just lost there.

I cant really script so im kinda asking for help.

#4
ffbj

ffbj
  • Members
  • 593 messages
No he means you are executing the script on object_self, should be on oDamager. Also on the executed script you have the various effects defined but don't apply them all, like the strength one. Maybe also get rid of the glow effect on the PC. Maybe looping through all the waypoints though is really causing some lag. also it seems you should move down the execute line to one more bracket, for it seems to me as is it is part of the while loop. Anyhow good thing you posted this.
since I bet someone will be able to fix it up for you. Btw you have a couple while loops in there for the wp's, not really sure that is needed. You are using those waypoints to respawn monsters.

#5
_Guile

_Guile
  • Members
  • 685 messages
It would be a lot easier to just count the Number of Waypoints from the OnEnter event for the Area, setting the variable on the Area and retrieving it through scripting rather than doing it from the creatures OnDeath even, sersiously.

Loops are a major source of lag on many servers, especially when those loops are looking for something in an area, and even more so if there are a lot of object to cycle through as well.

Those are my recommendation...

#6
Baragg

Baragg
  • Members
  • 271 messages
Tried to tweak it a bit combined the two scripts into one.

#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 );
  //}
}


#7
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Well i could dicth the strength one but the red glow is a must because it lets the pc know hes just received haste.

I thought they get applied once he kills the monster.It seems to work that way but i did edit some things out of that script.

Gyulie i guess i could do it that way by counting the waypoints when a player enters the area and then retreivving it i guess i could add a execute script to all my areas.BUt again i cant really script good so i dont want to make a mess out of things.I guess if this gets sorted out i could try it that way.The less lag i get would be great.I never really liked that cycle threw waypoint thing anyways.

#8
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Ok well i tested it out and things seem to be working.I have to test a little more on checking if they are spawning.But the red glow and haste are there.

Modifié par Builder_Anthony, 21 août 2011 - 10:14 .


#9
ffbj

ffbj
  • Members
  • 593 messages
The point I was trying to make about strength is that you don't actually increase the strength of the killer, the oPC. You need to add a line like:
if (d100() > 50)ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eStr, oDamager, 30.0);
And I would make eHeal d4()  I played in your mod and healing is pretty tough, getting back 1 pt for killing a creature that just beat you to a pulp, well to make up for that I would cut the str duration and haste to like 10 seconds haste is way powerful.  More of a taste thing though. Of course you could always compare the difference in levels, HitDice between the PC and thing they killed and award them something for that.  In other words a high level PC would get no bonus for killing stuff more tha 2 levels below them.  Or you could adjust the duration of the effects accordingly.
Oh and one last thing regarding the red glow.  It's fine if that's what you want to indicate a blood-lust sort of thing, but regardless the PC will know since they are hasted or buffed and that will show up above by the PC 's in the buff/deteriment bar.

Modifié par ffbj, 22 août 2011 - 12:27 .


#10
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Ya i do see the bar but thats a great idea for checking the pcs level and offering aditional things.IM testing the script baragg posted so it might be a few days before i can tell anyhting.Plus i need to determine that missing tag in there i forgot what its doing.I think i might just erase it out of there as long as the creatures spawn to random waypoints.

Nice talking to everyone im still on here i never really post though.

#11
Baragg

Baragg
  • Members
  • 271 messages
From this point on:

/*if( nWaypoint <= 0)

I commented most of the stuff there out. Cause if nWaypoint <= 0, it returns at that point and nothing else would happen.

Modifié par Baragg, 22 août 2011 - 11:43 .


#12
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Ya see thats zero i think its wrong and needs to be set to something but im not sure what its does.Heres the thing i already have like 8 waypoints in my areas taged ZSA_WAYPOINT i figured this script was picking one of those waypoints.But from reading something wayback i think im soupposed to edit something in the script to the maximum number of waypoints in the area.So i guess it was searching thew them.Im not sure what the zero is for but thats what i thought it was for and im just so darn lost lol.I just want the monsters to spawn at one of those ZSA_WAYPOINT randomly.


I guess my point is the part where the pc receive stats is working fine from what i can tell.
Im just trying to determine if monsters are spawning at a random waypoint tagged ZSA_WAYPOINT

Modifié par Builder_Anthony, 22 août 2011 - 04:27 .


#13
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
It looked to me as if the script looked for a waypoint with the same tag as the creature in order to spawn at, based on:
if( GetTag( oWaypoint) == GetTag( OBJECT_SELF))

Unless your monsters are also tagged ZSA_WAYPOINT they'll likely not respawn at a waypoint with that tag. You'd need this instead:
if( GetTag( oWaypoint) == "ZSA_WAYPOINT")

#14
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
My monsters are tagged zsa_zombie that i want to use the respawn.

I figure the monsters i dont want to use the respawn are just tagged something else.

I did not make any changes to braggs script.I would like that in there if anyone can hook it up.

Modifié par Builder_Anthony, 23 août 2011 - 01:20 .


#15
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
You'd just need to insert something like this before the respawn checks:

if (GetTag (OBJECT_SELF) != "zsa_zombie") return;

If you want the buff effect to take place regardless of respawn, that could be moved above this check.

#16
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
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 .


#17
Baragg

Baragg
  • Members
  • 271 messages
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 .


#18
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
Ya that sums it up right.zsa_waypoint.

#19
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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 .


#20
ffbj

ffbj
  • Members
  • 593 messages
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 .


#21
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
IM in here too lol

#22
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
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 .


#23
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
It says in game in one of the windows.

script zsa_zombie_death OID 8000221c TAG zombie ERROR too many instructions

#24
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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 .


#25
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
hmmm maybe its coming from the include script?Would the include script fire the error message if it was bad?