Go Back   Savage 2: A Tortured Soul Forum > Savage 2 Modding > Documentation


Documentation Post useful tutorials and other informative material.

Thread Tools Display Modes
Old 01-03-2012, 10:01 AM   #1

eaxs's Avatar
Join Date: May 2008
Location: Germany
Posts: 2,611
Thanks: 9
Thanked 40 Times in 24 Posts
Default Pets and Proximity Triggers

As you might know, pets don't seem to work with proximity triggers. Either they don't trigger them at all, or randomly as if their's a defective contact.

I did some empirical research on the subject and I have found a possible explanation about what is going on.

The Test
I made a small map with 2 bases, 4 mines and 6 proximity triggers. The first 3 triggers were used as spawn positions for 3 identical pets; one at each trigger:
  • Pet A
  • Pet B
  • Pet C

The remaining 3 triggers were used to give out a text message when a pet would enter the trigger radius:
  • Trigger A (Message: Entered Trigger A)
  • Trigger B (Message: Entered Trigger B)
  • Trigger C (Message: Entered Trigger C)

The goal here was to spawn the 3 pets and let them move to the triggers to see if they would get triggered:
  • Pet A ->Trigger A
  • Pet B ->Trigger B
  • Pet C ->Trigger C

The result of the test was that A and B failed, whereas C worked. I was able to repeat this over and over again, always with the same result. This made me wonder why, because the pets and triggers were practically identical.

To make sure the triggers were identical, I opened the map with winrar and extracted the "entitylist" file. And indeed, the triggers were identical. However, I also noticed that Trigger C was the last entity I had placed, and therefore had the largest index:
  • Trigger A -> Index 12
  • Trigger B -> Index 13
  • Trigger C -> Index 14

Out of curiosity I switched out the numbers between A and C:
  • Trigger A -> Index 14
  • Trigger B -> Index 13
  • Trigger C -> Index 12

Then I repeated the test and guess what...Trigger A worked and B and C didn't! So I made another test: I reverted the indexes back their original and then added a 4th trigger on the map. This 4th trigger had no purpose though, and the pets wouldn't even come close to it to trigger it. However, the result was that none of the 3 triggers worked.

This leads me to the following explanation:
Only the last proximity trigger (or to be precise: the trigger with the largest index) works for pets. I don't know why that is, but I think my tests have proven this well enough.

More Tests
I made some more tests to see if this behavior could be influenced or changed in any way and I came to the following results:
  • The proximity trigger must be placed in the editor so that it is present in the entitylist file right from the start.
  • The game does not take dynamically spawned (from script) triggers into consideration.
  • Having other entities, such as buildings or trees with a higher index in the entitylist file does not matter. The only thing that matters is that the last proximity trigger you place in the map editor works.
  • Not tested, but assuming from other experiences: Other proximity triggers may also work, but not guaranteed. Just the last one you place seems to work 100%.

Making use of this knowledge
With the "SetPosition" command, you could dynamically move the last working trigger around the map. The trigger radius will move with the entity and the functionality remains intact (I have tested this). You can make the trigger move to all the locations you need to cover in a self-repeating loop. For example, place Trigger A, B, C and D and let D jump between the other 3 triggers infinitely.

Last edited by eaxs; 01-03-2012 at 10:03 AM.
eaxs is offline   Reply With Quote
Old 01-03-2012, 01:07 PM   #2

Pidgeoni's Avatar
Join Date: Jul 2009
Posts: 1,734
Thanks: 185
Thanked 317 Times in 190 Posts

That's nice!
Pidgeoni is offline   Reply With Quote
Old 01-03-2012, 03:20 PM   #3

DeadAir's Avatar
Join Date: Sep 2010
Location: Over the moon
Posts: 570
Thanks: 1
Thanked 4 Times in 3 Posts

Sounds like truly epic lulz to my ears. Go legion, go legion go.
Signature removed by stony
DeadAir is offline   Reply With Quote
Old 01-03-2012, 03:55 PM   #4

Xigbar's Avatar
Join Date: Mar 2011
Posts: 3,053
Thanks: 505
Thanked 646 Times in 539 Posts

Sounds like a really simple fix in a code, I've had indexing things like that happen to me all the time.
They could probably fix it in 5 minutes if they knew the specific place in the code.

Really unfortunate, though.
It's time to take up the last defense. It's time to become as close to real as possible. I was found to be shining bright. When the day comes that I become greater than you, you can pick up your cards and play them again, the last one will fall and I'll pick you up, and carry you into the Door to Light.
and my heart will come alive.
Xigbar is offline   Reply With Quote
Old 05-08-2013, 04:26 PM   #5

Join Date: Jul 2011
Location: Belgium
Posts: 264
Thanks: 47
Thanked 67 Times in 54 Posts

after a 50mins long game, i'm confident enough to post this:

Here is how you should make your triggers:

Spawn early your triggers (according to my tests, before 5mins gametime, but the sooner the better)

SpawnEntityAtEntity #team1_base_index# Trigger_Proximity triggeronnpc 1 triggeronplayer 1 triggerradius 1500 triggerenter ""
set TP_T1_1 #GetScriptParam(spawnedindex)#
Don't ever remove them. Instead use RegisterEntityScript to redefine the script "enter" function to null when it's not needed.

RegisterEntityScript #TP_T1_1# enter ""
"enter" function example:
RegisterEntityScript #TP_T1_1# enter "ExecScript team1_pets_marksman index #GetScriptParam(index)# pet_team 1 pet_id 1 spell 1"
I can't explain why it works on PETs like this, but who cares?
You can test it live with my mod, from now on.
Operating System: Windows 7 x64
Graphic card : Geforce GT 540M
RAM : 8gb

Last edited by Durwyn; 05-08-2013 at 04:33 PM.
Durwyn is offline   Reply With Quote
The Following 2 Users Say Thank You to Durwyn For This Useful Post:
meankitty2 (05-09-2013), SonOfAthena (05-14-2013)
Old 05-08-2013, 11:05 PM   #6

Old55's Avatar
Join Date: Jun 2009
Posts: 2,586
Thanks: 14
Thanked 428 Times in 209 Posts

Good find. I had noticed that pets would occasionally trigger them when spawned but it was very inconsistent. Yet another K2 workaround. They might have written a shitty engine, but in many cases smart modders have been able to find solutions.
Old55 is offline   Reply With Quote
The Following User Says Thank You to Old55 For This Useful Post:
SonOfAthena (05-14-2013)

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT. The time now is 08:16 PM.