UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: HDKenny on June 02, 2014, 11:54:20 pm

Title: Triggers and such
Post by: HDKenny on June 02, 2014, 11:54:20 pm
Ok so like I said in my last post its a new way for power and I haven't done WaW coding for a while.

I have a trigger in my map that says how many seconds until the fuse goes bad and it says it has X seconds and counts down. The problem is, it gets stuck at 22 seconds. I debuged it and it was still counting down.

Also when the fuse blows your supposed to lose all your perks temporarily and it saves them in an array to make sure you get them back, and the problem Im having with that is the perk machine hintstrings aren't changing when the fuse blows.


Here is my code for watchFuse.gsc:
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;

main()
{
fuse_trig = getent("fuseTrig", "targetname");
fuse_trig sethintstring("Press and hold [&&1] to change fuse");
fuse_trig disable_trigger();

level.debugFuse = true;

self.hasPerks = [];
level.maxFuseTime = 20;
level.fuseTime = 0;

DF("Max Fuse Time: "+level.maxFuseTime);
DF("Fuse Time: "+level.fuseTime);

level.blownFuse = true;

DF("level.blownFuse = "+level.blownFuse);

thread watchPerkPower();



flag_wait("electricity_on");

thread createAndWatchHud();
doFuses();


}


watchPerkPower(){
while(1){
level waittill( "fuseBlow" );

DF("^5watchPerkPower() :: Fuse has blown");
//Machines = GetEntArray( "zombie_vending", "targetname" );
//Notworthy = [];
//for( i = 0; i < Machines.size; i++ )Notworthy[i] = Machines[i].scipt_noteworthy;
//for( i = 0; i < Notworthy.size; i++ ) Notworthy[i] thread maps\_zombiemode_perks::vending_set_hintstring( Notworthy[i], true );
getentarray("vending_jugg", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_armorvest", true );
getentarray("vending_doubletap", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_rof", true );
getentarray("vending_sleight", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_fastreload", true );
getentarray("vending_revive", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_quickrevive", true );

level waittill( "newFuse" );

DF("watchPerkPower() :: newFuse notified");

getentarray("vending_jugg", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_armorvest");
getentarray("vending_doubletap", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_rof");
getentarray("vending_sleight", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_fastreload");
getentarray("vending_revive", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_quickrevive");

}
}

doFuses(){
level.blownFuse = false;
thread watchPowerOut();
DF("level.blownFuse = "+level.blownFuse);

while(level.fuseTime < level.maxFuseTime && level.blownFuse == false){
level.fuseTime++;

//DF("Current Fuse: ["+level.fuseTime+"/"+level.maxFuseTime+"]");

if(level.fuseTime >= level.maxFuseTime){
thread blowDatFuse();

}
wait 1;
}
}

blowDatFuse(){
fuse_trig = getent("fuseTrig", "targetname");
level.blownFuse = true;
DF("level.blownFuse = "+level.blownFuse);
level notify( "fuseBlow" );
fuse_trig enable_trigger();
fuse_trig waittill("trigger");
thread changeFuse();
DF("Fuse Trigger Pushed");
}

changeFuse(){
fuse_trig = getent("fuseTrig", "targetname");
fuse_trig disable_trigger();
level notify( "newFuse" );
level.fuseTime = 0;
DF("Fuse Time: "+level.fuseTime);
doFuses();
}


watchPowerOut(){
level waittill( "fuseBlow" );

DF("Perks taken");

for(i=0;i<get_players().size;i++){
get_players()[i] thread takePerks();
}

level waittill( "newFuse" );
for(i=0;i<get_players().size;i++){
get_players()[i] notify( "giveEmBack" );
}
}


takePerks(){
DF("^1Take Perks Called");
savedPerks = [];
self.perks_num = 0;
perks = [];
perks[0] = "specialty_rof";
perks[1] = "specialty_fastreload";
perks[2] = "specialty_quickrevive";
perks[3] = "specialty_armorvest";

//for(i=0;i<self.perk_hud.size;i++){
// self.savedPerks[i] = self.hasPerks[i];
// DF("self.savedPerks["+i+"] = "+self.hasPerks[i]);
//}

for( i = 0; i < perks.size; i++ ){
DF("^3Checking Perk: "+perks[i]);
if(self HasPerk(perks[i]) == true){
savedPerks[self.perks_num] = perks[i];
self.perks_num++;
DF("Perk: "+self.savedPerks[i]+" saved   :::   "+self.perks_num);
}
}

self notify("fuse");

self waittill( "giveEmBack" );

DF("^5Givin em' Back");

for(i=0;i<self.perks_num;i++){
self SetPerk( self.savedPerks[i] );
self maps\_zombiemode_perks::perk_hud_create( self.savedPerks[i] );
self maps\_zombiemode_perks::perk_think( self.savedPerks[i] );
wait 0.1;
DF("Perk: "+self.savedPerks[i]+" returned");
}
}


createAndWatchHud(){
hud = create_simple_hud();
  hud.horzAlign = "right";
  hud.vertAlign = "top";
    hud.alignX = "right";
    hud.alignY = "top";
    hud.y = 10;
    hud.x = -10;
    hud.foreground = 1;
    hud.fontscale =1.3;
    hud.alpha = 0;
    hud.color = ( 0.423, 0.423, 0.1 );
hud SetText("Fuse [ ]");
wait 1;
hud fadeOverTime(1);
hud.alpha = 0.8;
wait 1.1;

while(1){
hud setText("Fuse ["+(level.maxFuseTime-level.fuseTime)+"]");
wait 1;
}
}

DF(text){
get_players()[0] iprintln(text);
}

I was expecting errors because I have 0 knowledge of how to make triggers so if someone could help me with that too, that would be nice :P Sorry this is a lot of problems and I'm still trying to figure it out, its just helpful if I can't.

I also have this in _zombiemods_perks.gsc:
Code Snippet
Plaintext

vending_set_hintstring( perk, fuse )
{
if(fuse == undefined)
fuse = false;


switch( perk )
{

case "specialty_armorvest":
if(fuse == false)
self SetHintString( &"ZOMBIE_PERK_JUGGERNAUT" );
else
self SetHintString( "Fuse blown, replace it!" );
break;

case "specialty_quickrevive":
flag_wait( "all_players_connected" );
players = get_players();

if(fuse == false){
if (players.size == 1)
self SetHintString( "Press & hold &&1 to buy Revive [Cost: 500]" );
else
self SetHintString( "Press & hold &&1 to buy Revive [Cost: 1500]" );
}
else
self SetHintString( "Fuse blown, replace it!" );
break;

case "specialty_fastreload":
if(fuse == false)
self SetHintString( &"ZOMBIE_PERK_FASTRELOAD" );
else
self SetHintString( "Fuse blown, replace it!" );
break;

case "specialty_leadfoot":
if(fuse == false)
self SetHintString( "Press & hold &&1 to buy Coupon Queen [Cost: 9000]"  );
else
self SetHintString( "Fuse blown, replace it!" );
break;

case "specialty_rof":
if(fuse == false)
self SetHintString( &"ZOMBIE_PERK_DOUBLETAP" );
else
self SetHintString( "Fuse blown, replace it!" );
break;

default:
self SetHintString( perk + " Cost: " + level.zombie_vars["zombie_perk_cost"] );
break;

}
}



P.S. This isnt a pretty code, its just a base and it doesnt fully do everything I want it to so dont judge me! As in perk machines wont turn off, just change hint string, and I want to make perks gray out when fuse blows, and a sound to play, ect. It will be epic if I can get it to work!
Title: Re: Triggers and such
Post by: PROxFTW on June 02, 2014, 11:59:20 pm
Hintstings aren't going out as it should be if( !IsDefined( fuse ) ) // Text else // Text. I believe. Maybe try that then what you have set up. Also I believe it might have to be threaded - This is actually a yes now that I remember.
I am working on why countdown isn't working.
Title: Re: Triggers and such
Post by: HDKenny on June 03, 2014, 12:16:44 am
Hintstings aren't going out as it should be if( !IsDefined( fuse ) ) // Text else // Text. I believe. Maybe try that then what you have set up. Also I believe it might have to be threaded. However I can't remember don't have my normal pc as it stopped working so I am just throwing out ideas now.
I am working on why countdown isn't working.
Yea its stuck at 25 now :P
also I dont think it would be the !IsDefined thing because that would be if the perks were being set to default text and also one more thing i thought of, in the set string function it says "self sethint....." so would I thread the trigger of the perk machine to fix that?
Title: Re: Triggers and such
Post by: PROxFTW on June 03, 2014, 12:19:11 am
You have to get Machines = GetEntArray( "WhateverIsTheSameForThemAll", "targetname" ); Oh to get the perk from there just put Perk = Machines.script_notworthy and thread on that (Perk). Hopefully that should fix that problem. This can be found at the top somewhere of _zombiemode_perks. Also Timer I believe will get stuck if HintStings are changed to much. There should be and i in [] for Perk and Machines.script_noteworthy if you can't see them.
Title: Re: Triggers and such
Post by: HDKenny on June 03, 2014, 12:26:28 am
You have to get Machines = GetEntArray( "WhateverIsTheSameForThemAll", "targetname" ); Oh to get the perk from there just put Perk = Machines.script_notworthy and thread on that (Perk). Hopefully that should fix that problem. This can be found at the top somewhere of _zombiemode_perks. Also Timer I believe will get stuck if HintStings are changed to much.
I did this for the threading(gonna test now):
Code Snippet
Plaintext
getentarray("vending_jugg", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_armorvest", true );
getentarray("vending_doubletap", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_rof", true );
getentarray("vending_sleight", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_fastreload", true );
getentarray("vending_revive", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_quickrevive", true );

level waittill( "newFuse" );

DF("watchPerkPower() :: newFuse notified");

getentarray("vending_jugg", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_armorvest");
getentarray("vending_doubletap", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_rof");
getentarray("vending_sleight", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_fastreload");
getentarray("vending_revive", "targetname") thread maps\_zombiemode_perks::vending_set_hintstring( "specialty_quickrevive");
And damn, so like would it get stuck if it only changed once every 10 minutes? because I need it to say one that says "Press f to change" and one that says "fuse is good" or something
Title: Re: Triggers and such
Post by: PROxFTW on June 03, 2014, 12:34:07 am
I believe there is a limit. If I remember correctly others may have had problems and it is something to do with the engine. But yah the threading should be like this. Sorry for all the confusion. Don't have sublime or any of the WAW codes or gsc in front of me until I get a new pc or get mine fixed. But try
Code Snippet
Plaintext
Machines = GetEntArray = ( "CantRemember this but at the top of _zombiemode_perks there is a thing vender_trigs that is this targetname", "targetname" );
Then to get the script_noteworthy do
Code Snippet
Plaintext
for( i = 0; i < Machines.size; i++ )Notworthy[i] = Machines[i].scipt_noteworthy
then thread on
Code Snippet
Plaintext
Notworthy[i]
Example
Code Snippet
Plaintext
for( i = 0; i < Notworthy.size; i++ ) Notworthy[i] thread maps\_zombiemode_perks::vending_set_hintstring( Notworthy[i], true );
Title: Re: Triggers and such
Post by: HDKenny on June 03, 2014, 12:50:49 am
I believe there is a limit. If I remember correctly others may have had problems and it is something to do with the engine. But yah the threading should be like this. Sorry for all the confusion. Don't have sublime or any of the WAW codes or gsc in front of me until I get a new pc or get mine fixed. But try
Code Snippet
Plaintext
Machines = GetEntArray = ( "CantRemember this but at the top of _zombiemode_perks there is a thing vender_trigs that is this targetname", "targetname" );
Then to get the script_noteworthy do
Code Snippet
Plaintext
for( i = 0; i < Machines.size; i++ )Notworthy[i] = Machines[i].scipt_noteworthy
then thread on
Code Snippet
Plaintext
Notworthy[i]
Example
Code Snippet
Plaintext
for( i = 0; i < Notworthy.size; i++ ) Notworthy[i] thread maps\_zombiemode_perks::vending_set_hintstring( Notworthy[i], true );
That gave me a syntax error :P
Thanks for the help tonight but Im really tired and cant stay up much longer so ill be on tomorrow working on it, if you think of anything tho just let me know
Title: Re: Triggers and such
Post by: PROxFTW on June 03, 2014, 12:55:15 am
Okay, this should be
Code Snippet
Plaintext
Machines = GetEntArray( "CantRemember this but at the top of _zombiemode_perks there is a thing vender_trigs that is this targetname", "targetname" );
My bad. Whenever you have time to test not in a rush to know if this works.
Title: Re: Triggers and such
Post by: HDKenny on June 03, 2014, 12:56:25 am
Okay, this should be
Code Snippet
Plaintext
Machines = GetEntArray( "CantRemember this but at the top of _zombiemode_perks there is a thing vender_trigs that is this targetname", "targetname" );
My bad. Whenever you have time to test not in a rush to know if this works.
Yea, i caught there error :P it was in the line with the for loop with Noteworthy
Title: Re: Triggers and such
Post by: PROxFTW on June 03, 2014, 01:01:03 am
Yea, i caught there error :P it was in the line with the for loop with Noteworthy
Forgot that
Code Snippet
Plaintext
;
on that line.
Title: Re: Triggers and such
Post by: YaPh1l on June 03, 2014, 10:47:50 am
Counting down seconds in a hintstring just produces way too many for WaW's limit of 48 in total. You gotta find another way to count down (HUD elem for example).

- Phil.
Title: Re: Triggers and such
Post by: HDKenny on June 03, 2014, 07:50:08 pm
Counting down seconds in a hintstring just produces way too many for WaW's limit of 48 in total. You gotta find another way to count down (HUD elem for example).

- Phil.
Ok, i can do a hud countdown but does that mean I cant change the hintstring to say "Not needed" then change to say "press *button* to change the fuse" like back and forth or would that hit a limit too, or is it just like 48 different ones?

Also I am confused with triggers :P will this do what i want, like wait till someone presses it then go to "changeFuse()"?
Code Snippet
Plaintext
blowDatFuse(){
fuse_trig = getent("fuseTrig", "targetname");
level.blownFuse = true;
DF("level.blownFuse = "+level.blownFuse);
level notify( "fuseBlow" );
fuse_trig enable_trigger();
fuse_trig sethintstring("Press and hold [&&1] to change fuse");
fuse_trig waittill("trigger");
thread changeFuse();
DF("Fuse Trigger Pushed");
}

Post Merge: June 03, 2014, 07:50:50 pm
Forgot that
Code Snippet
Plaintext
;
on that line.
lol wow, how did i miss that, i looked at that for like a minute and completely missed that :P

Post Merge: June 03, 2014, 09:36:26 pm
Updated code.
Most of it works, except it still doesn't change the hintstrings of perk machines
and also it checks for the perks I have in a different way, it checks them but even if you have the perk it doesn't save to the savedPerks array.

Here is the new way:
Code Snippet
Plaintext
takePerks(){
DF("^1Take Perks Called");
savedPerks = [];
self.perks_num = 0;
perks = [];
perks[0] = "specialty_rof";
perks[1] = "specialty_fastreload";
perks[2] = "specialty_quickrevive";
perks[3] = "specialty_armorvest";

//for(i=0;i<self.perk_hud.size;i++){
// self.savedPerks[i] = self.hasPerks[i];
// DF("self.savedPerks["+i+"] = "+self.hasPerks[i]);
//}

for( i = 0; i < perks.size; i++ ){
DF("^3Checking Perk: "+perks[i]);
if(self HasPerk(perks[i]) == true){
savedPerks[self.perks_num] = perks[i];
self.perks_num++;
DF("Perk: "+self.savedPerks[i]+" saved   :::   "+self.perks_num);
}
}

self notify("fuse");

self waittill( "giveEmBack" );

DF("^5Givin em' Back");

for(i=0;i<self.perks_num;i++){
self SetPerk( self.savedPerks[i] );
self maps\_zombiemode_perks::perk_hud_create( self.savedPerks[i] );
self maps\_zombiemode_perks::perk_think( self.savedPerks[i] );
wait 0.1;
DF("Perk: "+self.savedPerks[i]+" returned");
}
}
Title: Re: Triggers and such
Post by: PROxFTW on June 03, 2014, 09:53:32 pm
You are saving them in savedPerks then loading in self.savedPerks. Also it is just if self hasperk(perks) the true isn't needed
Title: Re: Triggers and such
Post by: HDKenny on June 03, 2014, 10:17:21 pm
You are saving them in savedPerks then loading in self.savedPerks. Also it is just if self hasperk(perks) the true isn't needed
yea I see the self.savedPerks but I was just testing somthing with the true, it wasnt there before.
and i think the condition in the if is returning false or something because when i have the debug on it says "checking : (perk)" but it never says the "saving perk (perk)" thing so it never gets past that
Title: Re: Triggers and such
Post by: PROxFTW on June 03, 2014, 10:29:55 pm
yea I see the self.savedPerks but I was just testing somthing with the true, it wasnt there before.
and i think the condition in the if is returning false or something because when i have the debug on it says "checking : (perk)" but it never says the "saving perk (perk)" thing so it never gets past that
The only things I can think of is remove the == true and also what is self.SavedPerks defined to as it isn't in that script so it would  not print but it would save to savedPerks. You then have it setperk to self.savedperks when according to that script you are saving to savedperks.If I can get either of my PCs working I'll show you what I mean.
Code Snippet
Plaintext
takePerks(){
DF("^1Take Perks Called");
savedPerks = []; // What your array is set to
self.perks_num = 0;
perks = [];
perks[0] = "specialty_rof";
perks[1] = "specialty_fastreload";
perks[2] = "specialty_quickrevive";
perks[3] = "specialty_armorvest";
// I use strTok for stuff like ^ but personal preference

//for(i=0;i<self.perk_hud.size;i++){
// self.savedPerks[i] = self.hasPerks[i];
// DF("self.savedPerks["+i+"] = "+self.hasPerks[i]);
//}

for( i = 0; i < perks.size; i++ ){
DF("^3Checking Perk: "+perks[i]);
if(self HasPerk(perks[i])){
savedPerks[self.perks_num] = perks[i]; // SavedPerks (Your current array)
self.perks_num++;
DF("Perk: "+self.savedPerks[i]+" saved   :::   "+self.perks_num); // Now it randomly uses self.SavedPerks - Where is this coming from?
// Show you proof this does work
DF("Perk: "+perks[i]);
}
}

self notify("fuse");

self waittill( "giveEmBack" ); // Also this is being notified correct?

DF("^5Givin em' Back");

for(i=0;i<self.perks_num;i++){
self SetPerk( self.savedPerks[i] ); // self.SavedPerks
self maps\_zombiemode_perks::perk_hud_create( self.savedPerks[i] ); // self.SavedPerks
self maps\_zombiemode_perks::perk_think( self.savedPerks[i] ); // self.SavedPerks
wait 0.1;
DF("Perk: "+self.savedPerks[i]+" returned"); // self.SavedPerks
}
}
Title: Re: Triggers and such
Post by: YaPh1l on June 03, 2014, 11:14:36 pm
does that mean I cant change the hintstring to say "Not needed" then change to say "press *button* to change the fuse" like back and forth or would that hit a limit too, or is it just like 48 different ones?
That would be counting as 2 for the limit. Should be fine.

- Phil.