Aller au contenu

Photo

Spawn script


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

#1
jsd313

jsd313
  • Members
  • 184 messages
What would I need to add to my area script to only spawn this creature if it isn't already present? Right now if I die and go back there is 2 of them and so on.

case EVENT_TYPE_AREALOAD_PRELOADEXIT:
     {
    object oWaypoint = GetObjectByTag("enemy_team");
    location lWaypoint = GetLocation(oWaypoint);
    object o = CreateObject(OBJECT_TYPE_CREATURE, R"knight.utc", lWaypoint);
      }

#2
Mengtzu

Mengtzu
  • Members
  • 258 messages
Just use a plot? Check if it's false, if it is spawn the creature and set it to true.

#3
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
[dascript]case EVENT_TYPE_AREALOAD_PRELOADEXIT:
{ object oWaypoint = GetObjectByTag( "enemy_team" );
   if( IsObjectValid( oWaypoint ) &&
       !IsObjectValid( UT_GetNearestObjectByTag( oWaypoint, "TAG_of_Knight_goes_here" )))
     CreateObject( OBJECT_TYPE_CREATURE, R "knight.utc", GetSafeLocation( GetLocation( oWaypoint )));
}[/dascript]
I think that's what you want...plug in the tag of your knight guy where indicated there.

Modifié par Axe_Murderer, 09 janvier 2010 - 10:32 .


#4
jsd313

jsd313
  • Members
  • 184 messages
{



case EVENT_TYPE_AREALOAD_PRELOADEXIT:

{ object oWaypoint = GetObjectByTag( "enemy_team" );

if( IsObjectValid( oWaypoint ) &&

!IsObjectValid( UT_GetNearestObjectByTag( oWaypoint, "enemy" )))

CreateObject( OBJECT_TYPE_CREATURE, R"knight.utc", GetSafeLocation( GetLocation( oWaypoint )));

}



break;

}



compiles and exports but nothing spawns in the area now.

#5
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Try this one...
[dascript]
case EVENT_TYPE_AREALOAD_PRELOADEXIT:
{ object oWaypoint = GetObjectByTag( "enemy_team" );
   if( IsObjectValid( oWaypoint ) &&
       !IsObjectValid( UT_GetNearestObjectByTag( oWaypoint, "SpecialKnight" )))
     SetTag( CreateObject( OBJECT_TYPE_CREATURE, R "knight.utc", GetSafeLocation( GetLocation( oWaypoint ))), "SpecialKnight" );
}
[/dascript]

#6
jsd313

jsd313
  • Members
  • 184 messages
Still not spawning the creature, hmm. Anyway to on EXIT destroy the creature if it still exist?

#7
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
I'm thinking it's not finding the waypoint. Are you sure that tag is correct and unique?


#8
jsd313

jsd313
  • Members
  • 184 messages
its unique to my module which is standalone yes. I can try changing it real fast.

#9
jsd313

jsd313
  • Members
  • 184 messages
lol well my bad I had the waypoint wrong, I hadn't changed it on that test script.



It did spawn the knight, I killed him but when I went back in he didn't respawn. Was gonna let him kill me see if there would be 2 next time in.



Any idea why he won't respawn when i enter the area again?

#10
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
When you kill him is he still there lying dead on the ground?

If so, you can try this:
[dascript]
case EVENT_TYPE_AREALOAD_PRELOADEXIT:
{ object oWaypoint = GetObjectByTag( "enemy_team" );
   object oKnight      = UT_GetNearestObjectByTag( oWaypoint, "SpecialKnight" );
   if( IsObjectValid( oWaypoint ) && (!IsObjectValid( oKnight ) || IsDead( oKnight )) )
      SetTag( CreateObject( OBJECT_TYPE_CREATURE, R "knight.utc", GetSafeLocation( GetLocation( oWaypoint ))), "SpecialKnight" );
}[/dascript]

