Still have one little Problem
I need help adding a new SetCursorMode like SetCursorMode (10)
When i use SetCursorMode (10) the game will crash when i click on Look in
Crash code
Error set cursor mode:
Invalid cursor mode specified
line 195
line 1637
If i use SetCursorMode (1) Any thing thats not set to if (UsedAction (A_LOOK_IN)) { and set to if (UsedAction (A_LOOK_AT)) {
when i do look in action on a plant it saids its a plant if its not set up to use if (UsedAction (A_LOOK_IN)) {
Heres Code
// ============================= action functions //===========================================
int global_action;
int default_action;
int alternative_action;
int used_action;
int action_button [A_COUNT_];
int action_button_normal [A_COUNT_];
int action_button_highlight [A_COUNT_];
int action_l_keycode [A_COUNT_];
int action_u_keycode [A_COUNT_];
int button_action [15];
function TranslateAction (string result, int action, string objects,
string item){
// get translated action template
if (action == A_WALK_TO) StrCopy (result, "Walk to %s");
else if (action == A_LOOK_AT) StrCopy (result, "Look at %s");
else if (action == A_LOOK_IN) StrCopy (result, "Look in %s"); // NEW
else if (action == A_TALK_TO) StrCopy (result, "Talk To %s");
else if (action == A_GIVE_TO)
{
if (StrLen (item) > 0) StrCopy (result, "Give !s to %s");
else StrCopy (result, "Give To %s");
}
else if (action == A_PICK_UP) StrCopy (result, "Pick Up %s");
else if (action == A_USE)
{
if (StrLen (item) > 0) StrCopy (result, "Use !s with %s");
else StrCopy (result, "Use %s");
}
else if (action == A_OPEN) StrCopy (result, "Open %s");
else if (action == A_CLOSE) StrCopy (result, "Close %s");
else if (action == A_PUSH) StrCopy (result, "Push %s");
else if (action == A_PULL) StrCopy (result, "Pull %s");
else if (action == A_SWITCH_TO) StrCopy (result, "Switch To %s");
// fill object and item into action template
StrCopy (result, GetTranslation (result));
int ip = StrContains (result, "!s");
if (ip >= 0)
{
int op = StrContains (result, "%s");
StrSetCharAt (result, ip, '%');
if (ip < op) StrFormat (result, result, item, objects);
else StrFormat (result, result, objects, item);
}
else StrFormat (result, result, objects);
}
function isAction (int test_action){
return global_action == test_action;
}
function UsedAction (int test_action){
return ((used_action == test_action) && (GSagsusedmode !=
MODE_USEINV)) || ((test_action == A_USE_INV) && (used_action == A_USE)
&& (GSagsusedmode == MODE_USEINV));
}
function SetAction (int new_action){
// set default action
if (new_action == A_DEFAULT) new_action = default_action;
// set corresponding cursormode
if (new_action == A_WALK_TO) SetCursorMode (9);
else if (new_action == A_LOOK_AT) SetCursorMode (1);
else if (new_action == A_TALK_TO) SetCursorMode (3);
else if (new_action == A_GIVE_TO) SetCursorMode (2);
else if (new_action == A_PICK_UP) SetCursorMode (5);
else if (new_action == A_USE) SetCursorMode (2);
else if (new_action == A_OPEN) SetCursorMode (8);
else if (new_action == A_CLOSE) SetCursorMode (8);
else if (new_action == A_PUSH) SetCursorMode (8);
else if (new_action == A_PULL) SetCursorMode (8);
else if (new_action == A_LOOK_IN) SetCursorMode (1); // Need to make new mode like 10 game //crash when i use 10 but if i use 1 it dose the thing that i was talking about.
// save action
global_action = new_action;
}
function SetDefaultAction (int def_action){
default_action = def_action;
SetAction (A_DEFAULT);
}
// ============================= GlobalCondition //===========================================
function GlobalCondition (int parameter){
// here are some conditions that are used many times in the script
int cond;
if (parameter == 1)
{
// if the mouse is in the inventory and modes Walk or pickup are selected
cond = ((GetInvAt (mouse.x, mouse.y) >= 0) && (isAction
(A_WALK_TO) || isAction (A_PICK_UP)));
}
else if (parameter == 2)
{
// if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
cond = ((character [GetPlayerCharacter ()].activeinv == GetInvAt
(mouse.x, mouse.y)) && (GetCursorMode () == 4));
}
else if (parameter == 3)
{
// if the mode is talk, or "Give", and the mouse isnt over a character
cond = ((isAction (A_TALK_TO) || (isAction (A_GIVE_TO) &&
(GetCursorMode () == 4))) && (GetLocationType (mouse.x, mouse.y) != 2));
}
else if (parameter == 4)
{
// if its GIVE and the mouse isnt over a inv.item
cond = ((GetCursorMode () == 2) && isAction (A_GIVE_TO) && (GetInvAt
(mouse.x, mouse.y) < 0));
//}
// NEW TRYED this but did not work
// else if (parameter == 5)
// {
// cond = ((GetCursorMode () == 10) && isAction (A_LOOK_AT) && (GetLocationType
// (mouse.x, mouse.y) < 0)); //
}
if (parameter == 5) // and changed that to 6
{
// if its over the "other characters" buttons in the inventory.
cond = ((GetGUIAt (mouse.x, mouse.y) == MAINGUI) && ((GetGUIObjectAt
(mouse.x, mouse.y) == 12) || (GetGUIObjectAt (mouse.x, mouse.y) == 13)));
}
return cond;
}
// ============================= ActionBar //===========================================
function UpdateActionBar (){
// set the text in the action bar
string madetext;
int action = global_action;
string objects;
string item;
StrCopy (objects, SHOWNlocation);
StrCopy (item, "");
if (GlobalCondition (5) == 1)
{
// write SWITCH TO CHAR
action = A_SWITCH_TO;
if (GetGUIObjectAt (mouse.x, mouse.y) == 12)
{
// StrCopy (objects, character [GSotherplayerup].name);
}
else
{
// StrCopy (objects, character [GSotherplayerdown].name);
}
}
else if (GetCursorMode () == 4)
{
// use or give inventory item
GetInvName (character [GetPlayerCharacter ()].activeinv, item);
RemoveExtension (item);
}
else if (GlobalCondition (1) == 1)
{
// if the mouse is in the inventory and modes Walk or pickup are selected
action = A_USE;
}
TranslateAction (madetext, action, objects, item);
// show action text
SetLabelText (ACTION, 0, madetext);
SetLabelColor (ACTION, 0, ActionLabelColorNormal);
}
// ============================= on_mouse_click ===========================================
// this section after GoToCharacter
#sectionstart on_mouse_click // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click (int button){
// called when a mouse button is clicked. button is either LEFT or RIGHT
int mrx = mouse.x + GetViewportX ();
int mry = mouse.y + GetViewportY ();
// get location under mouse cursor
GSloctype = GetLocationType (mouse.x, mouse.y);
if (GSloctype == 1) GSlocid = GetHotspotAt (mouse.x, mouse.y);
else if (GSloctype == 2) GSlocid = GetCharacterAt (mouse.x, mouse.y);
else if (GSloctype == 3) GSlocid = GetObjectAt (mouse.x, mouse.y);
else if (GetInvAt (mouse.x, mouse.y) >= 0) GSlocid = GetInvAt
(mouse.x, mouse.y);
GetLocationName (mouse.x, mouse.y, GSlocname);
GSagsusedmode = GetCursorMode ();
used_action = global_action;
if (IsGamePaused () == 1)
{
// Game is paused, so do nothing (ie. don't allow mouse click)
}
else if (IsGUIOn (MAPS) == 1)
{
// if map
if (button == LEFT)
{
if (IsInteractionAvailable (mouse.x, mouse.y, MODE_USE))
ProcessClick (mouse.x, mouse.y, MODE_USE);
else ProcessClick (mouse.x, mouse.y, MODE_WALK);
}
}
//end if map
else if (button == LEFT)
{
if (GlobalCondition (2) || GlobalCondition (3) || GlobalCondition (4))
{
// SetMode("default");
}
else if (GSagsusedmode == 9)
{
// walk to
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
if (IsInteractionAvailable (mouse.x, mouse.y, GSagsusedmode))
ProcessClick (mrx - GetViewportX (), mry - GetViewportY (), GSagsusedmode);
else ProcessClick (mrx - GetViewportX (), mry - GetViewportY (),
MODE_WALK);
}
else if ((GSagsusedmode == MODE_TALK) && (IsInteractionAvailable
(mouse.x, mouse.y, GSagsusedmode) == 1) && (GetCharacterAt (mouse.x,
mouse.y) < 0))
{
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
if (GoToCharacter (GSlocid, 0, 1, 2)) RunCharacterInteraction
(GSlocid, GSagsusedmode);
SetAction (A_DEFAULT);
}
else if ((GSagsusedmode == 4) && (GetLocationType (mouse.x, mouse.y)
== 2) && isAction (A_GIVE_TO) && (GetCharacterAt (mouse.x, mouse.y) < 0))
{
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
if (GoToCharacter (GSlocid, 0, 1, 2))
{
ItemGiven = character [GetPlayerCharacter ()].activeinv;
if (IsInteractionAvailable (mrx - GetViewportX (), mry -
GetViewportY (), MODE_USEINV) == 1)
{
RunCharacterInteraction (GSlocid, MODE_USEINV);
}
GiveInv (ItemGiven, GSlocid);
character [GetPlayerCharacter ()].activeinv = -1;
}
SetAction (A_DEFAULT);
}
else
{
UpdateActionBar ();
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
ProcessClick (mrx - GetViewportX (), mry - GetViewportY (),
GSagsusedmode);
SetAction (A_DEFAULT);
}
}
//end if button left
else if (button == RIGHT)
{
if (alternative_action == A_DEFAULT)
{
SetAction (A_DEFAULT);
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
if (GetCursorMode () == 9) ProcessClick (mrx - GetViewportX (),
mry - GetViewportY (), MODE_WALK);
else ProcessClick (mrx - GetViewportX (), mry - GetViewportY (),
GetCursorMode () );
}
else
{
SetAction (alternative_action);
used_action = global_action;
UpdateActionBar ();
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
GSagsusedmode = GetCursorMode ();
if ((GSagsusedmode == MODE_TALK) && (IsInteractionAvailable
(mouse.x, mouse.y, GSagsusedmode) == 1) && (GetCharacterAt (mouse.x,
mouse.y) < 7))
{
if (GoToCharacter (GSlocid, 0, 1, 2)) RunCharacterInteraction
(GSlocid, GSagsusedmode);
}
else ProcessClick (mrx - GetViewportX (), mry - GetViewportY (),
GSagsusedmode);
SetAction (A_DEFAULT);
}
}
else if (button == LEFTINV)
{
//left click in inventory
if (GlobalCondition (1))
{
// if the mouse is in the inventory and modes Walk or pickup are selected
SetAction (A_USE);
if ((Extension (GSinvloc) == 'u') &&
(IsInventoryInteractionAvailable (GSlocid, MODE_USE) == 1))
{
// use it immediately (not with anything else)
used_action = global_action;
RunInventoryInteraction (GSlocid, MODE_USE);
SetAction (A_DEFAULT);
}
else
{
SetActiveInventory (GSlocid);
}
}
else if (GlobalCondition (2) == 1)
{
// if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
}
else
{
used_action = global_action;
if (GetCursorMode () == 2)
{
if (isAction (A_USE) && IsInventoryInteractionAvailable
(GSlocid, MODE_USE) == 1)
{
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
RunInventoryInteraction (GSlocid, MODE_USE);
SetAction (A_DEFAULT);
}
else SetActiveInventory (GSlocid);
}
else
{
GSagsusedmode = GetCursorMode ();
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
RunInventoryInteraction (GSlocid, GetCursorMode ());
SetAction (A_DEFAULT);
}
}
}
else if (button == RIGHTINV)
{
if (alternative_action == A_DEFAULT)
{
SetAction (A_DEFAULT);
}
else
{
SetAction (alternative_action);
used_action = global_action;
GSagsusedmode = GetCursorMode ();
if (GetCursorMode () == 2)
{
if (isAction (A_USE) && IsInventoryInteractionAvailable
(GSlocid, MODE_USE) == 1)
{
UpdateActionBar ();
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
RunInventoryInteraction (GSlocid, MODE_USE);
SetAction (A_DEFAULT);
}
else SetActiveInventory (GSlocid);
}
else
{
UpdateActionBar ();
SetLabelColor (ACTION, 0, ActionLabelColorHighlighted);
RunInventoryInteraction (game.inv_activated, GetCursorMode ());
SetAction (A_DEFAULT);
}
}
}
}
#sectionend on_mouse_click // DO NOT EDIT OR REMOVE THIS LINE
Need help Haveing problem with new action. SetCursorMode
-
- Verpackungs-Wegwerfer
- Beiträge: 76
- Registriert: 14.03.2006, 21:45