Jump to content
Sign in to follow this  
PiNs_Da_Smoka

CreateUnit Bug/Missing function

Recommended Posts

Ok. I know people have had problems with CreateUnit before. But, i've seen it die down, i think they all pretty much got the point. But there is still one thing wrong with the command. They don't respond to given names. Let me elaborate if you don't know what i'm talking about. This is the syntax i am using:

guy1="SoldierWB" CreateUnit [getpos player, groupalpha]

I mean, the guy creates in my group at my position just fine and dandy. But, they don't respond to there given name. Say i have a script with a whole bunch of dynamic directions, they won't work because the game doesn't realize thier names. This is very frustrating, this command is very important to the MOD i am working on (Enduring Fantasy/RPG - plug plug) I BEG BIS/Codemasters, whichever, to tweak this command a little. I know many other people that are frustrated with this command. As a fellow OFPEC member said, "Don't release half-assed commands and expect us to put them to good use." mad.gif This would be a great improvement to the command if you actually did something about it. Thank you very much. :thumbsup:

                           PiNs_Da_Smoka

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">guy1="SoldierWB" CreateUnit [getpos player, groupalpha]<span id='postcolor'>

If you will check our command reference, you will see createUnit is not returning any value, while createVehicle does return newly created object. This is because createUnit is internally very different and unit "name" is not known by the time it is called, but later.

Possible way how to give unit a name is to use init line "unitName=this" in init field of createUnit argument array like this:

"SoldierWB" createUnit [getMarkerPos "barracks", groupAlpha, "soldier2=this"]

Unfortunatelly this currently does not work due to bug in createUnit implementation, but this bug will certainly be fixed in next patch available, and you will be able to use it.

Share this post


Link to post
Share on other sites

Inq = "SoldierWlaw" createUnit [(getpos a select 0),(getpos a select 1)] setIndentity "InqWiper"

Shouldn´t that give the unit the name "InqWiper" ?

Then I tried "InqWiper setdammage 1" in a trigger and nothing happend.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (InqWiper @ Feb. 11 2002,13:42)</td></tr><tr><td id="QUOTE">Inq = "SoldierWlaw" createUnit [(getpos a select 0),(getpos a select 1)] setIndentity "InqWiper"

Shouldn´t that give the unit the name "InqWiper" ?

Then I tried "InqWiper setdammage 1" in a trigger and nothing happend.<span id='postcolor'>

No, it should not. The statement you write here contains several errors.

Most important is createUnit does not return anything (or more precisely, it returns nothing - i.e. object of type nothing). If you will pass this nothing as left argument to setIndentity, it will be triggered as error and expression evaluation will abort

Share this post


Link to post
Share on other sites

If you really need to refer to a created unit, what about something like:

"SoldierWB" createUnit [getMarkerPos "barracks", groupAlpha]

soldier2 = (units groupAlpha) select ((count units groupAlpha)-1)

Couldn't you then use the soldier2 var to do the stuff you want?

Share this post


Link to post
Share on other sites

The soldier was created but I couldnt kill him with setdammage. So if the soldier is created, should the setIdentity give him the name ?

setIdentity SoldierOne

I also tried creating a soldier in the editor by placing him without using createvehicle, just the normal way. I gave him the name "a" and made a trigger activated by radio alpha

condition: this

On activation: a setIdentity b

then I made a trigger activated by radio bravo and

b setdammage 1

Nothing happend, but then I changed it to setdammage a and the unit was killed.

So it seems like the name of the unit isnt changed, have I missed the point with this function? Isn´t this the way it is supposed to work, to change the name of units?

Share this post


Link to post
Share on other sites

" should the setIdentity give him the name ?

setIdentity SoldierOne "

No, because the command setIdentity need the "person" (which is an Object, check the command reference) to work,

if the createunit command does return "Nothing" and not an "Object", using your syntax you just give that identity to "Nothing"... so you maybe would kill "Nothing" with setdammage command....

There is also another big bug you are in:

a setIdentity b

is Incorrect, because b is not an "identity" (check the command reference... "identity" is a STRING)

in the way you use b it seem to be any undeclared variable,

and an undelared variable would work only as leftvalue of the command "="

bye!

smile.gif

Share this post


Link to post
Share on other sites

Because a group in ofp is an array you can select a unit to get him to do something

------------------------------

e.g.

units alpha select 0 commandmove....etc...etc

------------------------------

If you know the groupname and the the number of the unit you can order it around.

similarly you can get the group to move with....

-----------------------------

alpha move house1

-----------------------------

hope this helps

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Possible way how to give unit a name is to use init line "unitName=this" in init field of createUnit argument array like this:

"SoldierWB" createUnit [getMarkerPos "barracks", groupAlpha, "soldier2=this"]

Unfortunatelly this currently does not work due to bug in createUnit implementation, but this bug will certainly be fixed in next patch available, and you will be able to use it.

<span id='postcolor'>

This problem is fixed in 1.45 and later. If you want to remmember an unit created via createUnit give in some variable, use following construct:

TypeName createUnit [position, group, "variableName=this"]

Share this post


Link to post
Share on other sites

yea i ran into that prob when i was messin with the map editor i couldnt get that right

Share this post


Link to post
Share on other sites

Ok, maybe Im just an idiot but I still cant get it to work using 1.46.

I have tried this one that U had posted.

"SoldierWB" createUnit [getMarkerPos "barracks", groupAlpha, "soldier2=this"]

Nothing happens.

I also tried alot of other things but Im not gonna put every thing Ive tried here because it doesnt work so its no use.

All I have been told is that Im doing it wrong, can someone plz tell me how to do it right ?

Plz test it for Urself so U know it works before telling me how to do, then copy and paste here plz. Some people post what they think is the right way without trying first.

Example of a thing people post when not testing first.

"This is the way you put weapons into boxes: this addweapon "m16,10"". Or something like that.

Plz help I wanna get this right, I tried the first time in 1.40 and I think its about time I get it to work.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">"SoldierWB" createUnit [getMarkerPos "barracks", groupAlpha, "soldier2=this"]

Nothing happens.<span id='postcolor'>

If nothing happens (i.e. unit is not created), I would check first if:

- is groupAlpha defined? If yes, how?

- is marker "barracks" defined?

Share this post


Link to post
Share on other sites

First off, i would like to thank Suma and all the other OFP programmers that have fixed this problem that plagued me for so long. I can now finish many projects that depend on this single command to be finished.

@InqWiper

Is the group defined with:

groupalpha = group this

And, did you actually place the marker. Not calling you stupid, but i forget things like that all the time. biggrin.gif

@Suma or other OFP programmers

I have tried to define the group leader with a game logic. And that works fine. They spawn where i tell them, and run to the game logic with no problem. But, they don't follow orders i give to them in a script for the life of me. I was wondering:

1. If you have even thought of this yourselves, what did you do to make this possible???

2. Are game logics not equipped to be performing such a task as being a group leader.

3. If this is not supposed to be used with game logics, is there anyway you can implement this into the next patch, which i am guessing will be "Resistence", but i could be wrong.

Thanks alot for your time. You guys do a great job at what you are doing. I know you have gotten alot of flaming from the community for your recent "decisions". But, there are people on your side, such as my self. Being an OFP Editing Center staff member, i have freedom to post news as it comes. I was the one to break the Oxy news to the OFPEC community that didn't already know. I had a few opinions in there that made alot of people mad because i agreed with you. I hope that you don't take everyones mis-directed anger in a bad way, and that you don't turn on the community. I doubt you would do that, but i understand what you are going through can be frustrating. Just know, that out of the 99% of people that are angry and are thinking about boycotting OFP and BIS/Codemasters (what dickless morons they are) there is a 1% that is behind you. Once again, thanks for your time and patience with the whole OFP community.

                          PiNs_Da_Smoka

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">2. Are game logics not equipped to be performing such a task as being a group leader.

<span id='postcolor'>

It was never intended to be used this way. You can get interesting results when using game logic instead of normal units, but do not be surprised if soemthing does not work as you wish. The game logic is handled as separate side and this brings some limitations in it.

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">3. If this is not supposed to be used with game logics, is there anyway you can implement this into the next patch, which i am guessing will be "Resistence", but i could be wrong<span id='postcolor'>

I am not sure what exactly are you reqesting to be implemented? What exactly do you need - and what benefits would it have?

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Just know, that out of the 99% of people that are angry there is a 1% that is behind you.<span id='postcolor'>

We are aware there is much more than 1 % of users that agrees or at least understands what we have done, but those who do not are much louder in expressing their feeling - which is understandable.

Share this post


Link to post
Share on other sites

Ok, i guess just plain out asking for that to be implemented was pretty stupid. tounge.gif But, would there be a way to give game logics properties like regular units. I don't know exactly the properties of game logics as they stand now, but i would GUESS that it would be possible to tweak them a little. I am no programmer, although i am getting into the whole game programming world very soon. The benefits, well....I know alot of people that use this command, wheter it be in SP or MP. And most of them complain that they have to use and actual object to do this, which can sometimes be annoying. Say for example:

You are making an MP map. You attack a base and overtake it. But, you want another wave to come in. But, if you have units sitting over the next hill, and have them come in, or even place them far away on the map, and use "setpos", that can cause lag. So, you decide to use CreateUnit in place of those options. But, you don't want to use an actuall object. So, you use a game logic to take the place to reduce lag as much as possible. But, when using it the units won't respond to orders, and will just stand at the game logic. I mean, you could place the game logic in the base, but how realistic would that be to have them just appear out of nowhere??? It would add alot more freedom when using that command to make choices like this to be used.

