Page 1 of 2
Big problem with script, need help fast!
Posted: Tue Aug 02, 2005 7:57 pm
by Goldeneye090
Ok I just released my map to my clan and they were going to put it up on our server but I noticed a problem when I was just messing around on the map with my cousin. The script decides who wins based on a point value, points being obtained by the Allies for every objective they complete. There are 4 points needed for them to win. 1 point for each of the 3 documents to be stolen, and 1 point from destroying a flak canon.
Now for some reason, the allies can steal the same document over an over just by hitting the use key on the place the document was, even after it's hidden the first time. If they do it 4 times, they get 4 points and they win the battle. How do I make it so each of the three documents can only be stolen once? Here's the complete script:
Code: Select all
// Objective: Bunkers
// ARCHITECTURE: GoldenEye
// SCRIPTING: GoldenEye
main:
setcvar "g_obj_alliedtext1" "Destroy the Flak"
setcvar "g_obj_alliedtext2" "Steal the Documents"
setcvar "g_obj_alliedtext3" "Kill the Axis"
setcvar "g_obj_axistext1" "Defend the Flak"
setcvar "g_obj_axistext2" "Protect the Documents"
setcvar "g_obj_axistext3" "Kill the Allies"
setcvar "g_scoreboardpic" "loading"
level waittill prespawn
exec global/DMprecache.scr
exec global/door_locked.scr::lock
exec global/ambient.scr Obj_Bunkers
level.script = maps/obj/Obj_Bunkers.scr
level waittill spawn
$document1_trigger setthread objective1
$document2_trigger setthread objective2
$document3_trigger setthread objective3
level.obj_to_achieve = 4
level.obj_done = 0
level.bomb_damage = 200
level.bomb_explosion_radius = 640
level.defusing_team = "axis"
level.planting_team = "allies"
level.dmrespawning = 0 // 1 or 0
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = axis // set to axis, allies, kills, or draw
level waittill roundstart
// Set the parameters for round based match
level.dmrespawning = 0 // 1 or 0 (0=no respawn)
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = axis // set to axis, allies, kills, or draw
$flak88_explosive1 thread global/obj_dm.scr::bomb_thinker
$flak88_explosive1 thread axis_win_timer
thread check_if_my_bomb_exploded
end // end of main
check_if_my_bomb_exploded:
while (true)
{
if ($flak88_explosive1.exploded ==1)
{
thread bomb_obj_done
}
wait 5
}
end
bomb_obj_done:
if(level.point_added !=1)
{
level.point_added = 1
iprintlnbold "The Flak has been destroyed!"
level.obj_done++
thread win_status
}
end
objective1:
if (parm.other.dmteam == allies)//chose the team
{
$document1 hide
$document1 playsound pickup_papers1
level.obj_done++ //That will add 1 point
iprintlnbold "A document has been stolen!"
}
thread win_status
end
objective2:
if (parm.other.dmteam == allies)//chose the team
{
$document2 hide
$document2 playsound pickup_papers1
level.obj_done++ //That will add 1 point
iprintlnbold "A document has been stolen!"
}
thread win_status
end
objective3:
if (parm.other.dmteam == allies)//chose the team
{
$document3 hide
$document3 playsound pickup_papers1
level.obj_done++ //That will add 1 point
iprintlnbold "A document has been stolen!"
}
thread win_status
end
win_status:
if(level.obj_done == level.obj_to_achieve)
{
teamwin allies
}
end
//*** --------------------------------------------
//*** "Axis Victory"
//*** --------------------------------------------
axis_win_timer:
level waittill axiswin
end
Another big problem...If the allies capture all the documents and then plant the bomb on the flak, but die afterwards, the axis can let it blow up but still win because they killed all the allies...instead of the allies winning by reaching their 4-point-based objective. Anyone know how to fix both of tese problems? Thanks.
Posted: Tue Aug 02, 2005 10:33 pm
by Bjarne BZR
Code: Select all
objective3:
if (parm.other.dmteam == allies)//chose the team
{
// Add this:
$NAME_OF_TRIGGER nottriggerable
$document3 hide
$document3 playsound pickup_papers1
level.obj_done++ //That will add 1 point
iprintlnbold "A document has been stolen!"
}
end
Replace the NAME_OF_TRIGGER with, you guessed it, the targetname of the trigger in question

