Aller au contenu

Photo

will this work?


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

#1
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
will this script work  the way i would like  it to?

it compiles fine but  i have several targets and i want to give the gold to each of them. the "Rate" and "Bonus" variables are set to a different value on each of the targets so i was wondering if i ask here.

or should i try doing a  while loop? i very rarely ever use loops since im not to familiar with them tho i was just starting to learn looping from what i saved from a post i saved in the old lesser toolset known features thread on the old forums.

here is the script i have right now:

void main()
{

object oTarget;

int Rate = GetLocalInt(oTarget, "Rate");
int Bonus = GetLocalInt(oTarget, "Bonus");
int Salary = Rate + Bonus;
int Pay = Salary * 8;

oTarget = GetObjectByTag("NPCTAG");

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG2");

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG3");

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG4");

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG5");

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG6");

GiveGoldToCreature(oTarget, Pay);

}

#2
ehye_khandee

ehye_khandee
  • Members
  • 855 messages
No, this will not work as written.
Specifically, you are trying to load Rate and Bonus from a variable on oTarget, while oTarget is not specified (OBJECT_INVALID) - so in this case, Rate and Bonus would be 0.

I presume you meant that each of the NPCs you use will have the variables stored on the NPC itself - and in this case you should likely use a loop - I can give you this example of sample code with a loop - though, I'm not certain I understand what you want, I'll give it my best shot.


void main()
{

object oTarget;

int Rate, Bonus, Salary, Pay, i; // declare all int variables

for (i=1; i < 7, i++) //set to run for NPCTAG1 thru NPCTAG6
{
  oTarget = GetObjectByTag("NPCTAG"+InToString(i));
  Rate = GetLocalInt(oTarget, "Rate");
  Bonus = GetLocalInt(oTarget, "Bonus");
  Salary = Rate + Bonus;
  Pay = Salary * 8;
  GiveGoldToCreature(oTarget, Pay);
}

}

Hope this helps. NOTE it is NOT tested - written off the top of my head, but it should do the trick.

Be well. Game on.
GM_ODA

#3
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
yes i have the Rate and Bonus variables set on the npcs themselves.

note the loop in the post above i did not realy understand what the for loop was running for or where to plug in the tags of the additional npc tags.

what im trying to do is give the gold to each of those 6 npcs using this math formula:
Pay = (Value of Integer Rate On Target NPC + Value of Integar Bonus On Target NPC) * 8

here is what i had originaly is below this but script editor said no because of how i defined pay if i remember right so i came up with script in the first post i did on this thread.

void main()
{

object oTarget;

int Pay;

oTarget = GetObjectByTag("NPCTAG");

Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG2");

Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG3");

Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG4");

Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG5");

Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;

GiveGoldToCreature(oTarget, Pay);

oTarget = GetObjectByTag("NPCTAG6");

Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;

GiveGoldToCreature(oTarget, Pay);

}

#4
KiKurA

KiKurA
  • Members
  • 8 messages

