MODSonline Subscriptions
View in iTunes
Please help us to raise in the ranks of podcasting and subscribe to our itunes feed using the link above.
The next MODSonair show will air LIVE on:
03/21/2010 12:03 EDT

Time remaining:
We Dontated to PixelEquity
"Mod or modification is a term generally applied to PC games, especially first-person shooters, RPGs and real-time strategy games." 2
 
Site News   |   Aggregated News   |   Forums   |   Tutorials   |   Downloads   |   Projects   |   Weblinks
Latest Forum Threads 
CoD4 Scripting.. Posts: (3) Views: (14) by Samuel033
General.. Posts: (1) Views: (12) by Morphisnb
CoD4 SP Mapping.. Posts: (8) Views: (104) by voidsource
CoD4 Map + Mod R.. Posts: (29) Views: (205) by sam_fisher3000
CoD4 MP Mapping.. Posts: (22) Views: (468) by DeekCiti
CoD2 MP Mapping.. Posts: (8) Views: (52) by Infern4ll
CoDUO Mapping.. Posts: (3) Views: (33) by Fawlty
CoDUO Mapping.. Posts: (4) Views: (27) by morgawr
CoD4 Map + Mod R.. Posts: (2) Views: (45) by Hajas
CoD4 Map + Mod R.. Posts: (6) Views: (495) by tomv8
Back to Home Page
MODSCON 2010 L4D2 Contest
Art of War Central
 
Forums
MODSonline.com Forums
 

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 MP Mapping
CoD 4 mapping and level design for multiplayer.
Moderators: foyleman, Foxhound, StrYdeR, techno2sl, batistablr, Welshy, Rasta, supersword, batistablr, playername, NovemberDobby
Latest Posts
Subscribed Posts
Search
Restricted Access Restricted Access
Page
Next Page
subscribe
Author Topic: Destroyable target
glitch10k
General Member
Since: May 26, 2008
Posts: 14
Last: Feb 13, 2010
[view latest posts]
Level 1
Category: CoD4 MP Mapping
Posted: Sunday, Feb. 7, 2010 09:19 pm
Hey, I'm trying to put a destroyable target into my "range" map...I have an idea of cutting the body size target into smaller squares and have the squares disappear when triggered by damage like bullet holes. I would also like the all squares to respawn back after a minute or so to make a new target...can anyone point me in the right direction of how to do this? thx
cskiller86
General Member
Since: Nov 23, 2009
Posts: 180
Last: Mar 16, 2010
[view latest posts]
Level 4
Category: CoD4 MP Mapping
Posted: Monday, Feb. 8, 2010 05:45 am
I don't know how advanced you are with mapping and scripting, so if there's something you don't understand feel free to ask.

Well, you could make it so the target is made of a few squares as script_brushmodel (actually, squares with jagged and irregular edges), and each of it would have its own trigger_damage. Don't make too many squares because it could impact on PC performance.
Name the trigger_damage: target_trigger and then connect each trigger to its corresponding script_brushmodel (this is important !!!).
Also, I suggest the target to be renewed when you press a button. Maybe a plaster wall could come down in front of the target, so you don't see when the pieces reappear (for realism). If you like this idea, tell me and I'll change the script.

As for script it would be something like:
Code:
main()
{
breakfx = loadfx ("misc/somefx"); //insert fx name and path here; you need an FX to cover the disappearing of the brush 
piece_trigger = getentarray("target_trigger", "targetname");
for(i=0; i<piece_trigger.size;i++)
   piece_trigger[i] thread break(breakfx);
}

