Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 2 Votes - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working combat system !
Author Message
stonecutter Offline
Member

Posts: 130
Joined: Feb 2011
Reputation: 4
Post: #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 !
04-02-2012 10:45 PM
Find all posts by this user Quote this message in a reply
Your Computer Offline
SCAN ME!

Posts: 3,236
Joined: Jul 2011
Reputation: 216
Post: #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
Visit this user's website Find all posts by this user Quote this message in a reply
Cranky Old Man Offline
Posting Freak

Posts: 925
Joined: Apr 2012
Reputation: 37
Post: #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 all posts by this user Quote this message in a reply
Statyk Offline
Modmau5

Posts: 3,600
Joined: Sep 2011
Reputation: 198
Post: #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
Visit this user's website Find all posts by this user Quote this message in a reply
Adny Online
Posting Freak

Posts: 1,754
Joined: Mar 2012
Reputation: 169
Post: #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.

Timorem and Friends are Hungryâ„¢
04-03-2012 12:27 AM
Find all posts by this user Quote this message in a reply
stonecutter Offline
Member

Posts: 130
Joined: Feb 2011
Reputation: 4
Post: #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
(This post was last modified: 04-03-2012 11:44 AM by stonecutter.)
04-03-2012 11:14 AM
Find all posts by this user Quote this message in a reply
stonecutter Offline
Member

Posts: 130
Joined: Feb 2011
Reputation: 4
Post: #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 !
(This post was last modified: 04-03-2012 12:19 PM by stonecutter.)
04-03-2012 12:18 PM
Find all posts by this user Quote this message in a reply
stonecutter Offline
Member

Posts: 130
Joined: Feb 2011
Reputation: 4
Post: #18
RE: Combat System !?




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


(This post was last modified: 04-03-2012 02:38 PM by stonecutter.)
04-03-2012 02:31 PM
Find all posts by this user Quote this message in a reply
stonecutter Offline
Member

Posts: 130
Joined: Feb 2011
Reputation: 4
Post: #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 !





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

(This post was last modified: 04-03-2012 07:20 PM by stonecutter.)
04-03-2012 07:18 PM
Find all posts by this user Quote this message in a reply
Datguy5 Offline
Senior Member

Posts: 622
Joined: Dec 2011
Reputation: 12
Post: #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 all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)