I’m looking for help is there any to check on an on enter
event to see if a creature has spawned already and if so don’t run the script that
spawns the creature until killed. I hope that makes sense. Any help on this
would be wonderful
on enter check
Débuté par
Surek
, avril 26 2013 06:00
#1
Posté 26 avril 2013 - 06:00
#2
Posté 26 avril 2013 - 07:01
if( GetObjectbytag("unique tag of creature",0) != OBJECT_INVALID) return;
...
...
#3
Posté 26 avril 2013 - 09:50
thank you for your help but now i'm getting an error
that says invalid declaration type.
I'm lost i don't know what i'm doing but if anyone can help me out many thanks
void main()
{
object A;
object B;
object oPC=GetEnteringObject();
if (!GetIsPC(oPC)) return;
}
if( GetObjectbytag("morella",0) != OBJECT_INVALID) return; ERROR occurs here
int nRand= Random(2);
nRand++;
switch (nRand)
{
case 1: A = GetWaypointByTag("morella_01");
B = CreateObject(OBJECT_TYPE_CREATURE,"morella",GetLocation(A));
break;
case 2: A = GetWaypointByTag("morella_02");
B = CreateObject(OBJECT_TYPE_CREATURE,"morella",GetLocation(A));
break;
case 3:
break;
case 4: //What happens on 4
break;
case 5: //What happens on 5
break;
}
}
that says invalid declaration type.
I'm lost i don't know what i'm doing but if anyone can help me out many thanks
void main()
{
object A;
object B;
object oPC=GetEnteringObject();
if (!GetIsPC(oPC)) return;
}
if( GetObjectbytag("morella",0) != OBJECT_INVALID) return; ERROR occurs here
int nRand= Random(2);
nRand++;
switch (nRand)
{
case 1: A = GetWaypointByTag("morella_01");
B = CreateObject(OBJECT_TYPE_CREATURE,"morella",GetLocation(A));
break;
case 2: A = GetWaypointByTag("morella_02");
B = CreateObject(OBJECT_TYPE_CREATURE,"morella",GetLocation(A));
break;
case 3:
break;
case 4: //What happens on 4
break;
case 5: //What happens on 5
break;
}
}
#4
Posté 26 avril 2013 - 10:52
You have extra brackets in there. I recoded it to be simpler and cleaner.
My inclination is to get rid of oWay altogether and just stick the GetWaypoint in the GetLocation, but I want to make sure you understand what's going on here. A few notes:
Random(X) returns a number between 0 (zero) and X-1. In this case, 0 or 1. Random(5) would be 0-4, Random(30) would be 0-29. Get used to beginning a count with zero, as this is VERY commonly done in coding.
CreateObject doesn't need a B = in front of it. You can declare an object for it if you're going to do something else to that object, but this code isn't doing that, so it's useless clutter.
Please feel free to ask any questions you might have - learning to code can be frustrating, but it can also be immensely fun and rewarding.
Funky
void main() {
object oWay, oPC=GetEnteringObject();
if (!GetIsPC(oPC))
return;
if( GetObjectbytag("morella",0) != OBJECT_INVALID)
return;
switch (Random(2)) {
case 0:
oWay = GetWaypointByTag("morella_01");
CreateObject(OBJECT_TYPE_CREATURE,"morella",GetLocation(oWay));
break;
case 1:
oWay = GetWaypointByTag("morella_02");
CreateObject(OBJECT_TYPE_CREATURE,"morella",GetLocation(oWay));
break;
}
}
My inclination is to get rid of oWay altogether and just stick the GetWaypoint in the GetLocation, but I want to make sure you understand what's going on here. A few notes:
Random(X) returns a number between 0 (zero) and X-1. In this case, 0 or 1. Random(5) would be 0-4, Random(30) would be 0-29. Get used to beginning a count with zero, as this is VERY commonly done in coding.
CreateObject doesn't need a B = in front of it. You can declare an object for it if you're going to do something else to that object, but this code isn't doing that, so it's useless clutter.
Please feel free to ask any questions you might have - learning to code can be frustrating, but it can also be immensely fun and rewarding.
Funky
#5
Posté 26 avril 2013 - 10:57
Here's an even shorter version of that same script, for giggles. I also changed your object validity check to a better method, though I'm not going to dwell on the details.
[Edit] The create line overflowed the post window - sigh @ Bioboards. Make sure to get it all the way to the semicolon if you copy/paste it.
Funky
void main() {
if (!GetIsPC(GetEnteringObject()))
return;
if (GetIsObjectValid(GetObjectbytag("morella",0)))
return;
CreateObject(OBJECT_TYPE_CREATURE,"morella",GetLocation(GetWaypointByTag("morella_0"+IntToString(d2()))));
}
[Edit] The create line overflowed the post window - sigh @ Bioboards. Make sure to get it all the way to the semicolon if you copy/paste it.
Funky
Modifié par FunkySwerve, 26 avril 2013 - 11:00 .





Retour en haut






