everybody needs help once in a while...

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

everybody needs help once in a while...

Post by nuggets »

ok, i've created a few of my own global scripts so when we release the map, making future maps will already have the scripting done... sound like a good idea... well yeah but somethings going wrong...

all is working 100% except for 1 small thing...

1stly though the scripts...
nuggets_obj_documents.scr
//*********************\\
// GET THOSE DOCUMENTS \\
// version 1.0 NUGGETS \\
//*********************\\

main level.stealers level.item level.vary_doc level.min_doc:
level.documents_taken = 0
$documents show
$documents solid
//// START OF ERROR HANDLER \\\\ ------
if ($documents.size == 0)
{println "no documents in map, or targetnames incorrect"
end}
level.docdebugcount = 0
for (local.i=1;local.i <= $documents.size;local.i++)
{if ($documents[local.i].here == NIL)
{println "documents without 0 set as #here"
println "origin = " $documents[local.i].origin
level.docdebugcount++}}
if (level.docdebugcount > 0)
{end}
if ((level.vary_doc == NIL) || (level.min_doc == NIL))
{println "no document amounts set"
println "maximum options set"
level.vary_doc = $documents.size;level.min_doc = 1}
if ((level.vary_doc + level.min_doc) > $documents.size)
{println "amend random values, options too high"
println "maximum options set"
level.vary_doc = $documents.size;level.min_doc = 1}
if !((level.stealers == "allies") || (level.stealers == "axis"))
{println "stealing force not determined correctly"
println "should be set to ''allies'' or ''axis''"
println "choosing allies"
level.stealers = "allies"}
if (level.item == NIL)
{println "no item name selected"
println "amending to papers"}
//// END OF ERROR HANDLER \\\\ ------
if (level.stealers == "allies")
{level.protectors = "axis"}
if (level.stealers == "axis")
{level.protectors = "allies"}
level.total_documents = (randomint(level.vary_doc) + level.min_doc)
level waittill spawn
level.docs_selected = 0

thread the_unhidden
end

/////////////////////////
//___the preperation___//
/////////////////////////

the_unhidden:
local.number = (randomint($documents.size) + 1)
if ($documents[local.number].here == 0)
{$documents[local.number].here = 1
level.docs_selected++
if (level.docs_selected == level.total_documents)
{goto which_to_hide}
else
{wait .001
goto the_unhidden}}
else
{goto the_unhidden}
end

which_to_hide:
for (local.doc=1;local.doc<=$documents.size;local.doc++)
{if ($documents[local.doc].here == 0)
{$documents[local.doc] hide
$documents[local.doc] notsolid}
else
{level.doc_name = ("documents_triggers" + local.doc)
spawn trigger_use "targetname" level.doc_name "#doc_num" local.doc "setthread" "scripts_of_nuggets/nuggets_obj_documents.scr::documents_theft"
level.doc_name.origin = $documents[local.doc].origin
level.doc_name.angles = $documents[local.doc].angles
level.doc_name nottriggerable}}
end

/////////////////////
//___the working___//
/////////////////////

documents_theft:
local.player = parm.other
if (local.player.dmteam == level.stealers)
{$documents[self.doc_num] hide
$documents[self.doc_num] notsolid
self nottriggerable
self thread scripts_of_nuggets/nuggets_rand_obj.scr::all_obj_off
level.documents_taken++
thread is_that_the_lot}
if (local.player.dmteam == level.protectors)
{iprintlnbold_noloc "You only need to protect the " level.item}
end

is_that_the_lot:
if (level.documents_taken == level.total_documents)
{iprintlnbold_noloc "all taken"
level.objectives_done++
level.doc_scr = 0
thread scripts_of_nuggets/nuggets_rand_obj.scr::briefing_multi_obj}
else
{iprintlnbold_noloc (level.total_documents - level.documents_taken) " more " level.item " to find!"}
end


nuggets_rand_obj.scr
//*********************\\
// RANDOM OBJECTIVES \\
// version 1.0 NUGGETS \\
//*********************\\

main level.skill level.gun_type level.planters level.bomb_time level.defuse_time level.detonate_time level.bomb_range level.vary_bomb level.min_bomb level.attackers level.item level.vary_doc level.min_doc level.area level.hold_time level.prevent_time:
level.obj_count = 0
level.objectives_done = 0
//// START OF ERROR HANDLER \\\\
if (($leader_to_die.size == 0) && ($nuggets_bomb.size == 0) && ($documents.size == 0) && ($documents.size == 0))
{println "can't establish random objective"
println "needed targetnames missing from map"}
//// END OF ERROR HANDLER \\\\
level.assassin_scr = 0
level.bomb_scr = 0
level.doc_scr = 0
level.koth_scr = 0
waitthread obj_choice
level waittill spawn
while (1)
{if (level.objectives_done == level.obj_count)
{teamwin level.attackers}
wait .25}
end

