FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

Combat in Hugo Games: how to do it?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
Frobozz
Guest





PostPosted: Wed Feb 06, 2013 7:42 pm    Post subject: Combat in Hugo Games: how to do it? Reply with quote

Hi.
I've been programming with hugo for a few years (starting in 2010). I'm wondering how to implement combat in hugo games. Nothing tactical; just something other than "Attack x" or "attack x with y". I'm also wondering how to implement multiple weapons, for example: The player has a shotgun and a switchblade. An NPC breaks into his home and fires a shot with is 22. The player has the option to either shoot him with his shotgun or stab him with his switchblade. Any advice and/or information is appreciated.
Back to top
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Wed Feb 06, 2013 8:37 pm    Post subject: Reply with quote

Welcome to the forum, Frobozz.

There are several aspects to doing the type of combat you describe. I'll go over some of them.

First things first, you'll need to declare some grammar for your code. For instance, your "shoot" verb definition might look like this:
Code:
verb "shoot"
*                                       DoVague
* object                             DoShoot
* object "with" held             DoShoot


Then, you might want to come up with some object classes (and maybe make up some new properties while you're at it), like:

Code:

property ammo

class gun
{
    type gun
    ammo 0
}
(See also HbE's type entry)

Then you can make all of the guns in your game using that object class. Lastly, you'll want to make a verb routine:

Code:
routine DoShoot
{
    ! first, check that the player has a gun
    local i , n

    if not xobject ! if the player didn't specify WHICH gun
    {
        for i in player
        {
             if i.type = gun
            {
                 xobject = i
                 n++  ! count how many guns we've found
             }
         }
         if n > 1 ! more than one gun
        {
            "You'll have to specify which gun to use."
            return false  ! don't use up a turn
        }
        elseif not n
        {
            "You don't have a gun."
            return false
         }
    }
    elseif xobject.type ~= gun
    {
         "That doesn't make any sense."
         return false
    }

    if not object.after
    {
         "Why would you shoot that?"
         return false
    }
    return true  ! take up a turn
}


Now, you could code your robber like such:
Code:
property hit_points

character ruffian "ruffian"
{
    article "the"
    adjective 0
    noun "ruffian"
    is unfriendly
    hit_points 100
    after
    {
        object DoShoot
        {
            if self is not living
            {
                "The ruffian is already dead."
                 return true
            }
            elseif random(2) = 2  ! hit the robber half of the time
           {
               "You hit!"
               self.hit_points -= 50
               if self.hit_points < 1
               {
                    "The ruffian dies!"
                    self is not living
                    self.name is "dead ruffian"
                    self.adjective is "dead"
                }
           }
           else
                "You miss!"
           return true
       }
}


Now, that doesn't cover everything and I'm sure there are some bugs there, and there are other ways you could do it. You can also do a system where you character has weapons equipped which are automatically used when the player attacks.

Still, I hope that gives you some ideas about how you'd like to handle it for your game.
Back to top
View user's profile Send private message AIM Address
Tdarcos



Joined: 16 May 2008
Posts: 4441
Location: University Park, Maryland

PostPosted: Thu Feb 07, 2013 8:32 am    Post subject: Reply with quote

I'd go a bit further than Roody. In the routine DoShoot I'd add a check to make sure you have ammo and that you shot at a person. I'd also do the check for living there to reduce having to include it in every character that can be shot. These three tests would be inserted right before the object.after test, like this:
Code:


    if i.ammo < 1
   {
       "You're out of ammo."
       return false
    }

    if ((object.type ~= character) and
       (object.type ~= female_character))
   {
        "You can only shoot at people."
        return false
    }

    if object is not living
    {
         "The ruffian is already dead."
          return false
    }

    if not object.after
    {
         "Why would you shoot that?"
         return false
    }



Doing it this way means you do not need to put the "self is not living" test in each character you could shoot at.

Or where I have the line that "you can only shoot at people." you could have the following:
Code:

    if ((object.type ~= character) and
       (object.type ~= female_character))
   {
        i.ammo --
        "The weapon makes a loud noise as the gun discharges, but it has no effect on the target other than to use up one round."
        return true
    }


_________________
The lessons of history teach us - if they teach us anything - that no one learns the lessons of history.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frobozz
Guest





PostPosted: Thu Feb 07, 2013 9:49 am    Post subject: Re: Combat in hugo games: How to do it? Reply with quote

Thanks a lot.
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended