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


Working combat system ! - stonecutter - 04-02-2012

Would it be possible to create a combatsystem and integrate (For example : Guns ) it in the game !?
Would be fucking great for Remaking some classic Horror Survival games !

Update !!!
Working script . Check out the Youtube Video ! Big thanks to Your Computer !

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



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

None that I know of... Perhaps possible in a VERY VERY restricted fashion. I would advise using another engine if you intend to use weapons.


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

what about a "LookAt" callback !?
For example ... everytime the player looks at an enemy the callback function will come up and asks if the player presses a button ( for example mouse1 ) ... if thats true ... we can add damage to a monster( if there is a function ) and play sounds and animations !

I think that could work if its possible to check if a button is pressed !?





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

Haha, I've discussed it with another member awhile back and there MAY be a way if you're a great scripter. Experiment with it, it'd be quite a feat.

Only thing is, the HPL2 can not check key presses if I'm not mistaken. If I am, there must be a much more intricate way of scripting it.

If you're looking for damage scripts, I'm not sure if you could lower an enemy's health, but you COULD set the entity inactive or fade to smoke in one shot. (one bullet per kill, fair enough, right?)
http://wiki.frictionalgames.com/hpl2/amnesia/script_functions



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

That would be possible with a counter ...
if(buttonpressed("mouse1", true){
hitCounterMonsterA++;
PlaySoundAtEntity("","Gunshot1.snt", "Player", 0, false);
PlaySoundAtEntity("","Monsterhit1.snt", "MonsterA", 0, false);
if(GetLocalVarInt("hitCounterMonsterA")==4){

SetEnemyDisabled("MonsterA, true);

}
}

Ok but it seems senseless if there is no option to check if a button is pressed. And if it were possible you have to create a function for every monster in the map ...



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

The closest thing to button detection is a lantern callback. I could make a quick script that could do the job.


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

(04-02-2012, 09:18 PM)Your Computer Wrote: The closest thing to button detection is a lantern callback. I could make a quick script that could do the job.
Ok thats a good idea ... set lantern to mouse2
so you think of something like that ?
SetLanternLitCallback("shooting");

void shooting(string &in asParent , string &in asChild , int alState){
PlaySoundAtEntity("","Gunshot1.snt", "Player", 0, false);
SetLanternActive(false,false);//Impoortant so everytime you click mouse2 you will deactivate the lantern/Gun ,
so that then you click again you will activate it again and activate the callback !
}

so i think one more thing we need is a check if the player looks at a enemy !?





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

Here's my current working code:

PHP Code:
string gun_target "";

void OnStart()
{
    
GiveItemFromFile("lantern""lantern.ent");

    for (
int i 1GetEntityExists("gun_target_"+i); ++i)
        
SetEntityPlayerLookAtCallback("gun_target_"+i"SetGunTarget"false);

    
SetLanternLitCallback("FireGun");
}

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

void FireGun(bool lit)
{
    if (
gun_target != "")
    {
        
SetPropActiveAndFade(gun_targetfalse1);
        
gun_target "";
        
SetMessage("Gun""Hit"1);
    }

    else
        
SetMessage("Gun""Miss"1);

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


For killing monsters, just add in FadeEnemyToSmoke where SetPropActiveAndFade is. Give any entity you want to "die" the following syntax: "gun_target_"+i.


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

yeah nice work fine Smile !!! but hard to hit something ... Tongue
but thats something we can work with Tongue

What about an hitcounter ? you can put it into the "for" function : AddLocalVarInt("HitCounter_"+i+"", 0);


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

(04-02-2012, 10:16 PM)stonecutter Wrote: What about an hitcounter ? you can put it into the "for" function : AddLocalVarInt("HitCounter_"+i+"", 0);

A hit counter is possible. I don't think using a for loop is the right way of doing it, but i'll leave you to implement that yourself.