Aller au contenu

Photo

Small Holes, Big Difference


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

#1
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
Howdy. I'm trying to make a tunnel... an area transition... that's only big enough for small sized or smaller creatures to crawl back and fourth through. I want the PC's followers to join them but only if they fit. My script (half-ganked from Lilac Soul's Script Generator) compiles but fails when I test it. Here's what I have in the OnUsed event of the hole...

void main()
{
object oPC = GetPCSpeaker();
object oTarget;
location lTarget;
if(GetLocalInt(OBJECT_SELF, "Is In Cave 1") == 1)
  {
  oTarget = GetWaypointByTag("CrawlToGoblinCave2");
  lTarget = GetLocation(oTarget);
  if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
  oTarget=GetFirstFactionMember(oPC, FALSE);
  while (GetIsObjectValid(oTarget))
   {
   if (GetCreatureSize(oTarget) != CREATURE_SIZE_SMALL || CREATURE_SIZE_TINY) return;
   AssignCommand(oTarget, ClearAllActions());
   AssignCommand(oTarget, ActionJumpToLocation(lTarget));
   oTarget=GetNextFactionMember(oPC, FALSE);
     return;
   }
  }
oTarget = GetWaypointByTag("CrawlToGoblinCave1");
lTarget = GetLocation(oTarget);
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
oTarget=GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oTarget))
   {
   if (GetCreatureSize(oTarget) != CREATURE_SIZE_SMALL | CREATURE_SIZE_TINY) return;
   AssignCommand(oTarget, ClearAllActions());
   AssignCommand(oTarget, ActionJumpToLocation(lTarget));
   oTarget=GetNextFactionMember(oPC, FALSE);
   }
}

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
I have not fully looked at the script. Just at a quick glance your conditionals are nessed up.

on the first one you have: if(GetCreatureSize(oTarget) != CREATURE_SIZE_SMALL || CREATURE_SIZE_TINY) return;

On the second you have: if(GetCreatureSize(oTarget) != CREATURE_SIZE_SMALL | CREATURE_SIZE_TINY) return;

in the second one you are doing a logical test Or and in the second you are doing a logical Bitwize Or.

Does not matter that much since nither is going to return the resutts you want.

here is what you are doing in the first one.
(GetCreatureSize(oTarget) != CREATURE_SIZE_SMALL) will return a true or false value. Then you are doing an Or against CREATURE_SIZE_TINY wich is a postive value making it true. This is causing your expression to always evaluate to be true. (true or false) || True =TRUE.

in the second one it does the operator first so you have (CREATURE_SIZE_SMALL | CREATURE_SIZE_TINY) since the tiny constant is equal to 1 and the small one equal to 2. This will evaluate out to be 3. now 3 is what the constant for creature size mediun is equal to. So this section will only transport the character it they are != CREATURE_SIZE_MEDIUM.


What you need to to make both checks seperate with an OR inbtween them.


if((GetCreatureSize(oTarget) != CREATURE_SIZE_SMALL) || GetCreatureSize(oTarget) != CREATURE_SIZE_TINY) return;

Modifié par Lightfoot8, 27 juillet 2010 - 10:38 .


#3
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
Ah hah! Without understanding the exact methodology, it's very easy to misconstrue the logic. I understand now, though. This was my first use of || in a script of my own.



Yeah, the two were different because I was hastily changing them for testing.



I still don't understand the Bitwize one, though, namely because I don't what a Bitwize is or what it's good for. ;)



Thanks again, Lightfoot!


#4
Redunct

Redunct
  • Members
  • 49 messages

Here's what I have in the OnUsed event of the hole...





object oPC = GetPCSpeaker();




This may be giving you trouble.



I'm pretty sure if you're not using a conversation this wont return anything.



Replace it with this:

object oPC= GetLastUsedBy();




I haven't looked at the rest yet. I'll do so and let you know if I see anything else.

#5
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
LOL!!! That's just embarrassing.

Wait, no, that's right. It's actually called from a conversation with the hole. Make me doubt myself like that.

Modifié par One Thousand Talons Mao Ra, 28 juillet 2010 - 12:59 .


#6
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
:?