But you'll still have problems if you let those dead bodies build up.

Modifié par Axe_Murderer, 10 janvier 2010 - 12:37 .


#11
jsd313

jsd313
  • Members
  • 184 messages
Ok now its doing what my original script did,but if I died and came back the original knight was there with 50% life and a new one had spawned.

#12
jsd313

jsd313
  • Members
  • 184 messages
Yeah I have been looking at solutions for the corpses for awhile, not much can be done. I need to much help with setting up a team array and then setting up resurrection stuff.. Ideally it would be nice if i could make it load the area fresh everytime :)

#13
jsd313

jsd313
  • Members
  • 184 messages
hmm, i have a very basic script to send me to my areas triggered from a conversation.



void main()

{

DoAreaTransition("cc", "cc");

}



Is there anything I can do to make it load the area as if it's the first time? That would solve all my problems with bodies and extra creatures after party wipes.



Thanks a lot for your help man

#14
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
No you have to manually clear the area and do everything necessary to reset it back. Sounds like what you need to do is spawn everything in the area enter event and destroy everything in the area exit event...unconditionally.

Modifié par Axe_Murderer, 10 janvier 2010 - 01:02 .


#15
jsd313

jsd313
  • Members
  • 184 messages
Yeah problem is i have over 30 creatures and then several areas to edit if I make changes heh.

#16
jsd313

jsd313
  • Members
  • 184 messages
bah commented to your orig comment, but yeah If I can set it up so when I enter it spawns them and when i leave no matter how it clears them. Here is one of my full working area scripts.

#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "var_constants_h"

void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
string sDebug;
int nEventHandled = FALSE;
switch(nEventType)
{

case EVENT_TYPE_AREALOAD_PRELOADEXIT:
{
object oWaypoint = GetObjectByTag("cod4v4_team1");
location lWaypoint = GetLocation(oWaypoint);

object o = CreateObject(OBJECT_TYPE_CREATURE, R"warrior01.utc", lWaypoint);
}
{
object oWaypoint = GetObjectByTag("cod4v4_team2");
location lWaypoint = GetLocation(oWaypoint);
object o = CreateObject(OBJECT_TYPE_CREATURE, R"priest01.utc", lWaypoint);
}
{
object oWaypoint = GetObjectByTag("cod4v4_team3");
location lWaypoint = GetLocation(oWaypoint);
object o = CreateObject(OBJECT_TYPE_CREATURE, R"hunter01.utc", lWaypoint);
}
{
object oWaypoint = GetObjectByTag("cod4v4_team4");
location lWaypoint = GetLocation(oWaypoint);
object o = CreateObject(OBJECT_TYPE_CREATURE, R"mage02.utc", lWaypoint);
}

break;
}

switch(nEventType)
{
case EVENT_TYPE_TEAM_DESTROYED:
{

DoAreaTransition("arena", "cod");

nEventHandled = TRUE; //set this if no further action is required for this event
break;
}
}
if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
}
}

Modifié par jsd313, 10 janvier 2010 - 01:01 .


#17
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Heh...wish you woodda posted that sooner. Try this instead:
[dascript]
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "var_constants_h"
 
