Author Topic: Small Holes, Big Difference  (Read 1302 times)

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Small Holes, Big Difference
« on: July 27, 2010, 10:14:13 pm »


               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);
   }
}
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #1 on: July 27, 2010, 11:35:07 pm »


               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 .
                     
                  


            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #2 on: July 28, 2010, 01:31:56 am »


               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. '<img'>



Thanks again, Lightfoot!

               
               

               
            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #3 on: July 28, 2010, 01:35:55 am »


               

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.
               
               

               
            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #4 on: July 28, 2010, 01:57:23 am »


               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 .
                     
                  


            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #5 on: July 28, 2010, 02:32:21 am »


               ':?'

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;
    }
   }
}

<><>

               
            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #6 on: July 28, 2010, 02:37:49 am »


               

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.
               
               

               
            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #7 on: July 28, 2010, 02:43:30 am »


               I have it there. Tags of waypoints are all right, the variable is set right. This should work! Buuut it doesn't.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #8 on: July 28, 2010, 02:50:40 am »


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


               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #9 on: July 28, 2010, 02:56:27 am »


               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.
               
               

               
            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #10 on: July 28, 2010, 02:57:26 am »


               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 .
                     
                  


            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #11 on: July 28, 2010, 03:02:17 am »


               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.
               
               

               
            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #12 on: July 28, 2010, 03:05:46 am »


               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 .
                     
                  


            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #13 on: July 28, 2010, 03:17:54 am »


               

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.
               
               

               
            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Small Holes, Big Difference
« Reply #14 on: July 28, 2010, 03:24:37 am »


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