Author Topic: Scripting Isn't a Spectator Sport  (Read 900 times)

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Scripting Isn't a Spectator Sport
« Reply #15 on: November 15, 2010, 10:49:54 pm »


               

I had read, however, that the on death event doesn't fire very reliably. Didn't wanna mess with variables over much if that is the case. Is this untrue?


I think you misread the statement.   There is no problem with the OnDeath event firing.  There is a problen with the OnUserDefined OnDeath  event firing.   The problem with the userdefined event signled from the death event is that the Creature my nolonger exsist once it trys to run.  With no Object to run the script on there is no Script. 


The NPC will however always exsist untill after the OnDeath script is finished.   
               
               

               
            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Scripting Isn't a Spectator Sport
« Reply #16 on: November 16, 2010, 03:02:16 am »


               Ahh. Which causes me to understand why a lot of my loops were grabbing their own corpse.
You're right, it was the OnUserDefined OnDeath event I was remembering. That boosts my confidence some.
               
               

               


                     Modifié par One Thousand Talons Mao Ra, 16 novembre 2010 - 03:02 .
                     
                  


            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Scripting Isn't a Spectator Sport
« Reply #17 on: November 16, 2010, 05:05:26 am »


               Completely rewriting this.

In the following loop, I want it to cycle through the gladiators in this area and tell them to leave, but this doesn't do it. Why? Is it just grabbing the same guy 10 times?

    object oCenter;
    oCenter = GetObjectByTag("ArenaCenter");
    object oVictor;
    int iVictors = 1;
    while (iVictors <= 10)
        {
        oVictor = GetNearestObjectByTag("Gladiator", oCenter, 1);
        AssignCommand(oVictor, ClearAllActions());
        AssignCommand(oVictor, ActionMoveToObject(GetObjectByTag("SouthGameExit")));
        AssignCommand(oVictor, ActionJumpToObject(GetObjectByTag("BigExit")));
          iVictors++;
        }
               
               

               


                     Modifié par One Thousand Talons Mao Ra, 16 novembre 2010 - 05:15 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Scripting Isn't a Spectator Sport
« Reply #18 on: November 16, 2010, 05:42:16 am »


               Replace the 1 in this line with iVictors:



oVictor = GetNearestObjectByTag("Gladiator", oCenter, 1);
               
               

               
            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Scripting Isn't a Spectator Sport
« Reply #19 on: November 16, 2010, 10:01:43 am »


               

FunkySwerve wrote...

Replace the 1 in this line with iVictors:

oVictor = GetNearestObjectByTag("Gladiator", oCenter, 1);


THAT makes sense. I'll test that in my script right now.

-Tests it.-
'<img'> Yes! Success! Flawless success.


//Added by me to the Gladiator's on spawn
if (GetLocalInt(OBJECT_SELF, "Carpathian")== 1)
    {
    object oArea;
    oArea = GetArea(OBJECT_SELF);
    int nInt;
    nInt = GetLocalInt(oArea, "Carpathians In Game");
    nInt += 1;
    SetLocalInt(oArea, "Carpathians In Game", nInt);
    }
if (GetLocalInt(OBJECT_SELF, "Sacrentian")== 1)
    {
    object oArea;
    oArea = GetArea(OBJECT_SELF);
    int nInt;
    nInt = GetLocalInt(oArea, "Sacrentians In Game");
    nInt += 1;
    SetLocalInt(oArea, "Sacrentians In Game", nInt);
    }
if (GetLocalInt(OBJECT_SELF, "Darkheart")== 1)
    {
    object oArea;
    oArea = GetArea(OBJECT_SELF);
    int nInt;
    nInt = GetLocalInt(oArea, "Darkhearts In Game");
    nInt += 1;
    SetLocalInt(oArea, "Darkhearts In Game", nInt);
    }

ActionMoveToObject(GetObjectByTag("ArenaCenter"));

And...