...
{
oTarget = GetObjectByTag("NPCTAG"+InToString(i)); // Here you change oTarget to the next npc :P
Rate = GetLocalInt(oTarget, "Rate");
...


^^ There is the change in oTarget to the next NPC

i think the InToString should be IntToString though :P

Modifié par KiKurA, 04 avril 2011 - 07:40 .


#5
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
ok i missed that line but whats the IntToString for tho in that line?

#6
KiKurA

KiKurA
  • Members
  • 8 messages
it makes the integer type (i) a string type so it can be added to the "NPCTAG"

#7
KiKurA

KiKurA
  • Members
  • 8 messages

here is what i had originaly is below this but script editor said no because of how i defined pay if i remember right so i came up with script in the first post i did on this thread.

void main()
{

object oTarget;

int Pay;

oTarget = GetObjectByTag("NPCTAG");

Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;
}


mmhmhmhm...

lol, try this :D 

Pay = (((int GetLocalInt(oTarget, "Rate")) + (int GetLocalInt(oTarget, "Bonus"))) * 8;



#8
ehye_khandee

ehye_khandee
  • Members
  • 855 messages
My script will cycle thru your NPCs tagged NPCTAG1 through NPCTAG6 - let me know if that works for you or not.

G

#9
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
@ehye_khandee it wouldnt fire tho so it might something with GetObjectByTag()
might be the tags of my npcs i plan on having this run on ill check quick and post back

@KiKurA will check that out as well to see what that does since that would be useful to know how to fix that error when i get it on not specifly that script i posted but on others tho

#10
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
@ehye_khandee yea there was a lower case letter in the tag that why it wouldnt fire so i fixed the tag and it worked

@KiKurA yea that made it work for all but to lines in that dont know how but i just copied and pasted your fixed line over again and then it worked might just be my toolset

it has been acting screwy lately while im trying to export 1 specific area in my module
it should not hang up for like 50 minutes in a 3 by 3 area with just 8 placeables( out of which only 2 are useable), 1 npc, and 4 encounters everything using default bioware scripts except by 2 useable placables.

the machine its being stupid on has a 2.8 quad core and 4 gigs of ram and a radeon hd 4550 with 512mb ram running windows 7 64bit. if toolset keeps acting screwy ill just reimage the machine

#11
ehye_khandee

ehye_khandee
  • Members
  • 855 messages
is your nwn configured to use only one core?

btw, my script had a typo in it "InToString" should be "IntToString"

#12
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
yea its set for just one core could just be the operating system being 64 bit being stupid....why Dell had to make it 64 bit is beyond me since none of the hardware in the box requires 64bit... i prefer 32 bit but i dont have a 32 bit win 7 disk >.< or id switch it........but anyway
Edit: For clarifaction it is just toolset that being stupid not the game itself

yes i fixed that line of the script but then toolset regeted your freshly recopied script...... i ended up making a home brew not tested yet but compiles fine its for a Inn in the module im working on. cuz i wanted to have a cool inn with live staff on shift and the staff getting paid when theyre shift is over. let me know what you think and any changes you would suggest?


void main()
{
 
object oDoor = GetObjectByTag("staffroom");
object oTarget;
 
int Pay;
 
if(GetTimeMinute() == 1 && GetTimeSecond() == 1 && GetTimeMillisecond() == 1)
{
 
AssignCommand(oDoor, ActionSpeakString("Sea Serpent Inn Staff Change If It Has Been 8 Hours Since The Current Staff Have Been On Shift", TALKVOLUME_SHOUT));
 
//pay the hourly employees
 
//waitress
oTarget = (GetObjectByTag("Prish"));
 
Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus"));
 
GiveGoldToCreature(oTarget, Pay);
 
//security guard
oTarget = (GetObjectByTag("Keli"));
 
Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus"));
 
GiveGoldToCreature(oTarget, Pay);
 
switch (GetTimeHour())
{
 
//3rd to 1st shift
case 8:
 
AssignCommand(oDoor, ActionOpenDoor(oDoor));
 
AssignCommand(oDoor, ActionSpeakString("Sea Serpent Inn Staff Change It Is Now Time For 3rd Shift To Leave And 1st Shift To Take Over", TALKVOLUME_SHOUT));
 
//Start Staff change
   oTarget = GetObjectByTag("CelawynFears");//Shift ending Room Renter
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("NW_STOREBAR01")));
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("CelawynFearsWP")));
 
   oTarget = GetObjectByTag("DalloDian");//Next shift room renter
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("room_renter")));
 
   oTarget = GetObjectByTag("SiliaBlake");//Shift ending Bar Tender
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("SiliaBlakeWP")));
 
   oTarget = GetObjectByTag("ElvawenAmolyan");//Next shift Bar Tender
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("bar_tender")));
//End Staff Change
 
DelayCommand(10.0, AssignCommand(oDoor, ActionCloseDoor(oDoor)));
 
//NPC PAY
oTarget = GetObjectByTag("CelawynFears");//room renter
 
Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;
 
GiveGoldToCreature(oTarget, Pay);
 
oTarget = GetObjectByTag("SiliaBlake");//bar tender
 
Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;
 
GiveGoldToCreature(oTarget, Pay);
     break;
 
//1st to 2nd shift
case 16:
 
AssignCommand(oDoor, ActionOpenDoor(oDoor));
 
AssignCommand(oDoor, ActionSpeakString("Sea Serpent Inn Staff Change It Is Now Time For 1st Shift To Leave And 2nd Shift To Take Over", TALKVOLUME_SHOUT));
 
//Start Staff change
   oTarget = GetObjectByTag("DalloDian");//Shift ending Room Renter
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("NW_STOREBAR01")));
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("DallosBed")));
 
   oTarget = GetObjectByTag("TeroLane");//Next shift room renter
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("room_renter")));
 
   oTarget = GetObjectByTag("ElvawenAmolyan");//Shift ending Bar Tender
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("ElvawensBed")));
 
   oTarget = GetObjectByTag("CarenaMendt");//Next shift Bar Tender
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("bar_tender")));
//End Staff Change
 
