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
Interesting code needed for lantern/pickup functions
SLAMnesia Offline
Member

Posts: 99
Threads: 39
Joined: May 2011
Reputation: 0
#1
Interesting code needed for lantern/pickup functions

Hey FG Forums! Great to be posting again after a long hiatus.

I have an idea for a Custom Story and it will have an interesting mechanic, if I can pull it off with the help of the community Smile

My main character is going to only have one arm, and complicate his use of lantern/pickup objects. If the character has the lantern active, and decides to pickup an object, the lantern will be sheathed BECAUSE the character doesn't have the arms to do two things.
Basically here's what I want:
1) The lantern should deactivate when any object is picked up (excluding items that go into your inventory #TDD)
2) The lantern should be impossible to use while holding an object, and display a message along the lines of "Drop that object to use your lantern!" when you try to use it.

And yes, my idea is pretty neat and I hope to use the upgraded engine as soon as possible!
09-11-2013, 07:54 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Interesting code needed for lantern/pickup functions

Well...
You could name all entities the same thing.
Like entity_1, entity_2, entity_3 etc.


Then create a large for-script combined with SetEntityPlayerInteractCallback.

Screw that idea. You won't be able to determine if the player has dropped the item. I don't think it's possible, since we don't have the right script-commands for this.

Sorry, I don't think it's possible

Trying is the first step to success.
(This post was last modified: 09-11-2013, 08:24 AM by FlawlessHappiness.)
09-11-2013, 08:23 AM
Find
Apfel Offline
Junior Member

Posts: 19
Threads: 3
Joined: Jun 2011
Reputation: 1
#3
RE: Interesting code needed for lantern/pickup functions

Here is something I got managed to work similar to what you wanted.


- When you grab an object and you use your lantern the grabbed object will be dropped.
- when your lantern is active and you try to grab an object the lantern will be switched off automatically (you can change it to manual, see commentary in the script).
- there is a timer to prevent to grab an object while the switch off animation of the lantern is still going on.
- Instead of normal messages I used debug-messages, so they need to be exchanged (bolded text)

regarding to your second request:
"2) The lantern should be impossible to use while holding an object, and display a message along the lines of "Drop that object to use your lantern!" when you try to use it."

I can do this, too, but without the message, because the lantern callback wouldn't be called when the lantern is disabled and/or has no oil.



script:

Spoiler below!


void OnStart()
{
SetLanternLitCallback("lantern");
for(int i=1; i<=8; i++) SetEntityPlayerInteractCallback("entity_"+i, "holding_entities", false);
}


void lantern(bool abLit)
{
RemoveTimer("lantern_switch_off_animation");
AddTimer("lantern_switch_off_animation", 0.6f, "");
for(int i=1; i<=8; i++) if(GetPropIsInteractedWith("entity_"+i) && abLit) AddDebugMessage("________You dropped the object because you used your lantern!______", false);
ChangePlayerStateToNormal();
}

void holding_entities(string &in asEntity)
{
if(GetTimerTimeLeft("lantern_switch_off_animation") != 0) ChangePlayerStateToNormal();
// This prevents the player to pick up an object while the
// switch-off animation is still playing, just for logical
// purpose (it is weird when you can still see the hand on
// the lantern while carrying something... all with one hand)


if(GetLanternActive())
{
AddDebugMessage("________You cannot hold an object while using your lantern!______", false);

// This is for switching off the lantern automatically/manually
SetLanternActive(false, false); // automatic
//ChangePlayerStateToNormal(); // manual
}
}


09-11-2013, 03:21 PM
Find




Users browsing this thread: 3 Guest(s)