So I noticed my objects were defined all wrong. Rewrote the script and still got nothin'. Here's my last version...

void main()
{
object oPC = GetPCSpeaker();
object oTarget;
object oCrawler;
location lTarget;
if(GetLocalInt(OBJECT_SELF, "Is In Cave 1") == 1)
  {
  oTarget = GetWaypointByTag("CrawlToGoblinCave2");
  lTarget = GetLocation(oTarget);
  if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
  oCrawler=GetFirstFactionMember(oPC, FALSE);
  while (GetIsObjectValid(oCrawler))
   {
   if((GetCreatureSize(oCrawler)==CREATURE_SIZE_SMALL) || GetCreatureSize(oCrawler)==CREATURE_SIZE_TINY) return;
    {
    AssignCommand(oCrawler, ClearAllActions());
    AssignCommand(oCrawler, ActionJumpToLocation(lTarget));
    oCrawler=GetNextFactionMember(oPC, FALSE);
      return;
    }
   }
  }
oTarget = GetWaypointByTag("CrawlToGoblinCave1");
lTarget = GetLocation(oTarget);
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
oCrawler=GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oCrawler))
   {
   if((GetCreatureSize(oCrawler)==CREATURE_SIZE_SMALL) || GetCreatureSize(oCrawler)==CREATURE_SIZE_TINY) return;
    {
    AssignCommand(oCrawler, ClearAllActions());
    AssignCommand(oCrawler, ActionJumpToLocation(lTarget));
    oCrawler=GetNextFactionMember(oPC, FALSE);
      return;
    }
   }
}

<_<

#7
Redunct

Redunct
  • Members
  • 49 messages

One Thousand Talons Mao Ra wrote...

LOL!!! That's just embarrassing.

Wait, no, that's right. It's actually called from a conversation with the hole. Make me doubt myself like that.



Well then, it doesn't go in a onUsed, it needs to go into the "Action Taken...." of the conversation file.

#8
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
I have it there. Tags of waypoints are all right, the variable is set right. This should work! Buuut it doesn't.

#9
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
if((GetCreatureSize(oCrawler)==CREATURE_SIZE_SMALL) || ( GetCreatureSize(oCrawler)==CREATURE_SIZE_TINY)) return;


#10
TSMDude

TSMDude
  • Members
  • 865 messages
wont this part here end all conversation anyhow?



if((GetCreatureSize(oCrawler)==CREATURE_SIZE_SMALL) || GetCreatureSize(oCrawler)==CREATURE_SIZE_TINY) return;



Lets just rewrite the thing. It is beign called on a conversation? So we make it like this.



void main()

{

object oPC = GetPCSpeaker();

object oTarget;

object oCrawler;

location lTarget;//alot of this is redundant and you could put a simple jump speaker to

//waypoint btw

if(GetLocalInt(OBJECT_SELF, "Is In Cave 1") == 1)

{

if((GetCreatureSize(oCrawler)==CREATURE_SIZE_SMALL) || GetCreatureSize(oCrawler)==CREATURE_SIZE_TINY);

{

AssignCommand(oCrawler, ClearAllActions());

AssignCommand(oCrawler, ActionJumpToLocation(lTarget));

}

}

}





Now put that on the text appears and then on the other conversation node a simple,



"You are too massive to skimmy through this hole. Quit eating sweet pies."



There is even easier ways but it is late and I just got home from playing pool and hanging out with the freinds so will check in the morning and post a true compiled script but hopfully this is in the right direction.

#11
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
Lightfoot, this is stuff I should see. Thanks! I don't have anybody I can run this stuff by except you fine folks.

Modifié par One Thousand Talons Mao Ra, 28 juillet 2010 - 01:59 .


#12
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
TSMDude, I want the PCs henchmen to follow if they're the right size, but be left behind otherwise. Your script doesn't do that.

#13
Redunct

Redunct
  • Members
  • 49 messages
Ah, so it was typo in the original post.

Let's see what we can do..