This way the trigger will not work after an allied has trigggered it once.
( and the same for objective 1 amd 2 )
Posted: Wed Aug 03, 2005 8:13 am
by Rookie One.pl
Bjarne BZR wrote:Replace the NAME_OF_TRIGGER with, you guessed it, the targetname of the trigger in question

Bjarne, this can be just self:
Code: Select all
objective3:
if (parm.other.dmteam == allies)//chose the team
{
// Add this:
self nottriggerable
$document3 hide
$document3 playsound pickup_papers1
level.obj_done++ //That will add 1 point
iprintlnbold "A document has been stolen!"
}
end
Re: Big problem with script, need help fast!
Posted: Wed Aug 03, 2005 8:58 am
by Bjarne BZR
Goldeneye090 wrote:Another big problem...If the allies capture all the documents and then plant the bomb on the flak, but die afterwards, the axis can let it blow up but still win because they killed all the allies...instead of the allies winning by reaching their 4-point-based objective. Anyone know how to fix both of tese problems? Thanks.
I dont have MOHAA installed because I'm on a Linux system, but take a look at the stock map "V2", because it has 2 bombs that work as you describe ( allies wins if both bombs blow even if all allies are dead ).
Posted: Wed Aug 03, 2005 2:54 pm
by Goldeneye090
Is the following script the kind of thing I need to include in my script for this to work?
Code: Select all
allies_win_bomb local.bomb1 local.bomb2:
while (local.bomb1.exploded != 1)
wait .1
while (local.bomb2.exploded != 1)
wait .1
teamwin allies
end
^^^That's from the map V2 Rocket Facility...
If so how would I make it so in my map if all the document objectives and the flak objective is done they win? Would it be this:
Code: Select all
win_status:
if(level.obj_done == level.obj_to_achieve)
allies_win_bomb local.flak88_weapon1 local.document1 local.document2 local.document3:
while (local.flak88_weapon1.exploded != 1)
wait .1
while (local.document1.stolen != 1)
wait .1
while (local.document2.stolen != 1)
wait .1
while (local.document3.stolen != 1)
wait .1
{
teamwin allies
}
end
Thanks.
Posted: Wed Aug 03, 2005 3:20 pm
by Bjarne BZR
The quickest and smothest solution I can see is this:
Instead of using the variables
level.obj_done and
level.obj_to_achieve, use the variables already used by the exploder system (
level.targets_destroyed and
level.targets_to_destroy )
Thus getting an allied victory test like this:
Code: Select all
// Allied victory test
allies_win_bomb:
// While undestroyed objectives left
while(level.targets_destroyed < level.targets_to_destroy) {
// chill out
waitframe
}
// No objectives left allies win
teamwin allies
end // end allied victory test
The good thing about this is that the exploder system will update the
level.targets_destroyed automatically once the bomb has blown, no need fort you to update it. Just add 1 to
level.targets_destroyed once a document has been stolen.
Posted: Wed Aug 03, 2005 3:34 pm
by Goldeneye090
Ok so here's the whole script:
Code: Select all
// Objective: Bunkers
// ARCHITECTURE: GoldenEye
// SCRIPTING: GoldenEye
main:
setcvar "g_obj_alliedtext1" "Destroy the Flak"
setcvar "g_obj_alliedtext2" "Steal the Documents"
setcvar "g_obj_alliedtext3" "Kill the Axis"
setcvar "g_obj_axistext1" "Defend the Flak"
setcvar "g_obj_axistext2" "Protect the Documents"
setcvar "g_obj_axistext3" "Kill the Allies"
setcvar "g_scoreboardpic" "loading"
level waittill prespawn
exec global/DMprecache.scr
exec global/door_locked.scr::lock
exec global/ambient.scr Obj_Bunkers
level.script = maps/obj/Obj_Bunkers.scr
level waittill spawn
$document1_trigger setthread objective1
$document2_trigger setthread objective2
$document3_trigger setthread objective3
level.targets_to_destroy = 4
level.targets_destroyed = 0
level.bomb_damage = 200
level.bomb_explosion_radius = 640
level.defusing_team = "axis"
level.planting_team = "allies"
level.dmrespawning = 0 // 1 or 0
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = axis // set to axis, allies, kills, or draw
// level waittill roundstart
// Set the parameters for round based match
level.dmrespawning = 0 // 1 or 0 (0=no respawn)
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = axis // set to axis, allies, kills, or draw
$flak88_explosive1 thread global/obj_dm.scr::bomb_thinker
$flak88_explosive1 thread axis_win_timer
thread check_if_my_bomb_exploded
end // end of main
check_if_my_bomb_exploded:
while (true)
{
if ($flak88_explosive1.exploded ==1)
{
thread bomb_obj_done
}
wait 5
}
end
bomb_obj_done:
if(level.point_added !=1)
{
level.point_added = 1
iprintlnbold "The Flak has been destroyed!"
level.obj_done++
thread win_status
}
end
objective1:
if (parm.other.dmteam == allies)//chose the team
{
$document1_trigger nottriggerable
$document1 hide
$document1 playsound pickup_papers1
level.obj_done++ //That will add 1 point
iprintlnbold "A document has been stolen!"
}
thread win_status
end
objective2:
if (parm.other.dmteam == allies)//chose the team
{
$document2_trigger nottriggerable
$document2 hide
$document2 playsound pickup_papers1
level.obj_done++ //That will add 1 point
iprintlnbold "A document has been stolen!"
}
thread win_status
end
objective3:
if (parm.other.dmteam == allies)//chose the team
{
$document3_trigger nottriggerable
$document3 hide
$document3 playsound pickup_papers1
level.obj_done++ //That will add 1 point
iprintlnbold "A document has been stolen!"
}
thread win_status
end
win_status:
if(level.obj_done == level.obj_to_achieve)
// Allied victory test
allies_win_bomb:
while(level.targets_destroyed < level.targets_to_destroy)
{
waitframe
}
// No objectives left allies win
teamwin allies
end // end allied victory test
{
teamwin allies
}
end
//*** --------------------------------------------
//*** "Axis Victory"
//*** --------------------------------------------
axis_win_timer:
level waittill axiswin
end
Should that work?
Posted: Wed Aug 03, 2005 3:59 pm
by Bjarne BZR
Cleaned it up a bit for you: May work
Code: Select all
// Objective: Bunkers
// ARCHITECTURE: GoldenEye
// SCRIPTING: GoldenEye
main:
setcvar "g_obj_alliedtext1" "Destroy the Flak"
setcvar "g_obj_alliedtext2" "Steal the Documents"
setcvar "g_obj_alliedtext3" "Kill the Axis"
setcvar "g_obj_axistext1" "Defend the Flak"
setcvar "g_obj_axistext2" "Protect the Documents"
setcvar "g_obj_axistext3" "Kill the Allies"
setcvar "g_scoreboardpic" "loading"
level waittill prespawn
exec global/DMprecache.scr
exec global/door_locked.scr::lock
exec global/ambient.scr Obj_Bunkers
level.script = maps/obj/Obj_Bunkers.scr
level waittill spawn
$document1_trigger setthread objective1
$document2_trigger setthread objective2
$document3_trigger setthread objective3
level.targets_to_destroy = 4
level.targets_destroyed = 0
level.bomb_damage = 200
level.bomb_explosion_radius = 640
level.defusing_team = "axis"
level.planting_team = "allies"
// level waittill roundstart
// Set the parameters for round based match
level.dmrespawning = 0 // 1 or 0 (0=no respawn)
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = axis // set to axis, allies, kills, or draw
$flak88_explosive1 thread global/obj_dm.scr::bomb_thinker
axis_win_timer
thread allies_win_test
end
check_if_my_bomb_exploded:
while ($flak88_explosive1.exploded == 0)
{
waitframe
}
iprintlnbold "The Flak has been destroyed!"
end
objective1:
if (parm.other.dmteam == allies) // chose the team
{
$document1_trigger nottriggerable
$document1 hide
$document1 playsound pickup_papers1
level.targets_destroyed++ // That will add 1 point
iprintlnbold "First document has been stolen!"
}
end
objective2:
if (parm.other.dmteam == allies) // chose the team
{
$document2_trigger nottriggerable
$document2 hide
$document2 playsound pickup_papers1
level.targets_destroyed++ // That will add 1 point
iprintlnbold "Second document has been stolen!"
}
end
objective3:
if (parm.other.dmteam == allies) // chose the team
{
$document3_trigger nottriggerable
$document3 hide
$document3 playsound pickup_papers1
level.targets_destroyed++ // That will add 1 point
iprintlnbold "Third document has been stolen!"
}
end
// Allied victory test
allies_win_test:
while(level.targets_destroyed < level.targets_to_destroy)
{
waitframe
}
// No objectives left allies win
teamwin allies
end
// Axis victory test, not a lot :)
axis_win_timer:
level waittill axiswin
end
Posted: Wed Aug 03, 2005 5:40 pm
by Goldeneye090
script didn't execute (scoreboard messages didn't show up, I couldn't set the bomb on the flak...don't know about the documents didn't try)
But the map resumed as if it were a round-based match. If the allies died the axis won...(I used my other computer for that part)

