Ok all fixed!
![[thumbs_up]](images/BBCode/smilies/thumbs_up.gif)
This new version is SP only, all FX are usable in both Cod and UO.
Here is a pic to prove it works :)

In the test map I had four tanks as targets, they all have to be destroyed for the obj1 to complete.
I was so worried about getting the final boom on the last tank that I forgot to get all the other tanks in the screenshot as well... LOL
To make it work from your own map gsc you may need to alter the obj parameters to suit.
This is all I used for testing.
test map gsc
Code:
main()
{
maps\_load::main();
level thread obj1();
}
obj1()
{
//this is just a script origin near the tanks
obj1 = getent("tank_obj", "targetname");
objective_add(1, "active", obj1.origin);
//I didnt bother with a compass, just set the obj for testing
objective_current(1);
//These are the two main lines you need to worry about
//for calling the additional tank obj script.
//The tank obj script will post a level notify when all targets
//are destroyed
level thread maps\my_SP_tank_obj::main();
level waittill("Targets destroyed");
objective_state(1, "done"); //Objective 1 is done
obj1 delete(); //Delete the origin
wait(2);
iprintlnbold("Tank Objective Complete, well done!");
}
And now for the updated tank obj script:
Code:
// Single player
// Destroy Single or multiple Tanks objective script
// By Grassy
main()
{
//All effects are Cod and UO usable
level._effect["tankmetalexp"] = loadfx ("fx/explosions/tank_explosion.efx");
level._effect["smallfire"] = loadfx ("fx/fire/tinybon.efx");
level._effect["ashsmoke"] = loadfx ("fx/smoke/ash_smoke.efx");
level._effect["steam"] = loadfx ("fx/smoke/whitesmoke_straight.efx");
//Trigger_damage triggers on the tank/s
//all targetnames MUST be "tank_trig"
//all triggers MUST target UNDAMAGED tank/s
trig = getentarray("tank_trig", "targetname");
if(isDefined(trig))
{
level.target_num = trig.size;
level.target_count = 0;
if(trig.size > 1)
{
for(a = 0 ; a < trig.size ; a++)
trig[a] thread tank_effects();
}
if(trig.size == 1)
trig[0] thread tank_effects();
thread monitor_targets();
level waittill("Targets destroyed");
}
}
monitor_targets()
{
while(1)
{
wait(0.5);
if(level.target_count == level.target_num)
{
level notify("Targets destroyed");
break;
}
}
}
tank_effects()
{
//If any of these entities are missing exit safely from the script
//Undamaged tank model targeted from it's trigger_damage
//make the model a script_model
goodmodel = getent(self.target, "targetname");
if(!isDefined(goodmodel))
return;
//Destroyed tank model targeted from Undmaged model
//make the model a script_model
destroyedmodel = getent(goodmodel.target, "targetname");
if(!isDefined(destroyedmodel))
return;
//Script origin targeted from Destroyed model
//place the origin where fx will play on tank
fxpos = getent(destroyedmodel.target, "targetname");
if(!isDefined(fxpos))
return;
//Hide the destroyed model
destroyedmodel hide();
//Get the fx origin to play effects on
fxpos_org = fxpos getorigin();
//Define a few variables
hit_count = 0;
level.fx = true;
//Loop until damage level reaches 90 then exit loop
while(1)
{
//waits here for each hit on the trigger
self waittill("trigger");
//Increment the variable hit_count by 30
//this is for panzerfaust hits as they will cause a lot of damage each hit
//and three hits should be enough to kill a tank
hit_count += 30;
//When the hit_count reaches 30 play a small smoke fx
if(hit_count == 30)
{
thread loopfx("ashsmoke", fxpos_org, 0.5, 1);
}
//When hit_count reaches 60 increase the fx a little more
if(hit_count == 60)
{
//level.fx = false;
//wait(0.5);
//level.fx = true;
thread loopfx("steam", fxpos_org, 0.5, 1);
thread loopfx("smallfire", fxpos_org, 0.3, 1);
}
//When we get to 90 play a nice BOOM!
//then delete the goodmodel and show the damaged one
//and exit the main loop, trigger is still there but dosn't do anything
if(hit_count == 90)
{
wait(2);
thread loopfx("steam", fxpos_org, 0.5, 1);
playfx(level._effect["tankmetalexp"], (fxpos_org));
goodmodel delete();
destroyedmodel show();
level.target_count += 1;
break;
}
}
}
loopfx(fxId, fxPos, waitime) {
if( (!isDefined(fxPos)) || (!isDefined(fxId)) )
return;
if(!isDefined(waitime))
waitime = 1;
while (level.fx) {
playfx(level._effect[fxId], fxPos);
wait (waitime);
}
}
In the editor:
You only need to add targetnames to the triggers (trigger_damage) themselves, all the rest will adopt their own targetnames when they are targeted.
Order of targeting:
[trigger]----->[goodmodel]----->[destroyed model]------>[script origin]----->[info null]
The tank models I used for testing were:
Good model
xmodel/static_vehicle_tank_tiger
Destroyed model
xmodel/static_vehicle_tank_tiger_d
Good luck with it, I hope you all find it useful.
Grassy
edited on Feb. 10, 2007 11:56 pm by WHC_Grassy