/////////////////////////
//___the preperation___//
/////////////////////////

obj_choice:
waitthread assassin
waitthread bombs
waitthread documents
waitthread koth
if (level.obj_count == 0)
{wait .1
goto obj_choice}
if (level.obj_count > 0)
{goto briefing_multi_obj}
end

assassin:
if ($leader_to_die.size > 0)
{level.assassin = 0 //(randomint(2) + 1)
if (level.assassin == 1)
{exec scripts_of_nuggets/nuggets_ai_setup.scr level.gun_type
exec scripts_of_nuggets/nuggets_obj_assassin.scr level.skill
level.obj_count++
level.assassin_scr = 1}
else
{$leader_to_die hide
$leader_to_die notsolid
$leader_to_die ai_off}}
end
assassin_obj:
iprintlnbold_noloc "assassin on"
level.ln_2 = ("Kill " + $leader_to_die.nuggets_name)
level.ln_3 = ("")
level.ln_5 = ("Protect " + $leader_to_die.nuggets_name)
level.ln_6 = ("")
end

bombs:
if (($nuggets_attack_bomb.size > 0) || ($nuggets_defend_bomb.size > 0))
{level.bombs = (randomint(2) + 1)
if (level.bombs == 1)
{exec scripts_of_nuggets/nuggets_obj_bombs.scr level.planters level.bomb_time level.defuse_time level.detonate_time level.bomb_range level.vary_bomb level.min_bomb
level.obj_count++
level.bomb_scr = 1}
else
{if ($nuggets_attack_bomb.size > 0)
{$nuggets_attack_bomb hide
$nuggets_attack_bomb notsolid}
if ($nuggets_defend_bomb.size > 0)
{$nuggets_defend_bomb hide
$nuggets_defend_bomb notsolid}}}
end
bomb_obj:
iprintlnbold_noloc "bombs on"
for (local.i=1;local.i<=$nuggets_attack_bomb.size;local.i++)
{$("nuggets_attack_bomb" + local.i) triggerable}
if (level.total_bombs > 1)
{level.ln_2 = ("Plant " + level.total_bombs + " bombs")}
else
{level.ln_2 = ("Plant 1 bomb")}
level.ln_3 = (" in the " + level.area)
level.ln_5 = ("Defuse all planted bombs")
level.ln_6 = ("")
end

documents:
if ($documents.size > 0)
{level.documents = (randomint(2) + 1)
if (level.documents == 1)
{exec scripts_of_nuggets/nuggets_obj_documents.scr level.attackers level.item level.vary_doc level.min_doc
level.obj_count++
level.doc_scr = 1}
else
{$documents hide;$documents notsolid}}
end
documents_obj:
iprintlnbold_noloc "docs on"
for (local.i=1;local.i<=$documents.size;local.i++)
{$("documents_triggers" + local.i) triggerable}
if (level.total_documents > 1)
{level.ln_3 = (level.item + "s")
level.ln_6 = (" taking the " + level.item + "s")}
else
{level.ln_3 = level.item
level.ln_6 = (" taking the " + level.item)}
level.ln_2 = ("Locate and take the " + level.total_documents)
level.ln_5 = ("Prevent " + level.attackers + " from")

end

koth:
if ($koth_trigger.size > 0)
{level.koth = (randomint(2) + 1)
if (level.koth == 1)
{exec scripts_of_nuggets/nuggets_obj_koth_mp.scr level.area level.hold_time level.prevent_time
level.objective_scr = "scripts_of_nuggets/nuggets_obj_koth_mp.scr"
level.obj_count++
level.koth_scr = 1}
else
{$koth_place hide
$koth_place notsolid
$koth_trigger nottriggerable}}
end
koth_obj:
iprintlnbold_noloc "koth on"
$koth_trigger triggerable
level.ln_2 = ("Hold the " + level.area + " for ")
level.ln_3 = (" " + level.hold_time + " seconds")
level.ln_5 = ("Prevent " + level.attackers + " from entering")
level.ln_6 = ("the " + level.area)
end

/////////////////////
//___the working___//
/////////////////////