void main()
{  int nEventHandled = FALSE;
   switch( GetEventType( GetCurrentEvent() ))
   {
      case EVENT_TYPE_AREALOAD_PRELOADEXIT:
      { object oWaypoint = GetObjectByTag( "cod4v4_team1" );
         SetTag( CreateObject( OBJECT_TYPE_CREATURE, R"warrior01.utc", GetSafeLocation( GetLocation( oWaypoint )) ), "SpecialWarrior01" );
        
         oWaypoint = GetObjectByTag( "cod4v4_team2" );
         SetTag( CreateObject( OBJECT_TYPE_CREATURE, R"priest01.utc", GetSafeLocation( GetLocation( oWaypoint )) ), "SpecialPriest01" );
        
         oWaypoint = GetObjectByTag( "cod4v4_team3" );
         SetTag( CreateObject( OBJECT_TYPE_CREATURE, R"hunter01.utc", GetSafeLocation( GetLocation( oWaypoint )) ), "SpecialHunter01" );

         oWaypoint = GetObjectByTag( "cod4v4_team4" );
         SetTag( CreateObject( OBJECT_TYPE_CREATURE, R"mage02.utc", GetSafeLocation( GetLocation( oWaypoint )) ), "SpecialMage02" );
      }
      break;

      case EVENT_TYPE_TEAM_DESTROYED:
      { object oWaypoint = GetObjectByTag( "cod4v4_team1" );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialWarrior01" ), 0 );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialPriest01" ),    0 );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialHunter01" ),  0 );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialMage02" ),    0 );
        
         DoAreaTransition( "arena", "cod" );
         nEventHandled = TRUE; // set this if no further action is required for this event
      }
      break;
   }

   // If this event wasn't handled by this script, let the core script try
   if ( !nEventHandled ) HandleEvent( GetCurrentEvent(), RESOURCE_SCRIPT_AREA_CORE );
}
[/dascript]

Modifié par Axe_Murderer, 10 janvier 2010 - 02:44 .


#18
jsd313

jsd313
  • Members
  • 184 messages
Still spawning a second one.

Modifié par jsd313, 10 janvier 2010 - 01:36 .


#19
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
[dascript]
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "var_constants_h"
 
void main()
{  int nEventHandled = FALSE;
   switch( GetEventType( GetCurrentEvent() ))
   {
      case EVENT_TYPE_AREALOAD_PRELOADEXIT:
      { object oWaypoint = GetObjectByTag( "cod4v4_team1" );
         SetTag( CreateObject( OBJECT_TYPE_CREATURE, R"warrior01.utc", GetSafeLocation( GetLocation( oWaypoint )) ), "SpecialWarrior01" );
        
         oWaypoint = GetObjectByTag( "cod4v4_team2" );
         SetTag( CreateObject( OBJECT_TYPE_CREATURE, R"priest01.utc", GetSafeLocation( GetLocation( oWaypoint )) ), "SpecialPriest01" );
        
         oWaypoint = GetObjectByTag( "cod4v4_team3" );
         SetTag( CreateObject( OBJECT_TYPE_CREATURE, R"hunter01.utc", GetSafeLocation( GetLocation( oWaypoint )) ), "SpecialHunter01" );

         oWaypoint = GetObjectByTag( "cod4v4_team4" );
         SetTag( CreateObject( OBJECT_TYPE_CREATURE, R"mage02.utc", GetSafeLocation( GetLocation( oWaypoint )) ), "SpecialMage02" );
      }
      break;

      case EVENT_TYPE_EXIT:
      { object oWaypoint = GetObjectByTag( "cod4v4_team1" );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialWarrior01" ), 0 );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialPriest01" ),    0 );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialHunter01" ),  0 );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialMage02" ),    0 );
      }
      break;

      case EVENT_TYPE_TEAM_DESTROYED:
      { DoAreaTransition( "arena", "cod" );
         nEventHandled = TRUE; // set this if no further action is required for this event
      }
      break;
   }

   // If this event wasn't handled by this script, let the core script try
   if ( !nEventHandled ) HandleEvent( GetCurrentEvent(), RESOURCE_SCRIPT_AREA_CORE );
}
[/dascript]

Modifié par Axe_Murderer, 10 janvier 2010 - 02:42 .


#20
jsd313

jsd313
  • Members
  • 184 messages
Still not clearing them under EVENT_TYPE_EXIT

#21
jsd313

jsd313
  • Members
  • 184 messages
I have all my enemy creatures set to the same team ID, maybe I can do Safe_Destroy_Object on a team ID. This is by far one of my biggest issues to overcome for this mod. Such tough stuff.

