Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,227 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Event Problem #301957
12/15/09 16:06
12/15/09 16:06
Joined: Mar 2007
Posts: 112
MikeS Offline OP
Member
MikeS  Offline OP
Member

Joined: Mar 2007
Posts: 112
Hi Guys.

I have an small Problem with an Event Funktion.

k, Thats the code:
Code:
function get_damage_event()
{

if ((EVENT_TYPE == EVENT_impact) && (your.skill7 == 1))
{
	if (my.skill12 > 0) // as long as i have Armor
	{
	my.skill12 -= your.skill8; // Armor get damage by 2
	}
	if (my.skill12 <= 0) // if i dont have any armor 
	{
	my.skill14 -= my.skill12;
	my.skill12 = 0;
	my.skill14 -= your.skill8;
	}
}
}



ok, myskill12 is initialy set to 10
Your.skill8 is set to 2
my.skill14 is set to 10 too.
im fireing 2 rocket to the target.
so each time the rockets hit, is should take 4 points from skill 12
allright, but if i reach skill 12 == 2
it should take 2 from skill 12 and 2 from skill 14
but it takes 2 from skill 12 and 4 from skill 14.
if i set my.skil2 to 1 it works fine, skill 12 is set to 0 and skill 14 is set to 7.
Maybe anyone has an suggestion for this?

Would be very great guys.

Greetings

Mike

Last edited by MikeS; 12/15/09 16:30.
Re: Event Problem [Re: MikeS] #301990
12/15/09 20:12
12/15/09 20:12
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

Is this a typo?

if ((EVENT_TYPE == EVENT_impact)

if ((EVENT_TYPE == EVENT_IMPACT)

edit : I looked at your code
Every time that there's a hit the function gets activated and does it's job.
On the first hits
the 2e part of the function "if (my.skill12 <= 0)"
does not do anything because it's not true.
But
there will come a time when both if situation will work at the same time. (one after the other)
so skill 12 will be barely greater than zero
It will do the subtraction (no matter what)
Then skill 12 is below zero
and it will
give the new values that you placed in the second if

Since your values must never be below zero you will have to rethink
your code. wink

My suggestion is to to use a situation like

if (!my.skill12 <= 0)
do
else
do



Last edited by Ottawa; 12/15/09 21:04.

Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: Event Problem [Re: Ottawa] #302043
12/16/09 07:46
12/16/09 07:46
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
This should do it I think....

Code:
if (my.skill12 > your.skill8)	// as long as i have armor STRONGER than damage
{	my.skill12 -= your.skill8;		}	// only armor gets damaged by all of skill8
else				//if i dont have enough armor for ALL damage
{	my.skill14 -= your.skill8-my.skill12;	//remove 'health' that armor didnt protect
	my.skill12  = 0;				//remove remaining armor
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Event Problem [Re: EvilSOB] #302093
12/16/09 15:22
12/16/09 15:22
Joined: Mar 2007
Posts: 112
MikeS Offline OP
Member
MikeS  Offline OP
Member

Joined: Mar 2007
Posts: 112
Thanks EvilSOB,

that works really good,

Greetings Mike

Re: Event Problem [Re: MikeS] #302095
12/16/09 15:38
12/16/09 15:38
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Excellent.

Glad to be of help...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1