Aller au contenu

Photo

Lagy death script


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

#26
Failed.Bard

Failed.Bard
  • Members
  • 774 messages

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() );
 

#27
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

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.

#28
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
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().

#29
Builder_Anthony

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


#30
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

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.

#31
Baragg

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

#32
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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);
}

#33
Builder_Anthony

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


#34
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

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

#35
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
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.

#36
Baragg

Baragg
  • Members
  • 271 messages
Cool

#37
Builder_Anthony

Builder_Anthony
  • Members
  • 450 messages
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));
}

#38
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Yep. Looks good.

#39
Builder_Anthony

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

#40
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Did you change all of the "ZSA_WAYPOINT" strings in the script to "ZSA_ZOMBIE" ?

#41
Builder_Anthony

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


#42
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Ill test it out a littler later. If someone does not get to it first.

#43
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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));
    }



#44
Builder_Anthony

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

#45
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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.