OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: mad_addons on 03 Aug 2005, 05:10:38

Title: Spawning Questions
Post by: mad_addons on 03 Aug 2005, 05:10:38
Hi all,

I was working on the OnSingleMapClick with CreateUnit, and I've come to several problems.. due to lack of my intelligience.

First, how do you set up a position on the location you clicked using OnSingleMapClick? For example, moving the game logic to that clicked area. If possible, could anybody tell me the syntax for this?

Is there a way to delete the dead bodies so that I can keep spawning units regardless of 64 group cap?

If you could answer those questions, I'd appreciate it.
Title: Re:Spawning Questions
Post by: RujiK on 03 Aug 2005, 17:24:51
onMapSingleClick {"SoldierEB" createUnit [_pos,group player]}

_pos is automaticly defined when you click so all you need to do is stick this in the init, however you will be able to create endless guys with this so it will need more work depending upon what you intend to do.

To delete bodies just give killed event handlers and the deletevehicle command for the scrpt.
Title: Re:Spawning Questions
Post by: mad_addons on 03 Aug 2005, 18:47:52
Okay, I'll get working on it.
Also, when I put init for soldiers I create on the script, it doesn't seem to work? Is it not supposed to?

I appreciate your help, RujiK.
Title: Re:Spawning Questions
Post by: Triggerhappy on 04 Aug 2005, 03:10:03
yes, it is very much supposed to work, and does, flawlessly, when used with correct syntax/commands etc

perhaps you could post your createunit code
Title: Re:Spawning Questions
Post by: mad_addons on 04 Aug 2005, 04:08:39
Uh.. I erased it just few hours ago.. sorry..

Okay, now I know that init works... Another question.

I was looking into another thread and I saw something with _alt and _shift in the field. Are these automatically applied to OnSingleMapClick or do I have to set them up?
Title: Re:Spawning Questions
Post by: mad_addons on 04 Aug 2005, 20:09:06
uh... anyone? sorry, but i really need to get this done as soon as possible.
Title: Re:Spawning Questions
Post by: mad_addons on 04 Aug 2005, 20:48:27
Sorry, but i have another thing to say.

OnMapSingleClick {"OfficerW" createunit [_pos, west1, "this addeventhandler ["killed", {deletevehicle this}]"]}

That is my code. When I try to execute it, it says. Unknown operator "killed". Why's that?
Title: Re:Spawning Questions
Post by: Triggerhappy on 05 Aug 2005, 03:43:50
because ofp doesn't read quotes the way you would. it sees this:

OnMapSingleClick {"OfficerW" createunit [_pos, west1, "this addeventhandler ["killed", {deletevehicle this}]" ]}

the curly brackets( { ) can be used instead of quotes, and will always work the way you want it to
Title: Re:Spawning Questions
Post by: Sui on 08 Aug 2005, 12:54:06
Yeap... that's about the size of it.

Back in the day before curly brackets came into OFP, we used to have to use a set of double quotes. It could get very confusing, but to cut a long story short this line should work for you:

OnMapSingleClick {"OfficerW" createunit [_pos, west1, "this addeventhandler [""killed"", {deletevehicle this}]"]}

Any set of quotes that's already inside a set of quotes needs to have two quotes. It gets even more fun using foreach commands... eg.

"_x setbehaviour ""Combat""" foreach units group

The 3 quotes at the end can really throw you off a bit ;)
Title: Re:Spawning Questions
Post by: macguba on 10 Aug 2005, 20:48:44
#Bump
Title: Re:Spawning Questions
Post by: Triggerhappy on 12 Aug 2005, 03:50:08
lol why? is this problem coming up a lot recently?
Title: Re:Spawning Questions
Post by: Planck on 12 Aug 2005, 03:59:42
Quote
lol why? is this problem coming up a lot recently?

Not really, but due to the large number of topics shunted back and forth from Advanced and General, recent posts were bumped back to the top.  

 ;D ;D

Planck
Title: Re:Spawning Questions
Post by: Triggerhappy on 12 Aug 2005, 04:07:02
ahhh
i noticed that topics had been moved around. i know this is getting offtopic but is there any particular reason why?
(My curiousity is exploding!! lol)
perhaps i should pm you instead. if so, go ahaed and delete this post or i will...or something
Title: Re:Spawning Questions
Post by: macguba on 12 Aug 2005, 15:47:33
Quote
is there any particular reason why?
Yes.    

Read this new sticky post. (http://www.ofpec.com/yabbse/index.php?board=8;action=display;threadid=25061)  ;)


PS - it's very rare that posts are deleted.   Questions about why something is happening at OFPEC, or suggestions about how it could be done better, are always welcome.