#22
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Replace exit event code with this:
[dascript]
      case EVENT_TYPE_EXIT:
      { object oWaypoint = GetObjectByTag( "cod4v4_team1" );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialWarrior01" ), 0 );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialPriest01" ),    0 );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialHunter01" ),  0 );
         Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "SpecialMage02" ),    0 );
         
         string sWarning  = "Exiting area. Waypoint 'cod4v4_team1' ";
         if( IsObjectValid( oWaypoint )) sWarning += "was found successfully.";
         else sWarning += "does not exist.";
         sWarning += "\\\\nSpecial Warrior 01 ";
         if( IsObjectValid( UT_GetNearestObjectByTag( oWaypoint, "SpecialWarrior01" ))) sWarning += "was found.";
         else sWarning += "does not exist.";
         sWarning += "\\\\nSpecial Priest 01 ";
         if( IsObjectValid( UT_GetNearestObjectByTag( oWaypoint, "SpecialPriest01" ))) sWarning += "was found.";
         else sWarning += "does not exist.";
         sWarning += "\\\\nSpecial Hunter 01 ";
         if( IsObjectValid( UT_GetNearestObjectByTag( oWaypoint, "SpecialHunter01" ))) sWarning += "was found.";
         else sWarning += "does not exist.";
         sWarning += "\\\\nSpecial Mage 02 ";
         if( IsObjectValid( UT_GetNearestObjectByTag( oWaypoint, "SpecialMage02" ))) sWarning += "was found.";
         else sWarning += "does not exist.";
         Warning( sWarning );
      }
      break;
[/dascript]
See what that spits out when you run it.

Modifié par Axe_Murderer, 10 janvier 2010 - 02:45 .


#23
jsd313

jsd313
  • Members
  • 184 messages
i don't get any messages, killed them all and then tried letting them kill me.

#24
jsd313

jsd313
  • Members
  • 184 messages
testing with this script now but still no results.



#include "utility_h"

#include "wrappers_h"

#include "events_h"

#include "var_constants_h"



void main()

{ int nEventHandled = FALSE;

switch( GetEventType( GetCurrentEvent() ))

{

case EVENT_TYPE_AREALOAD_PRELOADEXIT:

{ object oWaypoint = GetObjectByTag( "test" );

SetTag( CreateObject( OBJECT_TYPE_CREATURE, R"knight.utc", GetSafeLocation( GetLocation( oWaypoint )) ), "enemy" );





}

break;



case EVENT_TYPE_EXIT:

{

object oWaypoint = GetObjectByTag( "test" );

Safe_Destroy_Object( UT_GetNearestObjectByTag( oWaypoint, "enemy" ), 0 );





string sWarning = "Exiting area. Waypoint 'test' ";

if( IsObjectValid( oWaypoint )) sWarning += "was found successfully.";

else sWarning += "does not exist.";

sWarning += "\\\\nSpecial Warrior 01 ";



}

break;



case EVENT_TYPE_TEAM_DESTROYED:

{

DoAreaTransition( "arena", "duels" );

nEventHandled = TRUE; // set this if no further action is required for this event

}

break;

}



// If this event wasn't handled by this script, let the core script try

if ( !nEventHandled ) HandleEvent( GetCurrentEvent(), RESOURCE_SCRIPT_AREA_CORE );

}

#25
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
You left out the call to Warning() in there.

I guess EVENT_TYPE_EXIT isn't the right one. I can't find any useful information about those EVENT constants anywhere. The wiki says areas are supposed to receive that one but looks like that isn't the case. You should get a message every time you leave the area. I think the code is right but the event is wrong so it isn't running that cleanup stuff.

Maybe Warning() isn't the right function. There's some others you could try instead:
DEBUG_PrintToScreen( sWarning );
PrintString( sWarning );
PrintToLogWindow( sWarning );

Modifié par Axe_Murderer, 10 janvier 2010 - 03:13 .