Posted: Thu Aug 04, 2005 9:03 am
by Bjarne BZR
Find the error and fix it. Here is a description on how to find it:
http://gronnevik.se/rjukan/index.php?n= ... rDetection
Posted: Thu Aug 04, 2005 1:05 pm
by Goldeneye090
The only scripting "problems" that show up ( ^~^~^ ) are the precache errors. Are these errors:
Code: Select all
sv_maxclients will be changed upon restarting.
g_gametype will be changed upon restarting.
g_gametypestring will be changed upon restarting.
cheats will be changed upon restarting.
Code: Select all
-----------PARSING 'uberdialog.scr'------------
Any SetCurrentTiki errors means that tiki wasn't prefetched and tiki-specific sounds for it won't work. To fix prefetch the tiki. Ignore if you don't use that tiki on this level.
Parse/Load time: 0.674000 seconds.
-------------PARSING 'uberdialog.scr' DONE---------------
Code: Select all
-----------PARSING 'ubersound.scr'------------
Any SetCurrentTiki errors means that tiki wasn't prefetched and tiki-specific sounds for it won't work. To fix prefetch the tiki. Ignore if you don't use that tiki on this level.
Parse/Load time: 1.853000 seconds.
-------------PARSING 'ubersound.scr' DONE---------------
Code: Select all
stitched 10 LoD cracks
...loaded 3873 faces, 90 meshes, 0 trisurfs, 0 flares
R_LevelMarksLoad: maps/obj/obj_bunkers.dcl not found
Code: Select all
------- Sound Deallocation (472) -------
Deallocating 0x 1D8 (Done)
Deallocating 0x 1D8 (Done)
Deallocating 0x 1D8 (Done)
Deallocating 0x 1D8 (Done)
Deallocating 0x 1D8 (Done)
Deallocating 0x 1D8 (Done)
// .....(472 of these)
I really don't know waht I'm looking for here...
Posted: Thu Aug 04, 2005 4:49 pm
by Bjarne BZR
Nope, none of those are errors.
Strange... i found this error, and it should be found as a scripting error in console:
...at the end of the main function ( just before "end" ), should be:
Strange, you must have missed that in the coinsole...
Posted: Thu Aug 04, 2005 5:18 pm
by Goldeneye090
Oh I think I had found that one right after you posted the new script because it's already like that for me and I didn't get that error...also there should have been another line before the end of main...
...that wasn't there either but I recently added it and now I can plant the bomb and win through the objectives again.
However, now there's another problem. After the Flak has blown up, the iprintlnbolt "The Flak has been destroyed!" doesn't activate...here's what it currently looks like:
Code: Select all
check_if_my_bomb_exploded:
while ($flak88_explosive1.exploded == 0)
{
waitframe
}
iprintlnbold "The Flak has been destroyed!"
end
What's wrong with that?
Posted: Thu Aug 04, 2005 11:15 pm
by Bjarne BZR
The guy above wrote:However, now there's another problem. After the Flak has blown up, the iprintlnbolt "The Flak has been destroyed!" doesn't activate...here's what it currently looks like:
Code: Select all
check_if_my_bomb_exploded:
while ($flak88_explosive1.exploded == 0)
{
waitframe
}
iprintlnbold "The Flak has been destroyed!"
end
What's wrong with that?
Try
Code: Select all
check_if_my_bomb_exploded:
while (!$flak88_explosive1.exploded)
{
waitframe
}
iprintlnbold "The Flak has been destroyed!"
end
instead

Posted: Thu Aug 04, 2005 11:59 pm
by Goldeneye090
Yay! It's finally done
Thanks a lot Bjarne