// Gladiator's OnDeath script by Robert Donald Paiser
void main()
{
ExecuteScript("nw_c2_default7", OBJECT_SELF);

if (GetLocalInt(OBJECT_SELF, "Carpathian")== 1)
    {
    object oArea;
    oArea = GetArea(OBJECT_SELF);
    int nInt;
    nInt = GetLocalInt(oArea, "Carpathians In Game");
    nInt -= 1;
    SetLocalInt(oArea, "Carpathians In Game", nInt);
    }
if (GetLocalInt(OBJECT_SELF, "Sacrentian")== 1)
    {
    object oArea;
    oArea = GetArea(OBJECT_SELF);
    int nInt;
    nInt = GetLocalInt(oArea, "Sacrentians In Game");
    nInt -= 1;
    SetLocalInt(oArea, "Sacrentians In Game", nInt);
    }
if (GetLocalInt(OBJECT_SELF, "Darkheart")== 1)
    {
    object oArea;
    oArea = GetArea(OBJECT_SELF);
    int nInt;
    nInt = GetLocalInt(oArea, "Darkhearts In Game");
    nInt -= 1;
    SetLocalInt(oArea, "Darkhearts In Game", nInt);
    }
object oArea;
oArea = GetArea(OBJECT_SELF);
if (GetLocalInt(oArea, "Carpathians In Game")==0 && GetLocalInt(oArea, "Sacrentians In Game")==0)
    {
    object oCenter;
    oCenter = GetObjectByTag("ArenaCenter");
    object oVictor;
    int iVictors = 1;
    while (iVictors <= 10)
        {
        oVictor = GetNearestObjectByTag("Gladiator", oCenter, iVictors);
        AssignCommand(oVictor, ClearAllActions());
        AssignCommand(oVictor, ActionMoveToObject(GetObjectByTag("SouthGameExit")));
        AssignCommand(oVictor, ActionJumpToObject(GetObjectByTag("BigExit")));
          iVictors++;
        }
    object oSgate;
    oSgate = GetObjectByTag("SouthGameGate");
    SetLocked(oSgate, FALSE);
    AssignCommand(oSgate, ActionOpenDoor(oSgate));
    AssignCommand(GetModule(), DelayCommand(20.0, AssignCommand(oSgate, ActionCloseDoor(oSgate))));
    AssignCommand(GetModule(), DelayCommand(20.0, SetLocked(oSgate, TRUE)));
    AssignCommand(GetModule(), DelayCommand(30.0, SetLocalInt(oArea, "Darkhearts In Game", 0)));
    }
if (GetLocalInt(oArea, "Carpathians In Game")==0 && GetLocalInt(oArea, "Darkhearts In Game")==0)
    {
    object oCenter;
    oCenter = GetObjectByTag("ArenaCenter");
    object oVictor;
    int iVictors = 1;
    while (iVictors <= 10)
        {
        oVictor = GetNearestObjectByTag("Gladiator", oCenter, iVictors);
        AssignCommand(oVictor, ClearAllActions());
        AssignCommand(oVictor, ActionMoveToObject(GetObjectByTag("SouthGameExit")));
        AssignCommand(oVictor, ActionJumpToObject(GetObjectByTag("BigExit")));
          iVictors++;
        }
    object oSgate;
    oSgate = GetObjectByTag("SouthGameGate");
    SetLocked(oSgate, FALSE);
    AssignCommand(oSgate, ActionOpenDoor(oSgate));
    AssignCommand(GetModule(), DelayCommand(20.0, AssignCommand(oSgate, ActionCloseDoor(oSgate))));
    AssignCommand(GetModule(), DelayCommand(20.0, SetLocked(oSgate, TRUE)));
    AssignCommand(GetModule(), DelayCommand(30.0, SetLocalInt(oArea, "Sacrentians In Game", 0)));
    }
if (GetLocalInt(oArea, "Sacrentians In Game")==0 && GetLocalInt(oArea, "Darkhearts In Game")==0)
    {
    object oCenter;
    oCenter = GetObjectByTag("ArenaCenter");
    object oVictor;
    int iVictors = 1;
    while (iVictors <= 10)
        {
        oVictor = GetNearestObjectByTag("Gladiator", oCenter, iVictors);
        AssignCommand(oVictor, ClearAllActions());
        AssignCommand(oVictor, ActionMoveToObject(GetObjectByTag("SouthGameExit")));
        AssignCommand(oVictor, ActionJumpToObject(GetObjectByTag("BigExit")));
          iVictors++;
        }
    object oSgate;
    oSgate = GetObjectByTag("SouthGameGate");
    SetLocked(oSgate, FALSE);
    AssignCommand(oSgate, ActionOpenDoor(oSgate));
    AssignCommand(GetModule(), DelayCommand(20.0, AssignCommand(oSgate, ActionCloseDoor(oSgate))));
    AssignCommand(GetModule(), DelayCommand(20.0, SetLocked(oSgate, TRUE)));
    AssignCommand(GetModule(), DelayCommand(30.0, SetLocalInt(oArea, "Carpathians In Game", 0)));
    }

}

So basically, Nightmare, like your second variable tracking idea. I'm sooo happy this works! ':wub:'
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Scripting Isn't a Spectator Sport
« Reply #20 on: November 16, 2010, 01:07:55 pm »


               Sweet, good to hear that you got everything working! Now you need to add in the ability for the PC spectators to place wagers on the winning team. I've got 10 gold on the Darkhearts!
               
               

               
            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Scripting Isn't a Spectator Sport
« Reply #21 on: November 16, 2010, 08:25:05 pm »


               ':lol:' That's what I was thinking. And this method actually makes that very possible, too! When I finish this little module, I'll send it to ya. No haks necessary.