Aller au contenu

Photo

spawning creatures from on enter


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

#1
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
Am i doing this right? im trying to spawn in 2 kobolds if they dont exist in the area already each kobold at their designated waypoint on enter of a trigger. hope you guys dont mind my capped comments i tend to that to make things stand out to me for specific sections of code also like how everytime i have a } i comment what it is ending.

#include "nw_i0_generic"
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
location lTarget;
object oSpawn;
object oTarget;
object oWP;
//1ST KOBOLD START
oWP = GetWaypointByTag("kobold_guard_1");
oTarget = GetObjectByTag("KoboldGuardBennemeiger");
lTarget = GetLocation(oWP);
if(GetIsObjectValid(oTarget)== FALSE)
{
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "kobold002", lTarget);
SetIsTemporaryEnemy(oPC, oSpawn);
AssignCommand(oTarget, ActionAttack(oPC));
AssignCommand(oTarget, DetermineCombatRound(oPC));
}//end if
//1ST KOBOLD END

//2ND KOBOLD START
oWP = GetWaypointByTag("kobold_guard_2");
oTarget = GetObjectByTag("KoboldGuardBennemeigerUndt");
lTarget = GetLocation(oWP);
if(GetIsObjectValid(oTarget)== FALSE)
{
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "kobold002", lTarget);
SetIsTemporaryEnemy(oPC, oSpawn);
AssignCommand(oTarget, ActionAttack(oPC));
AssignCommand(oTarget, DetermineCombatRound(oPC));
}//end if
//2ND KOBOLD END
}//end main



#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
You are assigning the actions to oTarget which I believe is supposed to go to oSpawn unless oTarget does exist in which case it should go to oTarget. So you will have some problems there.
Another thing I would change though, you only need to use DetermineCombatRound to make the enemy hostile to the pc and attack. Maybe something like so:


#include "nw_i0_generic"
void main()
{
    object oPC = GetEnteringObject();
    if (!GetIsPC(oPC)) return;
    location lTarget;
    object oSpawn;
    object oTarget;
    object oWP;
    //1ST KOBOLD START
    oWP = GetWaypointByTag("kobold_guard_1");
    oTarget = GetObjectByTag("KoboldGuardBennemeiger");
    lTarget = GetLocation(oWP);
    if (GetIsObjectValid(oTarget) == FALSE)
    {
        oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "kobold002", lTarget);
        AssignCommand(oSpawn, DetermineCombatRound(oPC));
    }//end if
    else
    {
        AssignCommand(oTarget, DetermineCombatRound(oPC));
    }
    //1ST KOBOLD END

    //2ND KOBOLD START
    oWP = GetWaypointByTag("kobold_guard_2");
    oTarget = GetObjectByTag("KoboldGuardBennemeigerUndt");
    lTarget = GetLocation(oWP);
    if (GetIsObjectValid(oTarget) == FALSE)
    {
        oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "kobold002", lTarget);
        AssignCommand(oSpawn, DetermineCombatRound(oPC));
    }//end if
    else
    {
        AssignCommand(oTarget, DetermineCombatRound(oPC));
    }
    //2ND KOBOLD END
}//end main

EDITED

Modifié par GhostOfGod, 20 avril 2011 - 09:06 .


#3
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
your right GoG

your script does exactly what i want it to do but i would like to add time restrictions to it in the following ways now

1:every 5 minutes the creature will respawn if it does not exist between hour 18 minute 59 and hour 6 minute 59

2:the creatures will only exist and attack between hour 18 minute 59 and hour 6 minute 59

3:between hour 6 minute 59 and hour 18 minute 59 have the creatues not exist

Edit: i thought about it the have the creatures not exist and respawn sections should be done by a heartbeat script which i am working on just finished the have them not exist section just have to do the respawn section now

Modifié par Ryuhi2000, 20 avril 2011 - 10:40 .