Script related questions

Help regarding development/scripting, troubleshooting or just general gameplay -- anything that hasn't already been answered in the Wiki or pinned FAQs.

Moderator: Developers

Cimeries
Lumberjack (Developer)
Lumberjack (Developer)
Posts: 7720
Joined: Wed Jul 23, 2008 6:56 am

Script related questions

Post by Cimeries »

Script related questions.

I've created this topic in order to keep the Egoscript Functions thread from getting flooded with posts requiring help (Which, ironically, I started).

This topic is for help with Egoscript functions and general assistance with the more program related parts of developing Egoboo.
Small and simple questions would go here, if you have big scale scripting projects or something that requires a lot of attention, you can make your own thread, otherwise, stick to this one.
:wink:
Cimeries
Lumberjack (Developer)
Lumberjack (Developer)
Posts: 7720
Joined: Wed Jul 23, 2008 6:56 am

Post by Cimeries »

I need some help with this:

Code: Select all

IfUsed
  tmpargument = 220
  SetReloadTime
  MakeSimilarNamesKnown
  IfTargetIsHurt
    tmpargument = ACTIONML      //sit animation?
    TargetDoAction
    KeepAction
    tmpargument = 3
    PlaySound
    tmpargument = [WMAG]
    IfTargetHasSkillID
      tmpargument = targetwis * 64 + rand & 767   //Amount of life healed
      HealTarget
    Else
      tmpargument = targetwis * 32 + rand & 767   //Amount of life healed
      HealTarget
    CostAmmo
    UnkeepAction
    tmpdistance = SPAWNORIGIN
    tmpargument = 1
    SpawnAttachedHolderParticle
  Else
    tmpargument = 6
    SendMessageNear


This is a script for a medkit I'm making, I need help with two things:

1. How accurate are the heal target formulas? does the rand & 767 generate a number between 1 to 767 or something else?

2. I want to make the character sit down for the duration of the healing, which should be about 200 ticks. I can't seem to find a way to do it, I tried using SetTime and IfTimeOut functions, but it seems to ignore them.
:wink:
User avatar
penguinflyer5234
Sheep (Developer)
Sheep (Developer)
Posts: 3025
Joined: Wed Jul 23, 2008 1:39 am
Location: Best Southwest

Post by penguinflyer5234 »

According to "perl -e 'print unpack("B*", 767),"\n"'
767 in binary is 001101110011011000110111.

So the bits with 1 will randomly be 0 or 1. Not what you intended.
You need rand % 767. This will give you a number between 0 and 767.
...
Cimeries
Lumberjack (Developer)
Lumberjack (Developer)
Posts: 7720
Joined: Wed Jul 23, 2008 6:56 am

Post by Cimeries »

And what will % 768 give me?
:wink:
User avatar
penguinflyer5234
Sheep (Developer)
Sheep (Developer)
Posts: 3025
Joined: Wed Jul 23, 2008 1:39 am
Location: Best Southwest

Post by penguinflyer5234 »

Random number from 0-767. The % means modulus.
...
User avatar
Zefz
Squirrel Knight (Administrator)
Squirrel Knight (Administrator)
Posts: 3820
Joined: Wed Jul 23, 2008 1:27 am
Location: Norway
Contact:

Post by Zefz »

1. You can simply do what Penguinflyer said. You can use rand & 1023 instead. Which will correctly generate a random number between 0 and 1023.

2. Try the TargetDoActionOverride. The TargetDoAction only works if the target is not doing an animation already.
Cimeries
Lumberjack (Developer)
Lumberjack (Developer)
Posts: 7720
Joined: Wed Jul 23, 2008 6:56 am

Post by Cimeries »

Hmm... nevermind, I already have what I need. Thanks guys.
:wink:
User avatar
woodmouse
Monolich (Senior Member)
Monolich (Senior Member)
Posts: 4586
Joined: Wed Jul 23, 2008 3:53 pm
Location: Finland
Contact:

Post by woodmouse »

How can I script a mount fly only when it's mounted?
Once upon a time, when unicorns roamed the earth...
User avatar
Zefz
Squirrel Knight (Administrator)
Squirrel Knight (Administrator)
Posts: 3820
Joined: Wed Jul 23, 2008 1:27 am
Location: Norway
Contact:

Post by Zefz »

Code: Select all

SetTargetToRider
  tmpargument = 100
  SetFlyHeight
Else
  tmpargument = 0
  SetFlyHeight
User avatar
woodmouse
Monolich (Senior Member)
Monolich (Senior Member)
Posts: 4586
Joined: Wed Jul 23, 2008 3:53 pm
Location: Finland
Contact:

Post by woodmouse »

Thanks! Testing time! :D
Once upon a time, when unicorns roamed the earth...
Cimeries
Lumberjack (Developer)
Lumberjack (Developer)
Posts: 7720
Joined: Wed Jul 23, 2008 6:56 am

Post by Cimeries »

Zefz, I remember you were talking earlier about OHKOs in scripting, how can I make a weapon check if the holder scored a OHKO?
:wink:
User avatar
Zefz
Squirrel Knight (Administrator)
Squirrel Knight (Administrator)
Posts: 3820
Joined: Wed Jul 23, 2008 1:27 am
Location: Norway
Contact:

Post by Zefz »

Hmm, depending if the OHKO blow was dealt by said weapon.

My first thought is this:

Code: Select all

IfHolderScoredAHit      //This function also sets the target to who the holder hit last
  IfTargetIsAlive
    DoNothing              //He is still alive
  Else
    DoStuff                  //He is dead


Think that should work.
User avatar
Shade
Potion Mimic (Senior Member)
Potion Mimic (Senior Member)
Posts: 7349
Joined: Thu Jul 24, 2008 12:25 pm
Location: Gensokyo

Post by Shade »

Zefz wrote:Hmm, depending if the OHKO blow was dealt by said weapon.

My first thought is this:

Code: Select all

IfHolderScoredAHit      //This function also sets the target to who the holder hit last
  IfTargetIsAlive
    DoNothing              //He is still alive
  Else
    DoStuff                  //He is dead


Think that should work.

That code would be executed by any hit that killed the target though, not just by OHKOs...
Cimeries
Lumberjack (Developer)
Lumberjack (Developer)
Posts: 7720
Joined: Wed Jul 23, 2008 6:56 am

Post by Cimeries »

Yea, I added states though, so it works.
:wink:
User avatar
PurpleSquerkle
Massive Gelfeet (Developer)
Massive Gelfeet (Developer)
Posts: 3176
Joined: Wed Jul 23, 2008 4:54 am
Location: Oakland, CA
Contact:

Post by PurpleSquerkle »

I have an embarrassingly simple question regarding particles.
How do you make them stick to things (like flaming bodies etc.)?

I want to script a weapon (the Soul Carver, actually; I've been doing some improvements to it) so that will spawn flame-ish stuff on enemies under certain conditions....
How do I get it to spawn the particles on the enemy? Just set them as the target before I set it up for spawning, or what?
And how do I make it stick to their bodies like flames?
Does that just... happen? Or is there some mysterious force that governs stickiness and I am yet to discover what it is?
Post Reply