DelayCommand(10.0, AssignCommand(oDoor, ActionCloseDoor(oDoor)));
 
//NPC PAY
oTarget = GetObjectByTag("DalloDian");//room renter
 
Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;
 
GiveGoldToCreature(oTarget, Pay);
 
oTarget = GetObjectByTag("ElvawenAmolyan");//bar tender
 
Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;
 
GiveGoldToCreature(oTarget, Pay);
     break;
 
//2nd to 3rd shift
case 0:
 
AssignCommand(oDoor, ActionOpenDoor(oDoor));
 
AssignCommand(oDoor, ActionSpeakString("Sea Serpent Inn Staff Change It Is Now Time For 2nd Shift To Leave And 3rd Shift To Take Over", TALKVOLUME_SHOUT));
 
//Start Staff change
   oTarget = GetObjectByTag("TeroLane");//Shift ending Room Renter
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("NW_STOREBAR01")));
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("TeroLaneWP")));
 
   oTarget = GetObjectByTag("CelawynFears");//Next shift room renter
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("room_renter")));
 
   oTarget = GetObjectByTag("CarenaMendt");//Shift ending Bar Tender
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("CarenaMendtWP")));
 
   oTarget = GetObjectByTag("SiliaBlake");//Next shift Bar Tender
 
   AssignCommand(oTarget, ActionForceMoveToObject(GetObjectByTag("bar_tender")));
//End Staff Change
 
DelayCommand(10.0, AssignCommand(oDoor, ActionCloseDoor(oDoor)));
 
//NPC PAY
oTarget = GetObjectByTag("TeroLane");//room renter
 
Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;
 
GiveGoldToCreature(oTarget, Pay);
 
oTarget = GetObjectByTag("CarenaMendt");//bar tender
 
Pay = (GetLocalInt(oTarget, "Rate") + GetLocalInt(oTarget, "Bonus")) * 8;
 
GiveGoldToCreature(oTarget, Pay);
     break;
 
     default:
     // do nothing
     break;
 
}//end switch
 
}//end if
 
}//end main

Modifié par Ryuhi2000, 05 avril 2011 - 03:28 .


#13
ehye_khandee

ehye_khandee
  • Members
  • 855 messages
A bit of a longish script but it _looks_ like it would do the trick - I note you are not using the same tags as you had specified in the original request - so a loop is doable but not so straight forward. Still, this script could be reduced to a loop and maybe 10 or 15 lines of code. No offense, I'm just really strict about lean mean code (I can't help it - my first computer was a commodore 64!).

Be well. Game on.
GM_ODA

#14
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
i meant the tag of the npc not that the tag was "NPCTAG" fail.

and i honestly dont understand how can i further reduce the code lines can you like send me a example of how i can loop that to be less? i made it into switch/case which reduced my code by like 60 lines

#15
ehye_khandee

ehye_khandee
  • Members
  • 855 messages
Too late for my fuzzy brain tonight, I'll post an example tomorrow with my coffee.

#16
loch19

loch19
  • Members
  • 1 messages
my newest computer is a commodore 64

#17
Silent J 420

Silent J 420
  • Members
  • 2 messages

ehye_khandee wrote...

my first computer was a commodore 64!.

Be well. Game on.
GM_ODA


haha, so was mine :)

#18
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

Silent J 420 wrote...

ehye_khandee wrote...

my first computer was a commodore 64!.

Be well. Game on.
GM_ODA


haha, so was mine :)


Radio Shack TRS80 64k RAM with a tape drive here. WOOT! It was like a 20 lb. lap top. :lol:
I was trying to teach myself Basic on it..but then this thing called the Atari 2600 came a long and occupied all my time.

Modifié par GhostOfGod, 05 avril 2011 - 04:00 .


#19
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
thanks

ehye_khandee wrote...

Too late for my fuzzy brain tonight, I'll post an example tomorrow with my coffee.



#20
Ryuhi2000

Ryuhi2000
  • Members
  • 97 messages
mine was a webtv my brother let me use time to time in like 1998 to 2000 occasionaly

altho my first real real computer was a desktop in like 2000 that failed hard 128mb of ram and only a 500mhz cpu with a 5gb harddrive

GhostOfGod wrote...

Silent J 420 wrote...

ehye_khandee wrote...

my first computer was a commodore 64!.

Be well. Game on.
GM_ODA


haha, so was mine :)


Radio Shack TRS80 64k RAM with a tape drive here. WOOT! It was like a 20 lb. lap top. :lol:
I was trying to teach myself Basic on it..but then this thing called the Atari 2600 came a long and occupied all my time.