Also, a more specific example in my case. I am the Co-Leader of Operation-X, a small MOD team making an RPG style mod called "Enduring Fantasy". We have literally changed the whole gamplay aspect of OFP. It still has the military sim aspect by all mean, we just added a few perks such as spells, dialogue choices, buy/sell system and other goodies. The thing about "Enduring Fantasy" is that it is not a campaign. It is one BIG mission where you will have to buy saves. And, as you could imagine, we are having all the missions in one level. Although, with the implementation of the latest patch, we have been able to use CreateUnit to re-construct a few of the missions to cut down lag. But, we would like to reduce it even more. And this would mean taking out those units that are sitting there waiting for a group to be created with them to be a part of the next mission. To do this, we tried gamelogics, but as you know, that didn't work. And cutting down on every possible un-necessary unit would be a life saver.

But, you know and i know that is just one example for a small MOD team. And i doubt that would make you take time to add something all new to a patch. But like i said before, i know alot of people that have tried this, and would like for it to be implemented into a patch. But, i still doubt that it would be a high priority fix, just a perk i would guess. I still beg that it be put in there biggrin.gif

Also, i know there is a bigger percentage than that of people that are behind you. And you are right, the ones that disagree do make themselves heard a little more. But, from what i have seen, the ones that disagree out-weigh the ones that do. But still, don't let it get you down. You know people still support you and this great game. I would hope that brings a smile to your face.

Once again, i love what you guys are doing. Thanks for your help and time.

PiNs_Da_Smoka

Share this post


Link to post
Share on other sites

I have a marker named "barracks".

I created a group and in the officers init field i typed :

groupAlpha = groupthis

And the other stuff I told you earlier.

Share this post


Link to post
Share on other sites

I am sorry to be this picky, but you made a typo  - you are missing space in group this. I do not know if you made it now or when editing the mission, therefore I point it now here:

You wrote:

 groupAlpha = groupthis

You should have

 groupAlpha = group this

If nothing else helps, be sure to start with following simple examples:

1) "SoldierWB" createUnit [getpos player, group player]

2) "SoldierWB" createUnit [getpos player, group player, "soldierXX2=this"]

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (PiNs_Da_Smoka @ Mar. 07 2002,09:25)</td></tr><tr><td id="QUOTE">So, you decide to use CreateUnit in place of those options. But, you don't want to use an actuall object. So, you use a game logic to take the place to reduce lag as much as possible. But, when using it the units won't respond to orders, and will just stand at the game logic.<span id='postcolor'>

This solution contains one problem: each group belongs to some side. This is very important, all groups of the same side share some information.

When you create units into game logic group, nothing of this may work, as the group side is wrong.

I think there might be different solution:

What about creating an empty group? This may sound strange, but it is not that difficult. You can insert single soldier, and in his init field you can do:

groupAlpha = group this; deleteVehicle this

I did not test it, but it should result in an empty group stored in groupAlpha variable.

Share this post


Link to post
Share on other sites

that crashes

creating the empty group returns no error

but trying to spawn a soldier in does

i always use this way:

i place a dummy unit somewhwere on the map, where i spawn the soldier to

then i just reassign him to GrpNull

Sold=_Stype createUnit [getPos palyer, group dummy ,""]

Soldat=(units (dummy) select 1)

[soldat] join GrpNull

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">that crashes

creating the empty group returns no error

but trying to spawn a soldier in does

<span id='postcolor'>

I tested it before writing - no crashes here (version 1.46). I think it would crash in 1.42.

Share this post


Link to post
Share on other sites

ok, this really works !

thx

my fault was to let the actions run in 2 different init lines at the same time ( so i think the group was createt a millisecond after the soldier spawned in)

Share this post


Link to post
Share on other sites

Suma, you're the man....simple as that biggrin.gif Thanks for your help on this subject. This will help out my mod SO MUCH!!!! If i could give you a kiss, i would tounge.gif Keep up the damn fine work man.

PiNs_Da_Smoka

Share this post


Link to post
Share on other sites

One more thing: remmember group are precious resource. You can have only 27 on any side. Be sure to recycle them as often as possible. Group once created will be never destroyed.

Share this post


Link to post
Share on other sites

HHHHmmm.....that poses a little problem. I wish i could sit here and suggest to try something, but i'm shot. Damn, well....now is the time i ask for something to be implemented in to a patch. How about a small command called "Groupdestroy" or something like that. More then just my reasons, i know alot of people that like to make HUGE battles, but are frustrated by the amounts of groups allowed at one time. This, i see, could be a very useful command if implemented. Like i said, it would benefit more then one group of people. The large battles that people want so bad could finally be created.

Say, you are one of the people building one of those huge battle maps. But, you are still limited by the group numbers. So, you simply make the amount of groups you can, let the battle insue, and such. Then, when certain waves of soldiers are killed, you can destroy their groups and create a whole new one to keep the battle going.

Just a small example, but that is one of the major ways that would be used. I think this is one thing you may really want to pop in a patch. Like i said, i am no programmer and don't know how much trouble would go into it, but i think it would be very helpful. Thanks for listening to my jabber once again biggrin.gif

PiNs_Da_Smoka

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×