Home   Help Search Login Register  

Author Topic: Onmapclick and stuff...  (Read 663 times)

0 Members and 1 Guest are viewing this topic.

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Onmapclick and stuff...
« on: 10 Feb 2004, 14:33:17 »
Hi. In a mission I'm making the player can click on the map at the start of the mission to position troops, using the "onmapsingleclick" command.

Now, got two questions for ya:

#1. How can I limit the map clicking to one specified area? I guess I would have to use some "distance" command stuff?

# 2. When a group is being "teleported" to the position decided by the player, how do I make them appear in something that looks like a formation? I can only make them appear at the exact same spot. In Quake they would have been telefraged ;)
Anyway it looks stupid... I guess some form of random radius thingie would do the trick?

I'm not too good at this. I've been searching the forums for answers but so far the only thing that works is the "onmapsingleclick" command. :P
Weeee...

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Onmapclick and stuff...
« Reply #1 on: 10 Feb 2004, 15:16:00 »
1)   Your onmapsingleclick command is presumably starting a script.    That script "knows" the position of the click through the variable _pos.    All you have to do is check that _pos is within your allowed area.

There are lots of ways to do that depending on where the area is an how you define it.   For example, if it is circular then just check the distance from a marker (or the player) at the centre to _pos:   if it is too far then the script exits with a hint or something telling the player what went wrong.    


2)  I'm not sure exactly what you are doing, but it if you are moving groups then probably the best thing would be to move the group's next waypoint to their new position using setWPPos.    That WP would have the formation set to whatever you want.      Would that do the trick?
Plenty of reviewed ArmA missions for you to play

deaddog

  • Guest
Re:Onmapclick and stuff...
« Reply #2 on: 10 Feb 2004, 15:16:55 »
On your teleport you can do something like this:

Code: [Select]
_i=0
{_x setpos [(clickpos select 0) + _i,(clickpos select 1) + _i];_i=_i+3} foreach units groupname

where clickpos is position array from the onmapsingleclick function




Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Onmapclick and stuff...
« Reply #3 on: 10 Feb 2004, 18:21:42 »
Thanks guys... didn't really understand your code deaddog but that's OK :)
Weeee...

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Onmapclick and stuff...
« Reply #4 on: 10 Feb 2004, 19:24:14 »
i is an offset:  it increments by 3m for each member of the group so they are spread out rather than all landing on the same spot.

Head over to the comref and read up on the setpos command.   There's something about it under "array types".

Plenty of reviewed ArmA missions for you to play

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Onmapclick and stuff...
« Reply #5 on: 11 Feb 2004, 11:19:35 »
Thx, I'll do that...

Hmmm, I can teleport my group now but I still have a problem. There are 4 of them and if 2 gets killed they retreat. Thing is they run back to the place where they were before I teleported them. I've tried to teleport their waypoint too like this:    

[GroupName, 1] setWPPos getMarkerPos "MarkerName"

but it won't work. They still run back to their first start position. :(

What am I doing wrong?
Weeee...

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Onmapclick and stuff...
« Reply #6 on: 11 Feb 2004, 12:41:44 »
What's happening is that the remaining two are getting scared and fleeing.    Unit behaviour when fleeing is hardcoded:  basically they head for somewhere they regard as "safe".    I haven't experimented much but I think there are several possible locations.     For example, they might head towards other, unfleeing loons.    However, one place they always like is their start position.

In other words, you will find it hard to stop them fleeing back to their start position.

You could leave the teleport on a loop so that every time they go back to the start position they will get teleported again, though this might lead to them just running straight back there again.

Better would be to stop the fleeing in the first place.   If you want to prevent it absolutely, use a command like this (syntax not guaranteed):-

"_x allowFleeing 0" forEach units grp1

Alternatively, increase the ranks of all the soldiers.   Courage is related to rank, so the higher the rank of the group leader the less likely the group is to flee.

The Real Armstrong dug this out of the commented cpp in the Ed Depot.

 courage[] =
   {
      0.20, //Private
      0.35, //Corporal
      0.55, //Sergeant
      0.65, //Lieutenant
      0.70, //Captain
      0.80, //Major
      0.90  //Colonel
   };
};

In other words, don't have any privates in this group.
Plenty of reviewed ArmA missions for you to play

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Onmapclick and stuff...
« Reply #7 on: 11 Feb 2004, 14:04:19 »
Cool, figured it was something like that... and like you said they run to the closest "safe" place.. didn't realize that... I think I'll leave it as it is.. it's kinda neat when they run away... besides.. when you run away it's not necessary to go to a specific place.. only important thing is to get away   :o :)
Weeee...