break(breakfx)
{
piece_damage = 0;
piece_health = 10;
piece_broken = 0;
while(!piece_broken)
  {
self waittil("damage", amount);
piece_damage+=amount;
if (piece_damage>piece_health)
    {
     piece_broken = 1;
     self.target hide();
     self hide();
     wait 60; //waits for 60 secs before the pieces reappear
     self.target show();
     self show();
    }
  }
playFX(breakfx, self.origin);
//you could also play a sound everytime you hit the target
//self playsound("target_break");
}
glitch10k
General Member
Since: May 26, 2008
Posts: 14
Last: Feb 13, 2010
[view latest posts]
Level 1
Category: CoD4 MP Mapping
Posted: Monday, Feb. 8, 2010 10:47 pm
Tried out your code. don't know what i did wrong but kept getting a bad syntax...i'm kinda new to scripting to think you could simplify it a little.. maybe without sound and just the basics to build on. thx
[ZCT]Titan
General Member
Since: Feb 23, 2009
Posts: 112
Last: Feb 8, 2010
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 MP Mapping
Posted: Monday, Feb. 8, 2010 11:18 pm
Well the sound is already commented out. Make sure you gave the right targetname to the trigger and script_brushmodels.
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 838
Last: Mar 16, 2010
[view latest posts]
Level 7
Category: CoD4 MP Mapping
Posted: Monday, Feb. 8, 2010 11:37 pm
glitch10k writes...
Quote:
Tried out your code. don't know what i did wrong but kept getting a bad syntax...i'm kinda new to scripting to think you could simplify it a little.. maybe without sound and just the basics to build on. thx


You should post the line number or at least what "bad syntax" is causing the problem.

Press ( SHIFT + tilde ) to look at the full console.
glitch10k
General Member
Since: May 26, 2008
Posts: 14
Last: Feb 13, 2010
[view latest posts]
Level 1
Category: CoD4 MP Mapping
Posted: Monday, Feb. 8, 2010 11:55 pm
What should I name the script_brushmodels?
glitch10k
General Member
Since: May 26, 2008
Posts: 14
Last: Feb 13, 2010
[view latest posts]
Level 1
Category: CoD4 MP Mapping
Posted: Monday, Feb. 8, 2010 11:58 pm
It says:

"script compile error
bad suntax
piece_trigger thread break(breakfx);"
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 838
Last: Mar 16, 2010
[view latest posts]
Level 7
Category: CoD4 MP Mapping
Posted: Tuesday, Feb. 9, 2010 12:04 am
You have to use the code button to copy code or it gets messed up, that's why your line in Italic, which is why we use the code box. [biggrin]

I don't know if it is because of those quotes or not at the end of that statement, but I would just copy the original code he has up there and try again.
glitch10k
General Member
Since: May 26, 2008
Posts: 14
Last: Feb 13, 2010
[view latest posts]
Level 1
Category: CoD4 MP Mapping
Posted: Tuesday, Feb. 9, 2010 12:16 am
I don't know what the problem is but Ive changed my mind and ill use a model for the target...think you could throw out some code to make it do a 90 degree fall when shot?
cskiller86
General Member
Since: Nov 23, 2009
Posts: 180
Last: Mar 16, 2010
[view latest posts]
Level 4
Category: CoD4 MP Mapping
Posted: Tuesday, Feb. 9, 2010 05:35 am
What model will you use ?

Anyway, turn each of the models into script_model (you don't have to name them).
Next, for each of the targets, create a trigger_damage named trigger4target that has about the same dimensions as the target.
Next, connect each trigger to its corresponding script_model (first select trigger, then the target and press W).

Code:
main()
{
target_trigger = getentarray("trigger4target", "targetname");
for(i=0; i<piece_trigger.size;i++)
   target_trigger[i] thread targetdown();
}

targetdown()
{
target_damage = 0;
target_health = 10;
target_down = 0;
while(!target_down)
  {
self waittil("damage", amount);
target_damage+=amount;
if (target_damage>target_health)
    {
     target_down = 1;
     self.target rotateroll(90, 1);
     self hide();
     wait 60; //waits for 60 secs before the target pops back up
     self.target rotateroll(-90, 1);
     self show();
    }
  }
}
NOTES: - depending on the targets' rotation on the UP axis, you may have to use rotatepitch instead of rotateroll in these lines
Code:
    self.target rotateroll(90, 1);

    self.target rotateroll(-90, 1);


- the same applies to the angle; if your target falls towards you, then you'll have to switch 90 with -90 in the first line, and -90 with 90 in the second one

- if you decide to use brushes to make your target, then you'll need to add an origin brush at the base of the target, select all the pieces and that origin brush and transform them into script_brushmodel (models rotate on their own center, so they don't need an origin brush)
Restricted Access Restricted Access
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 MP Mapping