Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Idea for calculating position/angle?
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#11
RE: Idea for calculating position/angle?

Okay I think I have figured out a nice way of doing this. It's similar to something I tried before, but it works a lot better this time. There can be flaws, but I haven't encountered any. I can see where they can occur though, but I don't think that event will ever happen.

The new system looks like this:
[Image: dUqsyiM.jpg]

The player collides with the areas and call this script:

PHP Code: (Select All)
void CollideArea(string &in asParentstring &in asChildint alState)
{
    
SetLocalVarString("Area"StringSub(asChild54));
    
string s GetLocalVarString("Area");
    
    
AddDebugMessage("Area string == "+strue);
    
    
bool state;
    if(
alState == 1state false;
    else if(
alState == -1state true;

    
SetEntityActive("area_"+s+"_*"state);
    
SetEntityActive(asChildtrue);
    
SetEntityActive(s+"_Pick"true);
    
    
SetLocalVarString("angle_"+sasChild);


It's very simple and efficient by the looks of it. I was a bit unsure about disabling and re-enabling the current area that's being used to trigger the event, but it appears to work fine with no issues. The string "Area" results in the co-ord of the area, for example x1y1 or x2y1 depending on there you use the item. This is so that the event can easily be duplicated for a huge number of times, because there's this for-loop in OnStart.

PHP Code: (Select All)
    for(int x 110x++) for(int y 110y++) {
        
AddUseItemCallback("""ItemMirror_1""x"+x+"y"+y+"_Pick""UseItemOnPedestal"false);
        
AddUseItemCallback("""ItemSplit""x"+x+"y"+y+"_Pick""UseItemOnPedestal"false);
        
        
AddEntityCollideCallback("Player""area_x"+x+"y"+y+"_n_""CollideArea"false0);
        
AddEntityCollideCallback("Player""area_x"+x+"y"+y+"_s_""CollideArea"false0);
        
AddEntityCollideCallback("Player""area_x"+x+"y"+y+"_e_""CollideArea"false0);
        
AddEntityCollideCallback("Player""area_x"+x+"y"+y+"_w_""CollideArea"false0);
        
AddEntityCollideCallback("Player""area_x"+x+"y"+y+"_ne_""CollideArea"false0);
        
AddEntityCollideCallback("Player""area_x"+x+"y"+y+"_nw_""CollideArea"false0);
        
AddEntityCollideCallback("Player""area_x"+x+"y"+y+"_se_""CollideArea"false0);
        
AddEntityCollideCallback("Player""area_x"+x+"y"+y+"_sw_""CollideArea"false0);

        
SetLocalVarInt("IsOccupied_x"+x+"y"+y0);
    } 

The area in the middle is the _Pick one.

There is quite a bit more script, but I guess I won't need to post it. You can probably figure out how it works by now. Just wanted to let you know that, unless I encounter a problem, I have solved this little issue. The results are pretty nice.

I can imagine it can bug out if the player is outside all the areas when trying to use the item, but in that case it will just use the last entered area.

Still, in the for-loop, I just made the name ItemMirror_1 instead of +x due to the above problem. Anyone know anything about that?

(This post was last modified: 05-23-2014, 10:35 PM by Mudbill.)
05-23-2014, 10:17 PM
Find
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#12
RE: Idea for calculating position/angle?

Sorta whati suggested i see.
good it works man.
05-23-2014, 11:52 PM
Find




Users browsing this thread: 4 Guest(s)