briefing_multi_obj:
iprintlnbold_noloc level.assassin_scr level.bomb_scr level.doc_scr level.koth_scr
if (level.objectives_done < level.obj_count)
{if (level.assassin_scr == 1)
{thread assassin_obj}
else
{level.obj_num = randomint(3)
iprintlnbold_noloc "Random number of 3 = " level.obj_num

if (level.obj_num == 0)
{if (level.bomb_scr == 1)
{thread bomb_obj}
else
{level.obj_2 = randomint(2)
iprintlnbold_noloc "0 random number of 2 = " level.obj_2
if (level.obj_2 == 0)
{if (level.doc_scr == 1)
{thread documents_obj}
else
{thread koth_obj}}
else
{if (level.koth_obj == 1)
{thread koth_obj}
else
{thread documents_obj}}}}}
if (level.obj_num == 1)
{if (level.doc_scr == 1)
{thread documents_obj}
else
{level.obj_2 = randomint(2)
iprintlnbold_noloc "1 random number of 2 = " level.obj_2
if (level.obj_2 == 0)
{if (level.bomb_scr == 1)
{thread bomb_obj}
else
{thread koth_obj}}
else
{if (level.koth_obj == 1)
{thread koth_obj}
else
{thread bomb_obj}}}}
if (level.obj_num == 2)
{if (level.koth_scr == 1)
{thread koth_obj}
else
{level.obj_2 = randomint(2)
iprintlnbold_noloc "2 random number of 2 = " level.obj_2
if (level.obj_2 == 0)
{if (level.bomb_scr == 1)
{thread bomb_obj}
else
{thread documents_obj}}
else
{if (level.doc_obj == 1)
{thread documents_obj}
else
{thread bomb_obj}}}}

iprintln_noloc "******************************"
iprintln_noloc "OBJECTIVES UPDATED"
iprintln_noloc "******************************"

setcvar "g_obj_alliedtext1" ("Objective " + (level.objectives_done + 1) + " / " + level.obj_count + " ...")
setcvar "g_obj_alliedtext2" level.ln_2
setcvar "g_obj_alliedtext3" level.ln_3
setcvar "g_obj_axistext1" ("Objective " + (level.objectives_done + 1) + " / " + level.obj_count + " ...")
setcvar "g_obj_axistext2" level.ln_5
setcvar "g_obj_axistext3" level.ln_6}
end


test_bits.scr
main:
level waittill prespawn
/*
//in order
//assassin //skill level (1-5; 0=rand); bodyguard gun_type
//bombs //planters; bomb set time; defuse time; detonate time; bomb_range; variance; minimum # of bombs
//documents //stealing team; item name; variance; minimum # of items
//koth //area name; holding time; prevention time; hold type -1 axis, 0 both, 1 allies
*/
exec scripts_of_nuggets/nuggets_rand_obj.scr 1 -1 "allies" 3 3 5 512 2 1 "allies" "document" 4 2 "Town" 5 5 0

exec scripts_of_nuggets/nuggets_hudprints.scr
exec scripts_of_nuggets/nuggets_radar.scr
level waittill spawn
end


so if anyone is kind enough to have a look through these hyrogliphics, the problem is, the when the documents objective is the 1st to be called, the triggers aren't triggerable, but the objective text appears,

any other time, it'll work, why why why is it not working
Image
hope this helps, prob not cos it's all foreign 2 me :-/
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Do you have an indented version of that script? I find this one very hard to read :?
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

lol, sorry did have but it went out with the last lot of laundry :P

i've started the script again and getting to pretty much the same point now, hopefully this time though i'll have a bit more luck

if not i'll more than happily reindent everything and then you can look all you like, :D

just trying to work out a best clocktime method... :? as the objectives are random with random possibilties, should i:

a) clocktime = however long
if !obj4 clocktime = clocktime - obj4.time
if !obj3 etc...

or
b) clocktime = randomobj.time
once completed clocktime = randomobj.time

or
c) clocktime = randomobj.time
once completed clocktime = clocktime + randomobj.time

or
d) your input here please :D
hope this helps, prob not cos it's all foreign 2 me :-/
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Not sure what you mean here, is clocktime the same as a time limit?
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

yep... :D

short but straight to the point
hope this helps, prob not cos it's all foreign 2 me :-/
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

I'd say just use a constant time limit of 10 minutes or so, regardless of the number of objectives completed. Simplicity often is the best solution :wink:
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

although you right i don't think i explained the situation properly... :?

sometimes there could be 1 objective, sometimes 4, if i have a constant of 10 minutes, it'd be pretty difficult to to 4 objectives while doing 1 would be a doddle :P
hope this helps, prob not cos it's all foreign 2 me :-/
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Do I get it right when I take it this is for a map with some kind of random objectives? Like a random number of objectives per round?
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

yea, can either be an:
assassination;
bomb obj;
king of the hill;
or a theft obj,

could be 1 of the above, could be 2, or could be all of them
hope this helps, prob not cos it's all foreign 2 me :-/
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Well hard to tell without knowing the geometry of the map, but I think an initial timelimit of about 3 minutes plus 1 or so minute per objective is fair.
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

that's what i was thinking, but until play testing can be done i'll never know the final answer,

thanks for your time on this anyway. as always thanks for ur input

and SI if you read this, how's the VIS doing??? :P
hope this helps, prob not cos it's all foreign 2 me :-/
Post Reply