Egoboo Forum

The Legend of Egoboo Sporks of Yore
Help me script this hog?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Egoboo Forum Forum Index -> -> Help
View previous topic :: View next topic  
Author Message
Chainsaw
Lumberjack
Lumberjack


Joined: 20 Oct 2007
Age: 15
Posts: 2378
Location: Israel

PostPosted: Sat Oct 20, 2007 2:47 am    Post subject: Help me script this hog? If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

I'm almost done with the hog pet I'm making ( I'm finishing the one in the DEV bundle ), Now i can't code an entire script file myself, so i used the tundra bunny script instead.

Can someone please tell me which parts of the script i need to change to get the following results?:

Decrease the frequency in which sound is played.

Make it stop sniffing for items :P
( It won't pick them up , but it still tries to find them )

Make it attack. ( I'm guessing this has something to do with the model, so you'll have to download the entire folder to help me with that one. )

Here's the entire folder, so you can test it ( ZIP format , 16KB , Fixed... ):

http://xchainsaw1x.piranho.com/hog.obj.zip


Last edited by Chainsaw on Sun Oct 21, 2007 9:07 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Maxaxle
Elite Gamer
Elite Gamer


Joined: 06 Oct 2007
Age: 15
Posts: 2717
Location: San Diego

PostPosted: Sun Oct 21, 2007 2:55 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

Ehm...your link is broke(n)... Rolling Eyes
_________________
http://www.freewebs.com/maxaxle88/
Inventor class last updated: July 9, 2008
Download: https://sourceforge.net/projects/maxaxlesegoboos
FREE PIZZA TOMORROW
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Zefz
Lead Designer
Lead Designer


Joined: 16 Sep 2007
Posts: 2301
Location: Norway

PostPosted: Sun Oct 21, 2007 4:58 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

To make it pick up items, you need an pickup/drop items animation.

The same goes for attacks (Unless you use a damage on bump script).

Code:

//Damage on bump
IfBumped
  SetTargetToWhoeverBumped
  IfFacingTarget
    IfTargetIsOnHatedTeam
      IfTargetIsAlive
        tmpargument  = rand & 512 + 256
        tmpdistance = DAMAGEPOKE
        DamageTarget
//This deals 1-3 poke damage to the bumper


I don't think variable sound frequency is used in the new SDL_Mixer sound system. But the old one was set in tmpdistance:

Code:

tmpargument = 1    //Which sound to play
tmpargument = rand & 1500 + 9700    //Sound frequency
PlaySound


Finding items is done with an AI script. SetTargetToDistantBlahID, then making it move towards it, then making it pick them up, etc.

Think already some similar AI scripts exist somewhere...
_________________
http://egoboo.sourceforge.net

"The pen is mightier than the sword- IF it is sharpened, dipped in poison and thrown really really hard at your target. But seriously, you are better off with a sword."
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
bgbirdsey
Developer
Developer


Joined: 25 Sep 2007
Posts: 862
Location: Minnesota

PostPosted: Sun Oct 21, 2007 7:36 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

I hope this is helpful and not too long.....

Quote:
Make it stop sniffing for items Razz
( It won't pick them up , but it still tries to find them )


One way of programming AIs is to think of the AI as a "state machine". A state machine knows how to do one kind of task for each state that it is in. For instance, being in the state "hungry" would cause the hog to look for food and eat it, which would change the state to "satisfied".

If you look at it this way, the only thing you have to do is to figure out what kinds of tasks you want your AI to perform (the states) and what might cause the AI to change its state. For instance,

Code:
if the hog is not in follow mode and the ai times out, the hog switches to following its owner

if the hog is following its owner and an item of IDSZ [XXXX] is within the hog's block it sets a waypoint for the object and switches to the sniffing mode

if the hog is bumped by an enemy and the enemy is weak, it switches to attack mode

if the hog is bumped by an enemy and the enemy is strong, it switches to flee mode


So, here, there are several states: attack, flee, follow, sniff. And a couple of events that cause transitions: bumped by enemy, timed out.

Egoboo has a built-in system for tracking states, the default states are
: Parry, Wander, Guard, Follow, Surround, Retreat, Charge, Combat. But almost none of the AIs actually use the functions IfStateIsParry (or IfStateIsXXXX, or whichever). So, you can just use numbers to keep track of your AIs states and assign attack=1, flee=2, follow=3, sniff=4, ...

To test for these states, you can use IfStateIs1, IfStateIs2, IfStateIs3, ..., and to set the state you can use

Code:

tmpargument = XX
SetState


The only tick, then, is to figure out how to put the code into the script that switches the states at the correct times, and the code that implements a given AI action

For instance, you could change the code to

Code:
// ZZ> This function makes the character wanders around its enemy
IfSpawned
  MakeCrushValid
  SetTargetToWhoeverIsHolding
    IfTargetIsAPlayer
      SetOwnerToTarget
      JoinTargetTeam
      MakeNameKnown

IfGrabbed
  MakeCrushInvalid
  IfNameIsKnown
    SetTargetToWhoeverIsHolding
    IfTargetIsAPlayer
      SetOldTarget
      SetTargetToOwner
      IfTargetIsOldTarget
        tmpargument = 5
      Else
        tmpargument = 6
      SendMessageNear
  Else
    SetTargetToWhoeverIsHolding
    IfTargetIsAPlayer
      SetOwnerToTarget
      JoinTargetTeam
      MakeNameKnown
      tmpargument = 3
      SendMessageNear
      tmpargument = 4
      SendMessageNear
  SetTargetToSelf
  SetTargetToTargetLeftHand
    DropItems
    tmpargument = 16
    SendMessageNear

IfDropped
  SetTargetToSelf
  StopTargetMovement
  UnkeepAction

IfUsed
  SetTargetToWhoeverIsHolding
  tmpargument = 25
  SetTargetReloadTime
  IfTargetIsAPlayer
    // =Cuddles=
    SetTargetToSelf
    tmpargument = 7
    SendMessageNear

    // Level
    tmpx = targetlevel
    tmpy = 2
    IfXIsMoreThanY
      tmpx = 2
    tmpargument = 8 + tmpx
    SendMessageNear


    // Stats
    tmpx = targetlife > 9
    tmpy = 2
    IfXIsMoreThanY
      tmpx = 3
    tmpargument = 11 + tmpx
    tmpx = selfstr > 8
    tmpy = selfwis > 8
    SendMessageNear


    // Stats
    tmpx = selfint > 8
    tmpy = selfdex > 8
    tmpdistance = targetexp
    tmpargument = 15
    SendMessageNear

IfCrushed
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  tmpargument = 4
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  GoPoof
  tmpargument = 2
  SendMessageNear

IfCleanedUp            // Respawn
  IfTargetIsAlive           // Make sure killer is away
    tmpx = 1100                //
    tmpy = targetdistance          //
    IfXIsLessThanY             //
      RespawnCharacter               //
  Else                 // Killer is far away
    RespawnCharacter             //

IfKilled            // This reduces the height of the char
  IfNameIsKnown
    SetOldTarget
    SetTargetToOwner
    IfTargetIsAlive
      tmpargument = 0
      SendMessageNear
    SetTargetToOldTarget
  Else
    tmpargument = 1
    SendMessageNear
  tmpargument = 30           // Dead height
  SetBumpHeight              //
  tmpargument = 5           // Sound
  tmpdistance = rand & 2047 + 12000     //
  PlaySound              //

IfAttacked            // Don't take kindly to attackers
  SetTargetToWhoeverAttacked        //
  tmpargument = 4             // Sound
  tmpdistance = rand & 2047 + 9300       //
  PlaySound                //
  tmpargument = 1 // the attack state
  SetState


IfBumped            // Scooch around
  SetTargetToWhoeverBumped
  IfTargetIsOnHatedTeam
    tmpargument = 1 // the attack state
    SetState
  Else

    tmpx = rand & 1023 + targetx - 512
    tmpy = rand & 1023 + targety - 512
    ClearWaypoints
    AddWaypoint

IfTimeOut            // This is done every so often

// Do clucking
  GetContent
  tmpx = tmpargument
  tmpy = 0
  IfXIsMoreThanY
    tmpargument = tmpargument - 1
    SetContent
    tmpargument = rand & 3
    tmpdistance = rand & 2047 + 10000
    PlaySound
    tmpargument = 12
  Else
    tmpx = rand & 15
    tmpy = 7
    IfXIsMoreThanY
      tmpargument = tmpx > 1
      SetContent
    tmpargument = rand & 15 + 30
  SetTime

  // Handle the states here, so they process only every so often
  IfHeld
    // Don't bother moving around if held
    GetState
  Else
    IfStateIs1                                               // Attack
      IfTargetIsOnHatedTeam
        tmpx = targetspeedx + targetx
        tmpy = targetspeedy + targety
        ClearWaypoints
        AddWaypoint
      Else
        tmpargument = 3
        SetState
    IfStateIs2                                               // Flee
      IfTargetIsOnHatedTeam
        tmpx = selfx*2 - targetx
        tmpy = selfy*2 - targety
      Else
        tmpargument = 3
        SetState
    IfStateIs3                                               // Follow
      IfTargetIsOnHatedTeam
        tmpargument = 2
        SetState
      Else
        tmpx = targetx + targetspeedx
        tmpy = targety + targetspeedy
    IfStateIs4                                             // Sniff

       // Is it carrying something?
        SetTargetToSelf
        SetTargetToTargetLeftHand
          // Has an item, so bring it to owner
          tmpx = rand & 511 - 256 + ownerx
          tmpy = rand & 511 - 256 + ownery
        Else
          // No item, so find one
          tmpargument = [NONE]
          tmpdistance = BLAHITEMS
          SetTargetToNearestBlahID
            // Don't grab kursed items
            IfTargetIsKursed
              GetState
            Else
              // Get closer?
              tmpx = targetdistance
              tmpy = 20
              IfXIsLessThanY
                // Pick up the item
                tmpargument = LATCHALTLEFT
                PressLatchButton
              tmpx = targetx
              tmpy = targety
              tmpturn = targetturnto
              tmpdistance = 200
              Compass
            Else
              // The item is bad, so follow the owner
              tmpx = ownerx
              tmpy = ownery
           Else
            // No items around, so follow owner
            tmpx = ownerx
            tmpy = ownery
      ClearWaypoints           //
      AddWaypoint              //
End               // Finished with this character

Back to top
View user's profile Send private message
Maxaxle
Elite Gamer
Elite Gamer


Joined: 06 Oct 2007
Age: 15
Posts: 2717
Location: San Diego

PostPosted: Mon Oct 22, 2007 12:32 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

I hate to say this, but it's *still* broken Crying or Very sad
_________________
http://www.freewebs.com/maxaxle88/
Inventor class last updated: July 9, 2008
Download: https://sourceforge.net/projects/maxaxlesegoboos
FREE PIZZA TOMORROW
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Chainsaw
Lumberjack
Lumberjack


Joined: 20 Oct 2007
Age: 15
Posts: 2378
Location: Israel

PostPosted: Mon Oct 22, 2007 1:55 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

Thanks guys, you've been helpful.
I'm almost done, once i fix a few things I'll post it in the general forum, complete with it's own icons and three skins.
I'll try to come up with new sound if i can, right now it uses this annoying licking sound.

Sorry about the broken link, I'll defiantly have a working link once I'm done.
Here's a screenie:
( I made three skins: brownish red, azure and green. )



And that's how the icon will look, not my best, but meh.



By the way, i had trouble with removing the sniffing option, because it seemed to screw up it's movement.
I replaced the "tmpargument = [NONE]" under item finding
with "tmpargument = [ABCD]", and since there is no way it could have an item of ABCD type, it will never look for items.
Back to top
View user's profile Send private message Send e-mail
Maxaxle
Elite Gamer
Elite Gamer


Joined: 06 Oct 2007
Age: 15
Posts: 2717
Location: San Diego

PostPosted: Mon Oct 22, 2007 2:09 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

Maybe the Tundra Bunny will have something about grabbing items... Idea
_________________
http://www.freewebs.com/maxaxle88/
Inventor class last updated: July 9, 2008
Download: https://sourceforge.net/projects/maxaxlesegoboos
FREE PIZZA TOMORROW
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Zefz
Lead Designer
Lead Designer


Joined: 16 Sep 2007
Posts: 2301
Location: Norway

PostPosted: Mon Oct 22, 2007 2:12 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

Icon looks great to me . Very Happy

Seems you have some script errors shown in your screenshot, dunno if you knew this, but check them out to fix em.
_________________
http://egoboo.sourceforge.net

"The pen is mightier than the sword- IF it is sharpened, dipped in poison and thrown really really hard at your target. But seriously, you are better off with a sword."
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Agent of Dread
lolwut?? (Moderator)
lolwut?? (Moderator)


Joined: 23 Sep 2007
Age: 11
Posts: 4347
Location: FACEPLANT

PostPosted: Mon Oct 22, 2007 3:27 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

I got a script error with Zombor but he was perfectly playable.
_________________
FACEPLANT
Back to top
View user's profile Send private message Send e-mail MSN Messenger
bgbirdsey
Developer
Developer


Joined: 25 Sep 2007
Posts: 862
Location: Minnesota

PostPosted: Mon Oct 22, 2007 3:53 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

What was the error in parserr.txt?
Back to top
View user's profile Send private message
Agent of Dread
lolwut?? (Moderator)
lolwut?? (Moderator)


Joined: 23 Sep 2007
Age: 11
Posts: 4347
Location: FACEPLANT

PostPosted: Mon Oct 22, 2007 4:13 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

Yu-hu.
_________________
FACEPLANT
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Chainsaw
Lumberjack
Lumberjack


Joined: 20 Oct 2007
Age: 15
Posts: 2378
Location: Israel

PostPosted: Mon Oct 22, 2007 8:47 pm    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

bgbirdsey wrote:
What was the error in parserr.txt?


How do you check it?
i tried going to the error log but it had no relevant info.
And i can't find the file.
Back to top
View user's profile Send private message Send e-mail
Maxaxle
Elite Gamer
Elite Gamer


Joined: 06 Oct 2007
Age: 15
Posts: 2717
Location: San Diego

PostPosted: Mon Oct 22, 2007 9:27 pm    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

Maybe you should try "search" while in the folder.
_________________
http://www.freewebs.com/maxaxle88/
Inventor class last updated: July 9, 2008
Download: https://sourceforge.net/projects/maxaxlesegoboos
FREE PIZZA TOMORROW
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Chainsaw
Lumberjack
Lumberjack


Joined: 20 Oct 2007
Age: 15
Posts: 2378
Location: Israel

PostPosted: Mon Oct 22, 2007 9:56 pm    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

The script error is the only thing that's keeping me from finishing it.
It doesn't affect the hog in any way, but it's still annoying.

I searched the entire Egoboo folder for that file. no results.
Back to top
View user's profile Send private message Send e-mail
Zefz
Lead Designer
Lead Designer


Joined: 16 Sep 2007
Posts: 2301
Location: Norway

PostPosted: Tue Oct 23, 2007 2:28 am    Post subject: If a post contains some illegal issues you may abuse on it - just click Abuse and fill the form Reply with quote

Open parserror.txt which is located in the basicdat folder.
_________________
http://egoboo.sourceforge.net

"The pen is mightier than the sword- IF it is sharpened, dipped in poison and thrown really really hard at your target. But seriously, you are better off with a sword."
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Egoboo Forum Forum Index -> -> Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot 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


© 2007 Informe.com. Get Free Forum Hosting
Powered by phpBB © 2001, 2005 phpBB Group

RedSilver 1.01 Theme was programmed by DEVPPL HTML Forum
Images were made by DEVPPL Photoshop Forum