void main()
{
object oPC=GetPCSpeaker();
object oWay=GetObjectByTag("CrawlToGoblinCave2");
location iTarget=GetLocation(oWay);

if ((GetCreatureSize(oPC)==CREATURE_SIZE_SMALL) || (GetCreatureSize(oPC)==CREATURE_SIZE_TINY))
{
AssignCommand(oPC,ClearAllActions());
AssignCommand(oPC,ActionJumpToLocation(iTarget));
}
else
{
AssignCommand(oPC,SpeakString("I don't think I can fit."));
}
}


This works. Adding the check for the Int shouldn't hurt it any.

Is there a reason for the int? Or the checking for the existence of the WayPoint?

EDIT:

TSMDude, I want the PCs henchmen to follow if they're the right size,
but be left behind otherwise. Your script doesn't do that.


Ah, Henchmen add a whole other dimension to this.

Give me a few minutes.

Modifié par Redunct, 28 juillet 2010 - 02:10 .


#14
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages

TSMDude wrote...

wont this part here end all conversation anyhow?

if((GetCreatureSize(oCrawler)==CREATURE_SIZE_SMALL) || GetCreatureSize(oCrawler)==CREATURE_SIZE_TINY) return;


You just identified my problem. The ''return'' is killing the whole script.

#15
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
:wizard: It works now! I rarely say this but... Woot!

#16
Redunct

Redunct
  • Members
  • 49 messages

void main()
{
object oPC=GetPCSpeaker();
object oWay=GetObjectByTag("CrawlToGoblinCave2");
location iTarget=GetLocation(oWay);
object oHench=GetHenchman(oPC);


if ((GetCreatureSize(oPC)==CREATURE_SIZE_SMALL) || (GetCreatureSize(oPC)==CREATURE_SIZE_TINY))
{
AssignCommand(oPC,ActionJumpToLocation(iTarget));
}
else
{
AssignCommand(oPC,SpeakString("I don't think I can fit."));
}

if ((GetCreatureSize(oHench)==CREATURE_SIZE_SMALL) || (GetCreatureSize(oHench)==CREATURE_SIZE_TINY))
{
AssignCommand(oHench,ActionJumpToLocation(iTarget));
}
else
{
RemoveHenchman(oPC,oHench);
}

}


This works. If the Henchman can't fit, He'll leave the Player's group. He SHOULD wait for the player where he was left, where he can rejoin.

Modifié par Redunct, 28 juillet 2010 - 02:37 .


#17
Redunct

Redunct
  • Members
  • 49 messages

One Thousand Talons Mao Ra wrote...

:wizard: It works now! I rarely say this but... Woot!


It shouldn't, I don't see how you can define a henchmen via a Faction, but if it does, great.

#18
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
Isn't each PC party their own faction? I should be able to loop through that faction and move 'em if they're the right size. Worked on the PC anyway...

#19
Redunct

Redunct
  • Members
  • 49 messages

One Thousand Talons Mao Ra wrote...

Isn't each PC party their own faction? I should be able to loop through that faction and move 'em if they're the right size. Worked on the PC anyway...


No, I don't believe so.

In order to prevent them from coming through you're gonna have to either 1.Force them to stay there or 2.Remove them from the party. I'll test it now, but I believe only a PC belongs to his respective faction, no one else can join it.

Just tested it, I am correct. NPCs cannot belong to a PC faction.

Switch it to "GetHenchmen(oPC)" and make sure you put some command to prevent the henchman from materializing next to the PC.

#20
Redunct

Redunct
  • Members
  • 49 messages
Double post.

Modifié par Redunct, 28 juillet 2010 - 03:06 .


#21
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Sorry, Yes It should have been != in the check instead of the ==; The return should have been there if i was reading what he was trying to do right. Use the same convo for trafic both ways.





And yes a party if a faction. If they are in the party they are in that same faction. With the party leader the leader of the faction. If a PC leaves the party then they are in a different faction.


#22
Redunct

Redunct
  • Members
  • 49 messages

Lightfoot8 wrote...


And yes a party if a faction. If they are in the party they are in that same faction. With the party leader the leader of the faction. If a PC leaves the party then they are in a different faction.


I just tested this again, it appears to be a hit and miss.

Still think you'd be safest just changing it to GetHenchmen(oPC)