Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[SOLVED]Making Switches only effect one event

Status
Not open for further replies.
Before you read any further, I am not looking for how to use switches or Self Switches. This is different.

Hi. For ages I've been developing the ABS for my game. It's all evented, and works perfectly, but I have one problem. A problem that I think can be solved pretty easily with scripts. All of my enemy events are set up so as to read where the actor is in realation to the enemy event through variables. Then when the player fires a gun (it's a shooting game) the enemy will react differently depending on which gun. That all works. Then it checks the enemies health, and if it is bellow a certain variable, the enemy dies. Now here's my problem. This works really well, but it means each enemy must have a unique set of variables for each, so that all the enemies don't die at once. Are you with me so far? Ok.

What I want to know is is there a way with the script part of Conditional Branch to make the same variable store different numbers depending on the event it is being used in? I've tried, and this is what I've come up with, but it doesn't work:

A script entry at the top of the event page says

Name_Of_Event =
$game_map.events[@event_id].event.name

Then the eventing I have already done follows where it checks for what gun is equiped and how far away the player is, ect. Then when the player is in range and fire the gun, I tried the script input

$game_variables[14+Name_Of_Event.to_i] =
$game_variables[14+Name_Of_Event.to_i]
-7

Variable 14 is the enemies health. Then underneath that in the event page it says

Conditional Branch Script

$game_variables[14+Name_Of_Event] <= 20

The enemies event vanishes after there is a falling animation and it flashes. Basically.

So, what am I doing wrong? Can it even be done? Please help.

Thanks,
Fox
 
In the event say you don't want the enemy object to exist until a second page (or other pages), say you turn on self switch to make the second page active.

Above the turn self switch on, add that script there to initialize the enemy object.

But you probably won't need to do this. You should be fine just adding the comment on the first page, since the Abs_Enemy class doesn't actually have an processes and such.
 
Um... Could you use the event in the demo I sent you to set up what it should look like? And then send it back to me? That would be a great help. Because I don't really know what I'm doing. Thanks.
 
Could I get a full demo? I dont need graphics (I can know I trick that solves this problem) but I need to see it work in action. I tested it but I cannot attack back so I can't see the problem actually happening.

Or tell me what I need so that I can attack back to see the error?
 
Off-topic but:
Code:
module RPG::Cache

  class << self

    alias load_bitmap2 load_bitmap

    def load_bitmap(*args)

      begin

        load_bitmap2(*args)

      rescue

        return Bitmap.new(32, 32)

      end

    end

  end

end

I little trick for testers. You just won't see missing graphics but won't get the no bitmap found error. :box:
 
OH! Of course!
It works!!! Thanks so much. One other thing, though. The minimap I use displays enemies on the map by a red dot. It checks for the name ENEMY in a comment. Because this script also uses that, it shows as an enemy, which I don't want (yet) is it just a simple matter of changing the name ENEMY in the script to make it work?

EDIT: Ah, answered my own question. No. I need a quick script fix. For some reaon, an enemy's dot appears at the top left of the mini map whenever an enemy is playing. Could you have a look at the minimap script in the demo I sent you and see why, please? Then I hope I won't need to bother you again.
 
In this line of my script:
if ec.parameters[0].upcase.include?('ABS::ENEMY')


Just change 'ABS::ENEMY' to anything you want (just make sure whatever you put in there is uppercase). Then just change your comments to you put into that line.
 
Right, I've sorted it, it doesn't matter. Just wondering, is there a quick way to make each event individual? So I don't have to enter the event's ID each time? If not, doesn't matter, I don't care.
Thanks so much for your help.
 
If you add this in the Interpreter class:
Code:
 

class Interpreter

  def event

    return $game_map.events[@event_id]

  end

end

Now instead of:
Code:
$game_map.events[event_id].abs_enemy

You can just use:
Code:
event.abs_enemy

However that only works for the command the event belongs too (IE: you cannot use that in a script command in event 3 to get event's 5 abs_enemy data)
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top