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


Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working combat system !
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#11
RE: Combat System !?

Can you explain what this line will do ?
Quote: gun_target = (state == 1) ? entity : "";
Its the only line i dont understand how it works or what it will do !


We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
04-02-2012, 10:45 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#12
RE: Combat System !?

(04-02-2012, 10:45 PM)stonecutter Wrote: Can you explain what this line will do ?
Quote: gun_target = (state == 1) ? entity : "";
Its the only line i dont understand how it works or what it will do !

?: is known as a ternary operator. It's practically an inline if-else statement.

The same can be re-written as
PHP Code: (Select All)
if (state == 1)
    
gun_target entity;
else
    
gun_target ""

Tutorials: From Noob to Pro
04-02-2012, 11:19 PM
Website Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#13
RE: Combat System !?

Ruining the whole idea behind Amnesia aside, there's like one hundred FPS games on the market, and many of them are made through the excellent and free Unreal Development Kit. How come you settled on the HPL engine of all engines?


Noob scripting tutorial: From Noob to Pro

04-02-2012, 11:31 PM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#14
RE: Combat System !?

(04-02-2012, 11:31 PM)Cranky Old Man Wrote: Ruining the whole idea behind Amnesia aside, there's like one hundred FPS games on the market, and many of them are made through the excellent and free Unreal Development Kit. How come you settled on the HPL engine of all engines?
Sometimes it's fun to press the limitations of an engine. =]
04-02-2012, 11:33 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#15
RE: Combat System !?

Replace lantern model with a pistol/rifle with a flashlight on it = profit. Of course it would be very time consuming to make (judging by your model and texture creation skills) but it has potential.

I rate it 3 memes.
04-03-2012, 12:27 AM
Find
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#16
RE: Combat System !?

Would be nice if someone can create a simple model of a hand holding a gun with integrated flashlight , cause i am just have the modelskills for that Sad. Using both hands like this would be nice [Image: re4cube_092603_x12.jpg]

Will try to integrate a hit-counter and a ammunition-counter today!
Is it possible to get the name of the entity that your a looking at or that causes the collide function ?
Anyone got an idea ? If not , i have to write the hitcounter and soundplays for every enemy in the map Tongue

We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
(This post was last modified: 04-03-2012, 11:44 AM by stonecutter.)
04-03-2012, 11:14 AM
Find
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#17
RE: Combat System !?

string gun_target = "";

void OnStart()
{
//Player
SetSanityDrainDisabled(true);

//Shooting Script
AddLocalVarInt("AmmoCounter", 15); // Amount of munition

    GiveItemFromFile("lantern", "lantern.ent");

    for (int i = 1; GetEntityExists("gun_target_"+i); ++i){
        SetEntityPlayerLookAtCallback("gun_target_"+i, "SetGunTarget", false);
        AddLocalVarInt("HitCounter_"+i+"", 0);
        }
    SetLanternLitCallback("FireGun");
}

void SetGunTarget(string &in entity, int state)
{
    gun_target = (state == 1) ? entity : "";
}

void FireGun(bool lit)
{
    if(GetLocalVarInt("AmmoCounter")>0){
    if (gun_target != "")
    {
        //SetPropActiveAndFade(gun_target, false, 1);
        PlaySoundAtEntity("","gun_fire.snt", "Player", 0, false);
        gun_target = "";
        SetMessage("Messages", "Hit", 1);
        SetLocalVarInt("AmmoCounter", GetLocalVarInt("AmmoCounter")-1);
        
    }
    else
        SetMessage("Messages", "Miss", 1);
        PlaySoundAtEntity("","gun_fire.snt", "Player", 0, false);
        SetLocalVarInt("AmmoCounter", GetLocalVarInt("AmmoCounter")-1);
     }
     else
     SetMessage("Messages", "Empty", 1);
     PlaySoundAtEntity("","empty.snt", "Player", 0, false);

    if (!GetLanternActive())
    {
        SetLanternLitCallback("");
        SetLanternActive(true, true);
        SetLanternLitCallback("FireGun");
    }

}

