Page 1 of 1

[FIXED] Making soldier kits have minimap icons

PostPosted: Wed Dec 02, 2015 9:12 pm
by Classical Modder
I'm trying to make a special kit which would be visible on the minimap with the
Code: Select all
ObjectTemplate.SetMinimapIcon
command.

However, the description of that command on the MDT website states that you can only use it for PCOs. Has anyone tried to add a minimap icon to a soldier kit?

Re: Making soldier kits have minimap icons

PostPosted: Thu Dec 03, 2015 2:50 pm
by Battle GI
Simply try and see the results. If it does work, then it is fine,

Re: Making soldier kits have minimap icons

PostPosted: Tue Dec 08, 2015 12:41 pm
by Seth
It doesn't work, I've tried.
It will probably work by adding an ObjectSpawner which immediately spawns a PlayerControlObject with the desired minimap icon. It would be nice if a more elegant solution was found.

Re: Making soldier kits have minimap icons

PostPosted: Tue Dec 08, 2015 7:40 pm
by Classical Modder
Nope it doesn't, I've tried it too. One way to make this work is to addTemplate an ObjectSpawner to a kit part (not the kit itself) such as a soldier's back pack.

The spawned object would be a simple PCO with a custom minimap icon added to it with the command in my first post. The object would be as small as possible, with armor and collision physics and would be placed with a small offset next to the soldier's back pack. With the holdObject 1 command, the PCO would stick to the soldier wherever it goes, and when the soldier dies, well the PCO simply falls to the ground.

In order to not have multiple minimap icons lying around the map the PCO would have to ''die'' as soon as it touches the ground. Having multiple icons will happen if someone picks up the special kit (the PCO respawns as soon as the kit is picked up), and the icon from the previous owner of the kit would still be at the location where the person died. Giving the PCO a small timetolive value as well as a small distance value in the ObjectsSpawner will make it die almost instantly when the soldier dies.

Re: Making soldier kits have minimap icons

PostPosted: Wed Dec 09, 2015 7:48 pm
by Swaffy
Classical Modder wrote:The spawned object would be a simple PCO with a custom minimap icon added to it with the command in my first post. The object would be as small as possible, with armor and collision physics and would be placed with a small offset next to the soldier's back pack. With the holdObject 1 command, the PCO would stick to the soldier wherever it goes, and when the soldier dies, well the PCO simply falls to the ground.


Just make the PCO static. It doesn't need to move. This way holdObject isn't needed. Also set up the object spawner so the PCO takes max damage when it's out of the object spawner's radius (when it stops existing).

Re: Making soldier kits have minimap icons

PostPosted: Wed Dec 09, 2015 11:40 pm
by Classical Modder
Swaffy wrote:
Classical Modder wrote:The spawned object would be a simple PCO with a custom minimap icon added to it with the command in my first post. The object would be as small as possible, with armor and collision physics and would be placed with a small offset next to the soldier's back pack. With the holdObject 1 command, the PCO would stick to the soldier wherever it goes, and when the soldier dies, well the PCO simply falls to the ground.


Just make the PCO static. It doesn't need to move. This way holdObject isn't needed. Also set up the object spawner so the PCO takes max damage when it's out of the object spawner's radius (when it stops existing).


Hi, not quite sure you mean by making it static. Do you mean disabling mobile physics? So then when the player dies it stays in the air above the soldier and doesn't fall to the ground? But then, even without mobile physics, I think the object would still fall to the ground even without the HoldObject command. Could be an idea, I'll try it out.

And yes for the second thing you mentionned that's exactly what I'll do with the timetolive (set to 1 or an extremely small value) and the distance commands in the ObjectSpawner code.

Re: Making soldier kits have minimap icons

PostPosted: Fri Dec 11, 2015 8:51 pm
by Swaffy
Classical Modder wrote:Hi, not quite sure you mean by making it static. Do you mean disabling mobile physics? So then when the player dies it stays in the air above the soldier and doesn't fall to the ground?


It doesn't need to fall to the ground. The minimap doesn't take into account height, just an X/Y grid. Also, no need for collisions... maybe not even a visual mesh. Worth playing around with.

Re: Making soldier kits have minimap icons

PostPosted: Sun Dec 27, 2015 2:10 am
by Classical Modder
All right well this is very weird, but I got this to work a few weeks ago and now it doesn't work at all, even though the code I used today is identical to the code I used in the past.

So I am able to add a ''simple'' PCO (such as a Willy), but adding a spawner to either a kit part or the soldier itself doesn't work. This is the code I use, in my map's Objective OST.con:

*First I define an Object Spawner with a test PCO, in this case the Willy*
ObjectTemplate.create ObjectSpawner willyspawn
ObjectTemplate.setObjectTemplate 2 willy
ObjectTemplate.setObjectTemplate 1 willy
ObjectTemplate.MinSpawnDelay 5
ObjectTemplate.MaxSpawnDelay 10
ObjectTemplate.SpawnDelayAtStart 0
ObjectTemplate.TimeToLive 30
ObjectTemplate.Distance 40
ObjectTemplate.DamageWhenLost 10
ObjectTemplate.holdObject 1


*Second, I addTemplate that ObjectSpawner, which I named ''willyspawn'' to a kit part, in this case ''german_hippack''
ObjectTemplate.Active german_hippack
ObjectTemplate.AddTemplate willyspawn
ObjectTemplate.setPosition 0/3/0


This gives me an empty spawner, meaning when my player spawns there is no Willy addTemplate'd to it. However, about 3-4 weeks ago I used code which was 99% similar to this and was able to addTemplate a Willy with a minimap icon to my soldier. If anyone has any idea what might be the problem, please let me know.

Also, AddTemplating the Willy alone (without it being part of an ObjectSpawner) works, however when the player dies the game CTDs, and there is also no minimap icon since it is not part of an ObjectSpawner. I have also managed to addTemplate a CTF flag to a player when it spawns, but likewise when the player dies, the game CTDs.

EDIT: FIXED

Re: [FIXED] Making soldier kits have minimap icons

PostPosted: Thu Jan 14, 2016 7:41 pm
by Apache Thunder
Make sure you aren't addTemplating a PCO directly to a soldier object. It may appear to work, but WILL cause a crash at some point. The moment someone tries to switch seat positions when not in a vehicle will cause it to try and switch the soldier into the PCO. But the PCO is a child object of the soldier. You can see why this will cause problems. :P

In multiplayer, the end result is the server side of the game crashes.

Re: [FIXED] Making soldier kits have minimap icons

PostPosted: Thu Jan 14, 2016 10:02 pm
by Classical Modder
Yes, originally when I added the PCO (Willy) to the soldier directly WITHOUT an Object Spawn my game always crashed as soon as I died. Adding an object spawn instead of the PCO alone to one of the soldier's kit part (I used US_Hippack) instead fixes the problem. I have it coded in a way that is around 90% similar to the method you used in this topic (an invisible PCO addTemplated to a soldier through a soldier spawn in order to trigger "soldier landmines"), which you can see here: viewtopic.php?f=6&t=2087&p=14776&hilit=AP+mines#p14776

The minimap icon follows the soldier wherever he goes, and it's even blinking since I have set the timetolive and distance command to very low values. Adding it to a kit part is also better than to the soldier itself, since I want the blinking icon to be attached to one kit only, and not the whole allied/axis team.