Jump to content


Photo

Once used code in step event


  • Please log in to reply
5 replies to this topic

#1 Bloxtra

Bloxtra

    GMC Member

  • GMC Member
  • 134 posts
  • Version:GM8

Posted 14 April 2012 - 11:43 AM

Hi,
I am trying to make it so that when a certain weapon is equipted, the players current stats are boosted by the weapon's bonuses. T the moment I have the bonus variables stored in obj_weapon and I want my obj_player to have their stats boosted while the weapon is equipted. The problem is when I use my code it constantly adds the bonus every time the step event repeats. I want it just to be a one off occurance in the step event. Here is my current code:

Step event:

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////WEAPONS/////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

if obj_weapon.cwep = spr_bd
{
maxhit += bdmhbonus//0.05
splashrate += bdsrbonus//2.5
}

if obj_weapon.cwep = spr_bs
{
maxhit += bsmhbonus//0.1
splashrate += bdsrbonus//3
}


:thanks:
  • 0

#2 PetzI

PetzI

    GMC Member

  • GMC Member
  • 1026 posts
  • Version:GM8.1

Posted 14 April 2012 - 11:47 AM

Why don't you simply add the bonus when the player equips the weapon, instead? Just make sure you remove it once he unequips it.
  • 0

#3 lukew23

lukew23

    GMC Member

  • GMC Member
  • 276 posts
  • Version:Unknown

Posted 14 April 2012 - 11:50 AM

Why don't you simply add the bonus when the player equips the weapon, instead? Just make sure you remove it once he unequips it.

Alternatively, have a separate variable
for example:
for increasing attack, make a new variable (called attackBonus or something similar)
and when you reference the variable attack, use attack+attackBonus instead
  • 0

#4 Bloxtra

Bloxtra

    GMC Member

  • GMC Member
  • 134 posts
  • Version:GM8

Posted 14 April 2012 - 12:04 PM

Why don't you simply add the bonus when the player equips the weapon, instead? Just make sure you remove it once he unequips it.


Thanks I will give this a try!

EDIT: Unfortunatly when my weapon is changed it is all based on the current sprite so there is no part where it suddenly changes. Any other ideas?

Edited by Bloxtra, 14 April 2012 - 12:38 PM.

  • 0

#5 packocrayons

packocrayons

    GMC Member

  • New Member
  • 95 posts
  • Version:GM8

Posted 14 April 2012 - 01:19 PM

changing=1
if changing=1
{
//all of your adding code here
changing=0
}
when a weapon is changed, sprchange=the new sprite
if sprchange!=initial one
{
//subtract those weapon bonuses
change=1
}
  • 0

#6 Bloxtra

Bloxtra

    GMC Member

  • GMC Member
  • 134 posts
  • Version:GM8

Posted 14 April 2012 - 02:37 PM

Thanks that works great!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users