Post by vyckstjudas on Dec 19, 2012 23:50:59 GMT -5
Courtesy of Boodbane:
Intro: Generic Portal is advanced version of Alternate Portal above. They work exactly the same. The only difference is that Generic Portal allows modder to set different branch in level texts without making another portal.
This tutorial will describe how to modify alternate portal to make generic portal.
Procedure: 1st, here's example of alternate portal:
name Portal
nomove 1
type none
nolife 1
score 0 -1
antigravity 100
candamage player
setlayer 100
anim idle
loop 1
delay 50
followanim 1
followcond 1
offset 13 27
attack 1 2 32 26 0 0 1 1
noreflect 1
hitfx data/sounds/silent.wav
frame data/chars/misc/arrowr.png
frame data/chars/misc/empty.gif
anim follow1
delay 50
offset 13 27
frame data/chars/misc/arrowr.png
@cmd jumptobranch "Branch1" 1
frame data/chars/misc/empty.gif
frame data/chars/misc/arrowr.png
Now modify it into this:
name Portal
nomove 1
type none
nolife 1
score 0 -1
antigravity 100
candamage player
setlayer 100
anim idle
loop 1
delay 50
followanim 1
followcond 1
offset 13 27
attack 1 2 32 26 0 0 1 1
noreflect 1
hitfx data/sounds/silent.wav
frame data/chars/misc/arrowr.png
frame data/chars/misc/empty.gif
anim follow1
@script
void self = getlocalvar("self");
char Name = getentityproperty(self,"name");
if(frame == 1){
jumptobranch(Name, 1);
}
@end_script
delay 50
offset 13 27
frame data/chars/misc/arrowr.png
frame data/chars/misc/empty.gif
frame data/chars/misc/arrowr.png
As you can see, the script in FOLLOW1 is changed while the rest remains the same. What this script do is acquire this portal's alias then in 2nd frame, jumps to branch with that alias.
See above picture. This is example of how to set it in a level:
spawn Portal
alias T1
coords 30 222 130
at 0
spawn Portal
alias T2
flip 1
coords 290 222 130
at 0
spawn Portal
alias T3
coords 30 222 70
at 0
spawn Portal
alias T4
flip 1
coords 290 222 70
at 0
spawn Portal
alias T5
coords 30 222 10
at 0
spawn Portal
alias T6
flip 1
coords 290 222 10
at 0
With this, you only need one portal entity to set 6 branches. Efficient, don't you think?
Limitation: The issue is exactly same as alternate portal's so I only mention its limitation. The most obvious limitation is that generic portal uses specific image (or nothing if you use blank image) and specific portal size. So it's recommended to set generic image and size so the portal can be used almost anywhere.
Intro: Generic Portal is advanced version of Alternate Portal above. They work exactly the same. The only difference is that Generic Portal allows modder to set different branch in level texts without making another portal.
This tutorial will describe how to modify alternate portal to make generic portal.
Procedure: 1st, here's example of alternate portal:
name Portal
nomove 1
type none
nolife 1
score 0 -1
antigravity 100
candamage player
setlayer 100
anim idle
loop 1
delay 50
followanim 1
followcond 1
offset 13 27
attack 1 2 32 26 0 0 1 1
noreflect 1
hitfx data/sounds/silent.wav
frame data/chars/misc/arrowr.png
frame data/chars/misc/empty.gif
anim follow1
delay 50
offset 13 27
frame data/chars/misc/arrowr.png
@cmd jumptobranch "Branch1" 1
frame data/chars/misc/empty.gif
frame data/chars/misc/arrowr.png
Now modify it into this:
name Portal
nomove 1
type none
nolife 1
score 0 -1
antigravity 100
candamage player
setlayer 100
anim idle
loop 1
delay 50
followanim 1
followcond 1
offset 13 27
attack 1 2 32 26 0 0 1 1
noreflect 1
hitfx data/sounds/silent.wav
frame data/chars/misc/arrowr.png
frame data/chars/misc/empty.gif
anim follow1
@script
void self = getlocalvar("self");
char Name = getentityproperty(self,"name");
if(frame == 1){
jumptobranch(Name, 1);
}
@end_script
delay 50
offset 13 27
frame data/chars/misc/arrowr.png
frame data/chars/misc/empty.gif
frame data/chars/misc/arrowr.png
As you can see, the script in FOLLOW1 is changed while the rest remains the same. What this script do is acquire this portal's alias then in 2nd frame, jumps to branch with that alias.
See above picture. This is example of how to set it in a level:
spawn Portal
alias T1
coords 30 222 130
at 0
spawn Portal
alias T2
flip 1
coords 290 222 130
at 0
spawn Portal
alias T3
coords 30 222 70
at 0
spawn Portal
alias T4
flip 1
coords 290 222 70
at 0
spawn Portal
alias T5
coords 30 222 10
at 0
spawn Portal
alias T6
flip 1
coords 290 222 10
at 0
With this, you only need one portal entity to set 6 branches. Efficient, don't you think?
Limitation: The issue is exactly same as alternate portal's so I only mention its limitation. The most obvious limitation is that generic portal uses specific image (or nothing if you use blank image) and specific portal size. So it's recommended to set generic image and size so the portal can be used almost anywhere.