Frictional Games Forum (read-only)
Working combat system ! - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Articles (https://www.frictionalgames.com/forum/forum-40.html)
+---- Thread: Working combat system ! (/thread-14444.html)

Pages: 1 2 3 4 5


RE: Combat System !? - stonecutter - 04-02-2012

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 !




RE: Combat System !? - Your Computer - 04-02-2012

(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:
if (state == 1)
    
gun_target entity;
else
    
gun_target ""



RE: Combat System !? - Cranky Old Man - 04-02-2012

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?




RE: Combat System !? - Statyk - 04-02-2012

(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. =]


RE: Combat System !? - Adny - 04-03-2012

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.


RE: Combat System !? - stonecutter - 04-03-2012

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



RE: Combat System !? - stonecutter - 04-03-2012

Code:
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 !



RE: Combat System !? - stonecutter - 04-03-2012

[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:
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");
    }





RE: Combat System !? - stonecutter - 04-03-2012

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:
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);




RE: Working combat system ! - Datguy5 - 04-03-2012

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