Now with munitioncounter !

We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
(This post was last modified: 04-03-2012, 12:19 PM by stonecutter.)
04-03-2012, 12:18 PM
Find
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#18
RE: Combat System !?

[video=youtube]http://youtu.be/xuP9agineQY[/video]

Now with Munition Counter and Hitcounter ( 4 hits to fade the enemy )
"Daneben" means "miss" in german language. "Treffer" means "hit" !

Edit 1: It works with more than one enemy !!!!

finally the current script :

PHP Code: (Select All)
string gun_target "";

void OnStart()
{
//Player & Items
SetSanityDrainDisabled(true);
GiveItemFromFile("lantern""lantern.ent");
//SetLanternActive(true, true);

//Variables
AddLocalVarInt("AmmoCounter"50); // Amount of munition
AddLocalVarInt("MonsterSelection"0); // With this variable you select the monster you want to give damage
AddLocalVarInt("MonsterHitCounter_1"0);//Hitcounter for monster A. One for each monster

//LookAtCallbacks ..... One Callback for each enemy !
SetEntityPlayerLookAtCallback("gun_target_1""SetGunTarget_1"false); 
SetEntityPlayerLookAtCallback("gun_target_2""SetGunTarget_2"false);
SetLanternLitCallback("FireGun");
}

void SetGunTarget_1(string &in entityint state)
{
    
gun_target = (state == 1) ? entity "";
    
SetLocalVarInt("MonsterSelection"1);
}
void SetGunTarget_2(string &in entityint state)
{
    
gun_target = (state == 1) ? entity "";
    
SetLocalVarInt("MonsterSelection"2);
}
//Shooting Script
void FireGun(bool lit)
{
     if(
GetLocalVarInt("AmmoCounter")>0){ 
     if (
gun_target != "")
    {
        
//SetPropActiveAndFade(gun_target, false, 1);
        
PlaySoundAtEntity("","gun_fire.snt""Player"0false);
        
gun_target "";
        
SetMessage("Messages""Hit"1);
        
SetLocalVarInt("AmmoCounter"GetLocalVarInt("AmmoCounter")-1);
        switch( 
GetLocalVarInt("MonsterSelection") )
        {
        case 
1:
             
SetLocalVarInt("MonsterHitCounter_1"GetLocalVarInt("MonsterHitCounter_1")+1);
        break;
        case 
2:
             
SetLocalVarInt("MonsterHitCounter_2"GetLocalVarInt("MonsterHitCounter_2")+1);
        break;
        }
        for (
int i 1GetEntityExists("gun_target_"+i); ++i){
        if(
GetLocalVarInt("MonsterHitCounter_"+i)==4){
        
FadeEnemyToSmoke("gun_target_"+ifalse);
        }
        }
    }
    else
        
SetMessage("Messages""Miss"1);
        
PlaySoundAtEntity("","gun_fire.snt""Player"0false);
        
SetLocalVarInt("AmmoCounter"GetLocalVarInt("AmmoCounter")-1);
     }
     else
     
SetMessage("Messages""Empty"1);
     
PlaySoundAtEntity("","empty.snt""Player"0false);

    if (!
GetLanternActive())
    {
        
SetLanternLitCallback("");
        
SetLanternActive(truetrue);
        
SetLanternLitCallback("FireGun");
    }



We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
(This post was last modified: 04-03-2012, 02:38 PM by stonecutter.)
04-03-2012, 02:31 PM
Find
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#19
RE: Combat System !?

New Update

Able to pick up bullets to increase the amount of ammo you have and they will be removed after you shoot 15 bullets !

[video=youtube]http://youtu.be/oaZOkMXX-XU[/video]

PHP Code: (Select All)
string gun_target "";

void OnStart()
{
//Player & Items
SetSanityDrainDisabled(true);
GiveItemFromFile("lantern""lantern.ent");
//SetLanternActive(true, true);

//Variables
AddLocalVarInt("AmmoCounter"0); // Amount of munition
AddLocalVarInt("BulletCounter"0); // Counts the shooted bullets
AddLocalVarInt("MonsterSelection"0); // With this variable you select the monster you want to give damage
AddLocalVarInt("MonsterHitCounter_1"0);//Hitcounter for monster A. One for each monster

//LookAtCallbacks ..... One Callback for each enemy !
SetEntityPlayerLookAtCallback("gun_target_1""SetGunTarget_1"false); 
SetEntityPlayerLookAtCallback("gun_target_2""SetGunTarget_2"false);
SetLanternLitCallback("FireGun");
}

void SetGunTarget_1(string &in entityint state)
{
    
gun_target = (state == 1) ? entity "";
    
SetLocalVarInt("MonsterSelection"1);
}
void SetGunTarget_2(string &in entityint state)
{
    
gun_target = (state == 1) ? entity "";
    
SetLocalVarInt("MonsterSelection"2);
}
//Shooting Script
void FireGun(bool lit)
{
     if(
GetLocalVarInt("AmmoCounter")>0){ 
     if (
gun_target != "")
    {
        
//SetPropActiveAndFade(gun_target, false, 1);
        
PlaySoundAtEntity("","gun_fire.snt""Player"0false);
        
gun_target "";
        
SetMessage("Messages""Hit"1);
        
SetLocalVarInt("AmmoCounter"GetLocalVarInt("AmmoCounter")-1);
        
SetLocalVarInt("BulletCounter"GetLocalVarInt("BulletCounter")+1);
        switch( 
GetLocalVarInt("MonsterSelection") )
        {
        case 
1:
             
SetLocalVarInt("MonsterHitCounter_1"GetLocalVarInt("MonsterHitCounter_1")+1);
        break;
        case 
2:
             
SetLocalVarInt("MonsterHitCounter_2"GetLocalVarInt("MonsterHitCounter_2")+1);
        break;
        }
        for (
int i 1i<=2; ++i){
        if(
GetLocalVarInt("MonsterHitCounter_"+i)==4){
        
FadeEnemyToSmoke("gun_target_"+ifalse);
        }
        }
        if(
GetLocalVarInt("BulletCounter")==15// Remove bullets
        
{
         
SetLocalVarInt("BulletCounter",0);
         
RemoveItem("ammo_box");
        }
    }
    else
        
SetMessage("Messages""Miss"1);
        
PlaySoundAtEntity("","gun_fire.snt""Player"0false);
        
SetLocalVarInt("AmmoCounter"GetLocalVarInt("AmmoCounter")-1);
        
SetLocalVarInt("BulletCounter"GetLocalVarInt("BulletCounter")+1);
        if(
GetLocalVarInt("BulletCounter")==15// Remove bullets
        
{
         
SetLocalVarInt("BulletCounter",0);
         
RemoveItem("ammo_box");
        }
     }
     else
     
SetMessage("Messages""Empty"1);
     
PlaySoundAtEntity("","empty.snt""Player"0false);

    if (!
GetLanternActive())
    {
        
SetLanternLitCallback("");
        
SetLanternActive(truetrue);
        
SetLanternLitCallback("FireGun");
    }



//PickUpAmmo

void AmmoPickUp(string &in asEntity)
{
     
SetLocalVarInt("AmmoCounter"GetLocalVarInt("AmmoCounter")+15);
     
GiveItem("ammo_box","","ammo_box","ammo_box_cover.jpg",1);


We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
(This post was last modified: 04-03-2012, 07:20 PM by stonecutter.)
04-03-2012, 07:18 PM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#20
RE: Working combat system !

Oh..My..God..I cant believe you actually created a gun in amnesia.NICE JOB.

04-03-2012, 07:42 PM
Find




Users browsing this thread: 1 Guest(s)