will this work?
#1
Posté 04 avril 2011 - 06:27
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
Posté 04 avril 2011 - 06:45
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
Posté 04 avril 2011 - 07:20
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
Posté 04 avril 2011 - 07:37
...
{
oTarget = GetObjectByTag("NPCTAG"+InToString(i)); // Here you change oTarget to the next npc
Rate = GetLocalInt(oTarget, "Rate");
...
^^ There is the change in oTarget to the next NPC
i think the InToString should be IntToString though
Modifié par KiKurA, 04 avril 2011 - 07:40 .
#5
Posté 04 avril 2011 - 07:50
#6
Posté 04 avril 2011 - 07:52
#7
Posté 04 avril 2011 - 08:48
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
Pay = (((int GetLocalInt(oTarget, "Rate")) + (int GetLocalInt(oTarget, "Bonus"))) * 8;
#8
Posté 04 avril 2011 - 09:01
G
#9
Posté 04 avril 2011 - 09:24
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
Posté 04 avril 2011 - 09:49
@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
Posté 05 avril 2011 - 12:02
btw, my script had a typo in it "InToString" should be "IntToString"
#12
Posté 05 avril 2011 - 12:16
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
Posté 05 avril 2011 - 02:49
Be well. Game on.
GM_ODA
#14
Posté 05 avril 2011 - 03:24
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
Posté 05 avril 2011 - 03:42
#16
Posté 05 avril 2011 - 03:43
#17
Posté 05 avril 2011 - 03:44
ehye_khandee wrote...
my first computer was a commodore 64!.
Be well. Game on.
GM_ODA
haha, so was mine
#18
Posté 05 avril 2011 - 03:58
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.
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
Posté 05 avril 2011 - 04:06
ehye_khandee wrote...
Too late for my fuzzy brain tonight, I'll post an example tomorrow with my coffee.
#20
Posté 05 avril 2011 - 04:11
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.
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.





Retour en haut






