Jump to content
mak90_2000

1st time script attempt

Recommended Posts

greetings all

i am trying to do my first solo script, and its not going to well. i have been using this forum and the command reference to help but i still cant get my AI units to do what i want

i want solo AI units to stand up in a trench for a given time fire then lay back down. they will fire when standing in the trench, but not to the effect i want

here is my script so far

_unit = _this Select 0

#start

dostop _unit

_unit SetUnitPos "up"

_unit setCombatMode "blue"

_unit switchmove "CombatToLying"

~20.0

_unit switchmove "LyingToCombat"

_unit SetUnitPos "up"

_unit Fire [PGM_k98aB,PGM_maumag,PGM_maumag,PGM_maumag,PGM_maumag,PGM_maumag,PGM_maumag,PGM_maumag,PG

M_maumag,PGM_maumag,PGM_maumag]

~20.0

? (Alive _unit):Exit

goto "start"

they just lay in the trench now, i want the "whack a mole" effect as your team is running toward the trench

any help would be great

Mak banghead.gifhelp.gif

Share this post


Link to post
Share on other sites

Hi mak90_2000, nice to see that your script is for the WW1 mod.

I wouldn't use the "fire" command, but i'd cancel the combatmode "blue" using a "combatmode "green" (don't fire until someone in the group is fired at) or yellow (open fire)

I'd use :

the dostop command as you do, but as this command is cancelled when the group is fleeing, you should add the "allowfleeing 0" command :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{dostop _x;_x allowfleeing 0;_x disableai "target"} foreach units group _unit

The "disableai "target"" command avoids the squad leader to order any attack to its units. So the units chose themselves targets.

You don't need to use the switchmove command, just use the "setunitpos "up"" one to make them get up and the "setunitpos "down"" to make them crouch, along with the "combatmode" change.

Share this post


Link to post
Share on other sites

yeah I like the mod, except for the  NO ENTRY '.MODELSPECIAL'. error I get on the start of the missions. crazy_o.gif

I give up on this script,  all they want to do is lay in the trench, I even ungrouped the men and made each one launch the script, I even raised their inelegance level.  

now i get an error on the _unit= this select 0  line

_unit = _this Select 0

#start

{dostop _x;_x allowfleeing 0;_x disableai "target"} foreach units group _unit

_unit SetUnitPos "up"

_unit setCombatMode "red"

_unit Fire,PGM_maumag,PGM_maumag,PGM_maumag,PGM_maumag,PGM_maumag,PGM_maumag,PGM_maumag,PGM_mau

mag,P

GM_maumag,PGM_maumag]

~20.0

_unit SetUnitPos "down"

~15

? (Alive _unit):Exit

goto "start"

I think they are just lazy or they are cowards! muahahaha  j/k

I will keep searching the forums see if anyone made a "pop up" script I can use

i am just not cut out to make scripts, every several years i need to at least try

whistle.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]yeah I like the mod, except for the  NO ENTRY '.MODELSPECIAL'. error I get on the start of the missions.

Mmm, it's not because of my mod because i'm not using any "modelspecial" in the mod (modelspecial refers to some kinds of weapons, like mortars where the projectile is visible before firing).

Try the following script, place groups in the trenches but place the units where you want them to be (edit units before, and in the "special" area select "none" so that they won't be in formation at the beginning).

Launch the script by writing the following in the squad leader init area :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{[_x] exec "name_of_the_script.sqs"} foreach units group this

The script could be :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this Select 0

_unit allowfleeing 0

_unit disableai "target"

#start

dostop _unit

_unit SetUnitPos "up"

_unit setCombatMode "yellow"

~20.0

_unit SetUnitPos "down"

_unit setCombatMode "blue"

~15

? (Alive _unit):goto "start"

exit

Share this post


Link to post
Share on other sites

i'm trying to understand what is different from the script you have here, to the one i made. yours works! i want to be able to do scripts but i cant understand where i went wrong

anyhow, great effect tho. need to spread them out a bit more, adjust the time to fire, and i think it will work good

thank you my good man, for the help

yay.gifxmas_o.gif

Share this post


Link to post
Share on other sites

Your script has this command executing twice when I'm not sure it's needed:

_unit SetUnitPos "up"

Your script also is instructed to exit when the unit is still alive:

? (Alive _unit):Exit

Is this what you want?

Share this post


Link to post
Share on other sites

no i had put the ? (Alive _unit):Exit in to check if the unit was still alive

ProfTournesol helped me with this and i now have the effect i want.

i was just trying to understand how he made his work and mine failed.

thanks tho

biggrin_o.gif

Share this post


Link to post
Share on other sites

Another thing that had sorta this effect was with an animation.

Every time a unit reloaded they would crouch then reload then get back up and fire, since in the ww1 mod they use bolt rifles, they reload after each shot, so it had that whack a mole effect, together with dostop command they effectively gave the trenches a realistic vibe.

It sucks that there is no crouch command, since going from standing to prone is quite awkward for the units depending on which trench model you are using or how they are set up.

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

×