stonecutter
Member
Posts: 140
Threads: 17
Joined: Feb 2011
Reputation:
4
|
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 |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
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
if (state == 1) gun_target = entity; else gun_target = "";
|
|
04-02-2012, 11:19 PM |
|
Cranky Old Man
Posting Freak
Posts: 986
Threads: 20
Joined: Apr 2012
Reputation:
38
|
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?
|
|
04-02-2012, 11:31 PM |
|
Statyk
Schrödinger's Mod
Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation:
241
|
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 |
|
Adny
Posting Freak
Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation:
173
|
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 |
|
stonecutter
Member
Posts: 140
Threads: 17
Joined: Feb 2011
Reputation:
4
|
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 . Using both hands like this would be nice
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
(This post was last modified: 04-03-2012, 11:44 AM by stonecutter.)
|
|
04-03-2012, 11:14 AM |
|
stonecutter
Member
Posts: 140
Threads: 17
Joined: Feb 2011
Reputation:
4
|
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 |
|
stonecutter
Member
Posts: 140
Threads: 17
Joined: Feb 2011
Reputation:
4
|
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 :
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 entity, int state) { gun_target = (state == 1) ? entity : ""; SetLocalVarInt("MonsterSelection", 1); } void SetGunTarget_2(string &in entity, int 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", 0, false); 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 = 1; GetEntityExists("gun_target_"+i); ++i){ if(GetLocalVarInt("MonsterHitCounter_"+i)==4){ FadeEnemyToSmoke("gun_target_"+i, false); } } } 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"); }
}
(This post was last modified: 04-03-2012, 02:38 PM by stonecutter.)
|
|
04-03-2012, 02:31 PM |
|
stonecutter
Member
Posts: 140
Threads: 17
Joined: Feb 2011
Reputation:
4
|
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]
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 entity, int state) { gun_target = (state == 1) ? entity : ""; SetLocalVarInt("MonsterSelection", 1); } void SetGunTarget_2(string &in entity, int 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", 0, false); 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 = 1; i<=2; ++i){ if(GetLocalVarInt("MonsterHitCounter_"+i)==4){ FadeEnemyToSmoke("gun_target_"+i, false); } } if(GetLocalVarInt("BulletCounter")==15) // Remove bullets { SetLocalVarInt("BulletCounter",0); RemoveItem("ammo_box"); } } else SetMessage("Messages", "Miss", 1); PlaySoundAtEntity("","gun_fire.snt", "Player", 0, false); 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", 0, false);
if (!GetLanternActive()) { SetLanternLitCallback(""); SetLanternActive(true, true); 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 |
|
Datguy5
Senior Member
Posts: 629
Threads: 25
Joined: Dec 2011
Reputation:
12
|
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 |
|
|